mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Refactor code
This commit is contained in:
parent
3ca92c7a03
commit
6c137d9098
@ -42,7 +42,7 @@ func main() {
|
||||
friendRouterGroup.POST("/add_friend_response", friend.AddFriendResponse) //1
|
||||
friendRouterGroup.POST("/set_friend_remark", friend.SetFriendRemark) //1
|
||||
friendRouterGroup.POST("/is_friend", friend.IsFriend) //1
|
||||
friendRouterGroup.POST("/import_friend", friend.ImportFriend)
|
||||
friendRouterGroup.POST("/import_friend", friend.ImportFriend) //1
|
||||
}
|
||||
//group related routing group
|
||||
groupRouterGroup := r.Group("/group")
|
||||
|
@ -227,7 +227,10 @@ func CreateGroup(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
req := &rpc.CreateGroupReq{}
|
||||
utils.CopyStructFields(req, params)
|
||||
utils.CopyStructFields(req, ¶ms)
|
||||
for _, v := range params.MemberList {
|
||||
req.InitMemberList = append(req.InitMemberList, &rpc.GroupAddMemberInfo{UserID: v.UserID, RoleLevel: v.RoleLevel})
|
||||
}
|
||||
var ok bool
|
||||
ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
|
||||
if !ok {
|
||||
@ -246,13 +249,12 @@ func CreateGroup(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
resp := api.CreateGroupResp{CommResp: api.CommResp{ErrCode: RpcResp.ErrCode, ErrMsg: RpcResp.ErrMsg}}
|
||||
if RpcResp.ErrCode == 0 {
|
||||
resp := gin.H{"errCode": RpcResp.ErrCode, "errMsg": RpcResp.ErrMsg, "data": gin.H{"groupInfo": RpcResp.GroupInfo}}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
} else {
|
||||
c.JSON(http.StatusOK, gin.H{"errCode": RpcResp.ErrCode, "errMsg": RpcResp.ErrMsg})
|
||||
utils.CopyStructFields(&resp.GroupInfo, &RpcResp.GroupInfo)
|
||||
}
|
||||
log.NewInfo(req.OperationID, "InviteUserToGroup api return ", RpcResp)
|
||||
c.JSON(http.StatusOK, resp)
|
||||
}
|
||||
|
||||
//my application 我发出去的
|
||||
|
@ -1,7 +1,6 @@
|
||||
package base_info
|
||||
|
||||
import (
|
||||
pb "Open_IM/pkg/proto/group"
|
||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||
)
|
||||
|
||||
@ -77,7 +76,7 @@ type GetGroupAllMemberResp struct {
|
||||
}
|
||||
|
||||
type CreateGroupReq struct {
|
||||
MemberList []*pb.GroupAddMemberInfo `json:"memberList"`
|
||||
MemberList []*GroupAddMemberInfo `json:"memberList" binding:"required"`
|
||||
GroupName string `json:"groupName"`
|
||||
Introduction string `json:"introduction"`
|
||||
Notification string `json:"notification"`
|
||||
@ -88,7 +87,7 @@ type CreateGroupReq struct {
|
||||
}
|
||||
type CreateGroupResp struct {
|
||||
CommResp
|
||||
Data open_im_sdk.GroupInfo `json:"data"`
|
||||
GroupInfo open_im_sdk.GroupInfo `json:"data"`
|
||||
}
|
||||
|
||||
type GetGroupApplicationListReq struct {
|
||||
|
@ -16,6 +16,11 @@ type UserInfo struct {
|
||||
Ex string `json:"ex" binding:"omitempty,max=1024"`
|
||||
}
|
||||
|
||||
type GroupAddMemberInfo struct {
|
||||
UserID string `json:"userID" binding:"required"`
|
||||
RoleLevel int32 `json:"roleLevel" binding:"required"`
|
||||
}
|
||||
|
||||
func SetErrCodeMsg(c *gin.Context, status int) *CommResp {
|
||||
resp := CommResp{ErrCode: int32(status), ErrMsg: http.StatusText(status)}
|
||||
c.JSON(status, resp)
|
||||
|
Loading…
x
Reference in New Issue
Block a user