package controller import ( "service/api/consts" "service/api/errcode" accountrelationproto "service/api/proto/accountrelation/proto" "service/app/mix/service" "service/bizcommon/util" "service/library/logger" "github.com/gin-gonic/gin" ) func OpGetFollowAccountRelationList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountrelationproto.OpListReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.OpGetFollowAccountRelationList(ctx, req) if ec != errcode.ErrCodeAccountRelationSrvOk { logger.Error("OpGetFollowAccountRelationList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &accountrelationproto.OpListData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) } func OpGetIsFollowedAccountRelationList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountrelationproto.OpListReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.OpGetIsFollowedAccountRelationList(ctx, req) if ec != errcode.ErrCodeAccountRelationSrvOk { logger.Error("OpGetIsFollowedAccountRelationList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &accountrelationproto.OpListData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) } func OpGetFriendAccountRelationList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountrelationproto.OpListReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.OpGetFriendAccountRelationList(ctx, req) if ec != errcode.ErrCodeAccountRelationSrvOk { logger.Error("OpGetFriendAccountRelationList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &accountrelationproto.OpListData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) } func OpGetIgnoreAccountRelationList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountrelationproto.OpListReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.OpGetIgnoreAccountRelationList(ctx, req) if ec != errcode.ErrCodeAccountRelationSrvOk { logger.Error("OpGetIgnoreAccountRelationList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &accountrelationproto.OpListData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) } func OpGetAbleToAccessWeixinOfAccountRelationList(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountrelationproto.OpListReq) //设置默认页长 if req.Limit == 0 { req.Limit = consts.DefaultPageSize } list, ec := service.DefaultService.OpGetAbleToAccessWeixinOfAccountRelationList(ctx, req) if ec != errcode.ErrCodeAccountRelationSrvOk { logger.Error("OpGetAbleToAccessWeixinOfAccountRelationList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &accountrelationproto.OpListData{ List: list, Offset: req.Offset + len(list), } if len(list) >= req.Limit { data.More = 1 } ReplyOk(ctx, data) } func OpGetAccountRelationCount(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountrelationproto.OpCountReq) countMap, ec := service.DefaultService.OpGetAccountRelationCount(ctx, req) if ec != errcode.ErrCodeAccountRelationSrvOk { logger.Error("OpGetAccountRelationCount fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &accountrelationproto.OpCountData{ FollowCount: countMap[consts.Follow], IsFollowedCount: countMap[consts.IsFollowed], FriendCount: countMap[consts.Friend], } ReplyOk(ctx, data) } func OpGetAccountRelationBySentence(ctx *gin.Context) { req := ctx.MustGet("client_req").(*accountrelationproto.OpListBySentenceReq) _, ec := service.DefaultService.OpGetAccountRelationBySentence(ctx, req) isAccountRelationExisted := true if ec == errcode.ErrCodeAccountRelationNotExist { isAccountRelationExisted = false } else if ec != errcode.ErrCodeAccountRelationSrvOk { logger.Error("OpGetFriendAccountRelationList fail, req: %v, ec: %v", util.ToJson(req), ec) ReplyErrCodeMsg(ctx, ec) return } data := &accountrelationproto.OpListBySentenceData{ IsAccountRelationExisted: isAccountRelationExisted, } ReplyOk(ctx, data) }