瀏覽代碼

新增专用于宜搭复杂逻辑处理的接口服务

lvjs 4 天之前
父節點
當前提交
398590971f

+ 46 - 0
src/main/java/com/malk/eastar/controller/EastarYidaController.java

@@ -0,0 +1,46 @@
+package com.malk.eastar.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.malk.eastar.service.YidaService;
+import com.malk.server.common.McException;
+import com.malk.server.common.McR;
+import com.malk.utils.UtilMap;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+
+/**
+ * 专用于宜搭复杂逻辑处理的接口服务
+ * add by Jason 20260317
+ */
+@Slf4j
+@RestController
+@RequestMapping("/yida")
+public class EastarYidaController {
+
+    @Autowired
+    private YidaService yidaService;
+
+    /**
+     * 供宜搭应用检查当前接口服务是否可用
+     * @param data
+     * @return
+     */
+    @PostMapping("/test")
+    McR heartbeatTest(@RequestBody JSONObject data) {
+        log.info("心跳测试, {}", data);
+        McException.assertParamException_Null(data, "param");
+        String param = UtilMap.getString(data, "param");
+        Map result = yidaService.heartbeatTest(param);
+        if(result.get("error") == null){
+            return McR.success(result);
+        }else{
+            return McR.error("400",result.get("error").toString());
+        }
+    }
+}

+ 20 - 0
src/main/java/com/malk/eastar/service/YidaService.java

@@ -0,0 +1,20 @@
+package com.malk.eastar.service;
+
+import java.util.Map;
+
+/**
+ * 专用于宜搭复杂逻辑处理的接口服务
+ * add by Jason 20260317
+ */
+public interface YidaService {
+
+    /**
+     * 供宜搭应用检查当前接口服务是否可用
+     * @param param
+     * @return
+     */
+    Map heartbeatTest(String param);
+
+
+
+}

+ 33 - 0
src/main/java/com/malk/eastar/service/impl/YidaServiceImpl.java

@@ -0,0 +1,33 @@
+package com.malk.eastar.service.impl;
+
+import cn.hutool.core.date.DateUtil;
+import com.malk.eastar.service.YidaService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * 专用于宜搭复杂逻辑处理的接口服务
+ * add by Jason 20260317
+ */
+@Slf4j
+@Service
+public class YidaServiceImpl implements YidaService {
+
+    @Override
+    public Map heartbeatTest(String param) {
+        Map<String,Object> result = new LinkedHashMap<>();
+        if("EastarProgram".equals(param)){
+            result.put("col1","Eastar");
+            result.put("col2",888888);
+            result.put("col3", DateUtil.now());
+        }else{
+            result.put("error","错误的哦!");
+        }
+        return result;
+    }
+}