战报功能优化

master
duhui 2021-06-28 11:51:14 +08:00
parent 097e2ff566
commit 411ea5e007
1 changed files with 17 additions and 52 deletions

View File

@ -39,32 +39,10 @@ public class HttpRequestController {
public String getFightRecord (HttpServletRequest request, HttpServletResponse response) throws Exception {
// 玩家id和战斗id玩家id_服务器id_战斗类型_时间戳
String uid = request.getParameter("uid");
String fightid = request.getParameter("fightid");
String fightId = request.getParameter("fightid");
// 拼接参数
String cmd = "fightrecord " + fightid;
// 读库找到玩家信息
CUserInfo cUserInfo = userInfoDao.findUserInfoById(uid);
// 获取玩家服务器ip和端口
String rpcString = RedisUtil.getInstence().getObject(RedisUserKey.LOGIC_SERVER_INFO, String.valueOf(cUserInfo.getServerid()), String.class, -1);
if (null == rpcString) {
return "获取玩家服务器端口失败服务器id错误";
}
// ip
String thriftIp = rpcString.split(":")[0];
// 端口
String thriftPort = rpcString.split(":")[1];
if (thriftIp == null || thriftIp.isEmpty() || null == thriftPort || thriftPort.isEmpty()) {
return "获取玩家服务器端口为空";
}
// 通信游戏服
Result result = RPCClient.gmSend(cmd, thriftIp, thriftPort);
if (result.getResultCode() != 0) {
LOGGER.error("->userid:{},fightId:{}",uid,fightid);
LOGGER.error("->code:{},result:{}",result.resultCode,result.getResultMsg());
return "游戏服返回战报记录数据结果失败";
}
// 返回
return result.getResultMsg() == null ? "":result.getResultMsg();
String cmd = "fightrecord one " + fightId;
return sendGm(uid,cmd);
}
/**
@ -76,29 +54,9 @@ public class HttpRequestController {
*/
@RequestMapping(value = "/clearFightRecord", method = {RequestMethod.POST, RequestMethod.GET})
public String clearFightRecord (HttpServletRequest request, HttpServletResponse response) throws Exception {
String uid = request.getParameter("uid");
String cmd = "fightrecord delete";
CUserInfo cUserInfo = userInfoDao.findUserInfoById(uid);
String rpcString = RedisUtil.getInstence().getObject(RedisUserKey.LOGIC_SERVER_INFO, String.valueOf(cUserInfo.getServerid()), String.class, -1);
if (null == rpcString) {
return "获取玩家服务器端口失败服务器id错误";
}
String thriftIp = rpcString.split(":")[0];
String thriftPort = rpcString.split(":")[1];
if (thriftIp == null || thriftIp.isEmpty() || null == thriftPort || thriftPort.isEmpty()) {
return "获取玩家服务器端口为空";
}
Result result = RPCClient.gmSend(cmd, thriftIp, thriftPort);
if (result.getResultCode() != 0) {
LOGGER.error("->userid:{}",uid);
LOGGER.error("->code:{},result:{}",result.resultCode,result.getResultMsg());
return "游戏服返回战报记录数据结果失败";
}
return "ok";
return sendGm(uid,cmd);
}
/**
@ -110,13 +68,20 @@ public class HttpRequestController {
*/
@RequestMapping(value = "/getAllFightRecord", method = {RequestMethod.POST, RequestMethod.GET})
public String getAllFightRecord (HttpServletRequest request, HttpServletResponse response) throws Exception {
String uid = request.getParameter("uid");
String cmd = "fightrecord all " + uid;
return sendGm(uid,cmd);
}
/**
* gm
* @param uid
* @param cmd
* @return
* @throws Exception
*/
private String sendGm(String uid, String cmd) throws Exception {
CUserInfo cUserInfo = userInfoDao.findUserInfoById(uid);
String rpcString = RedisUtil.getInstence().getObject(RedisUserKey.LOGIC_SERVER_INFO, String.valueOf(cUserInfo.getServerid()), String.class, -1);
if (null == rpcString) {
return "获取玩家服务器端口失败服务器id错误";
@ -128,11 +93,11 @@ public class HttpRequestController {
}
Result result = RPCClient.gmSend(cmd, thriftIp, thriftPort);
if (result.getResultCode() != 0) {
LOGGER.error("->userid:{}",uid);
LOGGER.error("->code:{},result:{}",result.resultCode,result.getResultMsg());
LOGGER.error("获取战报返回错误,cmd:{},code:{},result:{}",cmd,result.resultCode,result.getResultMsg());
return "游戏服返回战报记录数据结果失败";
}
return result.getResultMsg();
return result.getResultMsg() == null ? "":result.getResultMsg();
}
}