浏览代码

更新用户最后一次阅读记录

xingzai 3 年之前
父节点
当前提交
8afceb582d
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      models/article_history_record.go

+ 6 - 1
models/article_history_record.go

@@ -1,6 +1,7 @@
 package models
 
 import (
+	"fmt"
 	"hongze/hongze_cygx/utils"
 	"rdluck_tools/orm"
 	"time"
@@ -23,6 +24,7 @@ func AddCygxArticleHistoryRecord(item *CygxArticleHistoryRecord) (lastId int64,
 	o := orm.NewOrm()
 	o.Begin()
 	defer func() {
+		fmt.Println(err)
 		if err == nil {
 			o.Commit()
 		} else {
@@ -32,7 +34,10 @@ func AddCygxArticleHistoryRecord(item *CygxArticleHistoryRecord) (lastId int64,
 	//var count int
 	//sql := `SELECT COUNT(1) AS count FROM cygx_article_history_record WHERE user_id=? AND article_id=? `
 	//err = o.Raw(sql, item.UserId, item.ArticleId).QueryRow(&count)
-	if err != nil && err.Error() != utils.ErrNoRow() {
+
+	sql := `UPDATE wx_user SET report_last_view_time=NOW() WHERE user_id=?`
+	_, err = o.Raw(sql, item.UserId).Exec()
+	if err != nil {
 		return
 	}
 	//if count > 0 {