wechat.go 968 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_task/models/yb"
  6. )
  7. // YbWxConf 研报小程序AppId配置
  8. type YbWxConf struct {
  9. AppId string `description:"AppID"`
  10. MsgRedirectType int `description:"公共模板消息跳转类型: 1-研报小程序; 4-备用小程序"`
  11. }
  12. func init() {
  13. confKey := "use_copy_yb"
  14. conf, e := yb.GetConfigByCode(confKey)
  15. if e != nil {
  16. fmt.Println(e.Error())
  17. return
  18. }
  19. fmt.Println("conf.ConfigValue", conf.ConfigValue)
  20. }
  21. // 根据研报配置获取研报小程序AppID信息
  22. func GetYbAppIdInfo() (ybConf *YbWxConf, err error) {
  23. confKey := "use_copy_yb"
  24. conf, e := yb.GetConfigByCode(confKey)
  25. if e != nil {
  26. err = errors.New("获取研报小程序配置信息失败, Err: " + e.Error())
  27. return
  28. }
  29. ybConf = &YbWxConf{
  30. AppId: "wxb059c872d79b9967",
  31. MsgRedirectType: 1,
  32. }
  33. if conf.ConfigValue == "true" {
  34. ybConf.AppId = "wx9a2a9b49a00513a0"
  35. ybConf.MsgRedirectType = 4
  36. }
  37. return
  38. }