sms_config.go 612 B

1234567891011121314151617181920212223242526272829
  1. package models
  2. import (
  3. "encoding/json"
  4. "github.com/beego/beego/v2/client/orm"
  5. "hongze/hongze_robot/utils"
  6. "time"
  7. )
  8. type SmsConfig struct {
  9. ConfigKey string
  10. ConfigValue string
  11. }
  12. func GetSmsConfigByConfigKey(configKey string) (item *SmsConfig, err error) {
  13. o := orm.NewOrm()
  14. sql := `SELECT *
  15. FROM sms_config AS a
  16. WHERE config_key=? `
  17. err = o.Raw(sql, configKey).QueryRow(&item)
  18. if err == nil && utils.Re == nil {
  19. body, err := json.Marshal(item)
  20. if err != nil {
  21. return item, err
  22. }
  23. utils.Rc.Put(utils.CACHE_HZ_SMS_CONFIG+configKey, string(body), 24*time.Hour)
  24. }
  25. return
  26. }