guard/internal/domain/repository/token.go

34 lines
1.2 KiB
Go
Raw Normal View History

package repository
import (
"ark-permission/internal/entity"
"context"
"time"
)
// TokenRepository token 的 redis 操作
type TokenRepository interface {
// Create 建立Token
Create(ctx context.Context, token entity.Token) error
// CreateOneTimeToken 建立臨時 Token
CreateOneTimeToken(ctx context.Context, key string, ticket entity.Ticket, dt time.Duration) error
GetAccessTokenByByOneTimeToken(ctx context.Context, oneTimeToken string) (entity.Token, error)
GetAccessTokenByID(ctx context.Context, id string) (entity.Token, error)
GetAccessTokensByUID(ctx context.Context, uid string) ([]entity.Token, error)
GetAccessTokenCountByUID(uid string) (int, error)
GetAccessTokensByDeviceID(ctx context.Context, deviceID string) ([]entity.Token, error)
GetAccessTokenCountByDeviceID(deviceID string) (int, error)
Delete(ctx context.Context, token entity.Token) error
DeleteOneTimeToken(ctx context.Context, ids []string, tokens []entity.Token) error
DeleteAccessTokenByID(ctx context.Context, ids []string) error
DeleteAccessTokensByUID(ctx context.Context, uid string) error
DeleteAccessTokensByDeviceID(ctx context.Context, deviceID string) error
}
type DeviceToken struct {
DeviceID string
TokenID string
}