2024-08-06 05:59:24 +00:00
|
|
|
package domain
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
|
|
const (
|
|
|
|
TicketKeyPrefix = "tic/"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
ClientDataKey = "permission:clients"
|
|
|
|
)
|
|
|
|
|
|
|
|
type RedisKey string
|
|
|
|
|
|
|
|
const (
|
|
|
|
AccessTokenRedisKey RedisKey = "access_token"
|
|
|
|
RefreshTokenRedisKey RedisKey = "refresh_token"
|
|
|
|
DeviceTokenRedisKey RedisKey = "device_token"
|
|
|
|
UIDTokenRedisKey RedisKey = "uid_token"
|
|
|
|
TicketRedisKey RedisKey = "ticket"
|
2024-08-11 12:21:42 +00:00
|
|
|
DeviceUIDRedisKey RedisKey = "device_uid"
|
2024-08-06 05:59:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (key RedisKey) ToString() string {
|
|
|
|
return "permission:" + string(key)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (key RedisKey) With(s ...string) RedisKey {
|
|
|
|
parts := append([]string{string(key)}, s...)
|
|
|
|
|
|
|
|
return RedisKey(strings.Join(parts, ":"))
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetAccessTokenRedisKey(id string) string {
|
|
|
|
return AccessTokenRedisKey.With(id).ToString()
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetUIDTokenRedisKey(uid string) string {
|
|
|
|
return UIDTokenRedisKey.With(uid).ToString()
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetTicketRedisKey(ticket string) string {
|
|
|
|
return TicketRedisKey.With(ticket).ToString()
|
|
|
|
}
|