|
|
@@ -1,10 +1,17 @@
|
|
|
package org.jeecg.modules.smscheck.configs;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
+import org.jeecg.modules.smscheck.entity.FileStaticUrl;
|
|
|
+import org.jeecg.modules.smscheck.entity.MyCustomAnnotation;
|
|
|
+import org.jeecg.modules.smscheck.entity.SmsCheckCustomerData;
|
|
|
+import org.jeecg.modules.smscheck.entity.UrlData;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
public class ObjectComparator {
|
|
|
public static Map<String, Object> compareObjects(Object obj1, Object obj2) throws IllegalAccessException {
|
|
|
@@ -54,4 +61,73 @@ public class ObjectComparator {
|
|
|
|
|
|
return diffProperties;
|
|
|
}
|
|
|
+
|
|
|
+ public static List<UrlData> downLoad(Object o){
|
|
|
+ if (o==null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<UrlData> urlDatas = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ Class<?> clazz = o.getClass();
|
|
|
+ Field[] fields = clazz.getDeclaredFields();
|
|
|
+ for (Field field : fields) {
|
|
|
+ field.setAccessible(true);
|
|
|
+ if (field.isAnnotationPresent(MyCustomAnnotation.class)) {
|
|
|
+ Object value = field.get(o);
|
|
|
+ MyCustomAnnotation annotation = field.getAnnotation(MyCustomAnnotation.class);
|
|
|
+ if (value!=null && !((String) value).isEmpty() && !value.toString().equals("[{}]")){
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(value.toString());
|
|
|
+ List<UrlStrObj> urlList = jsonArray.toJavaList(UrlStrObj.class);
|
|
|
+ List<FileStaticUrl> urls =new ArrayList<>();
|
|
|
+ for (UrlStrObj urlStrObj : urlList) {
|
|
|
+ FileStaticUrl fileStaticUrl = new FileStaticUrl();
|
|
|
+ fileStaticUrl.setFileName(urlStrObj.getFileName());
|
|
|
+ fileStaticUrl.setFileStaticUrl(urlStrObj.getUrl());
|
|
|
+ urls.add(fileStaticUrl);
|
|
|
+ }
|
|
|
+ UrlData urlData = new UrlData();
|
|
|
+ urlData.setFileId(field.getAnnotation(ApiModelProperty.class).value());
|
|
|
+ urlData.setFileStaticUrl(urls);
|
|
|
+ urlDatas.add(urlData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return urlDatas;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ static class UrlStrObj{
|
|
|
+ private String urlBase;
|
|
|
+
|
|
|
+ private String url;
|
|
|
+
|
|
|
+ private String fileName;
|
|
|
+
|
|
|
+ public String getUrlBase() {
|
|
|
+ return urlBase;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setUrlBase(String urlBase) {
|
|
|
+ this.urlBase = urlBase;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getUrl() {
|
|
|
+ return url;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setUrl(String url) {
|
|
|
+ this.url = url;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getFileName() {
|
|
|
+ return fileName;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setFileName(String fileName) {
|
|
|
+ this.fileName = fileName;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|