package com.fs.patient.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.*;
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.patient.domain.FsPatientBaseInfo;
import com.fs.patient.service.IFsPatientBaseInfoService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 患者基本信息Controller
 * 
 * @author fs
 * @date 2026-04-19
 */
@RestController
@RequestMapping("/patient/info")
public class FsPatientBaseInfoController extends BaseController
{
    @Autowired
    private IFsPatientBaseInfoService fsPatientBaseInfoService;

    /**
     * 查询患者基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('patient:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsPatientBaseInfo fsPatientBaseInfo)
    {
        startPage();
        List<FsPatientBaseInfo> list = fsPatientBaseInfoService.selectFsPatientBaseInfoList(fsPatientBaseInfo);
        return getDataTable(list);
    }

    /**
     * 导出患者基本信息列表
     */
    @PreAuthorize("@ss.hasPermi('patient:info:export')")
    @Log(title = "患者基本信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsPatientBaseInfo fsPatientBaseInfo)
    {
        List<FsPatientBaseInfo> list = fsPatientBaseInfoService.selectFsPatientBaseInfoList(fsPatientBaseInfo);
        ExcelUtil<FsPatientBaseInfo> util = new ExcelUtil<FsPatientBaseInfo>(FsPatientBaseInfo.class);
        return util.exportExcel(list, "患者基本信息数据");
    }

    /**
     * 获取患者基本信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('patient:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsPatientBaseInfoService.selectFsPatientBaseInfoById(id));
    }

    /**
     * 新增患者基本信息
     */
    @PreAuthorize("@ss.hasPermi('patient:info:add')")
    @Log(title = "患者基本信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsPatientBaseInfo fsPatientBaseInfo)
    {
        return toAjax(fsPatientBaseInfoService.insertFsPatientBaseInfo(fsPatientBaseInfo));
    }

    /**
     * 修改患者基本信息
     */
    @PreAuthorize("@ss.hasPermi('patient:info:edit')")
    @Log(title = "患者基本信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsPatientBaseInfo fsPatientBaseInfo)
    {
        return toAjax(fsPatientBaseInfoService.updateFsPatientBaseInfo(fsPatientBaseInfo));
    }

    /**
     * 删除患者基本信息
     */
    @PreAuthorize("@ss.hasPermi('patient:info:remove')")
    @Log(title = "患者基本信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsPatientBaseInfoService.deleteFsPatientBaseInfoByIds(ids));
    }

    /**
     * 审核
     */
    @PostMapping("/check")
    public AjaxResult check(@RequestBody FsPatientBaseInfo param) {
        return AjaxResult.success(fsPatientBaseInfoService.check(param));
    }
}
