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