package com.fs.his.controller;

import java.util.List;

import com.fs.his.param.FsFirstDiagnosisParam;
import com.fs.his.vo.FsFirstDiagnosisVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.his.domain.FsFirstDiagnosis;
import com.fs.his.service.IFsFirstDiagnosisService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 初诊单Controller
 * 
 * @author fs
 * @date 2025-09-01
 */
@RestController
@RequestMapping("/his/fsFirstDiagnosis")
public class FsFirstDiagnosisController extends BaseController
{
    @Autowired
    private IFsFirstDiagnosisService fsFirstDiagnosisService;

    /**
     * 查询初诊单列表
     */
    @PreAuthorize("@ss.hasPermi('his:fsFirstDiagnosis:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsFirstDiagnosisParam fsFirstDiagnosis)
    {
        startPage();
        List<FsFirstDiagnosisVO> list = fsFirstDiagnosisService.selectFsFirstDiagnosisVOList(fsFirstDiagnosis);
        return getDataTable(list);
    }

    /**
     * 导出初诊单列表
     */
    @PreAuthorize("@ss.hasPermi('his:fsFirstDiagnosis:export')")
    @Log(title = "初诊单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsFirstDiagnosisParam fsFirstDiagnosis)
    {
        List<FsFirstDiagnosisVO> list = fsFirstDiagnosisService.selectFsFirstDiagnosisVOList(fsFirstDiagnosis);
        ExcelUtil<FsFirstDiagnosisVO> util = new ExcelUtil<FsFirstDiagnosisVO>(FsFirstDiagnosisVO.class);
        return util.exportExcel(list, "初诊单数据");
    }

    /**
     * 获取初诊单详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:fsFirstDiagnosis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsFirstDiagnosisService.selectFsFirstDiagnosisById(id));
    }

    /**
     * 新增初诊单
     */
    @PreAuthorize("@ss.hasPermi('his:fsFirstDiagnosis:add')")
    @Log(title = "初诊单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsFirstDiagnosis fsFirstDiagnosis)
    {
        return toAjax(fsFirstDiagnosisService.insertFsFirstDiagnosis(fsFirstDiagnosis));
    }

    /**
     * 修改初诊单
     */
    @PreAuthorize("@ss.hasPermi('his:fsFirstDiagnosis:edit')")
    @Log(title = "初诊单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsFirstDiagnosis fsFirstDiagnosis)
    {
        return toAjax(fsFirstDiagnosisService.updateFsFirstDiagnosis(fsFirstDiagnosis));
    }

    /**
     * 删除初诊单
     */
    @PreAuthorize("@ss.hasPermi('his:fsFirstDiagnosis:remove')")
    @Log(title = "初诊单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsFirstDiagnosisService.deleteFsFirstDiagnosisByIds(ids));
    }
}
