From aa43a92c7ec9053dbaef92fe5ccb3011b670442c Mon Sep 17 00:00:00 2001 From: puzhibing <393733352@qq.com> Date: 星期三, 12 七月 2023 11:46:21 +0800 Subject: [PATCH] 更新线上视频奖励模块接口 --- cloud-server-activity/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java | 30 ++++++++++++++++++++++++++---- 1 files changed, 26 insertions(+), 4 deletions(-) diff --git a/cloud-server-activity/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java b/cloud-server-activity/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java index 2c53536..7e0a34d 100644 --- a/cloud-server-activity/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java +++ b/cloud-server-activity/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java @@ -73,15 +73,25 @@ props1.setProperty("algorithm-expression", "t_user_coupon$->{userId % 5 + 1}"); result1.getShardingAlgorithms().put("t_user_coupon-inline", new AlgorithmConfiguration("INLINE", props1)); result1.getKeyGenerators().put("t_user_coupon-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); + linkedList.add(result1); //分片规则配置 - result1.getTables().add(getUserPointsMerchandiseTableRuleConfiguration()); + ShardingRuleConfiguration result2 = new ShardingRuleConfiguration(); + result2.getTables().add(getUserPointsMerchandiseTableRuleConfiguration()); Properties props2 = new Properties(); props2.setProperty("algorithm-expression", "t_user_points_merchandise$->{userId % 5 + 1}"); - result1.getShardingAlgorithms().put("t_user_points_merchandise-inline", new AlgorithmConfiguration("INLINE", props2)); - result1.getKeyGenerators().put("t_user_points_merchandise-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); + result2.getShardingAlgorithms().put("t_user_points_merchandise-inline", new AlgorithmConfiguration("INLINE", props2)); + result2.getKeyGenerators().put("t_user_points_merchandise-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); + linkedList.add(result2); - linkedList.add(result1); + //分片规则配置 + 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; } @@ -110,4 +120,16 @@ 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; + } + } -- Gitblit v1.7.1