package thyyxxk.webserver.controller.medicalinsurance;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.login.UserInfo;
import thyyxxk.webserver.entity.medicalinsurance.worklog.WorkLog;
import thyyxxk.webserver.entity.medicalinsurance.worklog.WorkLogInquiry;
import thyyxxk.webserver.service.medicalinsurance.SiWorkLogService;
import thyyxxk.webserver.utils.ResultVoUtil;

import java.util.List;

@RestController
@RequestMapping("/siWorkLog")
public class SiWorkLogController {
    private final SiWorkLogService service;

    @Autowired
    public SiWorkLogController(SiWorkLogService service) {
        this.service = service;
    }

    @GetMapping("/getYbkStaff")
    public ResultVo<List<UserInfo>> getYbkStaff() {
        return ResultVoUtil.success(service.getYbkStaff());
    }

    @PostMapping("/getWorkLog")
    public ResultVo<List<WorkLog>> getWorkLog(@RequestBody WorkLogInquiry inquiry) {
        if (null == inquiry.getType()) {
            inquiry.setType(WorkLogInquiry.Type.ALL);
        }
        return ResultVoUtil.success(service.getWorkLog(inquiry));
    }
}
