package com.fs.doctor.controller;

import com.fs.common.annotation.Log;
import com.fs.common.config.LoginContextManager;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.doctor.domain.DoctorLevel;
import com.fs.doctor.service.IDoctorLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 讲者级别信息Controller
 * 
 * @author fs
 * @date 2025-12-30
 */
@RestController
@RequestMapping("/doctor/level")
public class DoctorLevelController extends BaseController
{
    @Autowired
    private IDoctorLevelService doctorLevelService;

    /**
     * 查询讲者级别信息列表
     */
    @PreAuthorize("@ss.hasPermi('doctor:level:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoctorLevel doctorLevel)
    {
        startPage();
        Long currentCompanyId = LoginContextManager.getCurrentCompanyId();
        doctorLevel.setCompanyId(currentCompanyId);
        List<DoctorLevel> list = doctorLevelService.selectDoctorLevelList(doctorLevel);
        return getDataTable(list);
    }

    /**
     * 导出讲者级别信息列表
     */
    @PreAuthorize("@ss.hasPermi('doctor:level:export')")
    @Log(title = "讲者级别信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DoctorLevel doctorLevel)
    {
        Long currentCompanyId = LoginContextManager.getCurrentCompanyId();
        doctorLevel.setCompanyId(currentCompanyId);
        List<DoctorLevel> list = doctorLevelService.selectDoctorLevelList(doctorLevel);
        ExcelUtil<DoctorLevel> util = new ExcelUtil<DoctorLevel>(DoctorLevel.class);
        return util.exportExcel(list, "讲者级别信息数据");
    }

    /**
     * 获取讲者级别信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('doctor:level:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(doctorLevelService.selectDoctorLevelById(id));
    }

    /**
     * 新增讲者级别信息
     */
    @PreAuthorize("@ss.hasPermi('doctor:level:add')")
    @Log(title = "讲者级别信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoctorLevel doctorLevel)
    {
        Long currentCompanyId = LoginContextManager.getCurrentCompanyId();
        doctorLevel.setCompanyId(currentCompanyId);
        return toAjax(doctorLevelService.insertDoctorLevel(doctorLevel));
    }

    /**
     * 修改讲者级别信息
     */
    @PreAuthorize("@ss.hasPermi('doctor:level:edit')")
    @Log(title = "讲者级别信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DoctorLevel doctorLevel)
    {
        Long currentCompanyId = LoginContextManager.getCurrentCompanyId();
        doctorLevel.setCompanyId(currentCompanyId);
        return toAjax(doctorLevelService.updateDoctorLevel(doctorLevel));
    }

    /**
     * 删除讲者级别信息
     */
    @PreAuthorize("@ss.hasPermi('doctor:level:remove')")
    @Log(title = "讲者级别信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorLevelService.deleteDoctorLevelByIds(ids));
    }
}
