| | |
| | | result2.getKeyGenerators().put("t_course_package_student-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | linkedList.add(result2); |
| | | |
| | | //分片规则配置 |
| | | ShardingRuleConfiguration result3 = new ShardingRuleConfiguration(); |
| | | result3.getTables().add(getPostCourseVideoTableRuleConfiguration()); |
| | | Properties props3 = new Properties(); |
| | | props3.setProperty("algorithm-expression", "t_post_course_video$->{coursePackageId % 5 + 1}"); |
| | | result3.getShardingAlgorithms().put("t_post_course_video-inline", new AlgorithmConfiguration("INLINE", props3)); |
| | | result3.getKeyGenerators().put("t_post_course_video-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | linkedList.add(result3); |
| | | |
| | | //分片规则配置 |
| | | ShardingRuleConfiguration result4 = new ShardingRuleConfiguration(); |
| | | result4.getTables().add(getUserVideoDetailsTableRuleConfiguration()); |
| | | Properties props4 = new Properties(); |
| | | props4.setProperty("algorithm-expression", "t_user_video_details$->{appUserId % 5 + 1}"); |
| | | result4.getShardingAlgorithms().put("t_user_video_details-inline", new AlgorithmConfiguration("INLINE", props4)); |
| | | result4.getKeyGenerators().put("t_user_video_details-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | linkedList.add(result4); |
| | | |
| | | return linkedList; |
| | | } |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 分片算法配置 |
| | | * @return |
| | | */ |
| | | private ShardingTableRuleConfiguration getPostCourseVideoTableRuleConfiguration() { |
| | | ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_post_course_video", "m_$->{0}.t_post_course_video$->{1..5}");//30 |
| | | result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("coursePackageId", "t_post_course_video-inline")); |
| | | result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_post_course_video-snowflake")); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 分片算法配置 |
| | | * @return |
| | | */ |
| | | private ShardingTableRuleConfiguration getUserVideoDetailsTableRuleConfiguration() { |
| | | ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_user_video_details", "m_$->{0}.t_user_video_details$->{1..5}");//30 |
| | | result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("appUserId", "t_user_video_details-inline")); |
| | | result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_user_video_details-snowflake")); |
| | | return result; |
| | | } |
| | | |
| | | } |