瀏覽代碼

更新!

TRX 1 年之前
父節點
當前提交
e8c7be6ecf

+ 6 - 6
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/httpRequest/ApiRequestService.java

@@ -1,16 +1,16 @@
 package com.zhongshu.iot.server.core.httpRequest;
 
 import cn.hutool.core.bean.BeanUtil;
+import com.github.microservice.core.util.net.apache.MethodType;
+import com.github.microservice.http.APIResponseModel;
+import com.github.microservice.http.ApiConfParam;
 import com.zhongshu.iot.server.core.dao.payment.RequestInfoDao;
-import com.zhongshu.iot.server.core.httpRequest.apiConf.APIResponseModel;
-import com.zhongshu.iot.server.core.httpRequest.apiConf.ApiConfParam;
 import com.zhongshu.iot.server.core.httpRequest.conf.FullCardAPIConfig;
 import com.zhongshu.iot.server.core.httpRequest.conf.FullCardConf;
 import com.zhongshu.iot.server.core.service.base.SuperService;
 import com.zhongshu.iot.server.core.service.other.RequestInfoService;
 import com.zhongshu.iot.server.core.util.net.apache.HttpClientUtil;
 import com.zhongshu.iot.server.core.util.net.apache.HttpModel;
-import com.zhongshu.iot.server.core.util.net.apache.MethodType;
 import com.zhongshu.iot.server.core.util.net.apache.ResponseModel;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
