Bladeren bron

读写分离

hanqingsong 3 jaren geleden
bovenliggende
commit
3a168ecbc9

+ 5 - 0
pom.xml

@@ -21,6 +21,11 @@
21 21
 
22 22
     <dependencies>
23 23
         <dependency>
24
+            <groupId>org.apache.shardingsphere</groupId>
25
+            <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
26
+            <version>5.1.0</version>
27
+        </dependency>
28
+        <dependency>
24 29
             <groupId>org.springframework.boot</groupId>
25 30
             <artifactId>spring-boot-starter-web</artifactId>
26 31
         </dependency>

+ 3 - 4
src/main/java/com/chinaitop/depot/system/controller/SystemLogController.java

@@ -70,9 +70,10 @@ public class SystemLogController {
70 70
 		if (null != username && !"".equals(username)) {
71 71
 			criteria.andUserNameLike("%"+username+"%");
72 72
 		}
73
-		example.setOrderByClause("operation_time desc");
73
+//		example.setOrderByClause("operation_time desc");
74 74
 
75 75
 		List<SystemLog> list = userOperationlogService.findSystemLogCondition(example);
76
+		// 控制parameter 请求参数在列表中展示的长度不超过50+"......"
76 77
 		if (null != list && list.size() > 0) {
77 78
 			SystemLog log = null;
78 79
 			String parameter = "";
@@ -90,9 +91,7 @@ public class SystemLogController {
90 91
 			}
91 92
 		}
92 93
 
93
-		PageInfo<SystemLog> pageInfo = new PageInfo<SystemLog>(list);
94
-
95
-		return pageInfo;
94
+		return new PageInfo<>(list);
96 95
 	}
97 96
 
98 97
 	@RequestMapping(value="/save", method = RequestMethod.POST)

+ 13 - 1
src/main/java/com/chinaitop/depot/system/mapper/SystemLogMapper.xml

@@ -464,7 +464,7 @@
464 464
   </update>
465 465
 
466 466
   <!-- 查询三张日志表集合 -->
467
-  <select id="queryAllLog" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.system.model.SystemLogExample">
467
+  <!--<select id="queryAllLog" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.system.model.SystemLogExample">
468 468
   	select system_log.*
469 469
     from (
470 470
 	SELECT C.* FROM system_log C
@@ -485,5 +485,17 @@
485 485
     <if test="orderByClause != null" >
486 486
       order by ${orderByClause}
487 487
     </if>
488
+  </select>-->
489
+
490
+  <select id="queryAllLog" resultMap="BaseResultMap" parameterType="com.chinaitop.depot.system.model.SystemLogExample">
491
+    SELECT
492
+    <include refid="Base_Column_List" />
493
+    FROM
494
+      system_log_temp
495
+    <if test="_parameter != null" >
496
+      <include refid="Example_Where_Clause" />
497
+    </if>
498
+    ORDER BY
499
+      operation_time DESC
488 500
   </select>
489 501
 </mapper>

+ 1 - 1
src/main/java/com/chinaitop/depot/system/mapper/UserBusinessMapper.xml

@@ -137,7 +137,7 @@
137 137
   
138 138
   <select id="queryBusinessList" resultType="java.lang.String" parameterType="java.lang.String" >
139 139
     select table_name 
140
-	from information_schema.columns 
140
+	from information_schema_columns
141 141
 	where table_schema='depot' and column_name = 'org_id'
142 142
 	<!-- gbase8s使用的sql -->
143 143
 	<!-- SELECT systables.tabname table_name FROM systables

+ 45 - 10
src/main/resources/bootstrap.yml

@@ -2,28 +2,63 @@ server:
2 2
   port: 9023
3 3
   tomcat:
4 4
     uri-encoding: utf-8
5
-
6 5
 # 注册中心配置
7 6
 eureka:
8 7
   client:
9 8
     service-url:
10
-      defaultZone: http://172.16.0.8:9001/eureka/,http://172.16.0.9:9001/eureka/
9
+      defaultZone: http://172.16.0.8:9001/eureka/
11 10
   instance:
12 11
     prefer-ip-address: true
13 12
     # 每隔10s发送一次心跳(默认30s)
14 13
     lease-renewal-interval-in-seconds: 10
15 14
     # 告知服务端30秒还未收到心跳的话,就将该服务移除列表(默认90s)
16 15
     lease-expiration-duration-in-seconds: 30
17
-
18 16
 spring:
19 17
   application:
20 18
     name: depot-system
21
-  # 数据库配置
22
-  datasource:
23
-    driverClassName: com.mysql.cj.jdbc.Driver
24
-    url: jdbc:mysql://101.36.160.140:10311/depot_yunnan?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
25
-    username: root
26
-    password: 123456
19
+  shardingsphere:
20
+    props:
21
+      sql-show: true
22
+    mode:
23
+      type: Standalone
24
+      overwrite: true
25
+      repository:
26
+        type: File
27
+        props:
28
+          path: D:/Standalone/depot-system
29
+#          path: /home/depot/Standalone/depot-system
30
+    datasource:
31
+      names: depot-master-01,depot-slave-01,depot-slave-02
32
+      depot-master-01:
33
+        type: com.zaxxer.hikari.HikariDataSource
34
+        driver-class-name: com.mysql.cj.jdbc.Driver
35
+        jdbc-url: jdbc:mysql://172.16.0.8:3306/depot?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
36
+        username: root
37
+        password: 123456
38
+      depot-slave-01:
39
+        type: com.zaxxer.hikari.HikariDataSource
40
+        driver-class-name: com.mysql.cj.jdbc.Driver
41
+        jdbc-url: jdbc:mysql://172.16.0.9:3306/depot?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
42
+        username: root
43
+        password: 123456
44
+      depot-slave-02:
45
+        type: com.zaxxer.hikari.HikariDataSource
46
+        driver-class-name: com.mysql.cj.jdbc.Driver
47
+        jdbc-url: jdbc:mysql://172.16.0.10:3306/depot?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC
48
+        username: root
49
+        password: 123456
50
+    rules:
51
+      readwrite-splitting:
52
+        data-sources:
53
+          depot:
54
+            type: Static
55
+            props:
56
+              write-data-source-name: depot-master-01
57
+              read-data-source-names: depot-slave-01,depot-slave-02
58
+            load-balancer-name: depot_algorithm
59
+        load-balancers:
60
+          depot_algorithm:
61
+            type: ROUND_ROBIN
27 62
   # 缓存配置
28 63
   session:
29 64
     store-type: redis
@@ -47,7 +82,7 @@ web:
47 82
   upload-path: /upload
48 83
 
49 84
 #设置全局变量判断是云端还是库端;1云端,2本地
50
-localOrCloud: 2
85
+localOrCloud: 1
51 86
 
52 87
 #设置出入库连接
53 88
 forTheConnection: http://101.36.160.210:9901/Base/Main.action