Browse Source

LinkedList加解密

zhaops 5 years ago
parent
commit
3a68a82505

+ 2 - 0
common/src/main/java/com/diagbot/biz/push/entity/Medicition.java

@@ -1,5 +1,6 @@
 package com.diagbot.biz.push.entity;
 
+import com.diagbot.annotation.CryptField;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -18,6 +19,7 @@ public class Medicition {
     /**
      * 药品名称
      */
+    @CryptField
     private String medicitionName;
     /**
      * 词性(10:药品通用名)

+ 19 - 0
common/src/main/java/com/diagbot/util/CryptPojoUtils.java

@@ -11,6 +11,7 @@ import com.diagbot.annotation.CryptField;
 import org.apache.commons.lang3.StringUtils;
 
 import java.lang.reflect.Field;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
@@ -70,6 +71,15 @@ public class CryptPojoUtils {
                         for (Object listValue : fieldValue) {
                             encryptField(listValue);
                         }
+                    } else if (field.getType().equals(LinkedList.class)) {
+                        field.setAccessible(true);
+                        LinkedList fieldValue = (LinkedList) field.get(t);
+                        if (ListUtil.isEmpty(fieldValue)) {
+                            continue;
+                        }
+                        for (Object listValue : fieldValue) {
+                            encryptField(listValue);
+                        }
                     } else {
                         field.setAccessible(true);
                         Object fieldValue = field.get(t);
@@ -136,6 +146,15 @@ public class CryptPojoUtils {
                         for (Object listValue : fieldValue) {
                             decryptField(listValue);
                         }
+                    } else if (field.getType().equals(LinkedList.class)) {
+                        field.setAccessible(true);
+                        LinkedList fieldValue = (LinkedList) field.get(t);
+                        if (ListUtil.isEmpty(fieldValue)) {
+                            continue;
+                        }
+                        for (Object listValue : fieldValue) {
+                            decryptField(listValue);
+                        }
                     } else {
                         field.setAccessible(true);
                         Object fieldValue = field.get(t);