package com.ruoyi.os.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.os.domain.StudentInfo;
import org.apache.poi.poifs.crypt.dsig.SignatureInfo;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.os.domain.HealthcareOsPatientInfo;
import com.ruoyi.os.service.IHealthcareOsPatientInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
=======
 * 患者信息Controller  IHealthcareOsComplaintsService
 * @author 何顺
>>>>>>> cf33b39dcb79314a02d35b6116058d8b46856eeb
 * @date 2024-09-17
 */
@RestController
@RequestMapping("/outpatientService/healthcareOsPatientInfo")
public class HealthcareOsPatientInfoController extends BaseController
{
    @Autowired
    private IHealthcareOsPatientInfoService osPatientInfoService;

    /**
     * 查询患者信息列表  PatientDiagnosisController
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsPatientInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(HealthcareOsPatientInfo osPatientInfo)
    {
        startPage();
        List<HealthcareOsPatientInfo> list = osPatientInfoService.selectOsPatientInfoList(osPatientInfo);
        return getDataTable(list);
    }

    /**
     * 导出患者信息列表
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsPatientInfo:export')")
    @Log(title = "患者信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HealthcareOsPatientInfo osPatientInfo)
    {
        List<HealthcareOsPatientInfo> list = osPatientInfoService.selectOsPatientInfoList(osPatientInfo);
        ExcelUtil<HealthcareOsPatientInfo> util = new ExcelUtil<HealthcareOsPatientInfo>(HealthcareOsPatientInfo.class);
        util.exportExcel(response, list, "患者信息数据");
    }

    /**
     * 获取患者信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsPatientInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(osPatientInfoService.selectOsPatientInfoById(id));
    }

    /**
     * 新增患者信息
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsPatientInfo:add')")
    @Log(title = "患者信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HealthcareOsPatientInfo osPatientInfo)
    {
        return toAjax(osPatientInfoService.insertOsPatientInfo(osPatientInfo));
    }

    /**
     * 修改患者信息
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsPatientInfo:edit')")
    @Log(title = "患者信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HealthcareOsPatientInfo osPatientInfo)
    {
        return toAjax(osPatientInfoService.updateOsPatientInfo(osPatientInfo));
    }

    /**
     * 删除患者信息
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsPatientInfo:remove')")
    @Log(title = "患者信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(osPatientInfoService.deleteOsPatientInfoByIds(ids));
    }



    /**
     *     获取 学生 信息
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsPatientInfo:getStudentInfo')")
    @GetMapping("/getStudentInfo")
    public TableDataInfo getStudentInfo(HealthcareOsPatientInfo patientInfo) {
        startPage();
        StudentInfo studentInfo = new StudentInfo();
        // 赋值 学号
        studentInfo.setStuNo(patientInfo.getStudentId());
        //
        studentInfo.setStuName(patientInfo.getName());
        return getDataTable(osPatientInfoService.getStudentInfoList(studentInfo));
    }

    /**
     *    获取 教师 信息 TeachingStaffInfo
     */
    @PreAuthorize("@ss.hasPermi('os:healthcareOsPatientInfo:getTeachingStaffInfo')")
    @GetMapping("/getTeachingStaffInfo")
    public TableDataInfo getTeachingStaffInfo(HealthcareOsPatientInfo patientInfo) {
        startPage();

        return getDataTable(osPatientInfoService.getTeachingStaffInfo(patientInfo));
    }

}
