Explorar el Código

字段加解密

gaodm hace 5 años
padre
commit
bd5e4632ef

+ 4 - 4
aipt-service/src/main/java/com/diagbot/aop/CryptAspect.java

@@ -6,12 +6,12 @@ import com.diagbot.client.bean.Response;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.util.CryptPojoUtils;
 import com.diagbot.util.RespDTOUtil;
-import lombok.extern.slf4j.Slf4j;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.Around;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Pointcut;
-import org.springframework.context.annotation.Configuration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
 
 /**
  * @Description: 数据库加解密
@@ -19,8 +19,8 @@ import org.springframework.context.annotation.Configuration;
  * @time: 2019/12/31 13:17
  */
 @Aspect
-@Slf4j
-@Configuration
+@Component
+@ConditionalOnProperty(prefix = "crypt", value = { "enable" }, havingValue = "true")
 public class CryptAspect {
 
     //切所有Controller

+ 29 - 0
aipt-service/src/main/java/com/diagbot/config/CryptConfiguer.java

@@ -0,0 +1,29 @@
+package com.diagbot.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/1/2 10:59
+ */
+@Component
+public class CryptConfiguer {
+
+    @Value("${crypt.enable}")
+    public Boolean cryptFlag;
+
+    private static CryptConfiguer cryptConfiguer;
+
+    public static CryptConfiguer getInstance() {
+        if (null == cryptConfiguer) {
+            synchronized (CryptConfiguer.class) {
+                if (null == cryptConfiguer) {
+                    cryptConfiguer = new CryptConfiguer();
+                }
+            }
+        }
+        return cryptConfiguer;
+    }
+}

+ 5 - 2
aipt-service/src/main/java/com/diagbot/web/ConceptDetailTestController.java

@@ -1,11 +1,10 @@
 package com.diagbot.web;
 
 import com.diagbot.annotation.SysLogger;
-import com.diagbot.dto.ConceptIntroduceDTO;
+import com.diagbot.config.CryptConfiguer;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.entity.ConceptDetail;
 import com.diagbot.facade.ConceptDetailTestFacade;
-import com.diagbot.vo.ConceptIntroduceVO;
 import io.swagger.annotations.Api;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -27,6 +26,9 @@ import java.util.List;
 @Api(value = "提示信息加密测试", tags = { "知识库标准化-提示信息加密测试相关API" })
 @SuppressWarnings("unchecked")
 public class ConceptDetailTestController {
+    @Autowired
+    private CryptConfiguer cryptConfiguer;
+
     @Autowired
     private ConceptDetailTestFacade conceptDetailTestFacade;
 
@@ -41,6 +43,7 @@ public class ConceptDetailTestController {
     @SysLogger("getById")
     public RespDTO<ConceptDetail> getById(@RequestParam Long id) {
         ConceptDetail data = conceptDetailTestFacade.getByIds(id);
+        System.out.println(cryptConfiguer.cryptFlag);
         return RespDTO.onSuc(data);
     }
 

+ 4 - 1
config-server/src/main/resources/shared/application-dev.yml

@@ -75,4 +75,7 @@ syslog:
   enable: true
 
 bilog:
-  enable: false
+  enable: false
+
+crypt:
+  enable: true

+ 4 - 1
config-server/src/main/resources/shared/application-local.yml

@@ -75,4 +75,7 @@ syslog:
   enable: true
 
 bilog:
-  enable: false
+  enable: false
+
+crypt:
+  enable: true

+ 4 - 1
config-server/src/main/resources/shared/application-pre.yml

@@ -75,4 +75,7 @@ syslog:
   enable: true
 
 bilog:
-  enable: false
+  enable: false
+
+crypt:
+  enable: true

+ 4 - 1
config-server/src/main/resources/shared/application-pro.yml

@@ -75,4 +75,7 @@ syslog:
   enable: true
 
 bilog:
-  enable: false
+  enable: false
+
+crypt:
+  enable: true

+ 4 - 1
config-server/src/main/resources/shared/application-test.yml

@@ -75,4 +75,7 @@ syslog:
   enable: true
 
 bilog:
-  enable: false
+  enable: false
+
+crypt:
+  enable: true

+ 4 - 4
knowledgeman-service/src/main/java/com/diagbot/aop/CryptAspect.java

@@ -6,12 +6,12 @@ import com.diagbot.client.bean.Response;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.util.CryptPojoUtils;
 import com.diagbot.util.RespDTOUtil;
-import lombok.extern.slf4j.Slf4j;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.Around;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Pointcut;
-import org.springframework.context.annotation.Configuration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.stereotype.Component;
 
 /**
  * @Description: 数据库加解密
@@ -19,8 +19,8 @@ import org.springframework.context.annotation.Configuration;
  * @time: 2019/12/31 13:17
  */
 @Aspect
-@Slf4j
-@Configuration
+@Component
+@ConditionalOnProperty(prefix = "crypt", value = { "enable" }, havingValue = "true")
 public class CryptAspect {
 
     //切所有Controller

+ 29 - 0
knowledgeman-service/src/main/java/com/diagbot/config/CryptConfiguer.java

@@ -0,0 +1,29 @@
+package com.diagbot.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/1/2 10:59
+ */
+@Component
+public class CryptConfiguer {
+
+    @Value("${crypt.enable}")
+    public Boolean cryptFlag;
+
+    private static CryptConfiguer cryptConfiguer;
+
+    public static CryptConfiguer getInstance() {
+        if (null == cryptConfiguer) {
+            synchronized (CryptConfiguer.class) {
+                if (null == cryptConfiguer) {
+                    cryptConfiguer = new CryptConfiguer();
+                }
+            }
+        }
+        return cryptConfiguer;
+    }
+}