From 631a5aa09e0147ca81fffcb1434e57b1cd1ba6f6 Mon Sep 17 00:00:00 2001 From: lisy <linlangsur163@163.com> Date: 星期三, 09 八月 2023 09:34:53 +0800 Subject: [PATCH] app端口:积分变动记录增加变动类型字段,代码同步更新;积分兑换操作的数量校验功能完善 --- cloud-server-activity/src/main/java/com/dsh/config/Sharding_jdbc/ShardingConfig.java | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 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 75f7e69..f8584a8 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 @@ -81,6 +81,12 @@ 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())); + //分片规则配置 + result1.getTables().add(getUserBenefitsVideosTableRuleConfiguration()); + Properties props3 = new Properties(); + props3.setProperty("algorithm-expression", "t_user_benefits_videos$->{appUserId % 5 + 1}"); + result1.getShardingAlgorithms().put("t_user_benefits_videos-inline", new AlgorithmConfiguration("INLINE", props3)); + result1.getKeyGenerators().put("t_user_benefits_videos-snowflake", new AlgorithmConfiguration("SNOWFLAKE", new Properties())); linkedList.add(result1); return linkedList; @@ -91,7 +97,7 @@ * @return */ private ShardingTableRuleConfiguration getUserCouponTableRuleConfiguration() { - ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_user_coupon", "m$->{0}.t_user_coupon->{1..5}");//50 + ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_user_coupon", "m_$->{0}.t_user_coupon$->{1..5}");//50 result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("userId", "t_user_coupon-inline")); result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_user_coupon-snowflake")); return result; @@ -104,10 +110,22 @@ * @return */ private ShardingTableRuleConfiguration getUserPointsMerchandiseTableRuleConfiguration() { - ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_user_points_merchandise", "m$->{0}.t_user_points_merchandise$->{1..5}");//30 + ShardingTableRuleConfiguration result = new ShardingTableRuleConfiguration("t_user_points_merchandise", "m_$->{0}.t_user_points_merchandise$->{1..5}");//30 result.setTableShardingStrategy(new StandardShardingStrategyConfiguration("userId", "t_user_points_merchandise-inline")); result.setKeyGenerateStrategy(new KeyGenerateStrategyConfiguration("id", "t_user_points_merchandise-snowflake")); 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