business_conf.go 853 B

12345678910111213141516171819202122232425262728293031323334
  1. package base_config
  2. import (
  3. "context"
  4. "fmt"
  5. "hongze/hongze_yb/global"
  6. "hongze/hongze_yb/models/tables/business_conf"
  7. "hongze/hongze_yb/utils"
  8. "html"
  9. "time"
  10. )
  11. func GetBusinessConfDisclaimer() (disclaimer string, err error) {
  12. cacheKey := utils.HONGZEYB_ + "business_conf:disclaimer"
  13. disclaimer, _ = global.Redis.Get(context.TODO(), cacheKey).Result()
  14. if disclaimer != "" {
  15. disclaimer = html.UnescapeString(disclaimer)
  16. return
  17. }
  18. obj := new(business_conf.BusinessConf)
  19. item, err := obj.GetItemByConfKey("Disclaimer")
  20. if err != nil {
  21. err = fmt.Errorf("GetBusinessConfDisclaimer err:%v", err)
  22. return
  23. }
  24. if item.Id <= 0 {
  25. err = fmt.Errorf("研报声明未配置")
  26. return
  27. }
  28. disclaimer = item.ConfVal
  29. _ = global.Redis.Set(context.TODO(), cacheKey, disclaimer, 24*time.Hour)
  30. disclaimer = html.UnescapeString(disclaimer)
  31. return
  32. }