package thyyxxk.webserver.controller.examinations;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.examinations.covidexam.QueryCovidExamParam;
import thyyxxk.webserver.service.examinations.CovidAssessmentService;
import thyyxxk.webserver.service.examinations.CovidExamService;

import java.util.Map;

@RestController
@RequestMapping("/covidExamReport")
public class CovidExamController {
    private final CovidExamService service;
    private final CovidAssessmentService assmntService;

    @Autowired
    public CovidExamController(CovidExamService service, CovidAssessmentService assmntService) {
        this.service = service;
        this.assmntService = assmntService;
    }

    @PostMapping("/queryResult")
    public ResultVo<Map<String, Object>> queryResult(@RequestBody @Validated QueryCovidExamParam param) {
        if (param.getType() == 3) {
            return assmntService.queryResult(param);
        }
        return service.queryResult(param);
    }

}
