package thyyxxk.webserver.controller.inpatient;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.inpatient.conventions.ConventionDetail;
import thyyxxk.webserver.entity.inpatient.conventions.RoughConvention;
import thyyxxk.webserver.service.inpatient.ConventionsService;

import java.util.List;

@RestController
@RequestMapping("/conventions")
public class ConventionsController {
    private final ConventionsService service;

    @Autowired
    public ConventionsController(ConventionsService service) {
        this.service = service;
    }

    @GetMapping("/getRoughConventions")
    public ResultVo<List<RoughConvention>> getRoughConventions(@RequestParam("inpatientNo") String inpatientNo,
                                                               @RequestParam("admissTimes") Integer admissTimes) {
        return service.getRoughConventions(inpatientNo, admissTimes);
    }

    @GetMapping("/getDetailConventions")
    public ResultVo<List<ConventionDetail>> getDetailConventions(@RequestParam("inpatientNo") String inpatientNo,
                                                                 @RequestParam("actOrderNo") String actOrderNo) {
        return service.getDetailConventions(inpatientNo, actOrderNo);
    }

    @PostMapping("/retractConventions")
    public ResultVo<String> retractConventions(@RequestBody List<String> actOrderNos) {
        return service.retractConventions(actOrderNos);
    }
}
