123333
This commit is contained in:
@@ -3,6 +3,7 @@ package com.ruoyi.cai.manager;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.github.houbb.sensitive.word.bs.SensitiveWordBs;
|
||||
import com.ruoyi.cai.domain.Account;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.domain.UserChatRecord;
|
||||
@@ -52,6 +53,10 @@ public class ImService {
|
||||
private AmqpProducer amqpProducer;
|
||||
@Autowired
|
||||
private ISysOssService sysOssService;
|
||||
@Autowired
|
||||
private SensitiveWordBs sensitiveWordBs;
|
||||
@Autowired
|
||||
private UserChatFilterService userChatFilterService;
|
||||
|
||||
public ImResp sendMessage(Long fromUserId, ImMessageDTO message) {
|
||||
ChatTypeEnum typeEnum = ChatTypeEnum.getByType(message.getType());
|
||||
@@ -129,15 +134,21 @@ public class ImService {
|
||||
if (fromUser.getIsAnchor().equals(0) && toUser.getIsAnchor().equals(0)) {
|
||||
throw new ServiceException("目前只能和女神私信!");
|
||||
}
|
||||
int filter = 0;
|
||||
String content = message.getContent();
|
||||
// 正则判断违规数据替换
|
||||
if(typeEnum == ChatTypeEnum.MESSAGE){
|
||||
|
||||
boolean contains = sensitiveWordBs.contains(message.getContent());
|
||||
if(contains){
|
||||
filter = 1;
|
||||
content = sensitiveWordBs.replace(message.getContent());
|
||||
}
|
||||
}
|
||||
if(fromUser.getIsAnchor().equals(1)){ // 女神发消息不要钱
|
||||
Account account = accountService.getByUserId(fromUserId);
|
||||
ImResp resp = new ImResp();
|
||||
resp.setCoin(account.getCoin()+ account.getIncomeCoin());
|
||||
resp.setContent(message.getContent());
|
||||
resp.setContent(content);
|
||||
return resp;
|
||||
}
|
||||
// 判断VIP获取价格
|
||||
@@ -150,15 +161,21 @@ public class ImService {
|
||||
// 存储聊天记录
|
||||
Account account = accountService.getByUserId(fromUserId);
|
||||
UserChatRecord record = userChatRecordService.saveRecord(fromUser, toUser, traceId, message);
|
||||
if(filter == 1){
|
||||
userChatFilterService.saveFilter(fromUser, toUser, content);
|
||||
}
|
||||
ImResp resp = new ImResp();
|
||||
resp.setCut(imPrice > 0);
|
||||
resp.setCutCoin(imPrice);
|
||||
resp.setCoin(account.getCoin()+ account.getIncomeCoin());
|
||||
resp.setRecordId(record.getId());
|
||||
resp.setContent(message.getContent());
|
||||
resp.setFilter(filter);
|
||||
resp.setContent(content);
|
||||
return resp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private Long getByImPrice(Long userId){
|
||||
UserMemberTypeEnum userMemberType = userMemberService.checkUserIsMember(userId);
|
||||
if(userMemberType == null){
|
||||
|
||||
Reference in New Issue
Block a user