package com.fs.his.controller;

import java.util.List;

import com.fs.his.param.FsHealthLifeParam;
import com.fs.his.vo.FsHealthLifeListVO;
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.FsHealthLife;
import com.fs.his.service.IFsHealthLifeService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 健康生活Controller
 *
 * @author fs
 * @date 2024-09-02
 */
@RestController
@RequestMapping("/his/healthLife")
public class FsHealthLifeController extends BaseController
{
    @Autowired
    private IFsHealthLifeService fsHealthLifeService;

    /**
     * 查询健康生活列表
     */

    @GetMapping("/list")
    public TableDataInfo list(FsHealthLifeParam fsHealthLife)
    {
        startPage();
        List<FsHealthLifeListVO> list = fsHealthLifeService.selectFsHealthLifeListVO(fsHealthLife);
        return getDataTable(list);
    }

    /**
     * 导出健康生活列表
     */
    @PreAuthorize("@ss.hasPermi('his:healthLife:export')")
    @Log(title = "健康生活", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsHealthLife fsHealthLife)
    {
        List<FsHealthLife> list = fsHealthLifeService.selectFsHealthLifeList(fsHealthLife);
        ExcelUtil<FsHealthLife> util = new ExcelUtil<FsHealthLife>(FsHealthLife.class);
        return util.exportExcel(list, "健康生活数据");
    }

    /**
     * 获取健康生活详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsHealthLifeService.selectFsHealthLifeById(id));
    }

    /**
     * 新增健康生活
     */
    @PreAuthorize("@ss.hasPermi('his:healthLife:add')")
    @Log(title = "健康生活", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsHealthLife fsHealthLife)
    {
        return toAjax(fsHealthLifeService.insertFsHealthLife(fsHealthLife));
    }

    /**
     * 修改健康生活
     */
    @PreAuthorize("@ss.hasPermi('his:healthLife:edit')")
    @Log(title = "健康生活", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsHealthLife fsHealthLife)
    {
        return toAjax(fsHealthLifeService.updateFsHealthLife(fsHealthLife));
    }

    /**
     * 删除健康生活
     */
    @PreAuthorize("@ss.hasPermi('his:healthLife:remove')")
    @Log(title = "健康生活", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsHealthLifeService.deleteFsHealthLifeByIds(ids));
    }
}
