Bladeren bron

fix : SDK更新, 敏感词检测, 角色拓展属性, 战力时实更新控制频率

bilingfeng 1 jaar geleden
bovenliggende
commit
1f82959cee

+ 4 - 1
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/GameUserRole.java

@@ -125,5 +125,8 @@ public class GameUserRole implements Serializable {
      */
     private LocalDateTime updateTime;
 
-
+    /**
+     * 角色拓展属性
+     */
+    private String extra;
 }

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/SDKApplication.java

@@ -23,7 +23,7 @@ public class SDKApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(SDKApplication.class, args);
-        System.out.println("赞象SDK服务启动成功 <敏感词检测> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <SDK更新, 敏感词检测, 角色拓展属性, 战力时实更新控制频率> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 5 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/constant/RedisKeyConstant.java

@@ -32,6 +32,11 @@ public class RedisKeyConstant {
      */
     public static final String ROLE_UPDATE_KEY = RedisKeyConstant.REDIS_PREFIX + "role_update";
 
+    /**
+     * 角色信息更新
+     */
+    public static final String ROLE_LEVEL_UP = RedisKeyConstant.REDIS_PREFIX + "role_level_up_";
+
     /**
      * 小程序token
      */

+ 5 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameUserRoleServiceImpl.java

@@ -102,6 +102,10 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
         }
         //等级提升更新
         if (Objects.equals(dataType, DataTypeEnum.TYPE_LEVEL_UP.getDateType())) {
+            //更新频率限制, 20秒更新一次, 避免游戏实时战力高频上报
+            if (!distributedLockComponent.doLock(RedisKeyConstant.ROLE_LEVEL_UP + userData.getUserId(), 0L, 20L, TimeUnit.SECONDS)) {
+                return Boolean.TRUE;
+            }
             return super.update(new LambdaUpdateWrapper<GameUserRole>()
                     .set(GameUserRole::getRoleName, param.getRoleName())
                     .set(GameUserRole::getRoleLevel, param.getRoleLevel())
@@ -156,6 +160,7 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
                 .createTime(param.getRoleGradeUpdateTime() == null || param.getRoleGradeUpdateTime() <= 0 ? LocalDateTime.now() : DateUtil.secondToLocalDateTime(param.getRoleGradeUpdateTime()))
                 .updateTime(LocalDateTime.now())
                 .lastLoginTime(LocalDateTime.now())
+                .extra(param.getExtra() == null ? null : JsonUtil.toString(param.getExtra()))
                 .build();
         super.save(userRole);
         //更新玩家创角数