Browse Source

fix: 问题修改

JieZ 2 years ago
parent
commit
c059a532d9

+ 3 - 0
bpm-core/src/main/java/com/srm/config/BpmConfig.java

@@ -5,6 +5,8 @@ package com.srm.config;
5 5
 import org.springframework.boot.context.properties.ConfigurationProperties;
6 6
 import org.springframework.stereotype.Component;
7 7
 
8
+import java.util.List;
9
+
8 10
 import lombok.Getter;
9 11
 import lombok.Setter;
10 12
 
@@ -31,4 +33,5 @@ public class BpmConfig {
31 33
     private String callbackUrl;
32 34
     
33 35
     private String pushmsgUrl;
36
+    private List<String> excludeUrl;
34 37
 }

+ 61 - 0
bpm-core/src/main/java/com/srm/config/WebConfig.java

@@ -0,0 +1,61 @@
1
+/*
2
+ * The Hefei JingTong RDC(Research and Development Centre) Group.
3
+ * __________________
4
+ *
5
+ *    Copyright 2015-2023
6
+ *    All Rights Reserved.
7
+ *
8
+ *    NOTICE:  All information contained herein is, and remains
9
+ *    the property of JingTong Company and its suppliers,
10
+ *    if any.
11
+ */
12
+
13
+package com.srm.config;
14
+
15
+import com.google.common.collect.Lists;
16
+
17
+import com.srm.web.LoginInterceptor;
18
+
19
+import org.springframework.beans.factory.annotation.Autowired;
20
+import org.springframework.context.annotation.Configuration;
21
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
22
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
23
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
24
+
25
+import java.util.List;
26
+import java.util.Objects;
27
+
28
+/**
29
+ * <p> </p>
30
+ *
31
+ * @author ZhangJie
32
+ * @version 1.0
33
+ * @since JDK 1.8
34
+ */
35
+@Configuration
36
+public class WebConfig implements WebMvcConfigurer {
37
+    @Override
38
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
39
+        registry.addResourceHandler("doc.html")
40
+                .addResourceLocations("classpath:/META-INF/resources/");
41
+        registry.addResourceHandler("/webjars/**")
42
+                .addResourceLocations("classpath:/META-INF/resources/webjars/");
43
+    }
44
+
45
+    @Autowired
46
+    private BpmConfig bpmConfig;
47
+    @Autowired
48
+    private LoginInterceptor loginInterceptor;
49
+
50
+    public void addInterceptors(InterceptorRegistry registry) {
51
+        List<String> exclude =
52
+                Lists.newArrayList("/process/bill/page/*", "/process/flow/*", "/doc.html",
53
+                        "/webjars/**", "/swagger-resources", "/static/**");
54
+        if (!Objects.isNull(bpmConfig.getExcludeUrl())) {
55
+            exclude.addAll(bpmConfig.getExcludeUrl());
56
+        }
57
+        registry.addInterceptor(loginInterceptor)
58
+                .addPathPatterns("/**")
59
+                .excludePathPatterns(exclude);
60
+    }
61
+}

+ 86 - 0
bpm-core/src/main/java/com/srm/web/LoginInterceptor.java

