service/app/mix/controller/accountrelation_op.go

173 lines
4.5 KiB
Go
Raw Permalink Normal View History

2023-12-21 22:17:40 +08:00
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)
2024-05-09 00:02:16 +08:00
followCount, isfollowedCount, ec := service.DefaultService.OpGetAccountRelationCount(ctx, req)
2023-12-21 22:17:40 +08:00
if ec != errcode.ErrCodeAccountRelationSrvOk {
logger.Error("OpGetAccountRelationCount fail, req: %v, ec: %v", util.ToJson(req), ec)
ReplyErrCodeMsg(ctx, ec)
return
}
data := &accountrelationproto.OpCountData{
2024-05-09 00:02:16 +08:00
FollowCount: followCount,
IsFollowedCount: isfollowedCount,
2023-12-21 22:17:40 +08:00
}
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)
}