补全交互操作

This commit is contained in:
easonzhu 2025-02-05 21:16:00 +08:00
parent 6022eb4752
commit add8f6dfa1
5 changed files with 9 additions and 27 deletions

View File

@ -93,7 +93,7 @@
<dependency> <dependency>
<groupId>org.csource</groupId> <groupId>org.csource</groupId>
<artifactId>fastdfs-client-java</artifactId> <artifactId>fastdfs-client-java</artifactId>
<version>1.31-SNAPSHOT</version> <version>1.31</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.whvcse</groupId> <groupId>com.github.whvcse</groupId>

View File

@ -14,7 +14,6 @@ import com.upchina.common.constant.CommentBlackType;
import com.upchina.common.entity.CommentBlack; import com.upchina.common.entity.CommentBlack;
import com.upchina.common.handler.BizException; import com.upchina.common.handler.BizException;
import com.upchina.common.mapper.CommentBlackMapper; import com.upchina.common.mapper.CommentBlackMapper;
import com.upchina.common.mapper.CommentMapper;
import com.upchina.common.query.AddCommentBlackQuery; import com.upchina.common.query.AddCommentBlackQuery;
import com.upchina.common.query.BaseProductQuery; import com.upchina.common.query.BaseProductQuery;
import com.upchina.common.query.CommentBlackQuery; import com.upchina.common.query.CommentBlackQuery;
@ -60,9 +59,6 @@ public class CommentBlackService {
@Resource @Resource
private CommentBlackMapper commentBlackMapper; private CommentBlackMapper commentBlackMapper;
@Resource
private CommentMapper commentMapper;
@Resource @Resource
private UserService userService; private UserService userService;

View File

@ -7,6 +7,7 @@ import com.upchina.common.handler.BizException;
import com.upchina.common.query.OnlyIdQuery; import com.upchina.common.query.OnlyIdQuery;
import com.upchina.common.result.AppPager; import com.upchina.common.result.AppPager;
import com.upchina.common.result.ResponseStatus; import com.upchina.common.result.ResponseStatus;
import com.upchina.common.service.CommentBlackService;
import com.upchina.common.service.SensitiveWordService; import com.upchina.common.service.SensitiveWordService;
import com.upchina.common.util.TextUtil; import com.upchina.common.util.TextUtil;
import com.upchina.common.vo.FrontUserVO; import com.upchina.common.vo.FrontUserVO;
@ -23,7 +24,6 @@ import com.upchina.group.service.common.GroupCommonService;
import com.upchina.group.service.common.GroupMessageService; import com.upchina.group.service.common.GroupMessageService;
import com.upchina.group.vo.GroupVO; import com.upchina.group.vo.GroupVO;
import com.upchina.group.vo.message.GroupMessageVO; import com.upchina.group.vo.message.GroupMessageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -54,6 +54,9 @@ public class AppGroupMessageService {
@Resource @Resource
private AdvisorInfoService advisorInfoService; private AdvisorInfoService advisorInfoService;
@Resource
private CommentBlackService commentBlackService;
public AppPager<GroupMessageVO> getMessageList(ListGroupMessageAppQuery query, FrontUserVO frontUser) { public AppPager<GroupMessageVO> getMessageList(ListGroupMessageAppQuery query, FrontUserVO frontUser) {
Integer groupId = query.getGroupId(); Integer groupId = query.getGroupId();
Integer lastId = query.getLastId(); Integer lastId = query.getLastId();
@ -103,10 +106,8 @@ public class AppGroupMessageService {
throw new BizException(ResponseStatus.MESSAGE_PERMISSION_ERROR, "互动已关闭"); throw new BizException(ResponseStatus.MESSAGE_PERMISSION_ERROR, "互动已关闭");
} }
// TODO 禁言check // 禁言check
// if (groupCommonService.checkUserForbidden(frontUser.getUserId())) { commentBlackService.check(frontUser.getUserId());
// throw new BizException(ResponseStatus.COMMENT_BLACK_USER_ERROR, "您已被禁言");
// }
GroupMessage message = query.toPO(frontUser); GroupMessage message = query.toPO(frontUser);
message.setContent(TextUtil.cleanUnsafeHtml(content)); message.setContent(TextUtil.cleanUnsafeHtml(content));

View File

@ -1,24 +1,13 @@
package com.upchina.group.service.common; package com.upchina.group.service.common;
import com.upchina.group.mapper.GroupInfoMapper;
import com.upchina.group.vo.GroupVO; import com.upchina.group.vo.GroupVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service @Service
public class GroupCommonService { public class GroupCommonService {
@Resource
private GroupInfoMapper groupInfoMapper;
public boolean checkUserForbidden(String userId) {
// 实现用户禁言检查逻辑
return false;
}
public boolean validateUserPermission(String userId, GroupVO groupVO) { public boolean validateUserPermission(String userId, GroupVO groupVO) {
return true; return true;
} }
} }

View File

@ -97,7 +97,6 @@ class AppGroupMessageServiceTest {
when(groupInfoService.getForApp(any(OnlyIdQuery.class), any())).thenReturn(mockGroupVO); when(groupInfoService.getForApp(any(OnlyIdQuery.class), any())).thenReturn(mockGroupVO);
when(groupCommonService.validateUserPermission(anyString(), any(GroupVO.class))).thenReturn(true); when(groupCommonService.validateUserPermission(anyString(), any(GroupVO.class))).thenReturn(true);
when(cacheService.get(eq(groupCache), anyString(), any())).thenReturn(mockSet); when(cacheService.get(eq(groupCache), anyString(), any())).thenReturn(mockSet);
when(groupCacheService.getMessage(anyInt())).thenReturn(mockMessageVO);
// 执行测试 // 执行测试
AppPager<GroupMessageVO> result = appGroupMessageService.getMessageList(query, mockFrontUser); AppPager<GroupMessageVO> result = appGroupMessageService.getMessageList(query, mockFrontUser);
@ -126,7 +125,6 @@ class AppGroupMessageServiceTest {
when(groupInfoService.getForApp(any(OnlyIdQuery.class), any())).thenReturn(mockGroupVO); when(groupInfoService.getForApp(any(OnlyIdQuery.class), any())).thenReturn(mockGroupVO);
when(groupCommonService.validateUserPermission(anyString(), any(GroupVO.class))).thenReturn(true); when(groupCommonService.validateUserPermission(anyString(), any(GroupVO.class))).thenReturn(true);
when(cacheService.get(eq(groupCache), anyString(), any())).thenReturn(mockSet); when(cacheService.get(eq(groupCache), anyString(), any())).thenReturn(mockSet);
when(groupCacheService.getMessage(anyInt())).thenReturn(mockMessageVO);
// 执行测试 // 执行测试
AppPager<GroupMessageVO> result = appGroupMessageService.getMessageList(query, mockFrontUser); AppPager<GroupMessageVO> result = appGroupMessageService.getMessageList(query, mockFrontUser);
@ -145,7 +143,6 @@ class AppGroupMessageServiceTest {
// 设置模拟行为 // 设置模拟行为
doNothing().when(sensitiveWordService).check(anyString()); doNothing().when(sensitiveWordService).check(anyString());
when(groupCommonService.checkUserForbidden(anyString())).thenReturn(false);
when(groupMessageMapper.insert(any(GroupMessage.class))).thenReturn(1); when(groupMessageMapper.insert(any(GroupMessage.class))).thenReturn(1);
// 执行测试 // 执行测试
@ -186,7 +183,6 @@ class AppGroupMessageServiceTest {
// 设置模拟行为 // 设置模拟行为
doNothing().when(sensitiveWordService).check(anyString()); doNothing().when(sensitiveWordService).check(anyString());
when(groupCommonService.checkUserForbidden(anyString())).thenReturn(true);
// 执行测试并验证异常 // 执行测试并验证异常
assertThrows(BizException.class, () -> assertThrows(BizException.class, () ->