mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-05-04 09:09:02 +08:00
Refactor code
This commit is contained in:
parent
7c3e429f22
commit
2936f886a9
@ -49,7 +49,7 @@ func main() {
|
|||||||
{
|
{
|
||||||
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
|
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
|
||||||
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
|
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
|
||||||
groupRouterGroup.POST("join_group", group.JoinGroup)
|
groupRouterGroup.POST("join_group", group.JoinGroup) //1
|
||||||
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
|
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
|
||||||
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse)
|
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse)
|
||||||
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner)
|
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner)
|
||||||
|
@ -258,7 +258,7 @@ func CreateGroup(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, resp)
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//my application 我发出去的
|
// 群主或管理员收到的
|
||||||
func GetGroupApplicationList(c *gin.Context) {
|
func GetGroupApplicationList(c *gin.Context) {
|
||||||
params := api.GetGroupApplicationListReq{}
|
params := api.GetGroupApplicationListReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
@ -279,16 +279,19 @@ func GetGroupApplicationList(c *gin.Context) {
|
|||||||
|
|
||||||
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImGroupName)
|
||||||
client := rpc.NewGroupClient(etcdConn)
|
client := rpc.NewGroupClient(etcdConn)
|
||||||
|
|
||||||
reply, err := client.GetGroupApplicationList(context.Background(), req)
|
reply, err := client.GetGroupApplicationList(context.Background(), req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.NewError(req.OperationID, "GetGroupApplicationList failed ", err.Error(), req.String())
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, Data: reply.GroupRequestList}
|
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, GroupRequestList: reply.GroupRequestList}
|
||||||
c.JSON(http.StatusOK, resp)
|
if len(resp.GroupRequestList) == 0 {
|
||||||
|
resp.GroupRequestList = []*open_im_sdk.GroupRequest{}
|
||||||
|
}
|
||||||
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
|
||||||
|
c.JSON(http.StatusOK, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetGroupsInfo(c *gin.Context) {
|
func GetGroupsInfo(c *gin.Context) {
|
||||||
|
@ -91,11 +91,11 @@ type CreateGroupResp struct {
|
|||||||
|
|
||||||
type GetGroupApplicationListReq struct {
|
type GetGroupApplicationListReq struct {
|
||||||
OperationID string `json:"operationID" binding:"required"`
|
OperationID string `json:"operationID" binding:"required"`
|
||||||
FromUserID string `json:"fromUserID" binding:"required"` //my application
|
FromUserID string `json:"fromUserID" binding:"required"` //作为管理员或群主收到的 进群申请
|
||||||
}
|
}
|
||||||
type GetGroupApplicationListResp struct {
|
type GetGroupApplicationListResp struct {
|
||||||
CommResp
|
CommResp
|
||||||
Data []*open_im_sdk.GroupRequest `json:"data"`
|
GroupRequestList []*open_im_sdk.GroupRequest `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetGroupInfoReq struct {
|
type GetGroupInfoReq struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user