From 1b33685f1809718f7844a1a049b8ad0b91469a3b Mon Sep 17 00:00:00 2001 From: Lansong <62054128+Lansongxx@users.noreply.github.com> Date: Thu, 11 Apr 2024 09:20:50 +0800 Subject: [PATCH] =?UTF-8?q?=20fix:=20=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BC=BA=E5=B0=91=E7=9A=84=E4=BF=A1=E6=81=AF?= =?UTF-8?q?,=E5=AE=9E=E7=8E=B0=E7=94=A8=E6=88=B7=E7=82=B9=E8=B5=9E/?= =?UTF-8?q?=E6=94=B6=E8=97=8F/=E8=AF=84=E8=AE=BA=E6=97=B6=E7=BB=99?= =?UTF-8?q?=E4=BD=9C=E8=80=85=E5=A2=9E=E5=8A=A0=E7=83=AD=E5=BA=A6=20=20(#1?= =?UTF-8?q?13)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 10 +++++++ biz/application/service/user.go | 34 +++++++++++++++++++++-- biz/domain/service/relation.go | 10 +++++++ biz/infrastructure/convertor/convertor.go | 9 ------ 4 files changed, 51 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 16af5ca..66d3c46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ +## 2024-04-11 + +### 🐛 Bug Fixes | Bug 修复 + +* 添加用户搜索缺少的信息 + +* 实现用户点赞/收藏/评论时给作者增加热度 + ## 2024-04-10 ### ✨ Features | 新功能 @@ -9,6 +17,8 @@ * 修复帖子修改不填标签500的BUG +* 添加搜索用户缺少的信息 + ## 2024-04-09 ### ✨ Features | 新功能 diff --git a/biz/application/service/user.go b/biz/application/service/user.go index 1852ca9..b8eeca8 100644 --- a/biz/application/service/user.go +++ b/biz/application/service/user.go @@ -198,6 +198,10 @@ func (s *UserService) GetUserDetail(ctx context.Context, _ *core_api.GetUserDeta func (s *UserService) SearchUser(ctx context.Context, req *core_api.SearchUserReq) (resp *core_api.SearchUserResp, err error) { resp = new(core_api.SearchUserResp) + userData, err := adaptor.ExtractUserMeta(ctx) + if err != nil { + return resp, consts.ErrNotAuthentication + } users, err := s.CloudMindContent.GetUsers(ctx, &content.GetUsersReq{ SearchOption: &content.SearchOption{ @@ -209,9 +213,33 @@ func (s *UserService) SearchUser(ctx context.Context, req *core_api.SearchUserRe if err != nil { return resp, err } - resp.Users = lo.Map[*content.User, *core_api.User](users.Users, func(user *content.User, _ int) *core_api.User { - return convertor.UserDetailToUser(user) - }) + resp.Users = make([]*core_api.User, 0, len(users.Users)) + + if err = mr.Finish(lo.Map[*content.User](users.Users, func(user *content.User, i int) func() error { + return func() error { + resp.Users[i] = &core_api.User{ + UserId: user.UserId, + Name: user.Name, + Url: user.Url, + Labels: user.Labels, + Description: user.Description, + } + if err = mr.Finish(func() error { + if userData.GetUserId() != user.UserId && userData.GetUserId() != "" { + s.UserDomainService.LoadFollowed(ctx, &resp.Users[i].Followed, userData.UserId, user.UserId) + } + return nil + }, func() error { + s.UserDomainService.LoadFollowedCount(ctx, &resp.Users[i].FollowedCount, user.UserId) + return nil + }); err != nil { + return err + } + return nil + } + })...); err != nil { + return resp, err + } resp.LastToken = users.LastToken return resp, nil } diff --git a/biz/domain/service/relation.go b/biz/domain/service/relation.go index 1f27b40..606bd64 100644 --- a/biz/domain/service/relation.go +++ b/biz/domain/service/relation.go @@ -228,6 +228,16 @@ func (s *RelationDomainService) CreateRelation(ctx context.Context, r *core_api. return err } + if r.RelationType == core_api.RelationType_LikeRelationType || r.RelationType == core_api.RelationType_CollectRelationType || r.RelationType == core_api.RelationType_CommentRelationType { + if _, err = s.CloudMindContent.IncrHotValue(ctx, &content.IncrHotValueReq{ + Action: content.Action(r.RelationType), + HotId: userId, + TargetType: content.TargetType_UserType, + }); err != nil { + return err + } + + } // 创建通知 msg, _ := sonic.Marshal(Msg{ FromName: userinfo.Name, diff --git a/biz/infrastructure/convertor/convertor.go b/biz/infrastructure/convertor/convertor.go index 774ada5..330d45e 100644 --- a/biz/infrastructure/convertor/convertor.go +++ b/biz/infrastructure/convertor/convertor.go @@ -120,15 +120,6 @@ func CoreSubjectToSubject(req *core_api.Subject) *platform.Subject { } } -func UserDetailToUser(req *content.User) *core_api.User { - return &core_api.User{ - UserId: req.UserId, - Name: req.Name, - Url: req.Url, - Labels: req.Labels, - } -} - func MakePaginationOptions(limit, offset *int64, lastToken *string, backward *bool) *basic.PaginationOptions { return &basic.PaginationOptions{ Limit: limit,