123
This commit is contained in:
26
ruoyi-admin/src/main/java/com/ruoyi/job/EveryDaysJob.java
Normal file
26
ruoyi-admin/src/main/java/com/ruoyi/job/EveryDaysJob.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.ruoyi.job;
|
||||
|
||||
import com.ruoyi.op.BusOp;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class EveryDaysJob {
|
||||
@Autowired
|
||||
private BusOp busOp;
|
||||
// 凌晨0点3分执行一次
|
||||
@Scheduled(cron = "0 3 0 * * ? ")
|
||||
public void run() {
|
||||
try {
|
||||
log.info("执行用户VIP状态码回转-开始");
|
||||
busOp.refreshUserVipStatus();
|
||||
}catch (Exception e){
|
||||
log.error("执行用户VIP状态码回转-失败!",e);
|
||||
}finally {
|
||||
log.info("执行用户VIP状态码回转-结束");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,6 +93,7 @@ public class RankJob {
|
||||
}catch (Exception e){
|
||||
log.error("报错昨日主播统计失败!",e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
40
ruoyi-admin/src/main/java/com/ruoyi/op/BusOp.java
Normal file
40
ruoyi-admin/src/main/java/com/ruoyi/op/BusOp.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.ruoyi.op;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.service.UserMemberService;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class BusOp {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private UserMemberService userMemberService;
|
||||
|
||||
public void refreshUserVipStatus(){
|
||||
int current = 0;
|
||||
Page<User> page = new Page<>(0, 10);
|
||||
while (true){
|
||||
current++;
|
||||
page.setCurrent(current);
|
||||
Page<User> userPage = userService.page(page);
|
||||
List<User> records = userPage.getRecords();
|
||||
if(records.isEmpty()){
|
||||
break;
|
||||
}
|
||||
for (User user : records) {
|
||||
if(user.getNoGreet() != null && user.getRankHide() != null){
|
||||
if(user.getNoGreet().equals(1) || user.getRankHide().equals(1)){
|
||||
userMemberService.checkAndUpdateUser(user.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.ruoyi.op;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.im.ImManager;
|
||||
import com.ruoyi.cai.service.UserService;
|
||||
@@ -86,4 +87,21 @@ public class ImOp {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshImUserInfo() {
|
||||
int current = 0;
|
||||
Page<User> page = new Page<>(0, 10);
|
||||
while (true){
|
||||
current++;
|
||||
page.setCurrent(current);
|
||||
Page<User> userPage = userService.page(page);
|
||||
List<User> records = userPage.getRecords();
|
||||
if(records.isEmpty()){
|
||||
break;
|
||||
}
|
||||
for (User user : records) {
|
||||
imManager.updateImInfo(user.getId(),user.getAvatar(),user.getNickname(),user.getGender());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.ruoyi.web.controller.cai.admin.op;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.op.BusOp;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/cai/op/bus")
|
||||
@Slf4j
|
||||
public class BusOpController {
|
||||
|
||||
@Autowired
|
||||
private BusOp busOp;
|
||||
|
||||
@GetMapping("/refreshUserVipStatus")
|
||||
public R<Void> refreshUserVipStatus(){
|
||||
busOp.refreshUserVipStatus();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,12 @@ public class ImOpController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/refreshImUserInfo")
|
||||
public R<Void> refreshImUserInfo(){
|
||||
imOp.refreshImUserInfo();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@GetMapping("/refreshImByUser")
|
||||
public R<Void> refreshImByUser(String usercode){
|
||||
imOp.refreshImToken(usercode);
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.alibaba.fastjson2.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ruoyi.cai.domain.UserChatRecord;
|
||||
import com.ruoyi.cai.executor.ExecutorConstant;
|
||||
import com.ruoyi.cai.im.ImCheckResp;
|
||||
import com.ruoyi.cai.im.ImManager;
|
||||
import com.ruoyi.cai.service.UserChatRecordService;
|
||||
import com.ruoyi.cai.service.UserOnlineService;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
@@ -36,6 +38,8 @@ public class YxNotifyController {
|
||||
private UserOnlineService onlineService;
|
||||
@Autowired
|
||||
private UserChatRecordService userChatRecordService;
|
||||
@Autowired
|
||||
private ImManager imManager;
|
||||
|
||||
@PostMapping("/notify")
|
||||
@Operation(hidden = true)
|
||||
@@ -95,6 +99,37 @@ public class YxNotifyController {
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@PostMapping("/check")
|
||||
@Operation(hidden = true)
|
||||
@SaIgnore
|
||||
public ImCheckResp checkYx(HttpServletRequest request) throws IOException {
|
||||
try {
|
||||
String appKey = request.getHeader("AppKey");
|
||||
String curTime = request.getHeader("CurTime");
|
||||
String md5 = request.getHeader("MD5");
|
||||
String checkSum = request.getHeader("CheckSum");
|
||||
String requestBody = readBody(request);
|
||||
boolean check = yunxinManager.checkNotify(requestBody, curTime, checkSum,md5);
|
||||
if(!check){
|
||||
log.info("检验失败!");
|
||||
return ImCheckResp.ok();
|
||||
}
|
||||
JSONObject body = JSON.parseObject(requestBody);
|
||||
if(body == null){
|
||||
return ImCheckResp.ok();
|
||||
}
|
||||
boolean message = imManager.filterMessage(body);
|
||||
if(message){
|
||||
return ImCheckResp.ok();
|
||||
}else{
|
||||
return ImCheckResp.fail();
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("拦截IM失败!",e);
|
||||
return ImCheckResp.ok();
|
||||
}
|
||||
}
|
||||
|
||||
private String readBody(HttpServletRequest request) throws IOException {
|
||||
if (request.getContentLength() > 0) {
|
||||
byte[] bytes = StreamUtils.copyToByteArray(request.getInputStream());
|
||||
|
||||
Reference in New Issue
Block a user