|
@@ -3,6 +3,8 @@ package org.thyy.thirdpartapi.inspection;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import jakarta.annotation.PostConstruct;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
@@ -19,31 +21,23 @@ import java.util.Map;
|
|
|
@RestController
|
|
|
@RequestMapping("/inspection")
|
|
|
public class InspectionController {
|
|
|
- private final Map<String, InspectionInterface> serviceMap;
|
|
|
- private final InspectionApi inspectionApi;
|
|
|
- private InspectionInterface service;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- public InspectionController(Map<String, InspectionInterface> serviceMap, InspectionApi inspectionApi) {
|
|
|
- this.serviceMap = serviceMap;
|
|
|
- this.inspectionApi = inspectionApi;
|
|
|
+ private final InspectionInterface service;
|
|
|
+
|
|
|
+ public InspectionController(InspectionInterface service) {
|
|
|
+ this.service = service;
|
|
|
}
|
|
|
|
|
|
- @PostConstruct
|
|
|
- public void init() {
|
|
|
- for (Map.Entry<String, InspectionInterface> map : serviceMap.entrySet()) {
|
|
|
- String key = map.getKey();
|
|
|
- if (inspectionApi.getConfig() == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- InspectionApi.Config config = inspectionApi.getConfig().get(key);
|
|
|
- if (config != null) {
|
|
|
- try {
|
|
|
- map.getValue().init(inspectionApi, config);
|
|
|
- service = map.getValue();
|
|
|
- } catch (Exception ignore) {}
|
|
|
- return;
|
|
|
- }
|
|
|
+ @Service
|
|
|
+ @ConditionalOnProperty(prefix = "thyy.inspection", name = "service", havingValue = "default", matchIfMissing = true)
|
|
|
+ static class Default implements InspectionInterface {
|
|
|
+ @Override
|
|
|
+ public List<JyIndexResponse> queryExamIndex(JSONObject request) {
|
|
|
+ return List.of();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JyDetailResponse queryExamDetail(JSONObject request) {
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|
|
|
|