|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- package hdl
-
- import (
- "applet/app/customer/lib/validate"
- "applet/app/customer/md"
- "applet/app/customer/svc"
- "applet/app/db"
- "applet/app/e"
- "applet/app/enum"
- "applet/app/utils"
- "encoding/json"
- "fmt"
- "github.com/gin-gonic/gin"
- )
-
- func AesDecrypt(c *gin.Context) {
- fmt.Println(">>>>>>>>>>>>>>>>>", c.Request.Body)
- var req md.CurlAesDecrypt
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- sysCfgDb := db.SysCfgDb{}
- sysCfgDb.Set()
- sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAesKey)
- req.AesKey = sysCfg[enum.OpenAppletAesKey]
-
- err, result := svc.AesDecrypt(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
-
- resByre, _ := json.Marshal(result)
- var aesStruct md.AesStruct
- json.Unmarshal(resByre, &aesStruct)
- aesStruct.Mobile = utils.Base64StdEncode(aesStruct.Mobile)
- e.OutSuc(c, aesStruct, nil)
- return
- }
-
- func SystemOauthToken(c *gin.Context) {
- var req md.SystemOauthTokenReq
- err := c.ShouldBindJSON(&req)
- if err != nil {
- err = validate.HandleValidateErr(err)
- err1 := err.(e.E)
- e.OutErr(c, err1.Code, err1.Error())
- return
- }
- utils.FilePutContents("SystemOauthToken", utils.SerializeStr(req))
- sysCfgDb := db.SysCfgDb{}
- sysCfgDb.Set()
- sysCfg := sysCfgDb.SysCfgFindWithDb(enum.OpenAppletAppid, enum.OpenAppletAppPrivateKey, enum.OpenAppletPublicKey)
- req.Config = struct {
- AliAppId string `json:"ali_app_id" label:"支付宝开放平台-小程序-appid"`
- AliPrivateKey string `json:"ali_private_key" label:"支付宝开放平台-小程序-应用私钥"`
- AliPublicKey string `json:"ali_public_key" label:"支付宝开放平台-小程序-支付宝公钥"`
- }{
- AliAppId: sysCfg[enum.OpenAppletAppid],
- AliPrivateKey: sysCfg[enum.OpenAppletAppPrivateKey],
- AliPublicKey: sysCfg[enum.OpenAppletPublicKey],
- }
- err, result := svc.SystemOauthToken(req)
- if err != nil {
- e.OutErr(c, e.ERR, err.Error())
- return
- }
- e.OutSuc(c, result, nil)
- return
- }
|