Browse Source

:fix:发消息

zhangxianyu 1 year ago
parent
commit
b11cdec4dd

+ 2 - 3
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/controller/RoleManageController.java

@@ -1,6 +1,6 @@
 package com.zanxiang.game.data.serve.controller;
 
-import com.zangxiang.game.base.pojo.vo.SendMsgVo;
+import com.zanxiang.game.module.base.pojo.vo.SendMsgVo;
 import com.zanxiang.erp.security.annotation.PreAuthorize;
 import com.zanxiang.game.data.serve.pojo.dto.MsgTaskDto;
 import com.zanxiang.game.data.serve.pojo.dto.RoleCombatRankingDTO;
@@ -13,7 +13,6 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -50,7 +49,7 @@ public class RoleManageController {
     }
 
     @ApiOperation(value = "创建发送消息任务")
-//    @PreAuthorize(permissionKey = "roleManage:sendMsgTask:create")
+    @PreAuthorize(permissionKey = "roleManage:sendMsgTask:create")
     @PostMapping("/sendMsgTask")
     public ResultVO createSendMsgTask(@RequestBody SendMsgTaskDto dto) {
         roleManageService.createSendMsgTask(dto);

+ 14 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/dto/GameDto.java

@@ -0,0 +1,14 @@
+package com.zanxiang.game.data.serve.pojo.dto;
+
+import lombok.Data;
+
+@Data
+public class GameDto {
+
+
+    private Integer id;
+
+    private Integer parentId;
+
+    private String gameName;
+}

+ 0 - 3
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/dto/MsgTaskDto.java

@@ -1,7 +1,6 @@
 package com.zanxiang.game.data.serve.pojo.dto;
 
 import com.zanxiang.game.data.serve.pojo.base.BasePage;
-import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
@@ -11,6 +10,4 @@ public class MsgTaskDto extends BasePage {
     @ApiModelProperty(value = "游戏id")
     private Long gameId;
 
-    @ApiModelProperty(value = "游戏名称")
-    private String gameName;
 }

+ 1 - 1
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/IRoleManageService.java

@@ -1,6 +1,6 @@
 package com.zanxiang.game.data.serve.service;
 
-import com.zangxiang.game.base.pojo.vo.SendMsgVo;
+import com.zanxiang.game.module.base.pojo.vo.SendMsgVo;
 import com.zanxiang.game.data.serve.pojo.dto.MsgTaskDto;
 import com.zanxiang.game.data.serve.pojo.dto.RoleCombatRankingDTO;
 import com.zanxiang.game.data.serve.pojo.dto.RoleRechargeRankingDTO;

+ 47 - 11
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/RoleManageServiceImpl.java

@@ -1,7 +1,8 @@
 package com.zanxiang.game.data.serve.service.impl;
 
 import com.alibaba.fastjson2.JSON;
-import com.zangxiang.game.base.pojo.vo.SendMsgVo;
+import com.zanxiang.game.data.serve.pojo.vo.GameDataDayVO;
+import com.zanxiang.game.module.base.pojo.vo.SendMsgVo;
 import com.zanxiang.erp.base.ErpServer;
 import com.zanxiang.erp.base.rpc.ISysUserRpc;
 import com.zanxiang.erp.security.util.SecurityUtil;
@@ -12,8 +13,11 @@ import com.zanxiang.game.data.serve.pojo.dto.SendMsgTaskDto;
 import com.zanxiang.game.data.serve.pojo.enums.OrderByEnum;
 import com.zanxiang.game.data.serve.service.IRoleManageService;
 import com.zanxiang.game.data.serve.utils.Page;
+import com.zanxiang.game.module.base.ServerInfo;
 import com.zanxiang.game.module.base.pojo.dto.SendMsgDto;
-import com.zanxiang.game.module.base.rpc.SendMsgRpc;
+import com.zanxiang.game.module.base.pojo.params.SendMsgTaskParam;
+import com.zanxiang.game.module.base.rpc.ICPSendMsgRpc;
+import com.zanxiang.game.module.base.util.PageUtil;
 import com.zanxiang.module.util.exception.BaseException;
 import com.zanxiang.module.util.pojo.ResultVO;
 import lombok.extern.slf4j.Slf4j;
@@ -29,7 +33,6 @@ import org.nutz.dao.sql.Sql;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import javax.validation.Valid;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -48,8 +51,8 @@ public class RoleManageServiceImpl implements IRoleManageService {
     @DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
     private ISysUserRpc sysUserRpc;
 
-    @DubboReference
-    private SendMsgRpc sendMsgRpc;
+    @DubboReference(providedBy = ServerInfo.SERVER_DUBBO_NAME)
+    private ICPSendMsgRpc sendMsgRpc;
 
 
 
@@ -338,13 +341,10 @@ public class RoleManageServiceImpl implements IRoleManageService {
     public void createSendMsgTask(SendMsgTaskDto dto) {
         //校验参数
         validation(dto);
-
         //获取当前用户id
         Long sysUserId = SecurityUtil.getUserId();
-
         //构建发送消息dto
         SendMsgDto sendMsgDto = buildSendMsgDto(dto, sysUserId);
-
         //调用发送消息接口
         ResultVO<Boolean> booleanResultVO = sendMsgRpc.sendMsg(sendMsgDto);
         if (!booleanResultVO.isSuccess()) {
@@ -379,7 +379,7 @@ public class RoleManageServiceImpl implements IRoleManageService {
         //筛选出角色id
         List<String> roleIdList = roleList.stream()
                 .map(map -> Optional.ofNullable(map.get("role_id")).map(Object::toString).orElse(null))
-                .collect(Collectors.toList());
+                .toList();
 
         SendMsgDto sendMsgDto = new SendMsgDto();
         //任务名称
@@ -588,8 +588,44 @@ public class RoleManageServiceImpl implements IRoleManageService {
      */
     @Override
     public Page<SendMsgVo> getSendMsgTaskList(MsgTaskDto dto) {
-//        sendMsgRpc.getSendMsgTaskList(dto);
-        return null;
+        try {
+            SendMsgTaskParam sendMsgTaskParam = new SendMsgTaskParam();
+            sendMsgTaskParam.setGameId(dto.getGameId());
+            sendMsgTaskParam.setPageNum(dto.getPageNum());
+            sendMsgTaskParam.setPageSize(dto.getPageSize());
+            PageUtil<SendMsgVo> sendMsgTaskList = sendMsgRpc.getSendMsgTaskList(sendMsgTaskParam);
+            //查询所有游戏名称
+            Sql sql = Sqls.create(getGameSql());
+            sql.setCallback(Sqls.callback.entities());
+            sql.setEntity(dao.getEntity(GameDataDayVO.class));
+            dao.execute(sql);
+            sendMsgTaskList.getRecords().forEach(item -> {
+                String game = "";
+                item.setGameName(game);
+            });
+            return new Page<>(sendMsgTaskList.getRecords(),sendMsgTaskList.getTotal(),sendMsgTaskList.getSize(),sendMsgTaskList.getCurrent(),sendMsgTaskList.getPages());
+        }catch (Exception exception){
+            log.error("获取发送消息任务列表失败", exception);
+            throw new BaseException("获取发送消息任务列表失败");
+        }
+    }
+
+    /**
+     * 查询游戏sql
+     * @return String
+     */
+    private String getGameSql() {
+        return """
+                 SELECT
+                            -- 游戏名称、游戏类型、父游戏id、超父游戏id
+                            source_system,
+                            id,
+                            game_name,
+                            classify,
+                            parent_id,
+                            super_game_id
+                        FROM dm_game_order.t_game
+                """;
     }
 
     /**

+ 22 - 0
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/params/SendMsgTaskParam.java

@@ -0,0 +1,22 @@
+package com.zanxiang.game.module.base.pojo.params;
+
+import com.zanxiang.module.web.pojo.BaseListDTO;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author : ZhangXianyu
+ * @time : 2024-03-14 10:42:18
+ * @description : 查询消息任务列表参数
+ */
+@Data
+public class SendMsgTaskParam extends BaseListDTO implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 游戏id
+     */
+    private Long gameId;
+
+}

+ 4 - 1
game-data/game-data-base/src/main/java/com/zangxiang/game/base/pojo/vo/SendMsgVo.java → game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/vo/SendMsgVo.java

@@ -1,4 +1,4 @@
-package com.zangxiang.game.base.pojo.vo;
+package com.zanxiang.game.module.base.pojo.vo;
 
 import lombok.Data;
 
@@ -10,6 +10,9 @@ public class SendMsgVo implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
+    private String gameName;
+
+
 
 
 

+ 10 - 0
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/rpc/ICPSendMsgRpc.java

@@ -1,6 +1,9 @@
 package com.zanxiang.game.module.base.rpc;
 
 import com.zanxiang.game.module.base.pojo.dto.SendMsgDto;
+import com.zanxiang.game.module.base.util.PageUtil;
+import com.zanxiang.game.module.base.pojo.params.SendMsgTaskParam;
+import com.zanxiang.game.module.base.pojo.vo.SendMsgVo;
 import com.zanxiang.module.util.pojo.ResultVO;
 
 /**
@@ -10,5 +13,12 @@ import com.zanxiang.module.util.pojo.ResultVO;
  */
 public interface ICPSendMsgRpc {
 
+    /**
+     * 发送消息
+     * @param sendMsgDto
+     * @return
+     */
     ResultVO<Boolean> sendMsg(SendMsgDto sendMsgDto);
+
+    PageUtil<SendMsgVo> getSendMsgTaskList(SendMsgTaskParam sendMsgTaskParam);
 }

+ 45 - 0
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/util/PageUtil.java

@@ -0,0 +1,45 @@
+package com.zanxiang.game.module.base.util;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author shishaosong
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class PageUtil<T> {
+
+    /**
+     * 查询数据列表
+     */
+    private List<T> records = Collections.emptyList();
+
+    /**
+     * 总数
+     */
+    private long total = 0;
+    /**
+     * 每页显示条数,默认 10
+     */
+    private long size = 10;
+
+    /**
+     * 当前页
+     */
+    private long current = 1;
+
+    /**
+     * 总页数
+     */
+    private long pages;
+
+
+}

+ 9 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/rpc/impl/CpSendMsgRpcImpl.java

@@ -1,6 +1,9 @@
 package com.zanxiang.game.module.manage.rpc.impl;
 
 import com.zanxiang.game.module.base.pojo.dto.SendMsgDto;
+import com.zanxiang.game.module.base.util.PageUtil;
+import com.zanxiang.game.module.base.pojo.params.SendMsgTaskParam;
+import com.zanxiang.game.module.base.pojo.vo.SendMsgVo;
 import com.zanxiang.game.module.base.rpc.ICPSendMsgRpc;
 import com.zanxiang.game.module.manage.enums.CpSendMsgTaskStatusEnum;
 import com.zanxiang.game.module.manage.enums.CpSendMsgTaskTypeEnum;
@@ -41,6 +44,12 @@ public class CpSendMsgRpcImpl implements ICPSendMsgRpc {
         }
     }
 
+    @Override
+    public PageUtil<SendMsgVo> getSendMsgTaskList(SendMsgTaskParam sendMsgTaskParam) {
+        return null;
+    }
+
+
     private CpSendMsgTask createSendMsgTask(SendMsgDto dto) {
         CpSendMsgTask cpSendMsgTask = new CpSendMsgTask();
         cpSendMsgTask.setMsg(dto.getMsg());