business_conf.go 1.1 KB

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