generated from root/miduo_server
master
parent
8d48663a8c
commit
d35d4a4905
|
|
@ -28,11 +28,13 @@ public class WebSecurityConfig extends WebMvcConfigurerAdapter{
|
|||
return new SecurityInterceptor();
|
||||
}
|
||||
|
||||
public void addInterceptors(InterceptorRegistry registry){
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry){
|
||||
InterceptorRegistration addInterceptor = registry.addInterceptor(getSecurityInterceptor());
|
||||
|
||||
addInterceptor.excludePathPatterns("/error");
|
||||
addInterceptor.excludePathPatterns("/login**");
|
||||
addInterceptor.excludePathPatterns("/req/**");
|
||||
|
||||
addInterceptor.addPathPatterns("/**");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,133 @@
|
|||
package com.jmfy.controller;
|
||||
|
||||
import com.jmfy.dao.UserInfoDao;
|
||||
import com.jmfy.model.CUserInfo;
|
||||
import com.jmfy.redisProperties.RedisUserKey;
|
||||
import com.jmfy.thrift.idl.Result;
|
||||
import com.jmfy.utils.RPCClient;
|
||||
import com.jmfy.utils.RedisUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping(value = "req")
|
||||
public class HttpRequestController {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(UserInfoController.class);
|
||||
|
||||
@Resource
|
||||
private UserInfoDao userInfoDao;
|
||||
|
||||
/**
|
||||
* 获取战斗记录
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/getFightRecord", method = {RequestMethod.POST, RequestMethod.GET})
|
||||
public String getFightRecord (HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
// 玩家id和战斗id(玩家id_服务器id_战斗类型_时间戳)
|
||||
String uid = request.getParameter("uid");
|
||||
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 null;
|
||||
}
|
||||
// ip
|
||||
String thriftIp = rpcString.split(":")[0];
|
||||
// 端口
|
||||
String thriftPort = rpcString.split(":")[1];
|
||||
if (thriftIp == null || thriftIp.isEmpty() || null == thriftPort || thriftPort.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
// 通信游戏服
|
||||
Result result = RPCClient.gmSend(cmd, thriftIp, thriftPort);
|
||||
if (result.getResultCode() != 0) {
|
||||
LOGGER.error("->userid:{},fightId:{}",uid,fightid);
|
||||
return null;
|
||||
}
|
||||
// 返回
|
||||
return result.getResultMsg() == null ? "":result.getResultMsg();
|
||||
}
|
||||
|
||||
/**
|
||||
* 清理游戏服全部战斗记录
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@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 "no";
|
||||
}
|
||||
String thriftIp = rpcString.split(":")[0];
|
||||
String thriftPort = rpcString.split(":")[1];
|
||||
if (thriftIp == null || thriftIp.isEmpty() || null == thriftPort || thriftPort.isEmpty()) {
|
||||
return "no";
|
||||
}
|
||||
Result result = RPCClient.gmSend(cmd, thriftIp, thriftPort);
|
||||
if (result.getResultCode() != 0) {
|
||||
return "no";
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取玩家全部战斗记录
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@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;
|
||||
|
||||
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 "no";
|
||||
}
|
||||
String thriftIp = rpcString.split(":")[0];
|
||||
String thriftPort = rpcString.split(":")[1];
|
||||
if (thriftIp == null || thriftIp.isEmpty() || null == thriftPort || thriftPort.isEmpty()) {
|
||||
return "no";
|
||||
}
|
||||
Result result = RPCClient.gmSend(cmd, thriftIp, thriftPort);
|
||||
if (result.getResultCode() != 0) {
|
||||
return "no";
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue