From ca92bc899bba63844c1c0ff1470e55e39aabcd14 Mon Sep 17 00:00:00 2001 From: wenxu12345 <44203734@qq.com> Date: Wed, 29 Dec 2021 21:26:56 +0800 Subject: [PATCH] Refactor code --- cmd/open_im_api/main.go | 2 +- internal/api/group/group.go | 2 +- pkg/base_info/group_api_struct.go | 3 ++- .../db/mysql_model/im_mysql_model/model_struct.go | 14 ++++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/open_im_api/main.go b/cmd/open_im_api/main.go index 7134127a1..259978c56 100644 --- a/cmd/open_im_api/main.go +++ b/cmd/open_im_api/main.go @@ -47,7 +47,7 @@ func main() { //group related routing group groupRouterGroup := r.Group("/group") { - groupRouterGroup.POST("/create_group", group.CreateGroup) + groupRouterGroup.POST("/create_group", group.CreateGroup) //1 groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) groupRouterGroup.POST("join_group", group.JoinGroup) groupRouterGroup.POST("/quit_group", group.QuitGroup) diff --git a/internal/api/group/group.go b/internal/api/group/group.go index 688686112..0c90d00c5 100644 --- a/internal/api/group/group.go +++ b/internal/api/group/group.go @@ -443,7 +443,7 @@ func SetGroupInfo(c *gin.Context) { c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "call rpc server failed"}) return } - resp := api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg} + resp := api.SetGroupInfoResp{CommResp: api.CommResp{ErrCode: RpcResp.CommonResp.ErrCode, ErrMsg: RpcResp.CommonResp.ErrMsg}} c.JSON(http.StatusOK, resp) log.NewInfo(req.OperationID, "SetGroupInfo api return ", resp) } diff --git a/pkg/base_info/group_api_struct.go b/pkg/base_info/group_api_struct.go index bcc657e43..b232f389c 100644 --- a/pkg/base_info/group_api_struct.go +++ b/pkg/base_info/group_api_struct.go @@ -1,6 +1,7 @@ package base_info import ( + imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model" open_im_sdk "Open_IM/pkg/proto/sdk_ws" ) @@ -135,7 +136,7 @@ type QuitGroupResp struct { } type SetGroupInfoReq struct { - open_im_sdk.GroupInfo + imdb.Group OperationID string `json:"operationID" binding:"required"` } type SetGroupInfoResp struct { 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 e53b02222..8c228cae0 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 @@ -63,17 +63,19 @@ type FriendRequest struct { //} // open_im_sdk.GroupInfo (OwnerUserID , MemberCount )> imdb.Group type Group struct { - GroupID string `gorm:"column:group_id;primaryKey;"` - GroupName string `gorm:"column:name"` - Notification string `gorm:"column:notification"` - Introduction string `gorm:"column:introduction"` - FaceUrl string `gorm:"column:face_url"` + //`json:"operationID" binding:"required"` + //`protobuf:"bytes,1,opt,name=GroupID" json:"GroupID,omitempty"` `json:"operationID" binding:"required"` + GroupID string `gorm:"column:group_id;primaryKey;" json:"groupID" binding:"required"` + GroupName string `gorm:"column:name" json:"groupName"` + Notification string `gorm:"column:notification" json:"notification"` + Introduction string `gorm:"column:introduction" json:"introduction"` + FaceUrl string `gorm:"column:face_url" json:"faceUrl"` CreateTime time.Time `gorm:"column:create_time"` Status int32 `gorm:"column:status"` CreatorUserID string `gorm:"column:creator_user_id"` GroupType int32 `gorm:"column:group_type"` - Ex string `gorm:"column:ex"` + Ex string `gorm:"column:ex" json:"ex"` } //message GroupMemberFullInfo {