From 04550dbf5e04aaca21ef72ce3e812c2d99d97197 Mon Sep 17 00:00:00 2001 From: zhangshanxue Date: Thu, 5 Nov 2020 10:59:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B8=A2=E4=BA=BA=E4=BF=AE=E6=94=B9=20=20?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=98=BE=E7=A4=BA=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jmfy/controller/GameTitleController.java | 1 + .../jmfy/controller/UserInfoController.java | 1 + src/main/java/com/jmfy/handler/GMHandler.java | 164 ++++++------------ src/main/java/com/jmfy/model/ServerInfo.java | 6 + src/main/java/com/jmfy/model/vo/CUserVo.java | 8 + src/main/resources/templates/chatInfo.html | 2 +- src/main/resources/templates/findFlow.html | 2 +- src/main/resources/templates/findOrder.html | 2 +- src/main/resources/templates/gameTitle.html | 22 +-- src/main/resources/templates/gameTitle2.html | 2 +- .../resources/templates/sendPersonalMail.html | 2 +- src/main/resources/templates/sendSysMSG.html | 2 +- src/main/resources/templates/sendSysMail.html | 2 +- .../resources/templates/toAddCDKGoods.html | 2 +- src/main/resources/templates/userInfo.html | 2 + 15 files changed, 83 insertions(+), 137 deletions(-) diff --git a/src/main/java/com/jmfy/controller/GameTitleController.java b/src/main/java/com/jmfy/controller/GameTitleController.java index bc7d6e8..b22940e 100644 --- a/src/main/java/com/jmfy/controller/GameTitleController.java +++ b/src/main/java/com/jmfy/controller/GameTitleController.java @@ -43,6 +43,7 @@ public class GameTitleController { public String toGameTitle(ModelMap map,Integer type){ try { List allServerInfo = serverInfoDao.getAllServerInfo(); + allServerInfo.add(0,new ServerInfo(0,"全服")); map.addAttribute("serverInfo",allServerInfo); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/jmfy/controller/UserInfoController.java b/src/main/java/com/jmfy/controller/UserInfoController.java index 9e69208..fcd335a 100644 --- a/src/main/java/com/jmfy/controller/UserInfoController.java +++ b/src/main/java/com/jmfy/controller/UserInfoController.java @@ -125,6 +125,7 @@ public class UserInfoController { if (gsUser == null) { cUserVo.setIsData(0); } else { + cUserVo.setOpenID(gsUser.getPlayerManager().getOpenId()); cUserVo.setIsData(1); cUserVo.setUserId(gsUser.getId()); cUserVo.setUserName(gsUser.getPlayerManager().getNickName()); diff --git a/src/main/java/com/jmfy/handler/GMHandler.java b/src/main/java/com/jmfy/handler/GMHandler.java index 2a8a136..f561821 100644 --- a/src/main/java/com/jmfy/handler/GMHandler.java +++ b/src/main/java/com/jmfy/handler/GMHandler.java @@ -33,129 +33,75 @@ public class GMHandler extends BaseHandler { dsid = jsonObject.getIntValue("dsid"); treat_type = jsonObject.getIntValue("treat_type"); - boolean allServer = false; + boolean allServer = dsid == 0; - String cmd = ""; - switch (treat_type){ - case 1: - if(!jsonObject.containsKey("actor_id")){ - throw new Exception("缺少参数"); - } - String actor_id_ban = jsonObject.getString("actor_id"); - cmd="silence "+actor_id_ban+" 1"; - break; - case 2: - if(!jsonObject.containsKey("actor_id")){ - throw new Exception("缺少参数"); - } - String actor_id_no_ban = jsonObject.getString("actor_id"); - cmd="silence "+actor_id_no_ban+" 0"; - break; - case 4: - if(dsid==0){ - allServer=true; - cmd="addblack "; - }else { - if(!jsonObject.containsKey("actor_id")){ - throw new Exception("缺少参数"); - } - String id = jsonObject.getString("actor_id"); - cmd="addblack "+id; - } - break; - case 5: - if(dsid==0){ - allServer=true; - cmd="reblack "; - }else { - if(!jsonObject.containsKey("actor_id")){ - throw new Exception("缺少参数"); - } - String id2 = jsonObject.getString("actor_id"); - cmd="reblack "+id2; - } - break; - case 3: - if(!jsonObject.containsKey("actor_id")){ - throw new Exception("缺少参数"); - } - String actor_id = jsonObject.getString("actor_id"); - cmd="kick "+actor_id; - break; - case 6: - if(!jsonObject.containsKey("actor_id")){ - throw new Exception("缺少参数"); - } - String actor_id2 = jsonObject.getString("actor_id"); - if(!jsonObject.containsKey("actor_name")){ - cmd="changename "+actor_id2; - }else { - String actor_name = jsonObject.getString("actor_name"); - cmd="changename "+actor_id2+" "+actor_name; - } - break; - } - - if(allServer){ - List coreUserInfoList = gsUserDao.findUserInfo(uid); - if (coreUserInfoList == null) { + List coreUserInfoList = gsUserDao.findUserInfo(uid); + if (coreUserInfoList == null) { + throw new Exception("帐号不存在"); + } else { + if (coreUserInfoList.size() == 0) throw new Exception("帐号不存在"); - } else { - if (coreUserInfoList.size() == 0) - throw new Exception("帐号不存在"); - for (CUserInfo coreUserInfo : coreUserInfoList) { - ServerInfo coreServerList = serverListDao.getServerinfo(coreUserInfo.getServerid()); - if (null == coreServerList) { - continue; - } else { - String rpcString = RedisUtil.getInstence().getObject(RedisUserKey.LOGIC_SERVER_INFO, String.valueOf(coreServerList.getServer_id()), String.class, -1); - if(null==rpcString){ - continue; - } - String thriftIp = rpcString.split(":")[0]; - String thriftPort = rpcString.split(":")[1]; - if (thriftIp == null || thriftIp.isEmpty() || null == thriftPort || thriftPort.isEmpty()) { - continue; - } else { - cmd = cmd+coreUserInfo.getUserId(); - Result result = RPCClient.gmSend(cmd, thriftIp, thriftPort); - //异常或者错误 -// if (result.getResultCode() != 0) { -// continue; -// } - } - } + for (CUserInfo coreUserInfo : coreUserInfoList) { + ServerInfo coreServerList = serverListDao.getServerinfo(coreUserInfo.getServerid()); + + if (null == coreServerList) { + continue; + } + if (!allServer && !coreServerList.getServer_id().equals(String.valueOf(dsid))) { + continue; } - } - return 1; - }else { + String cmd = ""; + switch (treat_type) { + case 1: + cmd = "silence " + coreUserInfo.getUserId() + " 1"; + break; + case 2: + cmd = "silence " + coreUserInfo.getUserId() + " 0"; + break; + case 4: + cmd = "addblack " + coreUserInfo.getUserId(); + break; + case 5: - ServerInfo coreServerList = serverListDao.getServerinfo(dsid); - if (null == coreServerList) { - throw new Exception("应用不存在"); - } else { + cmd = "reblack " + coreUserInfo.getUserId(); + + break; + case 3: + cmd = "kickuser " + coreUserInfo.getUserId(); + break; + case 6: + if (!jsonObject.containsKey("actor_id")) { + throw new Exception("缺少参数"); + } + if (!jsonObject.containsKey("actor_name")) { + cmd = "changename " + coreUserInfo.getUserId(); + } else { + String actor_name = jsonObject.getString("actor_name"); + cmd = "changename " + coreUserInfo.getUserId() + " " + actor_name; + } + break; + } String rpcString = RedisUtil.getInstence().getObject(RedisUserKey.LOGIC_SERVER_INFO, String.valueOf(coreServerList.getServer_id()), String.class, -1); - if(null==rpcString){ - throw new Exception("serverAddress not exist"); + if (null == rpcString) { + LOGGER.error("Exception send err rpcString dsid=>{},uid=>{},cmd=>{}", coreUserInfo.getServerid(), uid, cmd); + continue; } String thriftIp = rpcString.split(":")[0]; - String thriftPort = rpcString.split(":")[1]; + String thriftPort = rpcString.split(":")[1]; if (thriftIp == null || thriftIp.isEmpty() || null == thriftPort || thriftPort.isEmpty()) { - throw new Exception("serverAddress not exist"); - } else { - - Result result = RPCClient.gmSend(cmd, thriftIp, thriftPort); - if (result.getResultCode() != 0) { - throw new Exception(result.getResultMsg()); - } + continue; + } + Result result = RPCClient.gmSend(cmd, thriftIp, thriftPort); + // 异常或者错误 + if (result.getResultCode() != 0) { + LOGGER.error("Exception send err dsid=>{},uid=>{},cmd=>{}", coreUserInfo.getServerid(), uid, cmd); } - } - return 1; } + return 1; } diff --git a/src/main/java/com/jmfy/model/ServerInfo.java b/src/main/java/com/jmfy/model/ServerInfo.java index 44d8ab1..88ce873 100644 --- a/src/main/java/com/jmfy/model/ServerInfo.java +++ b/src/main/java/com/jmfy/model/ServerInfo.java @@ -52,6 +52,12 @@ public class ServerInfo { @Field(value = "open_type") private String open_type; + public ServerInfo(int _id, String name) { + this._id = _id; + this.server_id = String.valueOf(_id); + this.name = name; + } + public int get_id() { return _id; } diff --git a/src/main/java/com/jmfy/model/vo/CUserVo.java b/src/main/java/com/jmfy/model/vo/CUserVo.java index 66ec489..ffa10bd 100644 --- a/src/main/java/com/jmfy/model/vo/CUserVo.java +++ b/src/main/java/com/jmfy/model/vo/CUserVo.java @@ -5,6 +5,7 @@ public class CUserVo implements java.io.Serializable { public int isData; // 是否有数据 0:没有 1: 有 public int userId; + public String openID; public String serverId; public String userName; @@ -22,6 +23,13 @@ public class CUserVo implements java.io.Serializable { public String outLineTime; //离线时间 + public String getOpenID() { + return openID; + } + + public void setOpenID(String openID) { + this.openID = openID; + } public void setIsData(int isData) { this.isData = isData; diff --git a/src/main/resources/templates/chatInfo.html b/src/main/resources/templates/chatInfo.html index 94ad7ed..5e0aa85 100644 --- a/src/main/resources/templates/chatInfo.html +++ b/src/main/resources/templates/chatInfo.html @@ -30,7 +30,7 @@
服务器id:
diff --git a/src/main/resources/templates/findFlow.html b/src/main/resources/templates/findFlow.html index 2b8dca5..52e5410 100644 --- a/src/main/resources/templates/findFlow.html +++ b/src/main/resources/templates/findFlow.html @@ -65,7 +65,7 @@ 区服id:
diff --git a/src/main/resources/templates/findOrder.html b/src/main/resources/templates/findOrder.html index a0ddaca..3e24314 100644 --- a/src/main/resources/templates/findOrder.html +++ b/src/main/resources/templates/findOrder.html @@ -65,7 +65,7 @@ 区服id:
diff --git a/src/main/resources/templates/gameTitle.html b/src/main/resources/templates/gameTitle.html index 1ad0804..e037340 100644 --- a/src/main/resources/templates/gameTitle.html +++ b/src/main/resources/templates/gameTitle.html @@ -47,7 +47,7 @@ 区服id:
@@ -60,14 +60,7 @@ -
- -
- - -
-
+
diff --git a/src/main/resources/templates/sendPersonalMail.html b/src/main/resources/templates/sendPersonalMail.html index 6d208e7..78c1d55 100644 --- a/src/main/resources/templates/sendPersonalMail.html +++ b/src/main/resources/templates/sendPersonalMail.html @@ -47,7 +47,7 @@ 区服id:
diff --git a/src/main/resources/templates/sendSysMSG.html b/src/main/resources/templates/sendSysMSG.html index a50a429..c1bb946 100644 --- a/src/main/resources/templates/sendSysMSG.html +++ b/src/main/resources/templates/sendSysMSG.html @@ -45,7 +45,7 @@
diff --git a/src/main/resources/templates/sendSysMail.html b/src/main/resources/templates/sendSysMail.html index 97491d8..f98cfed 100644 --- a/src/main/resources/templates/sendSysMail.html +++ b/src/main/resources/templates/sendSysMail.html @@ -47,7 +47,7 @@ 区服id:
diff --git a/src/main/resources/templates/toAddCDKGoods.html b/src/main/resources/templates/toAddCDKGoods.html index fb88a5b..51394c3 100644 --- a/src/main/resources/templates/toAddCDKGoods.html +++ b/src/main/resources/templates/toAddCDKGoods.html @@ -57,7 +57,7 @@
diff --git a/src/main/resources/templates/userInfo.html b/src/main/resources/templates/userInfo.html index 681bdc8..664280d 100644 --- a/src/main/resources/templates/userInfo.html +++ b/src/main/resources/templates/userInfo.html @@ -34,6 +34,7 @@ ID + openID serverID 角色名 等級 @@ -55,6 +56,7 @@
+