2026-07-07 23:15:37 +08:00
|
|
|
// 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
|
|
|
|
|
}
|
2026-07-11 01:01:54 +08:00
|
|
|
limits := l.svcCtx.AuthService.DeviceLimits()
|
|
|
|
|
return &types.AccountDeviceListResponse{
|
|
|
|
|
Devices: toAPIAccountDevices(devices),
|
|
|
|
|
Limits: types.AccountDeviceLimits{
|
|
|
|
|
Desktop: limits.Desktop,
|
|
|
|
|
Mobile: limits.Mobile,
|
|
|
|
|
},
|
|
|
|
|
}, nil
|
2026-07-07 23:15:37 +08:00
|
|
|
}
|