feat:完善入驻信息管理

This commit is contained in:
henry
2021-12-07 16:10:12 +08:00
parent 3989befe92
commit 95e8fdb9bb
30 changed files with 397 additions and 89 deletions

View File

@ -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() {