package com.fs.his.controller;

import java.util.List;

import com.fs.his.param.FsDoctorPrescribeVO;
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.FsDoctorPrescribe;
import com.fs.his.service.IFsDoctorPrescribeService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 医生处方Controller
 *
 * @author fs
 * @date 2023-08-08
 */
@RestController
@RequestMapping("/his/doctorPrescribe")
public class FsDoctorPrescribeController extends BaseController
{
    @Autowired
    private IFsDoctorPrescribeService fsDoctorPrescribeService;

    /**
     * 查询医生处方列表
     */

    @GetMapping("/list")
    public TableDataInfo list(FsDoctorPrescribe fsDoctorPrescribe)
    {
        startPage();
        List<FsDoctorPrescribeVO> list = fsDoctorPrescribeService.selectFsDoctorPrescribeListVO(fsDoctorPrescribe);
        return getDataTable(list);
    }

    /**
     * 导出医生处方列表
     */
    @PreAuthorize("@ss.hasPermi('his:doctorPrescribe:export')")
    @Log(title = "医生处方", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsDoctorPrescribe fsDoctorPrescribe)
    {
        List<FsDoctorPrescribe> list = fsDoctorPrescribeService.selectFsDoctorPrescribeList(fsDoctorPrescribe);
        ExcelUtil<FsDoctorPrescribe> util = new ExcelUtil<FsDoctorPrescribe>(FsDoctorPrescribe.class);
        return util.exportExcel(list, "医生处方数据");
    }

    /**
     * 获取医生处方详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:doctorPrescribe:query')")
    @GetMapping(value = "/{prescribeId}")
    public AjaxResult getInfo(@PathVariable("prescribeId") Long prescribeId)
    {
        return AjaxResult.success(fsDoctorPrescribeService.selectFsDoctorPrescribeByPrescribeId(prescribeId));
    }

    /**
     * 新增医生处方
     */
    @PreAuthorize("@ss.hasPermi('his:doctorPrescribe:add')")
    @Log(title = "医生处方", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsDoctorPrescribe fsDoctorPrescribe)
    {
        return toAjax(fsDoctorPrescribeService.insertFsDoctorPrescribe(fsDoctorPrescribe));
    }

    /**
     * 修改医生处方
     */
    @PreAuthorize("@ss.hasPermi('his:doctorPrescribe:edit')")
    @Log(title = "医生处方", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsDoctorPrescribe fsDoctorPrescribe)
    {
        return toAjax(fsDoctorPrescribeService.updateFsDoctorPrescribe(fsDoctorPrescribe));
    }

    /**
     * 删除医生处方
     */
    @PreAuthorize("@ss.hasPermi('his:doctorPrescribe:remove')")
    @Log(title = "医生处方", businessType = BusinessType.DELETE)
	@DeleteMapping("/{prescribeIds}")
    public AjaxResult remove(@PathVariable Long[] prescribeIds)
    {
        return toAjax(fsDoctorPrescribeService.deleteFsDoctorPrescribeByPrescribeIds(prescribeIds));
    }





}
