package models import ( "eta_gn/eta_chart_lib/global" "eta_gn/eta_chart_lib/utils" "fmt" "html" "time" ) const ( BusinessConfCompanyName = "CompanyName" BusinessConfCompanyWatermark = "CompanyWatermark" BusinessConfWatermarkChart = "WatermarkChart" ) var FromSceneMap = map[int]string{ 1: "SmartReportSheetSize", 2: "ReportSheetSize", 3: "EnReportSheetSize", 4: "CnPptSheetSize", 5: "EnPptSheetSize", } type BusinessConf struct { Id int `gorm:"column:id;primaryKey" description:"配置ID" orm:"column(id);pk"` ConfKey string `gorm:"column:conf_key" description:"配置Key"` ConfVal string `gorm:"column:conf_val" description:"配置值"` ValType int `gorm:"column:val_type" description:"1-字符串;2-数值;3-字符串数组;4-富文本;"` Necessary int `gorm:"column:necessary" description:"是否必填:0-否;1-是"` Remark string `gorm:"column:remark" description:"备注"` CreateTime time.Time `gorm:"column:create_time" description:"创建时间"` } func GetBusinessConf() (list map[string]string, err error) { list = make(map[string]string) var items []*BusinessConf o := global.DEFAULT_DmSQL sql := `SELECT * FROM business_conf` err = o.Raw(sql).Scan(&items).Error 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 } func GetBusinessConfByKey(key string) (item *BusinessConf, err error) { o := global.DEFAULT_DmSQL sql := fmt.Sprintf(`SELECT * FROM business_conf WHERE conf_key = ? `) err = o.Raw(sql, key).First(&item).Error return } func InitUseMongoConf() { useMongo, e := GetBusinessConfByKey("UseMongo") if e != nil { return } if useMongo.ConfVal == `true` { utils.UseMongo = true } }