From 33211bfb27c268370ca0fc376e9e4247c05683a8 Mon Sep 17 00:00:00 2001 From: wangchuxiao Date: Thu, 21 Apr 2022 11:18:11 +0800 Subject: [PATCH] workMoments --- internal/api/office/work_moments.go | 9 +++++++++ internal/rpc/office/office.go | 14 -------------- pkg/base_info/work_moments_struct.go | 16 ++++++++-------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/internal/api/office/work_moments.go b/internal/api/office/work_moments.go index fcea9a1a0..05497727f 100644 --- a/internal/api/office/work_moments.go +++ b/internal/api/office/work_moments.go @@ -206,6 +206,15 @@ func GetWorkMomentByID(c *gin.Context) { if err := utils.CopyStructFields(&resp.Data.WorkMoment, respPb.WorkMoment); err != nil { log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } + if err := utils.CopyStructFields(&resp.Data.WorkMoment.AtUserIDList, respPb.WorkMoment.AtUserList); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed") + } + if err := utils.CopyStructFields(&resp.Data.WorkMoment.LikeUserList, respPb.WorkMoment.LikeUserList); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed") + } + if err := utils.CopyStructFields(&resp.Data.WorkMoment.Comments, respPb.WorkMoment.Comments); err != nil { + log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed") + } log.NewInfo(req.OperationID, utils.GetSelfFuncName(), "resp: ", resp) c.JSON(http.StatusOK, resp) } diff --git a/internal/rpc/office/office.go b/internal/rpc/office/office.go index cdcff1112..847faba11 100644 --- a/internal/rpc/office/office.go +++ b/internal/rpc/office/office.go @@ -286,20 +286,6 @@ func (s *officeServer) CreateOneWorkMoment(_ context.Context, req *pbOffice.Crea log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "CopyStructFields failed", err.Error()) } workMoment.PermissionUserIDList = s.getPermissionUserIDList(req.OperationID, req.WorkMoment.PermissionGroupList, req.WorkMoment.PermissionUserList) - for _, user := range req.WorkMoment.AtUserList { - if user.UserName == "" { - userName, err := imdb.GetUserNameByUserID(user.UserID) - if err != nil { - log.NewError(req.OperationID, utils.GetSelfFuncName(), "GetUserNameByUserID failed", user.UserID, err.Error()) - continue - } - user.UserName = userName - } - workMoment.AtUserList = append(workMoment.AtUserList, &db.AtUser{ - UserID: user.UserID, - UserName: user.UserName, - }) - } log.NewDebug(req.OperationID, utils.GetSelfFuncName(), "workMoment to create", workMoment) err = db.DB.CreateOneWorkMoment(&workMoment) if err != nil { diff --git a/pkg/base_info/work_moments_struct.go b/pkg/base_info/work_moments_struct.go index cb418b448..e69bcd4a1 100644 --- a/pkg/base_info/work_moments_struct.go +++ b/pkg/base_info/work_moments_struct.go @@ -45,19 +45,19 @@ type GetWorkMomentByIDReq struct { } type WorkMoment struct { - WorkMomentID string `json:"workMomentID"` - UserID string `json:"userID"` - Content string `json:"content"` - LikeUsers []*LikeUser `json:"likeUsers"` - Comments []*Comment `json:"comments"` + WorkMomentID string `json:"workMomentID"` + UserID string `json:"userID"` + Content string `json:"content"` + LikeUserList []*WorkMomentUser `json:"likeUsers"` + Comments []*Comment `json:"comments"` //Permission int32 `json:"permission"` //PermissionUserIDList []string `json:"permissionUserIDList"` //PermissionGroupIDList []string `json:"permissionGroupIDList"` - AtUserIDList []string `json:"atUserIDList"` - CreateTime int32 `json:"createTime,omitempty"` + AtUserIDList []*WorkMomentUser `json:"atUsers"` + CreateTime int32 `json:"createTime,omitempty"` } -type LikeUser struct { +type WorkMomentUser struct { UserID string `json:"userID"` UserName string `json:"userName"` }