business_conf.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package models
  2. import (
  3. "eta_gn/eta_report/global"
  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. )
  23. // BusinessConf 商户配置表
  24. type BusinessConf struct {
  25. Id int `gorm:"primaryKey;autoIncrement;column:id"`
  26. ConfKey string `description:"配置Key"`
  27. ConfVal string `description:"配置值"`
  28. ValType int `description:"1-字符串;2-数值;3-字符串数组;4-富文本;"`
  29. Necessary int `description:"是否必填:0-否;1-是"`
  30. Remark string `description:"备注"`
  31. CreateTime time.Time
  32. }
  33. // GetBusinessConf 获取商家配置
  34. func GetBusinessConf() (list map[string]string, err error) {
  35. list = make(map[string]string)
  36. // TODO 改写为 gorm 操作达梦数据库
  37. var items []*BusinessConf
  38. o := global.DmSQL["eta"]
  39. sql := `SELECT * FROM business_conf`
  40. err = o.Raw(sql).Find(&items).Error
  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. }