package com.fs.his.controller;

import java.util.List;

import com.fs.his.param.FsIllnessLibraryNameParam;
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.FsIllnessLibrary;
import com.fs.his.service.IFsIllnessLibraryService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 中医疾病Controller
 *
 * @author fs
 * @date 2023-09-04
 */
@RestController
@RequestMapping("/his/illnessLibrary")
public class FsIllnessLibraryController extends BaseController
{
    @Autowired
    private IFsIllnessLibraryService fsIllnessLibraryService;

    /**
     * 查询中医疾病列表
     */
    @PreAuthorize("@ss.hasPermi('his:illnessLibrary:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsIllnessLibrary fsIllnessLibrary)
    {
        startPage();
        List<FsIllnessLibrary> list = fsIllnessLibraryService.selectFsIllnessLibraryList(fsIllnessLibrary);
        return getDataTable(list);
    }

    /**
     * 导出中医疾病列表
     */
    @PreAuthorize("@ss.hasPermi('his:illnessLibrary:export')")
    @Log(title = "中医疾病", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsIllnessLibrary fsIllnessLibrary)
    {
        List<FsIllnessLibrary> list = fsIllnessLibraryService.selectFsIllnessLibraryList(fsIllnessLibrary);
        ExcelUtil<FsIllnessLibrary> util = new ExcelUtil<FsIllnessLibrary>(FsIllnessLibrary.class);
        return util.exportExcel(list, "中医疾病数据");
    }

    /**
     * 获取中医疾病详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:illnessLibrary:query')")
    @GetMapping(value = "/{illnessId}")
    public AjaxResult getInfo(@PathVariable("illnessId") Long illnessId)
    {
        return AjaxResult.success(fsIllnessLibraryService.selectFsIllnessLibraryByIllnessId(illnessId));
    }



    @GetMapping(value = "getIllness")
    public TableDataInfo getIllness(FsIllnessLibraryNameParam name)
    {
        startPage();
        return getDataTable(fsIllnessLibraryService.selectFsIllnessLibraryVOByIllnessName(name.getName()));
    }

    /**
     * 新增中医疾病
     */
    @PreAuthorize("@ss.hasPermi('his:illnessLibrary:add')")
    @Log(title = "中医疾病", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsIllnessLibrary fsIllnessLibrary)
    {
        return toAjax(fsIllnessLibraryService.insertFsIllnessLibrary(fsIllnessLibrary));
    }

    /**
     * 修改中医疾病
     */
    @PreAuthorize("@ss.hasPermi('his:illnessLibrary:edit')")
    @Log(title = "中医疾病", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsIllnessLibrary fsIllnessLibrary)
    {
        return toAjax(fsIllnessLibraryService.updateFsIllnessLibrary(fsIllnessLibrary));
    }

    /**
     * 删除中医疾病
     */
    @PreAuthorize("@ss.hasPermi('his:illnessLibrary:remove')")
    @Log(title = "中医疾病", businessType = BusinessType.DELETE)
	@DeleteMapping("/{illnessIds}")
    public AjaxResult remove(@PathVariable Long[] illnessIds)
    {
        return toAjax(fsIllnessLibraryService.deleteFsIllnessLibraryByIllnessIds(illnessIds));
    }
}
