business_conf.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "html"
  5. "time"
  6. )
  7. const (
  8. BusinessConfDisclaimer = "Disclaimer"
  9. BusinessConfH5ShareName = "H5ShareName"
  10. BusinessConfH5ShareEnName = "H5ShareEnName"
  11. BusinessConfH5ReportShareImg = "H5ReportShareImg"
  12. BusinessConfWatermarkChart = "WatermarkChart"
  13. BusinessConfWatermarkReport = "WatermarkReport"
  14. BusinessConfWxAppId = "WxAppId"
  15. BusinessConfWxAppSecret = "WxAppSecret"
  16. BusinessConfReportViewUrl = "ReportViewUrl"
  17. BusinessConfReport2ImgUrl = "Report2ImgUrl"
  18. BusinessConfReportLogo = "ReportLogo" // 报告logo
  19. BusinessConfReportCenterLogoShow = "ReportCenterLogoShow" // 报告logo
  20. BusinessConfReportEnLogoShow = "ReportEnLogoShow" // 报告logo
  21. BusinessConfDisclaimerEn = "DisclaimerEn" // 英文免责声明
  22. )
  23. // BusinessConf 商户配置表
  24. type BusinessConf struct {
  25. Id int `orm:"column(id);pk"`
  26. ConfKey string `description:"配置Key"`
  27. ConfVal string `description:"配置值"`
  28. ValType int `description:"1-字符串;2-数值;3-字符串数组;4-富文本;"`
  29. Necessary int `description:"是否必填:0-否;1-是"`
  30. Remark string `description:"备注"`
  31. CreateTime time.Time
  32. }
  33. // GetBusinessConf 获取商家配置
  34. func GetBusinessConf() (list map[string]string, err error) {
  35. list = make(map[string]string)
  36. var items []*BusinessConf
  37. o := orm.NewOrmUsingDB("eta")
  38. sql := `SELECT * FROM business_conf`
  39. _, err = o.Raw(sql).QueryRows(&items)
  40. if err != nil {
  41. return
  42. }
  43. for _, v := range items {
  44. if v.ValType == 4 {
  45. list[v.ConfKey] = html.UnescapeString(v.ConfVal)
  46. continue
  47. }
  48. list[v.ConfKey] = v.ConfVal
  49. }
  50. return
  51. }