33 lines
789 B
Go
33 lines
789 B
Go
|
|
package invite
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"apps/backend/internal/svc"
|
||
|
|
"apps/backend/internal/types"
|
||
|
|
|
||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
||
|
|
)
|
||
|
|
|
||
|
|
type GetInviteTreeLogic struct {
|
||
|
|
logx.Logger
|
||
|
|
ctx context.Context
|
||
|
|
svcCtx *svc.ServiceContext
|
||
|
|
}
|
||
|
|
|
||
|
|
func NewGetInviteTreeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetInviteTreeLogic {
|
||
|
|
return &GetInviteTreeLogic{Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx}
|
||
|
|
}
|
||
|
|
|
||
|
|
func (l *GetInviteTreeLogic) GetInviteTree() (resp *types.InviteTreeData, err error) {
|
||
|
|
forest, err := l.svcCtx.Auth.GetInviteTree(l.ctx)
|
||
|
|
if err != nil {
|
||
|
|
return nil, err
|
||
|
|
}
|
||
|
|
list := make([]types.InviteTreeNode, 0, len(forest))
|
||
|
|
for _, n := range forest {
|
||
|
|
list = append(list, types.InviteTreeFromUC(n))
|
||
|
|
}
|
||
|
|
return &types.InviteTreeData{List: list}, nil
|
||
|
|
}
|