package com.fs.his.controller;

import java.util.List;

import com.fs.his.vo.OptionsVO;
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.FsFollowTemp;
import com.fs.his.service.IFsFollowTempService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 随访模板Controller
 *
 * @author fs
 * @date 2023-07-14
 */
@RestController
@RequestMapping("/his/followTemp")
public class FsFollowTempController extends BaseController
{
    @Autowired
    private IFsFollowTempService fsFollowTempService;

    /**
     * 查询随访模板列表
     */
    @PreAuthorize("@ss.hasPermi('his:followTemp:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsFollowTemp fsFollowTemp)
    {
        startPage();
        List<FsFollowTemp> list = fsFollowTempService.selectFsFollowTempList(fsFollowTemp);
        return getDataTable(list);
    }

    /**
     * 导出随访模板列表
     */
    @PreAuthorize("@ss.hasPermi('his:followTemp:export')")
    @Log(title = "随访模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsFollowTemp fsFollowTemp)
    {
        List<FsFollowTemp> list = fsFollowTempService.selectFsFollowTempList(fsFollowTemp);
        ExcelUtil<FsFollowTemp> util = new ExcelUtil<FsFollowTemp>(FsFollowTemp.class);
        return util.exportExcel(list, "随访模板数据");
    }

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

    /**
     * 新增随访模板
     */
    @PreAuthorize("@ss.hasPermi('his:followTemp:add')")
    @Log(title = "随访模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsFollowTemp fsFollowTemp)
    {
        return toAjax(fsFollowTempService.insertFsFollowTemp(fsFollowTemp));
    }

    /**
     * 修改随访模板
     */
    @PreAuthorize("@ss.hasPermi('his:followTemp:edit')")
    @Log(title = "随访模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsFollowTemp fsFollowTemp)
    {
        return toAjax(fsFollowTempService.updateFsFollowTemp(fsFollowTemp));
    }

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


    /**
     * 查询模板名称列表
     */
    @GetMapping("/allList")
    public TableDataInfo getAllList()
    {
        List<OptionsVO> list = fsFollowTempService.selectAllFsFollowTempList();
        return getDataTable(list);
    }
}
