package thyyxxk.webserver.controller.reports;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.querydata.CovidVaccinateAppointment;
import thyyxxk.webserver.entity.querydata.CovidVaccinateFactory;
import thyyxxk.webserver.entity.querydata.CovidVaccinateThreshold;
import thyyxxk.webserver.entity.querydata.ZdCovidVaccinate;
import thyyxxk.webserver.service.reports.CovidVaccinateAppointmentService;

import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 新冠接种预约 前端控制器
 * </p>
 *
 * @author 肖蟾
 * @since 2021-03-16
 */
@RestController
@RequestMapping("/CovidVaccinateAppointment")
public class CovidVaccinateAppointmentController {
    private final CovidVaccinateAppointmentService server;

    @Autowired
    public CovidVaccinateAppointmentController(CovidVaccinateAppointmentService server) {
        this.server = server;
    }

    @PostMapping("/queryXGYM")
    public ResultVo<Map<String, Object>> queryCovidVaccinateAppointment(@RequestBody CovidVaccinateAppointment param) {
        return server.queryCovidVaccinateAppointment(param);
    }

    @GetMapping("/queryCount")
    public ResultVo<List<CovidVaccinateFactory>> queryCount() {
        return server.queryCount();
    }

    @GetMapping("/queryChangJiaDuiYingDeYuZhi")
    public ResultVo<List<CovidVaccinateThreshold>> queryChangJiaDuiYingDeYuZhi(@RequestParam("code") Integer code)
            throws ParseException {
        return server.queryChangJiaDuiYingDeYuZhi(code);
    }

    @PostMapping("/exportExcel")
    public void exportExcel(HttpServletResponse response,
                            @RequestBody @Validated CovidVaccinateAppointment param) {
        server.exportExcel(response, param);
    }

    @PostMapping("/xinZengYiMiao")
    public ResultVo<Integer> xinZengYiMiao(@RequestBody ZdCovidVaccinate param) {
        return server.xinZengYiMiao(param);
    }

    @PostMapping("/xinZengChangJia")
    public ResultVo<Boolean> xinZengChangJia(@RequestBody List<CovidVaccinateFactory> param) throws ParseException {
        return server.xinZengChangJia(param);
    }

    @GetMapping("/chaKanYiMiao")
    @PassToken
    public ResultVo<List<ZdCovidVaccinate>> chaKanYiMiao() {
        return server.chaKanYiMiao();
    }

    @GetMapping("/chaKanChangJia")
    public ResultVo<List<CovidVaccinateFactory>> chaKanChangJia(@RequestParam("id") int id) {
        return server.chaKanChangJia(id);
    }

    @PostMapping("/xiuGaiYiMiao")
    public ResultVo<Boolean> xiuGaiYiMiao(@RequestBody ZdCovidVaccinate param) {
        return server.xiuGaiYiMiao(param);
    }

    @PostMapping("/xiuGaiChangJia")
    public ResultVo<Boolean> xiuGaiChangJia(@RequestBody CovidVaccinateFactory param) {
        return server.xiuGaiChangJia(param);
    }

    @GetMapping("/shanChuChangJia")
    public ResultVo<Boolean> shanChuChangJia(@RequestParam("code") Integer code) {
        return server.shanChuChangJia(code);
    }

    @PostMapping("/yiJianXiuGaiRiQi")
    public ResultVo<Boolean> yiJianXiuGaiRiQi(@RequestBody List<CovidVaccinateThreshold> list) {
        return server.yiJianXiuGaiRiQi(list);
    }

    @GetMapping("/kaiQiHuoGuanBiYuYue")
    public ResultVo<Boolean> kaiQiHuoGuanBiYuYue(@RequestParam("code") Integer code,
                                                 @RequestParam("enableFlag") Integer enableFlag) {
        return server.kaiQiHuoGuanBiYuYue(code, enableFlag);
    }
}

