package thyyxxk.webserver.controller.examinations;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.examinations.adicon.AdiconIndex;
import thyyxxk.webserver.entity.examinations.inspections.InspectionsIndex;
import thyyxxk.webserver.entity.examinations.inspections.QueryInspectionParam;
import thyyxxk.webserver.entity.examinations.inspections.detail.InspectionDetail;
import thyyxxk.webserver.service.examinations.InspectionsService;

import java.util.List;

@RestController
@RequestMapping("/inspections")
public class InspectionsController {
    private final InspectionsService service;

    @Autowired
    public InspectionsController(InspectionsService service) {
        this.service = service;
    }

    @PassToken
    @GetMapping("/queryAdiconReportIndex")
    public ResultVo<List<AdiconIndex>> queryAdiconReportIndex(@RequestParam("patNo") String patNo) {
        return service.queryAdiconReportIndex(patNo);
    }

    @PassToken
    @GetMapping("/queryAdiconReportDetail")
    public ResultVo<InspectionDetail> queryAdiconReportDetail(@RequestParam("reportId") String reportId) {
        return service.queryAdiconReportDetail(reportId);
    }

    @PassToken
    @GetMapping("/queryAdiconInspection")
    public ResultVo<String> queryADICONInspection(@RequestParam("barCode") String barCode) {
        return service.queryAdiconInspection(barCode);
    }

    @PassToken
    @PostMapping("/queryInspectionsIndex")
    public ResultVo<List<InspectionsIndex>> queryInspectionsIndex(@RequestBody QueryInspectionParam param) {
        return service.queryInspectionsIndex(param);
    }

    @PassToken
    @GetMapping("/queryInspectionDetail")
    public ResultVo<InspectionDetail> queryInspectionDetail(@RequestParam("orderId") String orderId) {
        return service.queryInspectionDetail(orderId);
    }

    @PassToken
    @GetMapping("/getInspectionPic")
    public ResultVo<JSONObject> getInspectionPic(@RequestParam("orderId") String orderId) {
        return service.queryInspectionPic(orderId);
    }
}
