| | |
| | | props6.setProperty("algorithm-expression", "t_subject_record$->{userId % 5 + 1}"); |
| | | result1.getShardingAlgorithms().put("t_subject_record-inline", new AlgorithmConfiguration("INLINE", props6)); |
| | | result1.getKeyGenerators().put("t_subject_record-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | |
| | | //分片规则配置 |
| | | result1.getTables().add(getCoursePackageOrderTableRuleConfiguration1()); |
| | | Properties props7 = new Properties(); |
| | | props7.setProperty("algorithm-expression", "t_user_present_record$->{user_id % 5 + 1}"); |
| | | result1.getShardingAlgorithms().put("t_user_present_record-inline", new AlgorithmConfiguration("INLINE", props7)); |
| | | result1.getKeyGenerators().put("t_user_present_record-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | |
| | | //分片规则配置 |
| | | result1.getTables().add(getCoursePackageOrderTableRuleConfiguration2()); |
| | | Properties props8 = new Properties(); |
| | | props8.setProperty("algorithm-expression", "t_subject_record_detail$->{userId % 5 + 1}"); |
| | | result1.getShardingAlgorithms().put("t_subject_record_detail-inline", new AlgorithmConfiguration("INLINE", props8)); |
| | | result1.getKeyGenerators().put("t_subject_record_detail-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); |
| | | |
| | | linkedList.add(result1); |
| | | return linkedList; |
| | |
| | | result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("userId", "t_subject_record-inline")); |
| | | result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_subject_record-snowflake")); |
| | | return result; |
| | | }private ShardingTableRuleConfiguration getCoursePackageOrderTableRuleConfiguration1() { |
| | | } |
| | | private ShardingTableRuleConfiguration getCoursePackageOrderTableRuleConfiguration1() { |
| | | ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_user_present_record", "m_$->{0}.t_user_present_record$->{1..5}");//30 |
| | | result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("user_id", "t_user_present_record-inline")); |
| | | result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_user_present_record-snowflake")); |
| | | return result; |
| | | } |
| | | private ShardingTableRuleConfiguration getCoursePackageOrderTableRuleConfiguration2() { |
| | | ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_subject_record_detail", "m_$->{0}.t_subject_record_detail$->{1..5}");//30 |
| | | result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("userId", "t_subject_record_detail-inline")); |
| | | result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_subject_record_detail-snowflake")); |
| | | return result; |
| | | } |
| | | |
| | | } |