新增微信公众平台对接,增加缓存。默认10天

This commit is contained in:
2024-03-05 16:07:42 +08:00
parent b4039aab81
commit 02561cf149
3 changed files with 18 additions and 6 deletions
+9 -3
View File
@@ -1,7 +1,7 @@
package v1
import (
"fmt"
"context"
"github.com/gin-gonic/gin"
v1 "hospital-open-api/api/requests/v1"
"hospital-open-api/api/responses"
@@ -53,7 +53,13 @@ func (r *WeChat) GetScheme(c *gin.Context) {
envVersion = "release"
}
fmt.Println(req.Query)
// 获取缓存
redisKey := "c:official_account.scheme." + req.Path + "." + req.Query
scheme, _ := global.Redis.Get(context.Background(), redisKey).Result()
if scheme != "" {
responses.OkWithData(scheme, c)
return
}
// 构建请求数据
JumpWxaData := &Scheme.GetSchemeJumpWxaRequest{
@@ -66,7 +72,7 @@ func (r *WeChat) GetScheme(c *gin.Context) {
JumpWxa: JumpWxaData,
ExpireType: 1,
ExpireTime: 0,
ExpireInterval: req.ExpireInterval,
ExpireInterval: 10,
}
openLink, err := GetSchemeRequest.GetScheme(1)