package business_conf import ( "hongze/hongze_yb_en_api/global" "html" "time" ) type BusinessConf struct { Id int `gorm:"primaryKey;column:id" json:"id"` ConfKey string `gorm:"column:conf_key" json:"conf_key"` // 配置Key ConfVal string `gorm:"column:conf_val" json:"conf_val"` // 配置值 ValType int `gorm:"column:val_type" json:"val_type"` // 1-字符串;2-数值;3-字符串数组;4-富文本; Necessary int `gorm:"column:Necessary" json:"Necessary"` // 是否必填:0-否;1-是 Remark string `gorm:"column:remark" json:"remark"` // 备注 CreateTime time.Time `gorm:"autoCreateTime;column:create_time" json:"create_time"` //创建时间 } func (c *BusinessConf) TableName() string { return "business_conf" } const ( BusinessConfDisclaimer = "Disclaimer" BusinessConfH5ShareName = "H5ShareName" BusinessConfH5ShareEnName = "H5ShareEnName" BusinessConfH5ReportShareImg = "H5ReportShareImg" BusinessConfWatermarkChart = "WatermarkChart" BusinessConfWatermarkReport = "WatermarkReport" BusinessConfWxAppId = "WxAppId" BusinessConfWxAppSecret = "WxAppSecret" BusinessConfReportViewUrl = "ReportViewUrl" BusinessConfReport2ImgUrl = "Report2ImgUrl" BusinessConfReportLogo = "ReportLogo" // 报告logo BusinessConfReportCenterLogoShow = "ReportCenterLogoShow" // 报告logo BusinessConfReportEnLogoShow = "ReportEnLogoShow" // 报告logo BusinessConfDisclaimerEn = "DisclaimerEn" // 英文免责声明 ) func (c *BusinessConf) GetList(condition string, pars []interface{}) (list []*BusinessConf, err error) { err = global.MYSQL["master"].Model(c).Where(condition, pars).Order("create_time DESC").Scan(&list).Error return } // GetBusinessConf 获取商家配置 func (c *BusinessConf) GetBusinessConf() (list map[string]string, err error) { list = make(map[string]string) var items []*BusinessConf err = global.MYSQL["master"].Model(c).Order("create_time DESC").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 }