You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
package bdb
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"server/common"
|
|
|
|
|
"server/config"
|
|
|
|
|
"server/db"
|
|
|
|
|
"server/modules/backend/values"
|
|
|
|
|
|
|
|
|
|
"github.com/liangdas/mqant/log"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func GetPowerByRole(role int) map[int][]int {
|
|
|
|
|
one := &values.Role{Role: role}
|
|
|
|
|
BackDB.Get(one)
|
|
|
|
|
ret := map[int][]int{}
|
|
|
|
|
if len(one.Power) > 0 {
|
|
|
|
|
err := json.Unmarshal([]byte(one.Power), &ret)
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Error("err:%v", err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func InitAdminToken() {
|
|
|
|
|
if config.GetConfig().Backend.AdminToken == "" {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
one := new(values.User)
|
|
|
|
|
key := common.GetBackendTokenKey(config.GetConfig().Backend.AdminToken)
|
|
|
|
|
if err := db.Redis().GetJsonData(key, one); err != nil || one.Account == "" {
|
|
|
|
|
one.Account = "admin"
|
|
|
|
|
one.Name = "admin"
|
|
|
|
|
one.Role = values.UserRoleAdmin
|
|
|
|
|
db.Redis().SetJsonData(key, one)
|
|
|
|
|
}
|
|
|
|
|
}
|