generated from root/miduo_server
83 lines
3.4 KiB
Java
83 lines
3.4 KiB
Java
package com.ljsd.controller;
|
||
|
||
import com.ljsd.pojo.Operation;
|
||
import com.ljsd.pojo.ResultVo;
|
||
import com.ljsd.redis.RedisKey;
|
||
import com.ljsd.util.BaseGlobal;
|
||
import com.ljsd.util.HttpUtil;
|
||
import com.ljsd.util.MyMD5Util;
|
||
import org.slf4j.Logger;
|
||
import org.slf4j.LoggerFactory;
|
||
|
||
import javax.servlet.ServletException;
|
||
import javax.servlet.http.HttpServlet;
|
||
import javax.servlet.http.HttpServletRequest;
|
||
import javax.servlet.http.HttpServletResponse;
|
||
import java.io.IOException;
|
||
import java.io.PrintWriter;
|
||
import java.util.HashMap;
|
||
import java.util.UUID;
|
||
|
||
/**
|
||
* @author gaojie
|
||
* @version V1.0
|
||
* @className GameTitleController
|
||
* @packageName com.ljsd.controller
|
||
* @description
|
||
* @date 2022-02-22 10:10
|
||
* copyright(c) 2020-2030 蓝鲸时代技术有限公司
|
||
**/
|
||
public class GameTitleController extends HttpServlet {
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(GameTitleController.class);
|
||
@Override
|
||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||
req.setCharacterEncoding("UTF-8");
|
||
resp.setCharacterEncoding("UTF-8");
|
||
resp.setContentType("application/json; charset=utf-8");
|
||
PrintWriter out = resp.getWriter();
|
||
HashMap<String, String> parameterMap = HttpUtil.getParameterMap(req);
|
||
String accountid = parameterMap.get("userId");
|
||
String roleId = parameterMap.get("roleId");
|
||
String roleName = parameterMap.get("roleName");
|
||
String gameId = parameterMap.get("gameId");
|
||
String serviceId = parameterMap.get("serviceId");
|
||
//时间戳,毫秒,禁言时时间戳表示禁言截止日期,1表示永久禁言
|
||
String opStatus = parameterMap.get("opStatus");
|
||
String shutupTime = parameterMap.get("shutupTime");
|
||
String chatContents = parameterMap.get("chatContents");
|
||
String random = parameterMap.get("random");
|
||
String sign = parameterMap.get("sign");
|
||
boolean isSignSuccess = false;
|
||
for (String value : BaseGlobal.PAY_KEY.values()) {
|
||
String info = accountid + roleId + HttpUtil.getEncode(roleName).toLowerCase() +gameId + serviceId + opStatus + shutupTime + HttpUtil.getEncode(chatContents) + random + value;
|
||
String sig = MyMD5Util.encrypByMd5(info);
|
||
if (sig.equals(sign)){
|
||
isSignSuccess = true;
|
||
break;
|
||
}
|
||
LOGGER.info("GameTitleController==>info={},bt_md5Sign={},sig" + "={} sin derify fail !!!",info,sign,sig);
|
||
}
|
||
if (!isSignSuccess) {
|
||
ResultVo resultVo = new ResultVo(100,"sign fail");
|
||
out.print(HttpUtil.getResult(resultVo));
|
||
out.flush();
|
||
return;
|
||
}
|
||
try {
|
||
Operation operation = new Operation(Integer.parseInt(roleId),Integer.parseInt(opStatus),Long.parseLong(shutupTime));
|
||
String id = UUID.randomUUID().toString();
|
||
BaseGlobal.redisApp.hset( serviceId + ":" + RedisKey.BT_GAME_OPERATION_KEY,"",id,operation,-1);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
String result = HttpUtil.getResult(new ResultVo(200, "success"));
|
||
LOGGER.info("GameTitleController==>url:{},result={}",req.getRequestURI(),result);
|
||
out.print(result);
|
||
out.flush();
|
||
}
|
||
@Override
|
||
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||
this.doGet(req, resp);
|
||
}
|
||
}
|