Files
moteva/server/internal/logic/list_account_devices_logic.go
T

44 lines
1.0 KiB
Go
Raw Normal View History

// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1
package logic
import (
"context"
"img_infinite_canvas/internal/domain/design"
"img_infinite_canvas/internal/svc"
"img_infinite_canvas/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type ListAccountDevicesLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewListAccountDevicesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListAccountDevicesLogic {
return &ListAccountDevicesLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ListAccountDevicesLogic) ListAccountDevices() (resp *types.AccountDeviceListResponse, err error) {
devices, err := l.svcCtx.AuthService.ListDevices(l.ctx, design.UserIDFromContext(l.ctx))
if err != nil {
return nil, err
}
limits := l.svcCtx.AuthService.DeviceLimits()
return &types.AccountDeviceListResponse{
Devices: toAPIAccountDevices(devices),
Limits: types.AccountDeviceLimits{
Desktop: limits.Desktop,
Mobile: limits.Mobile,
},
}, nil
}