app-cloudep-permission-server/pkg/domain/redis.go

44 lines
1018 B
Go

package domain
import "strings"
type RedisKey string
const (
AccessTokenRedisKey RedisKey = "access_token"
RefreshTokenRedisKey RedisKey = "refresh_token"
UIDTokenRedisKey RedisKey = "uid_token"
TicketRedisKey RedisKey = "ticket"
DeviceTokenRedisKey RedisKey = "device_token"
)
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 GetRefreshTokenRedisKey(id string) string {
return RefreshTokenRedisKey.With(id).ToString()
}
func GetUIDTokenRedisKey(uid string) string {
return UIDTokenRedisKey.With(uid).ToString()
}
func GetDeviceTokenRedisKey(device string) string {
return DeviceTokenRedisKey.With(device).ToString()
}
func GetTicketRedisKey(ticket string) string {
return TicketRedisKey.With(ticket).ToString()
}