Files
2022-01-17 09:57:57 +08:00

75 lines
1.4 KiB
Go

package controller
import (
"SciencesServer/app/basic/config"
model2 "SciencesServer/app/common/model"
config2 "SciencesServer/config"
"fmt"
)
type Config struct{}
type (
// IndustryInfo 所属领域信息
IndustryInfo struct {
ID string `json:"id"`
Name string `json:"name"`
}
)
// Basic 基础配置信息
func (c *Config) Basic() {
}
// Config 配置信息
func (c *Config) Config() map[string]string {
return config2.SystemConfig
}
// Identity 身份信息
func (c *Config) Identity() map[int]string {
return config.TenantUserIdentityData
}
// Transaction 交易信息
func (c *Config) Transaction() map[int]string {
return config.TechnologyTransactionData
}
// Industry 行业信息
func (c *Config) Industry(parentID uint64) []*IndustryInfo {
out := make([]*model2.SysIndustry, 0)
err := model2.ScanFields(model2.NewSysIndustry(), &out, []string{"id", "name"}, &model2.ModelWhereOrder{
Where: model2.NewWhere("parent_id", parentID),
})
list := make([]*IndustryInfo, 0)
if err != nil {
return list
}
for _, v := range out {
list = append(list, &IndustryInfo{
//ID: v.GetEncodeID(),
ID: fmt.Sprintf("%d", v.ID),
Name: v.Name,
})
}
return list
}
// Area 区域信息
func (c *Config) Area(key string) map[string]string {
if key == "" {
key = config2.DefaultChinaAreaCode
}
return config.MemoryForAreaInfo[key]
}
func NewConfig() *Config {
return &Config{}
}