聊天室完成
This commit is contained in:
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@@ -23,6 +24,8 @@ import org.xyzh.api.workcase.vo.ChatMemberVO;
|
||||
import org.xyzh.api.workcase.vo.ChatRoomMessageVO;
|
||||
import org.xyzh.api.workcase.vo.ChatRoomVO;
|
||||
import org.xyzh.api.workcase.vo.CustomerServiceVO;
|
||||
import org.xyzh.common.auth.utils.JwtTokenUtil;
|
||||
import org.xyzh.common.auth.utils.LoginUtil;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.core.page.PageRequest;
|
||||
import org.xyzh.common.utils.validation.ValidationResult;
|
||||
@@ -56,6 +59,9 @@ public class WorkcaseChatContorller {
|
||||
@Autowired
|
||||
private ChatRoomService chatRoomService;
|
||||
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
|
||||
// ========================= ChatRoom聊天室管理(实时IM) =========================
|
||||
|
||||
@Operation(summary = "创建聊天室(转人工时调用)")
|
||||
@@ -107,8 +113,7 @@ public class WorkcaseChatContorller {
|
||||
@PreAuthorize("hasAuthority('workcase:room:view')")
|
||||
@PostMapping("/room/page")
|
||||
public ResultDomain<ChatRoomVO> getChatRoomPage(
|
||||
@RequestBody PageRequest<TbChatRoomDTO> pageRequest,
|
||||
@RequestParam(value = "userId", required = true) String userId) {
|
||||
@RequestBody PageRequest<TbChatRoomDTO> pageRequest) {
|
||||
ValidationResult vr = ValidationUtils.validate(pageRequest, Arrays.asList(
|
||||
ValidationUtils.requiredNumber("pageParam.page", "页码", 1, null),
|
||||
ValidationUtils.requiredNumber("pageParam.pageSize", "每页数量", 1, 100)
|
||||
@@ -116,6 +121,9 @@ public class WorkcaseChatContorller {
|
||||
if (!vr.isValid()) {
|
||||
return ResultDomain.failure(vr.getAllErrors());
|
||||
}
|
||||
|
||||
String userId = LoginUtil.getCurrentUserId();
|
||||
|
||||
return chatRoomService.getChatRoomPage(pageRequest, userId);
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface TbChatRoomMapper {
|
||||
List<ChatRoomVO> selectChatRoomList(@Param("filter") TbChatRoomDTO filter);
|
||||
|
||||
/**
|
||||
* 分页查询聊天室
|
||||
* 分页查询聊天室(含未读数)
|
||||
*/
|
||||
List<ChatRoomVO> selectChatRoomPage(@Param("filter") TbChatRoomDTO filter, @Param("pageParam") PageParam pageParam, @Param("userId") String userId);
|
||||
|
||||
|
||||
@@ -233,7 +233,13 @@ public class ChatRoomServiceImpl implements ChatRoomService {
|
||||
filter.setUserId(member.getUserId());
|
||||
List<ChatMemberVO> existingMembers = chatRoomMemberMapper.selectChatRoomMemberList(filter);
|
||||
if (existingMembers != null && !existingMembers.isEmpty()) {
|
||||
return ResultDomain.failure("用户已是聊天室成员");
|
||||
// 重置未读数量
|
||||
TbChatRoomMemberDTO updateMember = new TbChatRoomMemberDTO();
|
||||
updateMember.setMemberId(existingMembers.get(0).getMemberId());
|
||||
updateMember.setUnreadCount(0);
|
||||
chatRoomMemberMapper.updateChatRoomMember(updateMember);
|
||||
|
||||
return ResultDomain.failure("用户已是聊天室成员,更新未读");
|
||||
}
|
||||
|
||||
if (member.getMemberId() == null || member.getMemberId().isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user