Bläddra i källkod

Merge branch 'package' of GameCenter/game-center into dev

zhangxianyu 1 månad sedan
förälder
incheckning
f6f37c0bba

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

@@ -68,9 +68,9 @@ public class RoleManageController {
     }
     }
 
 
     @ApiOperation(value = "角色ip登录详情列表")
     @ApiOperation(value = "角色ip登录详情列表")
-    @PreAuthorize(permissionKey = "roleManage:ipInfo:listOfPage")
-    @PostMapping("/roleIpDetail/listOfPage")
-    public ResultVO<Page<Map>> roleIpDetailListOfPage(@RequestBody RoleIpInfoParamDTO dto) {
+    @PreAuthorize(permissionKey = "roleManage:ipInfo:list")
+    @PostMapping("/roleIpDetail/list")
+    public ResultVO<List<Map>> roleIpDetailListOfPage(@RequestBody RoleIpInfoParamDTO dto) {
         return ResultVO.ok(roleManageService.roleIpDetailListOfPage(dto));
         return ResultVO.ok(roleManageService.roleIpDetailListOfPage(dto));
     }
     }
 
 

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

@@ -83,7 +83,20 @@ public interface IRoleManageService {
      * @param dto
      * @param dto
      * @return
      * @return
      */
      */
-    Page<Map> roleIpDetailListOfPage(RoleIpInfoParamDTO dto);
+    Page<Map> roleIpDetailListOfPage2(RoleIpInfoParamDTO dto);
+
+    /**
+     * 角色ip登录详情
+     * @param dto
+     * @return
+     */
+    List<Map> roleIpDetailListOfPage(RoleIpInfoParamDTO dto);
+
+
+    List<Map> ipDetailList(RoleIpInfoParamDTO dto);
+
+    List<Map> ipCountList(List<String> ip);
+
 
 
     /**
     /**
      * 根据ip查询角色详情列表
      * 根据ip查询角色详情列表

+ 69 - 5
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/RoleManageServiceImpl.java

@@ -30,9 +30,11 @@ import org.nutz.dao.pager.Pager;
 import org.nutz.dao.sql.Criteria;
 import org.nutz.dao.sql.Criteria;
 import org.nutz.dao.sql.Sql;
 import org.nutz.dao.sql.Sql;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StopWatch;
 import org.springframework.util.StopWatch;
 
 
+import javax.annotation.Resource;
 import java.time.LocalTime;
 import java.time.LocalTime;
 import java.util.*;
 import java.util.*;
 import java.util.function.Function;
 import java.util.function.Function;
@@ -56,6 +58,10 @@ public class RoleManageServiceImpl implements IRoleManageService {
     @DubboReference(providedBy = ServerInfo.SERVER_DUBBO_NAME)
     @DubboReference(providedBy = ServerInfo.SERVER_DUBBO_NAME)
     private ICPSendMsgRpc sendMsgRpc;
     private ICPSendMsgRpc sendMsgRpc;
 
 
+    @Resource
+    @Lazy
+    private IRoleManageService baseService;
+
 
 
     /**
     /**
      * 角色充值排行榜
      * 角色充值排行榜
@@ -1064,10 +1070,11 @@ public class RoleManageServiceImpl implements IRoleManageService {
     }
     }
 
 
     @Override
     @Override
-    public Page<Map> roleIpDetailListOfPage(RoleIpInfoParamDTO dto) {
+    public Page<Map> roleIpDetailListOfPage2(RoleIpInfoParamDTO dto) {
         if (dto.getRoleId() == null) {
         if (dto.getRoleId() == null) {
             throw new BaseException("角色id不能为空");
             throw new BaseException("角色id不能为空");
         }
         }
+
         Criteria criteria = Cnd.cri();
         Criteria criteria = Cnd.cri();
         criteria.where().andEquals("role_id", dto.getRoleId());
         criteria.where().andEquals("role_id", dto.getRoleId());
         if (dto.getExcludeUserId() != null) {
         if (dto.getExcludeUserId() != null) {
@@ -1091,6 +1098,53 @@ public class RoleManageServiceImpl implements IRoleManageService {
         return new Page<>(list, pager);
         return new Page<>(list, pager);
     }
     }
 
 
+    @Override
+    public List<Map> roleIpDetailListOfPage(RoleIpInfoParamDTO dto) {
+        if (dto.getRoleId() == null) {
+            throw new BaseException("角色id不能为空");
+        }
+        List<Map> maps = baseService.ipDetailList(dto);
+        if (CollectionUtils.isEmpty(maps)) {
+            return null;
+        }
+        Map map = maps.get(0);
+        String ipCountIp = String.valueOf(map.get("ip_count_ip"));
+        if (StringUtils.isEmpty(ipCountIp)) {
+            return null;
+        }
+        return baseService.ipCountList(Arrays.stream(ipCountIp.split(",")).map(String::trim).collect(Collectors.toList()));
+    }
+
+    @Override
+    public List<Map> ipDetailList(RoleIpInfoParamDTO dto) {
+        Criteria criteria = Cnd.cri();
+        criteria.where().andEquals("role_id", dto.getRoleId());
+        String ipDetailListSql = getIpDetailListSql(criteria);
+        Sql sql = Sqls.create(ipDetailListSql);
+        sql.setCallback(Sqls.callback.maps());
+        dao.execute(sql);
+        return sql.getList(Map.class);
+    }
+
+    @Override
+    public List<Map> ipCountList(List<String> ip) {
+        Criteria criteria = Cnd.cri();
+        criteria.where().andInStrList("ip", ip);
+        String ipCountList= getIpCountList(criteria);
+        Sql sql = Sqls.create(ipCountList);
+        sql.setCallback(Sqls.callback.maps());
+        dao.execute(sql);
+        return sql.getList(Map.class);
+    }
+
+    private String getIpCountList(Criteria criteria) {
+        return """
+                select ip,count(distinct role_id) as ipRoleCount  from  dm_game_order.t_user_login_log 
+                 """+criteria+"""
+                 group by ip
+                """;
+    }
+
     @Override
     @Override
     public Page<Map> roleDetailListOfPage(RoleIpInfoParamDTO dto) {
     public Page<Map> roleDetailListOfPage(RoleIpInfoParamDTO dto) {
         Criteria criteria = getRoleDetailSqlByQuery(dto);
         Criteria criteria = getRoleDetailSqlByQuery(dto);
@@ -1306,6 +1360,16 @@ public class RoleManageServiceImpl implements IRoleManageService {
                 """ + criteria;
                 """ + criteria;
     }
     }
 
 
+    /**
+     * ipRoleCount 同ip的角色数量
+     */
+    private String getIpDetailListSql(Criteria criteria) {
+        return """
+                 select * from game_ads.role_ip_monitor
+                """ + criteria;
+    }
+
+
     private String getCountryListSql(Criteria criteria) {
     private String getCountryListSql(Criteria criteria) {
         return """
         return """
                 select country,server_id as serverId,parent_name as gameName,server_name as serverName,parent_game_id as gameId from dm_game_order.t_server_country
                 select country,server_id as serverId,parent_name as gameName,server_name as serverName,parent_game_id as gameId from dm_game_order.t_server_country
@@ -1341,11 +1405,11 @@ public class RoleManageServiceImpl implements IRoleManageService {
             cri.where().andEquals("server_id", dto.getServerId());
             cri.where().andEquals("server_id", dto.getServerId());
         }
         }
         cri.where().andInList("game_id", Arrays.asList(35L, 36L, 10035L));
         cri.where().andInList("game_id", Arrays.asList(35L, 36L, 10035L));
-        if(dto.getCountryLevel()!=null&&dto.getCountryLevel()==0){
-            cri.where().andLTE("role_level",13);
+        if (dto.getCountryLevel() != null && dto.getCountryLevel() == 0) {
+            cri.where().andLTE("role_level", 13);
         }
         }
-        if(dto.getCountryLevel()!=null&&dto.getCountryLevel()==1){
-            cri.where().andGT("role_level",13);
+        if (dto.getCountryLevel() != null && dto.getCountryLevel() == 1) {
+            cri.where().andGT("role_level", 13);
         }
         }
         return cri;
         return cri;
     }
     }