From ad339bf60cd5ac0fc7900f09566a9a78e059f03a Mon Sep 17 00:00:00 2001 From: DengBiao <2319963317@qq.com> Date: Thu, 12 Oct 2023 19:18:30 +0800 Subject: [PATCH] update --- app/customer/hdl/hdl_alipay.go | 9 ++++++++- app/customer/hdl/hdl_login.go | 9 +++++++++ app/customer/md/alipay.go | 6 ++++++ app/router/customer_router.go | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/customer/hdl/hdl_alipay.go b/app/customer/hdl/hdl_alipay.go index 6b9fb3c..b64fa90 100644 --- a/app/customer/hdl/hdl_alipay.go +++ b/app/customer/hdl/hdl_alipay.go @@ -7,6 +7,8 @@ import ( "applet/app/db" "applet/app/e" "applet/app/enum" + "applet/app/utils" + "encoding/json" "fmt" "github.com/gin-gonic/gin" ) @@ -31,7 +33,12 @@ func AesDecrypt(c *gin.Context) { e.OutErr(c, e.ERR, err.Error()) return } - e.OutSuc(c, result, nil) + + resByre, _ := json.Marshal(result) + var aesStruct md.AesStruct + json.Unmarshal(resByre, &aesStruct) + aesStruct.Mobile = utils.Base64StdEncode(aesStruct.Mobile) + e.OutSuc(c, aesStruct, nil) return } diff --git a/app/customer/hdl/hdl_login.go b/app/customer/hdl/hdl_login.go index 6593919..285d145 100644 --- a/app/customer/hdl/hdl_login.go +++ b/app/customer/hdl/hdl_login.go @@ -129,6 +129,8 @@ func WxDecryptMobile(c *gin.Context) { return } + res.PhoneNumber = utils.Base64StdEncode(res.PhoneNumber) + e.OutSuc(c, res, nil) return } @@ -184,6 +186,13 @@ func Register(c *gin.Context) { e.OutErr(c, e.ERR_DB_ORM, err) return } + //TODO::解密 + phone := utils.Base64StdDecode(req.Phone) + if phone == "" { + e.OutErr(c, e.ERR, "非法/恶意 参数!!!") + return + } + req.Phone = phone // 编译正则表达式 pattern := `^1[3456789]\d{9}$` r := regexp.MustCompile(pattern) diff --git a/app/customer/md/alipay.go b/app/customer/md/alipay.go index 637bb55..14dff06 100644 --- a/app/customer/md/alipay.go +++ b/app/customer/md/alipay.go @@ -33,3 +33,9 @@ type AliPayCallback struct { Version string `json:"version"` PayMethod string `json:"pay_method"` } + +type AesStruct struct { + Code string `json:"code"` + Msg string `json:"msg"` + Mobile string `json:"mobile"` +} diff --git a/app/router/customer_router.go b/app/router/customer_router.go index b19b19d..018a150 100644 --- a/app/router/customer_router.go +++ b/app/router/customer_router.go @@ -33,7 +33,7 @@ func CustomerInit(r *gin.RouterGroup) { r.POST("/wxPay", hdl.WxPay) r.POST("/register", hdl.Register) - r.POST("/aesDecrypt", hdl.AesDecrypt) + r.POST("/aesDecrypt", hdl.AesDecrypt) //TODO::专门给解密支付宝手机号 r.POST("/systemOauthToken", hdl.SystemOauthToken) r.GET("/getSysCfg", hdl.GetSysCfg) //获取基础配置 r.Use(mw.Auth) //检测登录状态