From a6ef8f0dd977a30abd878f8e6106630b97d6e5b0 Mon Sep 17 00:00:00 2001
From: lisy <linlangsur163@163.com>
Date: 星期一, 10 七月 2023 16:49:14 +0800
Subject: [PATCH] 本周福利:接口开发

---
 cloud-server-course/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/cloud-server-course/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java b/cloud-server-course/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java
index 179ef3d..79c5c4c 100644
--- a/cloud-server-course/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java
+++ b/cloud-server-course/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java
@@ -73,15 +73,16 @@
         props1.setProperty("algorithm-expression", "t_course_package_payment$->{appUserId % 5 + 1}");
         result1.getShardingAlgorithms().put("t_course_package_payment-inline", new AlgorithmConfiguration("INLINE", props1));
         result1.getKeyGenerators().put("t_course_package_payment-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties()));
+        linkedList.add(result1);
 
         //分片规则配置
-        result1.getTables().add(getCoursePackageStudentTableRuleConfiguration());
+        ShardingRuleConfiguration result2 = new ShardingRuleConfiguration();
+        result2.getTables().add(getCoursePackageStudentTableRuleConfiguration());
         Properties props2 = new Properties();
         props2.setProperty("algorithm-expression", "t_course_package_student$->{appUserId % 5 + 1}");
-        result1.getShardingAlgorithms().put("t_course_package_student-inline", new AlgorithmConfiguration("INLINE", props2));
-        result1.getKeyGenerators().put("t_course_package_student-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties()));
-
-        linkedList.add(result1);
+        result2.getShardingAlgorithms().put("t_course_package_student-inline", new AlgorithmConfiguration("INLINE", props2));
+        result2.getKeyGenerators().put("t_course_package_student-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties()));
+        linkedList.add(result2);
 
         return linkedList;
     }
@@ -91,7 +92,7 @@
      * @return
      */
     private ShardingTableRuleConfiguration getCoursePackagePaymentTableRuleConfiguration() {
-        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_course_package_payment", "m$->{0}.t_course_package_payment$->{1..5}");//50
+        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_course_package_payment", "m_$->{0}.t_course_package_payment$->{1..5}");//50
         result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("appUserId", "t_course_package_payment-inline"));
         result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_course_package_payment-snowflake"));
         return result;
@@ -104,7 +105,7 @@
      * @return
      */
     private ShardingTableRuleConfiguration getCoursePackageStudentTableRuleConfiguration() {
-        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_course_package_student", "m$->{0}.t_course_package_student$->{1..5}");//30
+        ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_course_package_student", "m_$->{0}.t_course_package_student$->{1..5}");//30
         result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("appUserId", "t_course_package_student-inline"));
         result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_course_package_student-snowflake"));
         return result;

--
Gitblit v1.7.1