蛋蛋星球-客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

48 line
1.6 KiB

  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/utils/cache"
  5. "applet/app/utils/logx"
  6. "code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
  7. "code.fnuoos.com/EggPlanet/egg_models.git/src/implement"
  8. "github.com/gin-gonic/gin"
  9. "github.com/tidwall/gjson"
  10. )
  11. func AliyunCaptchBase(c *gin.Context) (string, string) {
  12. redisConn := cache.GetPool().Get()
  13. sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
  14. defer func(sysCfgDb dao.SysCfgDao) {
  15. err := sysCfgDb.Close()
  16. if err != nil {
  17. logx.Error("redis close err:" + err.Error()) // 记录错误信息
  18. }
  19. }(sysCfgDb)
  20. data := sysCfgDb.SysCfgFindWithDb("aliyun_captch_id_android", "aliyun_captch_key_android", "aliyun_captch_id_ios", "aliyun_captch_key_ios", "aliyun_captch_id_h5", "aliyun_captch_key_h5")
  21. if c.GetHeader("platform") == "android" {
  22. return data["aliyun_captch_id_android"], data["aliyun_captch_key_android"]
  23. }
  24. if c.GetHeader("platform") == "iOS" {
  25. return data["aliyun_captch_id_ios"], data["aliyun_captch_key_ios"]
  26. }
  27. if c.GetHeader("platform") == "wap" {
  28. return data["aliyun_captch_id_h5"], data["aliyun_captch_key_h5"]
  29. }
  30. return "", ""
  31. }
  32. func AliyunSmsBase(c *gin.Context, types string) map[string]string {
  33. redisConn := cache.GetPool().Get()
  34. sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn)
  35. defer func(sysCfgDb dao.SysCfgDao) {
  36. err := sysCfgDb.Close()
  37. if err != nil {
  38. logx.Error("redis close err:" + err.Error()) // 记录错误信息
  39. }
  40. }(sysCfgDb)
  41. data := sysCfgDb.SysCfgFindWithDb("aliyun_sms_id", "aliyun_sms_secret", "aliyun_sms_code", "aliyun_sms_sign_name")
  42. data["aliyun_sms_code"] = gjson.Get(data["aliyun_sms_code"], types).String()
  43. return data
  44. }