package com.fs.company.controller.store;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.his.domain.FsHealthData;
import com.fs.his.param.FsHealthDataParam;
import com.fs.his.service.IFsHealthDataService;
import com.fs.his.vo.FsHealthDataListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 健康数据Controller
 *
 * @author fs
 * @date 2024-09-02
 */
@RestController
@RequestMapping("/store/healthData")
public class FsHealthDataController extends BaseController
{
    @Autowired
    private IFsHealthDataService fsHealthDataService;

    /**
     * 查询健康数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FsHealthDataParam fsHealthData)
    {
        startPage();
        List<FsHealthDataListVO> list = fsHealthDataService.selectFsHealthDataListVO(fsHealthData);
        return getDataTable(list);
    }

    /**
     * 导出健康数据列表
     */
    @PreAuthorize("@ss.hasPermi('his:healthData:export')")
    @Log(title = "健康数据", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsHealthData fsHealthData)
    {
        List<FsHealthData> list = fsHealthDataService.selectFsHealthDataList(fsHealthData);
        ExcelUtil<FsHealthData> util = new ExcelUtil<FsHealthData>(FsHealthData.class);
        return util.exportExcel(list, "健康数据数据");
    }

    /**
     * 获取健康数据详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsHealthDataService.selectFsHealthDataById(id));
    }
}
