|
@@ -18,12 +18,12 @@ import jakarta.validation.Valid;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
+import java.util.Collection;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
-import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.filterList;
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
|
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
|
|
|
|
@@ -65,12 +65,17 @@ public class AppKeFuMessageController {
|
|
@Operation(summary = "获得客服消息列表")
|
|
@Operation(summary = "获得客服消息列表")
|
|
public CommonResult<List<KeFuMessageRespVO>> getKefuMessageList(@Valid KeFuMessageListReqVO pageReqVO) {
|
|
public CommonResult<List<KeFuMessageRespVO>> getKefuMessageList(@Valid KeFuMessageListReqVO pageReqVO) {
|
|
List<KeFuMessageDO> list = kefuMessageService.getKeFuMessageList(pageReqVO);
|
|
List<KeFuMessageDO> list = kefuMessageService.getKeFuMessageList(pageReqVO);
|
|
-
|
|
|
|
|
|
+ Collection<Long> ids = convertSet(list,
|
|
|
|
+ KeFuMessageDO::getReceiverId);
|
|
|
|
+ Collection<Long> relids = convertSet(list,
|
|
|
|
+ KeFuMessageDO::getSenderId);
|
|
|
|
+ ids.addAll(relids);
|
|
// 拼接数据
|
|
// 拼接数据
|
|
List<KeFuMessageRespVO> result = BeanUtils.toBean(list, KeFuMessageRespVO.class);
|
|
List<KeFuMessageRespVO> result = BeanUtils.toBean(list, KeFuMessageRespVO.class);
|
|
- Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(filterList(result,
|
|
|
|
- item -> UserTypeEnum.ADMIN.getValue().equals(item.getSenderType())), KeFuMessageRespVO::getSenderId));
|
|
|
|
|
|
+ Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(ids);
|
|
result.forEach(item -> findAndThen(userMap, item.getSenderId(), user -> item.setSenderAvatar(user.getAvatar())));
|
|
result.forEach(item -> findAndThen(userMap, item.getSenderId(), user -> item.setSenderAvatar(user.getAvatar())));
|
|
|
|
+ result.forEach(item -> findAndThen(userMap, item.getReceiverId(),
|
|
|
|
+ user -> item.setReceiverAvatar(user.getAvatar())));
|
|
return success(result);
|
|
return success(result);
|
|
}
|
|
}
|
|
|
|
|