puzhibing
2023-07-07 c148720d31eb2f8d68352e64eaddf17fd5b66a5a
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;
    }