...
|
...
|
@@ -58,17 +58,43 @@ func (l *SystemGetArticleDraftLogic) SystemGetArticleDraft(req *types.SystemArti |
|
|
})
|
|
|
})
|
|
|
resp = &types.SystemArticleDraftGetResponse{
|
|
|
Id: articleDraft.Id,
|
|
|
Title: articleDraft.Title,
|
|
|
Content: articleDraft.Content,
|
|
|
AuthorId: articleDraft.AuthorId,
|
|
|
Images: images,
|
|
|
Videos: videos,
|
|
|
TargetUser: int(articleDraft.TargetUser),
|
|
|
WhoRead: articleDraft.WhoRead,
|
|
|
WhoReview: articleDraft.WhoReview,
|
|
|
MatchUrl: articleDraft.MatchUrl,
|
|
|
Tags: articleDraft.Tags,
|
|
|
Id: articleDraft.Id,
|
|
|
Title: articleDraft.Title,
|
|
|
Content: articleDraft.Content,
|
|
|
AuthorId: articleDraft.AuthorId,
|
|
|
Images: images,
|
|
|
Videos: videos,
|
|
|
TargetUser: int(articleDraft.TargetUser),
|
|
|
WhoRead: articleDraft.WhoRead,
|
|
|
WhoReadInfo: make([]types.UserShowName, 0),
|
|
|
WhoReview: articleDraft.WhoReview,
|
|
|
WhoReviewInfo: make([]types.UserShowName, 0),
|
|
|
MatchUrl: articleDraft.MatchUrl,
|
|
|
Tags: articleDraft.Tags,
|
|
|
}
|
|
|
userIds := lo.Union(resp.WhoRead, resp.WhoReview)
|
|
|
if len(userIds) > 0 {
|
|
|
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, l.conn, domain.NewQueryOptions().WithKV("ids", userIds))
|
|
|
if err != nil {
|
|
|
return nil, xerr.NewErrMsgErr("获取帖子异常", err)
|
|
|
}
|
|
|
userSlices := make(map[int64]types.UserShowName)
|
|
|
lo.ForEach(users, func(user *domain.User, index int) {
|
|
|
userSlices[user.Id] = types.UserShowName{
|
|
|
Id: int(user.Id),
|
|
|
Name: user.Name,
|
|
|
}
|
|
|
})
|
|
|
lo.ForEach(resp.WhoRead, func(userId int64, index int) {
|
|
|
if value, ok := userSlices[userId]; ok {
|
|
|
resp.WhoReadInfo = append(resp.WhoReadInfo, value)
|
|
|
}
|
|
|
})
|
|
|
lo.ForEach(resp.WhoReview, func(userId int64, index int) {
|
|
|
if value, ok := userSlices[userId]; ok {
|
|
|
resp.WhoReviewInfo = append(resp.WhoReviewInfo, value)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|