瀏覽代碼

新增阅读接口

rdluck 4 年之前
父節點
當前提交
52cb391c36
共有 4 個文件被更改,包括 30 次插入2 次删除
  1. 8 1
      controllers/article.go
  2. 1 1
      controllers/user.go
  3. 20 0
      models/article_view_record.go
  4. 1 0
      models/db.go

+ 8 - 1
controllers/article.go

@@ -63,7 +63,14 @@ func (this *ArticleController) Detail() {
 	if interviewApplyCount > 0 {
 		detail.IsInterviewApply = true
 	}
-
+	//新增浏览记录
+	{
+		record := new(models.CygxArticleViewRecord)
+		record.UserId = uid
+		record.ArticleId = articleId
+		record.CreateTime = time.Now()
+		go models.AddCygxArticleViewRecord(record)
+	}
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "获取成功"

+ 1 - 1
controllers/user.go

@@ -217,6 +217,7 @@ func (this *UserController) CheckLogin() {
 	br.Success = true
 	br.Msg = "获取成功"
 	br.Data = resp
+	br.Ret = 200
 }
 
 //
@@ -351,7 +352,6 @@ func (this *UserController) CollectList() {
 	br.Data = resp
 }
 
-
 // @Title 获取申请访谈列表
 // @Description 获取申请访谈列表
 // @Param   PageSize    query   int true       "PageSize"

+ 20 - 0
models/article_view_record.go

@@ -0,0 +1,20 @@
+package models
+
+import (
+	"rdluck_tools/orm"
+	"time"
+)
+
+type CygxArticleViewRecord struct {
+	Id              int `orm:"column(id);pk"`
+	ArticleId       int
+	UserId          int
+	CreateTime      time.Time
+}
+
+//添加收藏信息
+func AddCygxArticleViewRecord(item *CygxArticleViewRecord) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}

+ 1 - 0
models/db.go

@@ -32,5 +32,6 @@ func init() {
 		new(WxUserLog),
 		new(WxUserCode),
 		new(CygxArticleCollect),
+		new(CygxArticleViewRecord),
 	)
 }