feat:完善入驻信息管理
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
"SciencesServer/config"
|
||||
"SciencesServer/serve/orm"
|
||||
"SciencesServer/utils"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type synchronized struct {
|
||||
@ -74,6 +75,43 @@ func initModel() {
|
||||
}
|
||||
return out
|
||||
}},
|
||||
&synchronized{iModel: model.NewSysIndustry(), iValues: func() interface{} {
|
||||
file := "./file/sys_industry.json"
|
||||
src := make([]*config2.MemoryForIndustry, 0)
|
||||
utils.LoadConfig(file, &src)
|
||||
out := make([]*model.SysIndustry, 0)
|
||||
|
||||
var id uint64 = 1
|
||||
|
||||
for _, v := range src {
|
||||
var parentID uint64 = 0
|
||||
|
||||
data := &model.SysIndustry{
|
||||
Model: model.Model{
|
||||
ID: id,
|
||||
},
|
||||
ParentID: parentID,
|
||||
Name: v.Name,
|
||||
}
|
||||
out = append(out, data)
|
||||
|
||||
if v.Children != nil && len(v.Children) > 0 {
|
||||
parentID = id
|
||||
for _, val := range v.Children {
|
||||
id++
|
||||
data = &model.SysIndustry{
|
||||
Model: model.Model{
|
||||
ID: id,
|
||||
},
|
||||
ParentID: parentID,
|
||||
Name: val.Name,
|
||||
}
|
||||
out = append(out, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}},
|
||||
// 日志管理
|
||||
&synchronized{iModel: model.NewSysLog()}, &synchronized{iModel: model.NewSysUserLoginLog()},
|
||||
// 用户管理
|
||||
@ -114,6 +152,18 @@ func initCacheMode() {
|
||||
}
|
||||
}},
|
||||
)
|
||||
function(
|
||||
&caches{iModel: model.NewSysIndustry(), iValues: func() interface{} {
|
||||
out := make([]*model.SysIndustry, 0)
|
||||
_ = model.ScanFields(model.NewSysIndustry(), &out, []string{"id", "name"})
|
||||
return out
|
||||
}, toCache: func(values interface{}) {
|
||||
out := values.([]*model.SysIndustry)
|
||||
for _, v := range out {
|
||||
config2.MemoryForIndustryInfo[fmt.Sprintf("%d", v.ID)] = v.Name
|
||||
}
|
||||
}},
|
||||
)
|
||||
}
|
||||
|
||||
func Init() {
|
||||
|
Reference in New Issue
Block a user