From 18251264e0840d54fc5c91b93f312f6b9cdafb89 Mon Sep 17 00:00:00 2001
From: CZT <czt18638530771@163.com>
Date: 星期五, 03 十一月 2023 10:50:55 +0800
Subject: [PATCH] 广东接口非必填字段增加固定值
---
src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java | 103 +++++++++++++++++++--------------------------------
1 files changed, 39 insertions(+), 64 deletions(-)
diff --git a/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java b/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java
index 182f078..d920975 100644
--- a/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java
+++ b/src/main/java/com/fzzy/push/gd2022/GD2022ApiRemoteService2022.java
@@ -16,6 +16,7 @@
import com.fzzy.push.gd2022.dto.Gd2022Api1208;
import com.fzzy.push.gd2022.dto.Gd2022Api1307;
import com.fzzy.push.gd2022.dto.Gd2022Api1308;
+import com.fzzy.push.sh2023.SH2023Constant;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
@@ -24,6 +25,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.lang.reflect.Field;
import java.util.*;
/**
@@ -51,6 +53,11 @@
@Override
public String getProtocol() {
return PushProtocol.SB_GD_2022.getCode();
+ }
+
+ @Override
+ public ResponseDto pushData(ApiParam param, Object data) {
+ return pushData(param, null, data);
}
@Override
@@ -115,76 +122,12 @@
ResponseDto resd = new ResponseDto();
resd.setSuccess(responseDto.getCode() == 200 ? 0 : responseDto.getCode());
resd.setMsg(responseDto.getMsg());
- //updateGD2022AuthToken(responseDto,conf, token);
return resd;
} catch (Exception e) {
log.error(e.getMessage(), e);
return new ResponseDto(99, e.getMessage());
}
}
-
- @Override
- public ResponseDto pushData(ApiParam param, Object data) {
- return pushData(param, null, data);
- }
-
-// @Override
-// public ResponseDto pushFile(ApiParam param, ApiConfs conf, Object data) {
-//
-// String inteId = param.getInteId();
-// String kqdm = param.getKqdm();
-//
-// try {
-//
-// if (null == conf) {
-// conf = apiCommonService.getConf(kqdm);
-// }
-// //鑾峰彇TOKEN
-// GD2022AuthToken token = getGD2022AuthToken(conf);
-//
-// ApiLog apiLog = new ApiLog();
-// apiLog.setId(ContextUtil.getUUID());
-// apiLog.setInteId(inteId);
-// apiLog.setData(JSON.toJSONString(data));
-// apiLog.setKqdm(kqdm);
-// apiLog.setUploadTime(new Date());
-//
-// String wjdz = "";
-// if (Constant.API_CODE_1109.equals(inteId)) {
-// //灏佽鏁版嵁,鑾峰彇鏂囦欢鍦板潃
-// Gd2022Api1109 api1109 = new Gd2022Api1109();
-// BeanUtils.copyProperties(data, api1109);
-// wjdz = api1109.getWjdz();
-// } else if (Constant.API_CODE_1307.equals(inteId)) {
-// //灏佽鏁版嵁,鑾峰彇鏂囦欢鍦板潃
-// Gd2022Api1307 api1307 = new Gd2022Api1307();
-// BeanUtils.copyProperties(data, api1307);
-// wjdz = api1307.getWjdz();
-// } else if (Constant.API_CODE_1308.equals(inteId)) {
-// //灏佽鏁版嵁,鑾峰彇鏂囦欢鍦板潃
-// Gd2022Api1308 api1308 = new Gd2022Api1308();
-// BeanUtils.copyProperties(data, api1308);
-// wjdz = api1308.getWjdz();
-// }
-// if (StringUtils.isEmpty(wjdz)) {
-// ResponseDto responseDto = new ResponseDto(99, "娌℃湁鑾峰彇鍒版枃浠跺湴鍧�", wjdz);
-// apiLog.setStatus(99);
-// apiLog.setResult("娌℃湁鑾峰彇鍒版枃浠跺湴鍧�");
-// apiLogRep.save(apiLog);
-// return responseDto;
-// }
-// //鍏堜笂浼犳枃浠�,鑾峰彇鏂囦欢id
-// GD2022ResponseDto responseDto = GD2022HttpClientUtil.postUploadData(conf.getApiUrl(), token, wjdz);
-// ResponseDto resd = new ResponseDto();
-// resd.setSuccess(responseDto.getCode() == 200 ? 0 : responseDto.getCode());
-// resd.setBizId((String) responseDto.getData());
-// resd.setMsg(responseDto.getMsg());
-// return resd;
-// } catch (Exception e) {
-// log.error(e.getMessage(), e);
-// return new ResponseDto(99, e.getMessage());
-// }
-// }
/**
* 鎺ㄩ�佽储鍔℃暟鎹帴鍙�
@@ -324,6 +267,35 @@
}
}
+ private Object changeObject(Object object) {
+ // 浣跨敤鍙嶅皠鑾峰彇灞炴�у垪琛� object涓哄疄浣撳璞″悕
+ Field[] fields = object.getClass().getDeclaredFields();
+ for (Field field : fields) {
+ field.setAccessible(true);
+ try {
+ // 鍒ゆ柇灞炴�у�兼槸鍚︿负null
+ if (field.get(object) == null || field.get(object) == "") {
+ //鏍规嵁绫诲瀷璁剧疆榛樿鍊�
+ if (field.getType() == String.class) {
+ field.set(object, "0");
+ }
+ if (field.getType() == Integer.class) {
+ field.set(object, 0);
+ }
+ if (field.getType() == Double.class) {
+ field.set(object, 0.0);
+ }
+ if (field.getType() == Date.class) {
+ field.set(object, new Date());
+ }
+ }
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ return object;
+ }
+
private String getJsonData(String inteId, Object data, String url, GD2022AuthToken authToken) throws Exception {
if (Constant.API_CODE_1101.equals(inteId)) {
Gd2022Api1101 api1101 = new Gd2022Api1101();
@@ -336,10 +308,12 @@
} else if (Constant.API_CODE_1103.equals(inteId)) {
Gd2022Api1103 api1103 = new Gd2022Api1103();
BeanUtils.copyProperties(data, api1103);
+ changeObject(api1103);
return JSON.toJSONString(api1103);
} else if (Constant.API_CODE_1104.equals(inteId)) {
Gd2022Api1104 api1104 = new Gd2022Api1104();
BeanUtils.copyProperties(data, api1104);
+ changeObject(api1104);
return JSON.toJSONString(api1104);
} else if (Constant.API_CODE_1105.equals(inteId)) {
Gd2022Api1105 api1105 = new Gd2022Api1105();
@@ -394,6 +368,7 @@
api1308.setFileStorageId((String) responseDto.getData());
return JSON.toJSONString(api1308);
} else {
+ changeObject(data);
return JSON.toJSONString(data);
}
}
--
Gitblit v1.9.3