package thyyxxk.webserver.controller.surgicalmanagement;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.surgeryarrangement.BriefOpRecord;
import thyyxxk.webserver.entity.surgeryarrangement.QuerySurgeryParams;
import thyyxxk.webserver.entity.zhuyuanyisheng.shoushu.OpRecord;
import thyyxxk.webserver.service.surgicalmanagement.SurgeryRecordService;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/surgeryRecord")
public class SurgeryRecordController {
    private final SurgeryRecordService service;

    @Autowired
    public SurgeryRecordController(SurgeryRecordService service) {
        this.service = service;
    }

    @GetMapping("/getDicList")
    public ResultVo<Map<String, List<CodeName>>> getDicList() {
        return service.getDicList();
    }

    @PostMapping("/fetchBriefOpRecordList")
    public ResultVo<List<BriefOpRecord>> fetchBriefOpRecordList(@RequestBody QuerySurgeryParams params) {
        return service.fetchBriefOpRecordList(params);
    }

    @GetMapping("/fetchSurgeryRecord")
    public ResultVo<OpRecord> fetchSurgeryRecord(@RequestParam("recordId") Integer recordId) {
        return service.fetchSurgeryRecord(recordId);
    }

    @PostMapping("/saveSurgeryRecord")
    public ResultVo<String> saveSurgeryRecord(@RequestBody OpRecord record) {
        return service.saveSurgeryRecord(record);
    }
}
