business_conf.go 1.2 KB

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