package com.fs.his.controller;

import java.util.List;

import com.fs.his.param.FsInquiryTempParam;
import com.fs.his.vo.FsInquiryTempListVO;
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.FsInquiryTemp;
import com.fs.his.service.IFsInquiryTempService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 模板Controller
 *
 * @author fs
 * @date 2023-09-04
 */
@RestController
@RequestMapping("/his/inquiryTemp")
public class FsInquiryTempController extends BaseController
{
    @Autowired
    private IFsInquiryTempService fsInquiryTempService;

    /**
     * 查询模板列表
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryTemp:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsInquiryTempParam fsInquiryTemp)
    {
        startPage();
        List<FsInquiryTempListVO> list = fsInquiryTempService.selectFsInquiryTempListVO(fsInquiryTemp);
        return getDataTable(list);
    }

    /**
     * 导出模板列表
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryTemp:export')")
    @Log(title = "模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsInquiryTemp fsInquiryTemp)
    {
        List<FsInquiryTemp> list = fsInquiryTempService.selectFsInquiryTempList(fsInquiryTemp);
        ExcelUtil<FsInquiryTemp> util = new ExcelUtil<FsInquiryTemp>(FsInquiryTemp.class);
        return util.exportExcel(list, "模板数据");
    }

    /**
     * 获取模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryTemp:query')")
    @GetMapping(value = "/{tempId}")
    public AjaxResult getInfo(@PathVariable("tempId") Long tempId)
    {
        return AjaxResult.success(fsInquiryTempService.selectFsInquiryTempByTempId(tempId));
    }

    /**
     * 新增模板
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryTemp:add')")
    @Log(title = "模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsInquiryTemp fsInquiryTemp)
    {
        return toAjax(fsInquiryTempService.insertFsInquiryTemp(fsInquiryTemp));
    }

    /**
     * 修改模板
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryTemp:edit')")
    @Log(title = "模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsInquiryTemp fsInquiryTemp)
    {
        return toAjax(fsInquiryTempService.updateFsInquiryTemp(fsInquiryTemp));
    }

    /**
     * 删除模板
     */
    @PreAuthorize("@ss.hasPermi('his:inquiryTemp:remove')")
    @Log(title = "模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tempIds}")
    public AjaxResult remove(@PathVariable Long[] tempIds)
    {
        return toAjax(fsInquiryTempService.deleteFsInquiryTempByTempIds(tempIds));
    }
}
