Преглед изворни кода

fix : Websocket调试修改12

bilingfeng пре 1 година
родитељ
комит
d3f4db49b2

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -23,7 +23,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 <Websocket调试修改11> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <Websocket调试修改12> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 38 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/KfAppletMsgServiceImpl.java

@@ -126,13 +126,48 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
                 .gameId(gameApplet.getGameId())
                 .userId(user == null ? null : user.getId())
                 .isWait(Boolean.FALSE)
-                .lastRoleId(gameUserRole == null ? null : gameUserRole.getRoleId())
-                .lastRoleName(gameUserRole == null ? null : gameUserRole.getRoleName())
+                .lastRoleId(gameUserRole == null ? "0" : gameUserRole.getRoleId())
+                .lastRoleName(gameUserRole == null ? kfAppletMsgDTO.getFromUserName() : gameUserRole.getRoleName())
                 .createTime(LocalDateTime.now())
                 .updateTime(LocalDateTime.now())
                 .build();
     }
 
+
+    private void kfSessionUserUpdateSave(KfAppletMsgDTO kfAppletMsgDTO, GameApplet gameApplet) {
+        KfSessionUser kfSessionUser = kfSessionUserService.getById(kfAppletMsgDTO.getFromUserName());
+        //查询用户
+        User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getOpenId, kfAppletMsgDTO.getFromUserName()));
+        //最近角色信息
+        GameUserRole gameUserRole = null;
+        if (user != null) {
+            gameUserRole = gameUserRoleService.getLastGameUserRoleName(user.getId(), user.getGameId());
+        }
+        //不存在玩家信息, 创建保存
+        if (kfSessionUser == null) {
+            kfSessionUserService.save(this.transform(kfAppletMsgDTO, gameApplet, user, gameUserRole));
+            return;
+        }
+        //存在, 更新玩家信息
+//        kfSessionUserService.update()
+
+    }
+
+
+    private KfSessionUser transform(KfAppletMsgDTO kfAppletMsgDTO, GameApplet gameApplet, User user, GameUserRole gameUserRole) {
+        return KfSessionUser.builder()
+                .openId(kfAppletMsgDTO.getFromUserName())
+                .gameId(gameApplet.getGameId())
+                .userId(user == null ? null : user.getId())
+                .isWait(Boolean.FALSE)
+                .lastRoleId(gameUserRole == null ? "0" : gameUserRole.getRoleId())
+                .lastRoleName(gameUserRole == null ? kfAppletMsgDTO.getFromUserName() : gameUserRole.getRoleName())
+                .createTime(LocalDateTime.now())
+                .updateTime(LocalDateTime.now())
+                .build();
+    }
+
+
     private KfRoomMsg transform(KfAppletMsgDTO kfAppletMsgDTO, GameApplet gameApplet, KfRoom kfRoom, String postData,
                                 KfWebSocketMsgDTO.MsgContentBean msgContent) {
         return KfRoomMsg.builder()
@@ -146,6 +181,7 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
                 .content(JsonUtil.toString(msgContent))
                 .source(postData)
                 .createTime(LocalDateTime.now())
+                .updateTime(LocalDateTime.now())
                 .build();
     }