2024-08-06 05:59:24 +00:00
|
|
|
package repository
|
|
|
|
|
|
|
|
import (
|
|
|
|
"ark-permission/internal/entity"
|
|
|
|
"context"
|
2024-08-10 01:52:23 +00:00
|
|
|
"time"
|
2024-08-06 05:59:24 +00:00
|
|
|
)
|
|
|
|
|
2024-08-12 14:19:34 +00:00
|
|
|
// TokenRepository token 的 redis 操作
|
2024-08-06 05:59:24 +00:00
|
|
|
type TokenRepository interface {
|
2024-08-12 14:19:34 +00:00
|
|
|
// Create 建立Token
|
2024-08-06 05:59:24 +00:00
|
|
|
Create(ctx context.Context, token entity.Token) error
|
2024-08-12 14:19:34 +00:00
|
|
|
// CreateOneTimeToken 建立臨時 Token
|
2024-08-10 01:52:23 +00:00
|
|
|
CreateOneTimeToken(ctx context.Context, key string, ticket entity.Ticket, dt time.Duration) error
|
|
|
|
|
2024-08-12 14:19:34 +00:00
|
|
|
GetAccessTokenByByOneTimeToken(ctx context.Context, oneTimeToken string) (entity.Token, error)
|
2024-08-10 01:52:23 +00:00
|
|
|
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)
|
|
|
|
|
2024-08-08 03:02:13 +00:00
|
|
|
Delete(ctx context.Context, token entity.Token) error
|
2024-08-12 14:19:34 +00:00
|
|
|
DeleteOneTimeToken(ctx context.Context, ids []string, tokens []entity.Token) error
|
2024-08-11 12:21:42 +00:00
|
|
|
DeleteAccessTokenByID(ctx context.Context, ids []string) error
|
2024-08-10 01:52:23 +00:00
|
|
|
DeleteAccessTokensByUID(ctx context.Context, uid string) error
|
|
|
|
DeleteAccessTokensByDeviceID(ctx context.Context, deviceID string) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type DeviceToken struct {
|
|
|
|
DeviceID string
|
|
|
|
TokenID string
|
2024-08-06 05:59:24 +00:00
|
|
|
}
|