business_conf.go 1007 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "html"
  5. "time"
  6. )
  7. const (
  8. BusinessConfDisclaimer = "Disclaimer"
  9. )
  10. // BusinessConf 商户配置表
  11. type BusinessConf struct {
  12. Id int `orm:"column(id);pk"`
  13. ConfKey string `description:"配置Key"`
  14. ConfVal string `description:"配置值"`
  15. ValType int `description:"1-字符串;2-数值;3-字符串数组;4-富文本;"`
  16. Necessary int `description:"是否必填:0-否;1-是"`
  17. Remark string `description:"备注"`
  18. CreateTime time.Time
  19. }
  20. // GetBusinessConf 获取商家配置
  21. func GetBusinessConf() (list map[string]string, err error) {
  22. list = make(map[string]string)
  23. var items []*BusinessConf
  24. o := orm.NewOrmUsingDB("eta")
  25. sql := `SELECT * FROM business_conf`
  26. _, err = o.Raw(sql).QueryRows(&items)
  27. if err != nil {
  28. return
  29. }
  30. for _, v := range items {
  31. if v.ValType == 4 {
  32. list[v.ConfKey] = html.UnescapeString(v.ConfVal)
  33. continue
  34. }
  35. list[v.ConfKey] = v.ConfVal
  36. }
  37. return
  38. }