|
@@ -65,3 +65,48 @@ func Login(c *gin.Context) {
|
|
Authorization: token,
|
|
Authorization: token,
|
|
}, c)
|
|
}, c)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// 消息解密请求参数
|
|
|
|
+type EncryptReq struct {
|
|
|
|
+ EncryptedData string
|
|
|
|
+ Iv string
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// GetEncryptInfo 消息解密
|
|
|
|
+// @Tags 微信相关接口
|
|
|
|
+// @Summary 消息解密
|
|
|
|
+// @Description 消息解密
|
|
|
|
+// @Accept json
|
|
|
|
+// @Product json
|
|
|
|
+// @Param encryptedData query string true "加密数据"
|
|
|
|
+// @Param iv query string true "加密算法初始向量"
|
|
|
|
+// @Success 200 {string} string "获取成功"
|
|
|
|
+// @Router /wechat/getEncryptInfo [post]
|
|
|
|
+func GetEncryptInfo(c *gin.Context) {
|
|
|
|
+ var req EncryptReq
|
|
|
|
+ err := c.ShouldBind(&req)
|
|
|
|
+ if err != nil {
|
|
|
|
+ response.Fail("参数异常", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if req.EncryptedData == "" {
|
|
|
|
+ response.Fail("参数异常:encryptedData", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if req.Iv == "" {
|
|
|
|
+ response.Fail("参数异常:iv", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ // 获取登录用户信息
|
|
|
|
+ userInfo := user.GetInfoByClaims(c)
|
|
|
|
+ if userInfo.SessionKey == "" {
|
|
|
|
+ response.Fail("请重新登录", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ decryptData, err := wx_app.GetDecryptInfo(userInfo.SessionKey, req.EncryptedData, req.Iv)
|
|
|
|
+ if err != nil {
|
|
|
|
+ response.Fail("获取失败,Err:" + err.Error(), c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ response.OkData("获取成功", decryptData, c)
|
|
|
|
+}
|