business_conf.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. BusinessConfWatermarkChart = "WatermarkChart"
  13. BusinessConfWatermarkReport = "WatermarkReport"
  14. BusinessConfWxAppId = "WxAppId"
  15. BusinessConfWxAppSecret = "WxAppSecret"
  16. BusinessConfReportViewUrl = "ReportViewUrl"
  17. BusinessConfReport2ImgUrl = "Report2ImgUrl"
  18. BusinessConfReportLogo = "ReportLogo" // 报告logo
  19. BusinessConfReportCenterLogoShow = "ReportCenterLogoShow" // 报告logo
  20. BusinessConfReportEnLogoShow = "ReportEnLogoShow" // 报告logo
  21. BusinessConfDisclaimerEn = "DisclaimerEn" // 英文免责声明
  22. BusinessConfReport2ImgReplace = "Report2ImgReplace" // 报告转图替换地址
  23. )
  24. // BusinessConf 商户配置表
  25. type BusinessConf struct {
  26. Id int `orm:"column(id);pk"`
  27. ConfKey string `description:"配置Key"`
  28. ConfVal string `description:"配置值"`
  29. ValType int `description:"1-字符串;2-数值;3-字符串数组;4-富文本;"`
  30. Necessary int `description:"是否必填:0-否;1-是"`
  31. Remark string `description:"备注"`
  32. CreateTime time.Time
  33. }
  34. // GetBusinessConf 获取商家配置
  35. func GetBusinessConf() (list map[string]string, err error) {
  36. list = make(map[string]string)
  37. var items []*BusinessConf
  38. o := orm.NewOrmUsingDB("eta")
  39. sql := `SELECT * FROM business_conf`
  40. _, err = o.Raw(sql).QueryRows(&items)
  41. if err != nil {
  42. return
  43. }
  44. for _, v := range items {
  45. if v.ValType == 4 {
  46. list[v.ConfKey] = html.UnescapeString(v.ConfVal)
  47. continue
  48. }
  49. list[v.ConfKey] = v.ConfVal
  50. }
  51. return
  52. }
  53. type Report2ImgReplace struct {
  54. IsReplace bool `description:"是否替换"`
  55. OssUrlOrigin string `description:"被替换的资源地址"`
  56. OssUrlNew string `description:"新的资源地址"`
  57. ChartUrlOrigin string `description:"被替换的图表地址"`
  58. ChartUrlNew string `description:"新的图表地址"`
  59. }