|
@@ -1,6 +1,7 @@
|
|
|
package services
|
|
|
|
|
|
import (
|
|
|
+ "encoding/json"
|
|
|
"fmt"
|
|
|
"github.com/beego/beego/v2/server/web/context"
|
|
|
"hongze/hongze_cygx/models"
|
|
@@ -25,8 +26,27 @@ func AddCygxPageHistoryRecord(user *models.WxUserItem, Ctx *context.Context) {
|
|
|
}
|
|
|
if Ctx.Input.Method() == "POST" {
|
|
|
item.Parameter = string(Ctx.Input.RequestBody)
|
|
|
+ var pr models.PageRouter
|
|
|
+ err := json.Unmarshal(Ctx.Input.RequestBody, &pr)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ utils.FileLog.Info(err.Error())
|
|
|
+ }
|
|
|
+ item.PageRouter = pr.PageRouter
|
|
|
}
|
|
|
- //fmt.Println("body:", string(Ctx.Input.RequestBody))
|
|
|
+ if strings.Contains(item.Router, "/api/article/detail") {
|
|
|
+ cacheKey := fmt.Sprint("uid:", user.UserId, "_Parameter:", item.Parameter)
|
|
|
+ isExist := utils.Rc.IsExist(cacheKey)
|
|
|
+ if !isExist {
|
|
|
+ setNX := utils.Rc.SetNX(cacheKey, user.Mobile, time.Second*10)
|
|
|
+ if !setNX {
|
|
|
+ go utils.SendAlarmMsg("记录用户阅读文章,设置Redis Key 过期时间失败:key"+cacheKey, 3)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
_, err := models.AddCygxPageHistoryRecord(item)
|
|
|
if err != nil {
|
|
|
fmt.Println(err)
|