package com.fs.his.controller;

import java.util.List;
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.FsHealthHistoryTemp;
import com.fs.his.service.IFsHealthHistoryTempService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 健康史模板Controller
 * 
 * @author fs
 * @date 2024-08-29
 */
@RestController
@RequestMapping("/his/healthHistoryTemp")
public class FsHealthHistoryTempController extends BaseController
{
    @Autowired
    private IFsHealthHistoryTempService fsHealthHistoryTempService;

    /**
     * 查询健康史模板列表
     */
    @PreAuthorize("@ss.hasPermi('his:healthHistoryTemp:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsHealthHistoryTemp fsHealthHistoryTemp)
    {
        startPage();
        List<FsHealthHistoryTemp> list = fsHealthHistoryTempService.selectFsHealthHistoryTempList(fsHealthHistoryTemp);
        return getDataTable(list);
    }

    /**
     * 导出健康史模板列表
     */
    @PreAuthorize("@ss.hasPermi('his:healthHistoryTemp:export')")
    @Log(title = "健康史模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsHealthHistoryTemp fsHealthHistoryTemp)
    {
        List<FsHealthHistoryTemp> list = fsHealthHistoryTempService.selectFsHealthHistoryTempList(fsHealthHistoryTemp);
        ExcelUtil<FsHealthHistoryTemp> util = new ExcelUtil<FsHealthHistoryTemp>(FsHealthHistoryTemp.class);
        return util.exportExcel(list, "健康史模板数据");
    }

    /**
     * 获取健康史模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:healthHistoryTemp:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsHealthHistoryTempService.selectFsHealthHistoryTempById(id));
    }

    /**
     * 新增健康史模板
     */
    @PreAuthorize("@ss.hasPermi('his:healthHistoryTemp:add')")
    @Log(title = "健康史模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsHealthHistoryTemp fsHealthHistoryTemp)
    {
        return toAjax(fsHealthHistoryTempService.insertFsHealthHistoryTemp(fsHealthHistoryTemp));
    }

    /**
     * 修改健康史模板
     */
    @PreAuthorize("@ss.hasPermi('his:healthHistoryTemp:edit')")
    @Log(title = "健康史模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsHealthHistoryTemp fsHealthHistoryTemp)
    {
        return toAjax(fsHealthHistoryTempService.updateFsHealthHistoryTemp(fsHealthHistoryTemp));
    }

    /**
     * 删除健康史模板
     */
    @PreAuthorize("@ss.hasPermi('his:healthHistoryTemp:remove')")
    @Log(title = "健康史模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsHealthHistoryTempService.deleteFsHealthHistoryTempByIds(ids));
    }
}
