【代码评审】MALL:review 客服的实现

This commit is contained in:
YunaiV 2024-07-02 20:59:29 +08:00
parent 80a1f50cc8
commit b7e4f8e460
7 changed files with 12 additions and 16 deletions

View File

@ -61,10 +61,8 @@ public class KeFuConversationController {
// 拼接数据
Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(convertSet(respList, KeFuConversationRespVO::getUserId));
respList.forEach(item->{
findAndThen(userMap, item.getUserId(), memberUser-> item.setUserAvatar(memberUser.getAvatar())
.setUserNickname(memberUser.getNickname()));
});
respList.forEach(item-> findAndThen(userMap, item.getUserId(),
memberUser-> item.setUserAvatar(memberUser.getAvatar()).setUserNickname(memberUser.getNickname())));
return success(respList);
}

View File

@ -67,9 +67,8 @@ public class KeFuMessageController {
PageResult<KeFuMessageRespVO> result = BeanUtils.toBean(pageResult, KeFuMessageRespVO.class);
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result.getList(),
item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId));
result.getList().forEach(item->{
findAndThen(userMap, item.getSenderId(), adminUser -> item.setSenderAvatar(adminUser.getAvatar()));
});
result.getList().forEach(item-> findAndThen(userMap, item.getSenderId(),
user -> item.setSenderAvatar(user.getAvatar())));
return success(result);
}

View File

@ -23,9 +23,9 @@ public class KeFuMessageSendReqVO {
// ========== 后端设置的参数前端无需传递 ==========
@Schema(description = "发送人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "24571", hidden = true)
@Schema(description = "发送人编号", example = "24571", hidden = true)
private Long senderId;
@Schema(description = "发送人类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1", hidden = true)
@Schema(description = "发送人类型", example = "1", hidden = true)
private Integer senderType;
}

View File

@ -28,7 +28,7 @@ public interface KeFuConversationMapper extends BaseMapperX<KeFuConversationDO>
.setSql("admin_unread_message_count = admin_unread_message_count + 1"));
}
default KeFuConversationDO selectByUserId(Long userId){
default KeFuConversationDO selectByUserId(Long userId) {
return selectOne(KeFuConversationDO::getUserId, userId);
}

View File

@ -39,7 +39,7 @@ public interface KeFuConversationService {
*
* @param id 编号
*/
void updateAdminUnreadMessageCountWithZero(Long id);
void updateAdminUnreadMessageCountToZero(Long id);
/**
* 管理员更新会话对于管理员是否可见

View File

@ -65,10 +65,10 @@ public class KeFuConversationServiceImpl implements KeFuConversationService {
}
@Override
public void updateAdminUnreadMessageCountWithZero(Long id) {
public void updateAdminUnreadMessageCountToZero(Long id) {
// 校验存在
validateKefuConversationExists(id);
// 管理员未读消息数归零
conversationMapper.updateById(new KeFuConversationDO().setId(id).setAdminUnreadMessageCount(0));
}

View File

@ -96,9 +96,8 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
if (UserTypeEnum.MEMBER.getValue().equals(userType) && ObjUtil.notEqual(conversation.getUserId(), userId)) {
throw exception(KEFU_CONVERSATION_NOT_EXISTS);
}
// 1.2 查询会话所有的未读消息 (tips: 多个客服一个人点了就都点了)
// 1.3 查询会话所有的未读消息 (tips: 多个客服一个人点了就都点了)
List<KeFuMessageDO> messageList = keFuMessageMapper.selectListByConversationIdAndReadStatus(conversationId, Boolean.FALSE);
// 1.3 情况一没有未读消息
if (CollUtil.isEmpty(messageList)) {
return;
}
@ -107,7 +106,7 @@ public class KeFuMessageServiceImpl implements KeFuMessageService {
keFuMessageMapper.updateReadStatusBatchByIds(convertSet(messageList, KeFuMessageDO::getId),
new KeFuMessageDO().setReadStatus(Boolean.TRUE));
// 2.2 将管理员未读消息计数更新为零
conversationService.updateAdminUnreadMessageCountWithZero(conversationId);
conversationService.updateAdminUnreadMessageCountToZero(conversationId);
// 2.3 发送消息通知会员管理员已读 -> 会员更新发送的消息状态
// TODO @puhui999待定~