This commit is contained in:
张良(004796)
2024-02-05 15:46:29 +08:00
parent 144c5d1335
commit caac9f5cc1
14 changed files with 176 additions and 80 deletions

View File

@@ -1,6 +1,9 @@
package com.ruoyi.web.controller.cai.app;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.cai.service.UserOnlineService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.yunxin.manager.YunxinManager;
import io.swagger.v3.oas.annotations.Operation;
@@ -24,6 +27,8 @@ public class YxNotifyController {
@Autowired
private YunxinManager yunxinManager;
@Autowired
private UserOnlineService onlineService;
@PostMapping("/notify")
@Operation(hidden = true)
@@ -33,14 +38,23 @@ public class YxNotifyController {
String curTime = request.getHeader("CurTime");
String md5 = request.getHeader("MD5");
String checkSum = request.getHeader("CheckSum");
log.info("request headers: AppKey = {}, CurTime = {}, " +
"MD5 = {}, CheckSum = {}", appKey, curTime, md5, checkSum);
log.info("request headers: AppKey = {}, CurTime = {},MD5 = {}, CheckSum = {}", appKey, curTime, md5, checkSum);
String requestBody = readBody(request);
log.info("request body = {}", requestBody);
boolean check = yunxinManager.checkNotify(requestBody, curTime);
boolean check = yunxinManager.checkNotify(requestBody, curTime, checkSum,md5);
if(!check){
log.info("检验失败!");
return R.fail("500",null);
return R.fail("401",null);
}
JSONObject body = JSON.parseObject(requestBody);
if(body == null){
return R.fail("401",null);
}
String eventType = body.getString("eventType");
if("2".equals(eventType) || "3".equals(eventType)){ // 登陆登出事件
String accid = body.getString("accid");
String timestamp = body.getString("timestamp");
onlineService.updateOnlineByYunxin(eventType,Long.valueOf(accid),Long.valueOf(timestamp));
}
return R.ok();
}