123333
This commit is contained in:
@@ -45,6 +45,10 @@
|
||||
<artifactId>IJPay-AliPay</artifactId>
|
||||
<version>${ijapy.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-sensitive-word</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>aliyun-java-sdk-core</artifactId>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ruoyi.cai.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
@@ -22,7 +23,7 @@ public class UserChatFilter implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(value = "id")
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.cai.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.domain.UserChatFilter;
|
||||
|
||||
/**
|
||||
@@ -11,4 +12,5 @@ import com.ruoyi.cai.domain.UserChatFilter;
|
||||
*/
|
||||
public interface UserChatFilterService extends IService<UserChatFilter> {
|
||||
|
||||
void saveFilter(User fromUser, User toUser, String content);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.cai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ruoyi.cai.domain.User;
|
||||
import com.ruoyi.cai.domain.UserChatFilter;
|
||||
import com.ruoyi.cai.mapper.UserChatFilterMapper;
|
||||
import com.ruoyi.cai.service.UserChatFilterService;
|
||||
@@ -14,4 +15,12 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public class UserChatFilterServiceImpl extends ServiceImpl<UserChatFilterMapper,UserChatFilter> implements UserChatFilterService {
|
||||
@Override
|
||||
public void saveFilter(User fromUser, User toUser, String content) {
|
||||
UserChatFilter chatFilter = new UserChatFilter();
|
||||
chatFilter.setFromUid(fromUser.getId());
|
||||
chatFilter.setToUid(toUser.getId());
|
||||
chatFilter.setContent(content);
|
||||
this.save(chatFilter);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user