package tokenservicelogic import ( ers "code.30cm.net/digimon/library-go/errors" "context" "app-cloudep-permission-server/gen_result/pb/permission" "app-cloudep-permission-server/internal/svc" "github.com/zeromicro/go-zero/core/logx" ) type CancelTokenByDeviceIdLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger } func NewCancelTokenByDeviceIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CancelTokenByDeviceIdLogic { return &CancelTokenByDeviceIdLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } // CancelTokenByDeviceId 取消 Token, 從 Device 視角出發,可以選,登出這個Device 下所有 token ,登出這個Device 下指定token func (l *CancelTokenByDeviceIdLogic) CancelTokenByDeviceId(in *permission.DoTokenByDeviceIDReq) (*permission.OKResp, error) { if err := l.svcCtx.Validate.ValidateAll(&getUserTokensByDeviceIdReq{ DeviceID: in.GetDeviceId(), }); err != nil { return nil, ers.InvalidFormat(err.Error()) } err := l.svcCtx.TokenRedisRepo.DeleteAccessTokensByDeviceID(l.ctx, in.GetDeviceId()) if err != nil { logx.WithCallerSkip(1).WithFields( logx.Field("func", "TokenRedisRepo.DeleteAccessTokensByDeviceID"), logx.Field("DeviceID", in.GetDeviceId()), ).Error(err.Error()) return nil, err } return &permission.OKResp{}, nil }