REQ-3345: 返回用户头像
This commit is contained in:
parent
45943bba97
commit
44ca936d1c
@ -69,6 +69,16 @@ public class GroupMessagePageQueryResponse {
|
||||
*/
|
||||
private String unitName;
|
||||
|
||||
/**
|
||||
* 发送者名称
|
||||
*/
|
||||
private String fromPersonName;
|
||||
|
||||
/**
|
||||
* 发送者头像
|
||||
*/
|
||||
private String fromPersonAvatar;
|
||||
|
||||
/**
|
||||
* 客户端id
|
||||
*/
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.axzo.im.gateway.domain;
|
||||
|
||||
import cn.axzo.basics.profiles.dto.basic.PersonProfileDto;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author yanglin
|
||||
*/
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class PersonProfiles {
|
||||
|
||||
private final List<PersonProfileDto> profiles;
|
||||
|
||||
public static PersonProfiles wrap(List<PersonProfileDto> profiles) {
|
||||
return new PersonProfiles(profiles);
|
||||
}
|
||||
|
||||
public Optional<PersonProfileDto> findByUserId(Long personId) {
|
||||
return profiles.stream()
|
||||
.filter(p -> p.getId().equals(personId))
|
||||
.findFirst();
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,9 @@ import cn.axzo.im.dao.repository.GroupMessageDao;
|
||||
import cn.axzo.im.entity.GroupMessage;
|
||||
import cn.axzo.im.entity.UpdatableMessage;
|
||||
import cn.axzo.im.gateway.OrgGateway;
|
||||
import cn.axzo.im.gateway.ProfilesApiGateway;
|
||||
import cn.axzo.im.gateway.domain.OrgCollection;
|
||||
import cn.axzo.im.gateway.domain.PersonProfiles;
|
||||
import cn.axzo.im.updatable.UpdatableMessageQueryService;
|
||||
import cn.axzo.im.updatable.domain.UpdatableMessages;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -36,6 +38,7 @@ public class GroupMessageController implements GroupMessageApi {
|
||||
private final GroupMessageDao groupMessageDao;
|
||||
private final OrgGateway orgGateway;
|
||||
private final UpdatableMessageQueryService updatableMessageQueryService;
|
||||
private final ProfilesApiGateway profilesApiGateway;
|
||||
|
||||
@Override
|
||||
public ApiPageResult<GroupMessagePageQueryResponse> pageQuery(GroupMessagePageQueryRequest request) {
|
||||
@ -51,6 +54,13 @@ public class GroupMessageController implements GroupMessageApi {
|
||||
.filter(message -> message.getMessageType() == NimMessageType.CUSTOM)
|
||||
.map(GroupMessagePageQueryResponse::getMessageId)
|
||||
.collect(toList())));
|
||||
PersonProfiles personProfiles = PersonProfiles.wrap(
|
||||
profilesApiGateway.getPersonProfilesByIds(messages.stream()
|
||||
.map(GroupMessagePageQueryResponse::getFromPersonId)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(personId -> personId > 0)
|
||||
.distinct()
|
||||
.collect(toList())));
|
||||
OrgCollection units = OrgCollection.wrap(orgGateway.getUnits(messages.stream()
|
||||
.map(GroupMessagePageQueryResponse::getFromPersonOuId)
|
||||
.filter(Objects::nonNull)
|
||||
@ -60,9 +70,13 @@ public class GroupMessageController implements GroupMessageApi {
|
||||
for (GroupMessagePageQueryResponse message : messages) {
|
||||
units.findUnit(message.getFromPersonOuId())
|
||||
.ifPresent(unit -> message.setUnitName(unit.getName()));
|
||||
updatableMessages
|
||||
.findByNimMessageId(message.getMessageId())
|
||||
updatableMessages.findByNimMessageId(message.getMessageId())
|
||||
.ifPresent(updatableMessage -> updateMsgBody(message, updatableMessage));
|
||||
personProfiles.findByUserId(message.getFromPersonId())
|
||||
.ifPresent(profile -> {
|
||||
message.setFromPersonName(profile.getRealName());
|
||||
message.setFromPersonAvatar(profile.getAvatarUrl());
|
||||
});
|
||||
}
|
||||
PageResp<GroupMessagePageQueryResponse> pageResp = PageResp.list(
|
||||
page.getCurrent(),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user