business_conf.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. BusinessConfWxAppId = "WxAppId"
  13. BusinessConfWxAppSecret = "WxAppSecret"
  14. BusinessConfReportViewUrl = "ReportViewUrl"
  15. )
  16. // BusinessConf 商户配置表
  17. type BusinessConf struct {
  18. Id int `orm:"column(id);pk"`
  19. ConfKey string `description:"配置Key"`
  20. ConfVal string `description:"配置值"`
  21. ValType int `description:"1-字符串;2-数值;3-字符串数组;4-富文本;"`
  22. Necessary int `description:"是否必填:0-否;1-是"`
  23. Remark string `description:"备注"`
  24. CreateTime time.Time
  25. }
  26. // GetBusinessConf 获取商家配置
  27. func GetBusinessConf() (list map[string]string, err error) {
  28. list = make(map[string]string)
  29. var items []*BusinessConf
  30. o := orm.NewOrmUsingDB("eta")
  31. sql := `SELECT * FROM business_conf`
  32. _, err = o.Raw(sql).QueryRows(&items)
  33. if err != nil {
  34. return
  35. }
  36. for _, v := range items {
  37. if v.ValType == 4 {
  38. list[v.ConfKey] = html.UnescapeString(v.ConfVal)
  39. continue
  40. }
  41. list[v.ConfKey] = v.ConfVal
  42. }
  43. return
  44. }