Explorar el Código

Merge remote-tracking branch 'origin/master'

tmp
huangjiajun hace 1 semana
padre
commit
217d563af8
Se han modificado 2 ficheros con 12 adiciones y 10 borrados
  1. +10
    -8
      app/hdl/comm/hdl_comm.go
  2. +2
    -2
      app/router/router.go

+ 10
- 8
app/hdl/comm/hdl_comm.go Ver fichero

@@ -107,8 +107,16 @@ func AccessRecords(c *gin.Context) {

user := svc.GetUser(c)
date := time.Now().Format("2006-01-02")

cacheKey := fmt.Sprintf(md.UserAccessRecordsKey, date, req.Index)
if !cache.Exists(cacheKey) {
ttl := 24 * 60 * 60 // 记录保存24小时
_, err := cache.SetEx(cacheKey, nil, ttl)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}
}

get, err1 := cache.GetBit(cacheKey, user.Id)
if err1 != nil || get == 0 {
recordsDb := implement.NewEggAccessRecordsDb(db.Db)
@@ -128,14 +136,8 @@ func AccessRecords(c *gin.Context) {
return
}
}
ttl := 24 * 60 * 60 // 记录保存24小时
_, err = cache.SetBit(cacheKey, user.Id, 1)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

_, err = cache.Expire(cacheKey, ttl)
_, err = cache.SetBit(cacheKey, user.Id, 1)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return


+ 2
- 2
app/router/router.go Ver fichero

@@ -225,6 +225,6 @@ func rCircleFriends(r *gin.RouterGroup) {
}

func rComm(r *gin.RouterGroup) {
r.POST("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
r.GET("/accessRecords", comm.AccessRecords) // 访问记录
r.POST("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
r.POST("/accessRecords", comm.AccessRecords) // 访问记录
}

Cargando…
Cancelar
Guardar