package com.bonus.canteen.core.nutrition.controller;

import com.bonus.canteen.core.nutrition.common.dto.HealthCustMedicalReportEditDTO;
import com.bonus.canteen.core.nutrition.service.HealthCustMedicalReportService;
import com.bonus.canteen.core.nutrition.service.HealthMedicalReportTmplService;
import com.bonus.canteen.core.nutrition.common.vo.HealthCustMedicalReportProjectVO;
import com.bonus.canteen.core.nutrition.common.vo.HealthCustMedicalReportVO;
import com.bonus.canteen.core.nutrition.common.vo.HealthMedicalReportProjectVO;
import com.bonus.canteen.core.nutrition.common.vo.HealthMedicalReportTmplVO;
import com.bonus.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping({"/health/medicalreport"})
@Api(
   tags = {"人员体检报告"}
)
public class HealthMedicalReportController {
   @Autowired
   @Lazy
   private HealthCustMedicalReportService healthCustMedicalReportService;
   @Autowired
   @Lazy
   private HealthMedicalReportTmplService healthMedicalReportTmplService;

   @PostMapping({"/list-medicalreport"})
   @ApiOperation("查询人员体检报告记录")
   public List<HealthCustMedicalReportVO> listMedicalReport(@RequestHeader Map<String, String> headers) {
      return this.healthCustMedicalReportService.listMedicalReport();
   }

   @PostMapping({"/get-medicalreport-info"})
   @ApiOperation("根据体检id查询报告详情")
   public List<HealthCustMedicalReportProjectVO> getMedicalReportInfo(@RequestBody HealthCustMedicalReportEditDTO dto) {
      return this.healthCustMedicalReportService.getMedicalReportInfo(dto.getMedicalId());
   }

   @PostMapping({"/list-template"})
   @ApiOperation("查询体检报告模板")
   public List<HealthMedicalReportTmplVO> listTemplate() {
      return this.healthMedicalReportTmplService.listTemplate();
   }

   @PostMapping({"/get-template-info"})
   @ApiOperation("根据体检报告模板id查询模板详情")
   public List<HealthMedicalReportProjectVO> getTemplateInfo(@RequestBody HealthMedicalReportTmplVO vo) {
      return this.healthMedicalReportTmplService.getTemplateInfoByTmplId(vo.getMedicalTemplateId());
   }

   @PostMapping({"/edit-medicalreport"})
   @ApiOperation("编辑人员体检报告")
   public AjaxResult editMedicalReport(@RequestBody HealthCustMedicalReportEditDTO dto) {
      return AjaxResult.success(this.healthCustMedicalReportService.editMedicalReport(dto));
   }

   @PostMapping({"/delete-medicalreport"})
   @ApiOperation("删除人员体检报告")
   public void deleteMedicalReport(Long medicalId) {
      this.healthCustMedicalReportService.deleteMedicalReport(medicalId);
   }

}
