package svc import ( "applet/app/db" "applet/app/utils/cache" "applet/app/utils/logx" "code.fnuoos.com/EggPlanet/egg_models.git/src/dao" "code.fnuoos.com/EggPlanet/egg_models.git/src/implement" "github.com/gin-gonic/gin" "github.com/tidwall/gjson" ) func AliyunCaptchBase(c *gin.Context) (string, string) { redisConn := cache.GetPool().Get() sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn) defer func(sysCfgDb dao.SysCfgDao) { err := sysCfgDb.Close() if err != nil { logx.Error("redis close err:" + err.Error()) // 记录错误信息 } }(sysCfgDb) 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") if c.GetHeader("platform") == "android" { return data["aliyun_captch_id_android"], data["aliyun_captch_key_android"] } if c.GetHeader("platform") == "iOS" { return data["aliyun_captch_id_ios"], data["aliyun_captch_key_ios"] } if c.GetHeader("platform") == "wap" { return data["aliyun_captch_id_h5"], data["aliyun_captch_key_h5"] } return "", "" } func AliyunSmsBase(c *gin.Context, types string) map[string]string { redisConn := cache.GetPool().Get() sysCfgDb := implement.NewSysCfgDb(db.Db, redisConn) defer func(sysCfgDb dao.SysCfgDao) { err := sysCfgDb.Close() if err != nil { logx.Error("redis close err:" + err.Error()) // 记录错误信息 } }(sysCfgDb) data := sysCfgDb.SysCfgFindWithDb("aliyun_sms_id", "aliyun_sms_secret", "aliyun_sms_code", "aliyun_sms_sign_name") data["aliyun_sms_code"] = gjson.Get(data["aliyun_sms_code"], types).String() return data }