Refactor code

pull/131/head
wenxu12345 3 years ago
parent 7c3e429f22
commit 2936f886a9

@ -49,8 +49,8 @@ func main() {
{
groupRouterGroup.POST("/create_group", group.CreateGroup) //1
groupRouterGroup.POST("/set_group_info", group.SetGroupInfo) //1
groupRouterGroup.POST("join_group", group.JoinGroup)
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
groupRouterGroup.POST("join_group", group.JoinGroup) //1
groupRouterGroup.POST("/quit_group", group.QuitGroup) //1
groupRouterGroup.POST("/group_application_response", group.ApplicationGroupResponse)
groupRouterGroup.POST("/transfer_group", group.TransferGroupOwner)
groupRouterGroup.POST("/get_group_applicationList", group.GetGroupApplicationList)

@ -258,7 +258,7 @@ func CreateGroup(c *gin.Context) {
c.JSON(http.StatusOK, resp)
}
//my application 我发出去
// 群主或管理员收到
func GetGroupApplicationList(c *gin.Context) {
params := api.GetGroupApplicationListReq{}
if err := c.BindJSON(&params); 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)
client := rpc.NewGroupClient(etcdConn)
reply, err := client.GetGroupApplicationList(context.Background(), req)
if err != nil {
log.NewError(req.OperationID, "GetGroupApplicationList failed ", err.Error(), req.String())
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": err.Error()})
return
}
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, Data: reply.GroupRequestList}
c.JSON(http.StatusOK, resp)
resp := api.GetGroupApplicationListResp{CommResp: api.CommResp{ErrCode: reply.ErrCode, ErrMsg: reply.ErrMsg}, GroupRequestList: reply.GroupRequestList}
if len(resp.GroupRequestList) == 0 {
resp.GroupRequestList = []*open_im_sdk.GroupRequest{}
}
log.NewInfo(req.OperationID, "GetGroupApplicationList api return ", resp)
c.JSON(http.StatusOK, resp)
}
func GetGroupsInfo(c *gin.Context) {

@ -91,11 +91,11 @@ type CreateGroupResp struct {
type GetGroupApplicationListReq struct {
OperationID string `json:"operationID" binding:"required"`
FromUserID string `json:"fromUserID" binding:"required"` //my application
FromUserID string `json:"fromUserID" binding:"required"` //作为管理员或群主收到的 进群申请
}
type GetGroupApplicationListResp struct {
CommResp
Data []*open_im_sdk.GroupRequest `json:"data"`
GroupRequestList []*open_im_sdk.GroupRequest `json:"data"`
}
type GetGroupInfoReq struct {

Loading…
Cancel
Save