business_conf.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. BusinessConfIsOpenChartExpired = "IsOpenChartExpired" // 图表是否鉴权
  24. )
  25. // BusinessConf 商户配置表
  26. type BusinessConf struct {
  27. Id int `orm:"column(id);pk"`
  28. ConfKey string `description:"配置Key"`
  29. ConfVal string `description:"配置值"`
  30. ValType int `description:"1-字符串;2-数值;3-字符串数组;4-富文本;"`
  31. Necessary int `description:"是否必填:0-否;1-是"`
  32. Remark string `description:"备注"`
  33. CreateTime time.Time
  34. }
  35. // GetBusinessConf 获取商家配置
  36. func GetBusinessConf() (list map[string]string, err error) {
  37. list = make(map[string]string)
  38. var items []*BusinessConf
  39. o := orm.NewOrmUsingDB("eta")
  40. sql := `SELECT * FROM business_conf`
  41. _, err = o.Raw(sql).QueryRows(&items)
  42. if err != nil {
  43. return
  44. }
  45. for _, v := range items {
  46. if v.ValType == 4 {
  47. list[v.ConfKey] = html.UnescapeString(v.ConfVal)
  48. continue
  49. }
  50. list[v.ConfKey] = v.ConfVal
  51. }
  52. return
  53. }
  54. type Report2ImgReplace struct {
  55. IsReplace bool `description:"是否替换"`
  56. OssUrlOrigin string `description:"被替换的资源地址"`
  57. OssUrlNew string `description:"新的资源地址"`
  58. ChartUrlOrigin string `description:"被替换的图表地址"`
  59. ChartUrlNew string `description:"新的图表地址"`
  60. }