package com.fs.his.controller;

import java.util.List;

import com.fs.his.param.FsDrugReportParam;
import com.fs.his.vo.FsDrugReportListVO;
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.FsDrugReport;
import com.fs.his.service.IFsDrugReportService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 用药报告Controller
 *
 * @author fs
 * @date 2024-04-28
 */
@RestController
@RequestMapping("/his/drugReport")
public class FsDrugReportController extends BaseController
{
    @Autowired
    private IFsDrugReportService fsDrugReportService;

    /**
     * 查询用药报告列表
     */
    @PreAuthorize("@ss.hasPermi('his:drugReport:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsDrugReportParam fsDrugReport)
    {
        startPage();
        List<FsDrugReportListVO> list = fsDrugReportService.selectFsDrugReportListVO(fsDrugReport);
        return getDataTable(list);
    }

    /**
     * 导出用药报告列表
     */
    @PreAuthorize("@ss.hasPermi('his:drugReport:export')")
    @Log(title = "用药报告", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsDrugReportParam fsDrugReport)
    {
        List<FsDrugReportListVO> list = fsDrugReportService.selectFsDrugReportListVO(fsDrugReport);
        ExcelUtil<FsDrugReportListVO> util = new ExcelUtil<FsDrugReportListVO>(FsDrugReportListVO.class);
        return util.exportExcel(list, "用药报告数据");
    }

    /**
     * 获取用药报告详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:drugReport:query')")
    @GetMapping(value = "/{reportId}")
    public AjaxResult getInfo(@PathVariable("reportId") Long reportId)
    {
        return AjaxResult.success(fsDrugReportService.selectFsDrugReportByReportIdVO(reportId));
    }

    /**
     * 新增用药报告
     */
    @PreAuthorize("@ss.hasPermi('his:drugReport:add')")
    @Log(title = "用药报告", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsDrugReport fsDrugReport)
    {
        return toAjax(fsDrugReportService.insertFsDrugReport(fsDrugReport));
    }

    /**
     * 修改用药报告
     */
    @PreAuthorize("@ss.hasPermi('his:drugReport:edit')")
    @Log(title = "用药报告", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsDrugReport fsDrugReport)
    {
        return toAjax(fsDrugReportService.updateFsDrugReport(fsDrugReport));
    }

    /**
     * 删除用药报告
     */
    @PreAuthorize("@ss.hasPermi('his:drugReport:remove')")
    @Log(title = "用药报告", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportIds}")
    public AjaxResult remove(@PathVariable Long[] reportIds)
    {
        return toAjax(fsDrugReportService.deleteFsDrugReportByReportIds(reportIds));
    }
}
