package thyyxxk.webserver.controller.inpatient;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import thyyxxk.webserver.config.exception.ExceptionEnum;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.inpatient.doctorsadvise.BriefPatInfo;
import thyyxxk.webserver.service.inpatient.DoctorsAdviseService;
import thyyxxk.webserver.utils.ListUtil;
import thyyxxk.webserver.utils.ResultVoUtil;

import java.util.List;

@RestController
@RequestMapping("/doctorsAdvise")
public class DoctorsAdviseController {
    private final DoctorsAdviseService service;

    @Autowired
    public DoctorsAdviseController(DoctorsAdviseService service) {
        this.service = service;
    }

    @GetMapping("/selectPatientList")
    public ResultVo<List<BriefPatInfo>> selectPatientList(@RequestParam("ward") String ward) {
        List<BriefPatInfo> result = service.selectPatientList(ward);
        if (ListUtil.isBlank(result)) {
            return ResultVoUtil.fail(ExceptionEnum.NO_DATA_EXIST);
        }
        return ResultVoUtil.success(result);
    }
}
