This commit is contained in:
dute7liang
2024-01-21 19:55:39 +08:00
parent e36ad030e4
commit 5c9218ea83
18 changed files with 222 additions and 76 deletions

View File

@@ -7,23 +7,18 @@ import com.ruoyi.cai.dto.app.dto.ImMessageDTO;
import com.ruoyi.cai.dto.app.vo.ImResp;
import com.ruoyi.cai.enums.GenderEnum;
import com.ruoyi.cai.enums.ImTypeEnum;
import com.ruoyi.cai.enums.SystemConfigEnum;
import com.ruoyi.cai.enums.UserMemberTypeEnum;
import com.ruoyi.cai.service.*;
import com.ruoyi.common.exception.ServiceException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Set;
@Component
public class ImService {
@Autowired
private UserService userService;
@Autowired
private SystemConfigManager systemConfigManager;
@Autowired
private AccountService accountService;
@Autowired
private UserFollowService userFollowService;
@@ -31,6 +26,8 @@ public class ImService {
private UserMemberService userMemberService;
@Autowired
private UserChatRecordService userChatRecordService;
@Autowired
private InnerUserFilter innerUserFilter;
public ImResp sendMessage(Long fromUserId, ImMessageDTO message) {
ImTypeEnum typeEnum = ImTypeEnum.getByType(message.getType());
@@ -61,9 +58,9 @@ public class ImService {
resp.setContent(message.getContent());
return resp;
}
Set<Long> systemCustomerService = systemConfigManager.getSystemConfigOfLongSet(SystemConfigEnum.SYSTEM_CUSTOMER_SERVICE);
boolean inner = innerUserFilter.checkInner(fromUserId, toUserId);
// 有内部用户参与的 跳过所有校验
if(systemCustomerService.contains(fromUserId) || systemCustomerService.contains(toUserId)){
if(inner){
Account account = accountService.getByUserId(fromUserId);
ImResp resp = new ImResp();
resp.setCoin(account.getCoin()+ account.getIncomeCoin());
@@ -72,11 +69,9 @@ public class ImService {
}
boolean fileType = typeEnum.isFileType();
if(fileType){
if(!systemCustomerService.contains(fromUserId) && !systemCustomerService.contains(toUserId)){
boolean star = userFollowService.checkStar(toUserId, fromUserId);
if(!star){
throw new ServiceException("对方关注你才能发送图片|语音|视频");
}
boolean star = userFollowService.checkStar(toUserId, fromUserId);
if(!star){
throw new ServiceException("对方关注你才能发送图片|语音|视频");
}
}
if(fromUserId.equals(toUserId)){
@@ -111,7 +106,7 @@ public class ImService {
throw new ServiceException("目前只能和女神私信!");
}
// 正则判断违规数据替换
if(typeEnum == ImTypeEnum.MESSAGE && !systemCustomerService.contains(fromUserId) && !systemCustomerService.contains(toUserId)){
if(typeEnum == ImTypeEnum.MESSAGE){
}
if(fromUser.getIsAnchor().equals(1)){ // 女神发消息不要钱