39 lines
765 B
Go
39 lines
765 B
Go
![]() |
package controller
|
||
|
|
||
|
import (
|
||
|
"SciencesServer/app/service"
|
||
|
"SciencesServer/config"
|
||
|
"SciencesServer/serve/cache"
|
||
|
"SciencesServer/utils"
|
||
|
)
|
||
|
|
||
|
// Platform
|
||
|
type Platform struct{ *service.Session }
|
||
|
|
||
|
func (c *Platform) Format() string {
|
||
|
return c.TenantKey
|
||
|
}
|
||
|
|
||
|
// ReturnPages 分页数据
|
||
|
type ReturnPages struct {
|
||
|
Page int `json:"page"`
|
||
|
Data interface{} `json:"data"`
|
||
|
TotalCount int64 `json:"total_count"`
|
||
|
}
|
||
|
|
||
|
type Key struct{}
|
||
|
|
||
|
// Generate 生成秘钥
|
||
|
func (*Key) Generate(len int) string {
|
||
|
key := utils.GetRandomString(len)
|
||
|
for {
|
||
|
isExist, _ := cache.Cache.SIsMember(config.RedisKeyForTenantKeys, key)
|
||
|
|
||
|
if !isExist {
|
||
|
_ = cache.Cache.SAdd(config.RedisKeyForTenantKeys, key)
|
||
|
return key
|
||
|
}
|
||
|
key = utils.GetRandomString(len)
|
||
|
}
|
||
|
}
|