business_conf.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package business_conf
  2. import (
  3. "hongze/hongze_yb_en_api/global"
  4. "html"
  5. "time"
  6. )
  7. type BusinessConf struct {
  8. Id int `gorm:"primaryKey;column:id" json:"id"`
  9. ConfKey string `gorm:"column:conf_key" json:"conf_key"` // 配置Key
  10. ConfVal string `gorm:"column:conf_val" json:"conf_val"` // 配置值
  11. ValType int `gorm:"column:val_type" json:"val_type"` // 1-字符串;2-数值;3-字符串数组;4-富文本;
  12. Necessary int `gorm:"column:Necessary" json:"Necessary"` // 是否必填:0-否;1-是
  13. Remark string `gorm:"column:remark" json:"remark"` // 备注
  14. CreateTime time.Time `gorm:"autoCreateTime;column:create_time" json:"create_time"` //创建时间
  15. }
  16. func (c *BusinessConf) TableName() string {
  17. return "business_conf"
  18. }
  19. const (
  20. BusinessConfDisclaimer = "Disclaimer"
  21. BusinessConfH5ShareName = "H5ShareName"
  22. BusinessConfH5ShareEnName = "H5ShareEnName"
  23. BusinessConfH5ReportShareImg = "H5ReportShareImg"
  24. BusinessConfWatermarkChart = "WatermarkChart"
  25. BusinessConfWatermarkReport = "WatermarkReport"
  26. BusinessConfWxAppId = "WxAppId"
  27. BusinessConfWxAppSecret = "WxAppSecret"
  28. BusinessConfReportViewUrl = "ReportViewUrl"
  29. BusinessConfReport2ImgUrl = "Report2ImgUrl"
  30. BusinessConfReportLogo = "ReportLogo" // 报告logo
  31. BusinessConfReportCenterLogoShow = "ReportCenterLogoShow" // 报告logo
  32. BusinessConfReportEnLogoShow = "ReportEnLogoShow" // 报告logo
  33. BusinessConfDisclaimerEn = "DisclaimerEn" // 英文免责声明
  34. )
  35. func (c *BusinessConf) GetList(condition string, pars []interface{}) (list []*BusinessConf, err error) {
  36. err = global.MYSQL["master"].Model(c).Where(condition, pars).Order("create_time DESC").Scan(&list).Error
  37. return
  38. }
  39. // GetBusinessConf 获取商家配置
  40. func (c *BusinessConf) GetBusinessConf() (list map[string]string, err error) {
  41. list = make(map[string]string)
  42. var items []*BusinessConf
  43. err = global.MYSQL["master"].Model(c).Order("create_time DESC").Scan(&items).Error
  44. if err != nil {
  45. return
  46. }
  47. for _, v := range items {
  48. if v.ValType == 4 {
  49. list[v.ConfKey] = html.UnescapeString(v.ConfVal)
  50. continue
  51. }
  52. list[v.ConfKey] = v.ConfVal
  53. }
  54. return
  55. }