@@ -59,7 +59,7 @@ public class ApiRequestService extends SuperService {
             stopWatch.start();
             String url = fullCardConf.getUrl() + fullCardConf.getCardServerName() + apiConfParam.getApiName();
             ResponseModel request = HttpClientUtil.request(HttpModel.builder()
-                    .url(url).method(apiConfParam.getMethodType()).charset("utf-8").body(data).build());
+                    .url(url).method(MethodType.Json).charset("utf-8").body(data).build());
             if (request.getCode() == 200) {
                 responseModel = BeanUtil.copyProperties(request.getBody(), APIResponseModel.class);
             } else {
@@ -84,11 +84,11 @@ public class ApiRequestService extends SuperService {
         try {
             ApiConfParam apiConfParam = new ApiConfParam();
             apiConfParam.setApiName(url);
-            apiConfParam.setMethodType(MethodType.Json);
+            apiConfParam.setMethodType(MethodType.Json.name());
             StopWatch stopWatch = new StopWatch();
             stopWatch.start();
             ResponseModel request = HttpClientUtil.request(HttpModel.builder()
-                    .url(url).method(apiConfParam.getMethodType()).charset("utf-8").body(data).build());
+                    .url(url).method(MethodType.Json).charset("utf-8").body(data).build());
             int code = request.getCode();
             if (code == 200) {
                 responseModel = BeanUtil.copyProperties(request.getBody(), APIResponseModel.class);

+ 0 - 76
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/httpRequest/apiConf/APIResponseModel.java

@@ -1,76 +0,0 @@
-package com.zhongshu.iot.server.core.httpRequest.apiConf;
-
-import cn.hutool.json.JSONObject;
-import cn.hutool.json.JSONUtil;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.apache.commons.lang3.StringUtils;
-
-/**
- * @author TRX
- * @date 2024/6/25
- */
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public class APIResponseModel {
-
-    @Schema(description = "是否错误")
-    private boolean failed;
-
-    @Schema(description = "是否成功")
-    private boolean success;
-
-    @Schema(description = "返回消息")
-    private String msg;
-
-    private String state;
-
-    private String content;
-
-    @Schema(description = "访问的URL")
-    private ApiConfParam param;
-
-    private Object data;
-
-    @Schema(description = "请求耗时:毫秒")
-    private Long millis;
-
-    public <T> T toBean(Class<T> tClass) {
-        if (content != null) {
-            return JSONUtil.toBean(content, tClass);
-        }
-        return null;
-    }
-
-    public JSONObject toJson() {
-        if (content != null) {
-            return JSONUtil.parseObj(content);
-        }
-        return null;
-    }
-
-    public boolean isSuccess() {
-        if (StringUtils.isNotEmpty(this.state) && "Fail".equals(state)) {
-            return false;
-        }
-        return success;
-    }
-
-    public boolean isFailed() {
-        return !this.isSuccess();
-    }
-
-    public void setIsFailed() {
-        this.success = Boolean.FALSE;
-        this.failed = Boolean.TRUE;
-        this.state = "Fail";
-    }
-
-    public void setIsFailed(String msg) {
-        this.setIsFailed();
-        this.msg = msg;
-    }
-}

+ 0 - 26
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/httpRequest/apiConf/ApiConfParam.java

@@ -1,26 +0,0 @@
-package com.zhongshu.iot.server.core.httpRequest.apiConf;
-
-import com.zhongshu.iot.server.core.util.net.apache.MethodType;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author TRX
- * @date 2024/6/25
- */
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-@Builder
-public class ApiConfParam {
-
-    @Schema(description = "API名称")
-    private String apiName;
-
-    @Schema(description = "方式")
-    private MethodType methodType;
-
-}

+ 13 - 13
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/httpRequest/conf/FullCardAPIConfig.java

@@ -1,7 +1,7 @@
 package com.zhongshu.iot.server.core.httpRequest.conf;
 
-import com.zhongshu.iot.server.core.httpRequest.apiConf.ApiConfParam;
-import com.zhongshu.iot.server.core.util.net.apache.MethodType;
+import com.github.microservice.core.util.net.apache.MethodType;
+import com.github.microservice.http.ApiConfParam;
 
 import java.util.HashMap;
 
@@ -39,26 +39,26 @@ public class FullCardAPIConfig {
     public static final HashMap<String, ApiConfParam> map = new HashMap<>();
 
     static {
-        map.put(sendMessage, ApiConfParam.builder().apiName(sendMessage).methodType(MethodType.Json).build());
-        map.put(ping, ApiConfParam.builder().apiName(ping).methodType(MethodType.Get).build());
+        map.put(sendMessage, ApiConfParam.builder().apiName(sendMessage).methodType(MethodType.Json.name()).build());
+        map.put(ping, ApiConfParam.builder().apiName(ping).methodType(MethodType.Json.name()).build());
 
         // ----------------------------云版消费机 start -----------------
-        map.put(ServerTime, ApiConfParam.builder().apiName(ServerTime).methodType(MethodType.Json).build());
+        map.put(ServerTime, ApiConfParam.builder().apiName(ServerTime).methodType(MethodType.Json.name()).build());
 
         // 刷卡支付相关的接口配置
-        map.put(ConsumTransactions, ApiConfParam.builder().apiName(ConsumTransactions).methodType(MethodType.Json).build());
-        map.put(orderQuery, ApiConfParam.builder().apiName(orderQuery).methodType(MethodType.Json).build());
+        map.put(ConsumTransactions, ApiConfParam.builder().apiName(ConsumTransactions).methodType(MethodType.Json.name()).build());
+        map.put(orderQuery, ApiConfParam.builder().apiName(orderQuery).methodType(MethodType.Json.name()).build());
 
         // B扫C功能接口配置
-        map.put(QRCodeTransaction, ApiConfParam.builder().apiName(QRCodeTransaction).methodType(MethodType.Json).build());
-        map.put(TransactionInquiry, ApiConfParam.builder().apiName(TransactionInquiry).methodType(MethodType.Json).build());
+        map.put(QRCodeTransaction, ApiConfParam.builder().apiName(QRCodeTransaction).methodType(MethodType.Json.name()).build());
+        map.put(TransactionInquiry, ApiConfParam.builder().apiName(TransactionInquiry).methodType(MethodType.Json.name()).build());
 
 
         // ----------------------------全卡项目 start -----------------
-        map.put(deviceSync, ApiConfParam.builder().apiName(deviceSync).methodType(MethodType.Json).build());
-        map.put(syncGateWays, ApiConfParam.builder().apiName(syncGateWays).methodType(MethodType.Json).build());
-        map.put(syncDeviceOnLineState, ApiConfParam.builder().apiName(syncDeviceOnLineState).methodType(MethodType.Json).build());
-        map.put(lastDeviceOnLineTime, ApiConfParam.builder().apiName(lastDeviceOnLineTime).methodType(MethodType.Json).build());
+        map.put(deviceSync, ApiConfParam.builder().apiName(deviceSync).methodType(MethodType.Json.name()).build());
+        map.put(syncGateWays, ApiConfParam.builder().apiName(syncGateWays).methodType(MethodType.Json.name()).build());
+        map.put(syncDeviceOnLineState, ApiConfParam.builder().apiName(syncDeviceOnLineState).methodType(MethodType.Json.name()).build());
+        map.put(lastDeviceOnLineTime, ApiConfParam.builder().apiName(lastDeviceOnLineTime).methodType(MethodType.Json.name()).build());
     }
 
     public static ApiConfParam getApiConfParam(String apiName) {

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/artemis/OperationMessageService.java

@@ -23,7 +23,7 @@ import com.zhongshu.iot.server.core.domain.iot.mqtt.OperationMessage;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.OperationMessageResult;
 import com.zhongshu.iot.server.core.domain.other.ExecuteMethodInfo;
 import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;
-import com.zhongshu.iot.server.core.httpRequest.apiConf.APIResponseModel;
+import com.github.microservice.http.APIResponseModel;
 import com.zhongshu.iot.server.core.service.base.SuperService;
 import com.zhongshu.iot.server.core.service.iot.IotDataVerifyService;
 import com.zhongshu.iot.server.core.service.mqtt.DeviceInfoService;

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/other/RequestInfoService.java

@@ -4,7 +4,7 @@ import com.github.microservice.models.hxz.base.IotBaseResult;
 import com.zhongshu.iot.client.type.RequestType;
 import com.zhongshu.iot.server.core.dao.payment.RequestInfoDao;
 import com.zhongshu.iot.server.core.domain.payment.RequestInfo;
-import com.zhongshu.iot.server.core.httpRequest.apiConf.APIResponseModel;
+import com.github.microservice.http.APIResponseModel;
 import com.zhongshu.iot.server.core.util.DateUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/payment/HxzService.java

@@ -8,7 +8,7 @@ import com.zhongshu.iot.server.core.domain.ExecuteAnnotationService;
 import com.zhongshu.iot.server.core.domain.ExecuteAnnotationServiceMethod;
 import com.zhongshu.iot.server.core.domain.iot.mqtt.DeviceInfo;
 import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;
-import com.zhongshu.iot.server.core.httpRequest.apiConf.APIResponseModel;
+import com.github.microservice.http.APIResponseModel;
 import com.zhongshu.iot.server.core.httpRequest.conf.FullCardAPIConfig;
 import com.zhongshu.iot.server.core.service.base.SuperService;
 import com.zhongshu.iot.server.core.service.other.RequestInfoService;

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/sync/DeviceSyncFullCardService.java

@@ -15,7 +15,7 @@ import com.zhongshu.iot.server.core.event.DeviceStateChangeEvent;
 import com.zhongshu.iot.server.core.event.DeviceSyncEvent;
 import com.zhongshu.iot.server.core.event.GateWaySyncEvent;
 import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;
-import com.zhongshu.iot.server.core.httpRequest.apiConf.APIResponseModel;
+import com.github.microservice.http.APIResponseModel;
 import com.zhongshu.iot.server.core.httpRequest.conf.FullCardAPIConfig;
 import com.zhongshu.iot.server.core.service.base.SuperService;
 import com.zhongshu.iot.server.core.service.user.OperationLogsService;

+ 2 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/util/net/apache/HttpClientUtil.java

@@ -1,4 +1,6 @@
 package com.zhongshu.iot.server.core.util.net.apache;
+
+import com.github.microservice.core.util.net.apache.MethodType;
 import com.zhongshu.iot.server.core.util.net.JsonUtil;
 import lombok.Cleanup;
 import lombok.SneakyThrows;

+ 2 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/util/net/apache/HttpModel.java

@@ -1,5 +1,7 @@
 package com.zhongshu.iot.server.core.util.net.apache;
 
+import com.github.microservice.core.util.net.apache.MethodType;
+import com.github.microservice.http.MethodType1;
 import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;

+ 0 - 10
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/util/net/apache/MethodType.java

@@ -1,10 +0,0 @@
-package com.zhongshu.iot.server.core.util.net.apache;
-
-/**
- * 方法类型
- */
-public enum MethodType {
-    Post,
-    Get,
-    Json
-}