package com.fs.doctor.controller;

import com.fs.common.annotation.Log;
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.DoctorLevelMaterial;
import com.fs.doctor.service.IDoctorLevelMaterialService;
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/material")
public class DoctorLevelMaterialController extends BaseController
{
    @Autowired
    private IDoctorLevelMaterialService doctorLevelMaterialService;

    /**
     * 查询定级证明材料列表
     */
    @PreAuthorize("@ss.hasPermi('doctor:material:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoctorLevelMaterial doctorLevelMaterial)
    {
        startPage();
        List<DoctorLevelMaterial> list = doctorLevelMaterialService.selectDoctorLevelMaterialList(doctorLevelMaterial);
        return getDataTable(list);
    }

    /**
     * 导出定级证明材料列表
     */
    @PreAuthorize("@ss.hasPermi('doctor:material:export')")
    @Log(title = "定级证明材料", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DoctorLevelMaterial doctorLevelMaterial)
    {
        List<DoctorLevelMaterial> list = doctorLevelMaterialService.selectDoctorLevelMaterialList(doctorLevelMaterial);
        ExcelUtil<DoctorLevelMaterial> util = new ExcelUtil<DoctorLevelMaterial>(DoctorLevelMaterial.class);
        return util.exportExcel(list, "定级证明材料数据");
    }

    /**
     * 获取定级证明材料详细信息
     */
    @PreAuthorize("@ss.hasPermi('doctor:material:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(doctorLevelMaterialService.selectDoctorLevelMaterialById(id));
    }

    /**
     * 新增定级证明材料
     */
    @PreAuthorize("@ss.hasPermi('doctor:material:add')")
    @Log(title = "定级证明材料", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoctorLevelMaterial doctorLevelMaterial)
    {
        return toAjax(doctorLevelMaterialService.insertDoctorLevelMaterial(doctorLevelMaterial));
    }

    /**
     * 修改定级证明材料
     */
    @PreAuthorize("@ss.hasPermi('doctor:material:edit')")
    @Log(title = "定级证明材料", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DoctorLevelMaterial doctorLevelMaterial)
    {
        return toAjax(doctorLevelMaterialService.updateDoctorLevelMaterial(doctorLevelMaterial));
    }

    /**
     * 删除定级证明材料
     */
    @PreAuthorize("@ss.hasPermi('doctor:material:remove')")
    @Log(title = "定级证明材料", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(doctorLevelMaterialService.deleteDoctorLevelMaterialByIds(ids));
    }
}
