business_conf.go 1.2 KB

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