package models
import (
"html"
"time"
"github.com/beego/beego/v2/client/orm"
)
const ConfAreaCodeListKey = "AreaCodeList" // 手机号区号列表
type MiniConfig struct {
ConfigID int `description:"配置id"`
ConfigCode string `description:"配置编码"` // 配置编码
ConfigValue string `description:"配置值"` // 配置值
ValType int `description:"配置类型"` // 配置类型
Remark string `description:"备注信息"` // 备注信息
CreateTime time.Time `description:"创建时间"` // 创建时间
}
func GetConfigDetailByCode(configCode string) (config_value string, err error) {
o := orm.NewOrm()
sql := ` SELECT config_value FROM mini_config WHERE config_code=? `
err = o.Raw(sql, configCode).QueryRow(&config_value)
return
}
// GetMiniConf 获取小程序配置
func GetMiniConf() (list map[string]string, err error) {
list = make(map[string]string)
var items []*MiniConfig
o := orm.NewOrm()
sql := `SELECT * FROM mini_config `
_, err = o.Raw(sql).QueryRows(&items)
if err != nil {
return
}
for _, v := range items {
if v.ValType == 4 {
list[v.ConfigCode] = html.UnescapeString(v.ConfigValue)
continue
}
list[v.ConfigCode] = v.ConfigValue
}
return
}
// GetMiniConf 获取eta的服务的配置
func GetEtaConf() (list map[string]string, err error) {
list = make(map[string]string)
var items []*BusinessConf
o := orm.NewOrmUsingDB("eta")
sql := `SELECT * FROM business_conf`
_, err = o.Raw(sql).QueryRows(&items)
if err != nil {
return
}
for _, v := range items {
if v.ValType == 4 {
list[v.ConfKey] = html.UnescapeString(v.ConfVal)
continue
}
list[v.ConfKey] = v.ConfVal
}
return
}