package thyyxxk.webserver.controller.covid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.covid.CovidDetail;
import thyyxxk.webserver.entity.covid.CovidIndex;
import thyyxxk.webserver.entity.covid.Region;
import thyyxxk.webserver.service.covid.CovidService;

import java.util.List;

@RestController
@RequestMapping("/covid")
public class CovidController {
    private final CovidService service;

    @Autowired
    public CovidController(CovidService service) {
        this.service = service;
    }

    @PassToken
    @GetMapping("/getList")
    public ResultVo<List<CovidIndex>> getList(@RequestParam("patientId") String patientId) {
        return service.getList(patientId);
    }

    @PassToken
    @GetMapping("/getDetail")
    public ResultVo<CovidDetail> getDetail(@RequestParam("id") Integer id) {
        return service.getDetail(id);
    }

    @PassToken
    @GetMapping("/getPatientInfo")
    public ResultVo<CovidDetail> getPatientInfo(@RequestParam("patientId") String patientId) {
        return service.getPatientInfo(patientId);
    }

    @PassToken
    @GetMapping("/getRegionProvince")
    public ResultVo<List<Region>> getRegionProvince() {
        return service.getRegionProvince();
    }

    @PassToken
    @GetMapping("/getChildRegion")
    public ResultVo<List<Region>> getChildRegion(@RequestParam("parentCode") Integer parentCode) {
        return service.getChildRegion(parentCode);
    }

    @PassToken
    @PostMapping("/submit")
    public ResultVo<String> submit(@RequestBody CovidDetail pojo) {
        return service.submit(pojo);
    }
}