@@ -0,0 +1,86 @@
1
+/*
2
+ * The Hefei JingTong RDC(Research and Development Centre) Group.
3
+ * __________________
4
+ *
5
+ *    Copyright 2015-2023
6
+ *    All Rights Reserved.
7
+ *
8
+ *    NOTICE:  All information contained herein is, and remains
9
+ *    the property of JingTong Company and its suppliers,
10
+ *    if any.
11
+ */
12
+
13
+package com.srm.web;
14
+
15
+import com.google.common.base.Strings;
16
+
17
+import com.srm.bpm.logic.service.LoginUserHolder;
18
+
19
+import org.springframework.stereotype.Component;
20
+import org.springframework.web.servlet.HandlerInterceptor;
21
+import org.springframework.web.servlet.ModelAndView;
22
+
23
+import java.io.PrintWriter;
24
+import java.util.Objects;
25
+
26
+import javax.servlet.http.Cookie;
27
+import javax.servlet.http.HttpServletRequest;
28
+import javax.servlet.http.HttpServletResponse;
29
+
30
+import lombok.RequiredArgsConstructor;
31
+
32
+/**
33
+ * <p> </p>
34
+ *
35
+ * @author ZhangJie
36
+ * @version 1.0
37
+ * @since JDK 1.8
38
+ */
39
+@Component
40
+@RequiredArgsConstructor
41
+public class LoginInterceptor implements HandlerInterceptor {
42
+    private final LoginUserHolder loginUserHolder;
43
+
44
+    @Override
45
+    public boolean preHandle(
46
+            HttpServletRequest request, HttpServletResponse response, Object handler
47
+    ) throws Exception {
48
+        boolean flag;
49
+        String userCode = loginUserHolder.getUserCode();
50
+        final Cookie[] cookies = request.getCookies();
51
+        if (!Objects.isNull(cookies)) {
52
+            for (Cookie cookie : cookies) {
53
+                final String name = cookie.getName();
54
+                if (name.equals("token")) {
55
+                    userCode = cookie.getValue();
56
+                }
57
+            }
58
+        }
59
+        if (Strings.isNullOrEmpty(userCode)) {
60
+            response.setContentType("text/html; charset=utf-8");
61
+            PrintWriter writer = response.getWriter();
62
+            writer.print("无权限");
63
+            writer.close();
64
+            response.flushBuffer();
65
+            flag = false;
66
+        } else {
67
+            flag = true;
68
+        }
69
+        return flag;
70
+    }
71
+
72
+    @Override
73
+    public void postHandle(
74
+            HttpServletRequest request, HttpServletResponse response, Object handler,
75
+            ModelAndView modelAndView
76
+    ) throws Exception {
77
+
78
+    }
79
+
80
+    @Override
81
+    public void afterCompletion(
82
+            HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex
83
+    ) throws Exception {
84
+
85
+    }
86
+}

+ 1 - 9
bpm-server/src/main/java/com/BpmApplication.java

@@ -5,8 +5,6 @@ package com;
5 5
 import org.activiti.spring.boot.SecurityAutoConfiguration;
6 6
 import org.springframework.boot.SpringApplication;
7 7
 import org.springframework.boot.autoconfigure.SpringBootApplication;
8
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
9
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
10 8
 
11 9
 /**
12 10
  * <p> </p>
@@ -16,16 +14,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
16 14
  * @since JDK 1.8
17 15
  */
18 16
 @SpringBootApplication(exclude= {SecurityAutoConfiguration.class})
19
-public class BpmApplication implements WebMvcConfigurer {
17
+public class BpmApplication {
20 18
 
21 19
     public static void main(String[] args) {
22 20
         SpringApplication.run(BpmApplication.class, args);
23 21
     }
24 22
 
25
-
26
-    @Override
27
-    public void addResourceHandlers(ResourceHandlerRegistry registry) {
28
-        registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
29
-        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
30
-    }
31 23
 }

+ 6 - 12
bpm-server/src/main/resources/application.yml

@@ -20,8 +20,8 @@ spring:
20 20
       max-file-size: 100MB
21 21
       max-request-size: 1000MB
22 22
   #环境 dev|test|prod
23
-#  profiles:
24
-#    active: test
23
+  profiles:
24
+    active: prod
25 25
   messages:
26 26
     encoding: UTF-8
27 27
     basename: i18n/messages_common
@@ -45,7 +45,7 @@ spring:
45 45
     druid:
46 46
       #MySQL
47 47
       driver-class-name: com.mysql.jdbc.Driver
48
-      url: jdbc:mysql://119.3.5.90:3306/jqh_srm_9000?useUnicode=true&characterEncoding=utf-8&useSSL=true&allowMultiQueries=true
48
+      url: jdbc:mysql://119.3.5.90:3306/jqh_srm_9001?useUnicode=true&characterEncoding=utf-8&useSSL=true&allowMultiQueries=true
49 49
       username: root
50 50
       password: Jingtong@2021
51 51
       initial-size: 10
@@ -79,21 +79,15 @@ spring:
79 79
       client:
80 80
         url: http://127.0.0.1:9095
81 81
 management:
82
-  endpoint:
83
-    jolokia:
84
-      enabled: false
85
-    logfile:
86
-      external-file: "/Users/jiez/workspace/t-oa-bpm/bpm/logs/public.log"
87
-  endpoints:
88
-    web:
89
-      exposure:
90
-        include: '*'
82
+  server:
83
+    port: -1
91 84
 logging:
92 85
   config: classpath:logback-spring.xml
93 86
   level:
94 87
     root: info
95 88
     com.srm: debug
96 89
     com.srm.bpm.infra.dao.ToaBillDao.selectTodoSizeByStatus: error
90
+    de.codecentric.boot.admin.client.registration: off
97 91
 feign:
98 92
   sentinel:
99 93
     enabled: true