From 4b38f0bc6b5adb62ac8f2dd3b95087386a666c20 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Wed, 29 Dec 2021 18:26:49 +0800 Subject: [PATCH 1/2] Refactor code --- internal/rpc/group/group.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index f759bc903..e9d937863 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -94,8 +94,10 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR } //to group member + groupMemberTmp := imdb.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner} + utils.CopyStructFields(&groupMemberTmp, us) groupMember := imdb.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner} - utils.CopyStructFields(&groupMember, us) + groupMember = groupMemberTmp err = im_mysql_model.InsertIntoGroupMember(groupMember) if err != nil { log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember) From 479ce592fae3a50363c115b9e65bb570811dc29e Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Wed, 29 Dec 2021 18:36:56 +0800 Subject: [PATCH 2/2] Refactor code --- internal/rpc/group/group.go | 4 +--- pkg/common/db/mysql_model/im_mysql_model/model_struct.go | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/internal/rpc/group/group.go b/internal/rpc/group/group.go index e9d937863..f759bc903 100644 --- a/internal/rpc/group/group.go +++ b/internal/rpc/group/group.go @@ -94,10 +94,8 @@ func (s *groupServer) CreateGroup(ctx context.Context, req *pbGroup.CreateGroupR } //to group member - groupMemberTmp := imdb.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner} - utils.CopyStructFields(&groupMemberTmp, us) groupMember := imdb.GroupMember{GroupID: groupId, RoleLevel: constant.GroupOwner} - groupMember = groupMemberTmp + utils.CopyStructFields(&groupMember, us) err = im_mysql_model.InsertIntoGroupMember(groupMember) if err != nil { log.NewError(req.OperationID, "InsertIntoGroupMember failed ", err.Error(), groupMember) diff --git a/pkg/common/db/mysql_model/im_mysql_model/model_struct.go b/pkg/common/db/mysql_model/im_mysql_model/model_struct.go index bd35c6314..e53b02222 100644 --- a/pkg/common/db/mysql_model/im_mysql_model/model_struct.go +++ b/pkg/common/db/mysql_model/im_mysql_model/model_struct.go @@ -94,7 +94,7 @@ type GroupMember struct { RoleLevel int32 `gorm:"column:role_level"` JoinTime time.Time `gorm:"column:join_time"` Nickname string `gorm:"column:nickname"` - FaceUrl string `gorm:"user_group_face_url"` + FaceUrl string `gorm:"column:user_group_face_url"` JoinSource int32 `gorm:"column:join_source"` OperatorUserID string `gorm:"column:operator_user_id"` Ex string `gorm:"column:ex"`