Kaynağa Gözat

文章详细关闭方式

xingzai 3 yıl önce
ebeveyn
işleme
ec54f127d0

+ 5 - 7
controllers/article.go

@@ -533,17 +533,17 @@ func (this *ArticleController) AddStopTime() {
 	uid := user.UserId
 	articleId := req.ArticleId
 	stopTime := req.StopTime
+	outType := req.OutType
 	if articleId <= 0 {
 		br.Msg = "参数错误"
 		br.ErrMsg = "参数错误"
 		return
 	}
-
 	if stopTime == 0 {
 		stopTime = 1
-		//br.Msg = "时间格式错误"
-		//br.ErrMsg = "时间错误"
-		//return
+	}
+	if outType != 1 {
+		outType = 2
 	}
 	detail := new(models.ArticleDetail)
 	hasPermission := 0
@@ -607,13 +607,11 @@ func (this *ArticleController) AddStopTime() {
 			if hasPersion {
 				detailNew, err := models.GetNewArticleHistoryRecord(uid, articleId)
 				if err == nil {
-					//br.Msg = "获取信息失败"
-					//br.ErrMsg = "获取最新阅读信息失败,Err:" + err.Error() + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
-					//return
 					hasPermission = 1
 					historyRecord := new(models.AddStopTimeNewRep)
 					historyRecord.StopTime = detailNew.StopTime + stopTime
 					historyRecord.Id = detailNew.Id
+					historyRecord.OutType = outType
 					go models.AddArticleStopTime(historyRecord)
 				}
 

+ 1 - 1
controllers/home.go

@@ -109,7 +109,7 @@ func (this *HomeController) ListHome() {
 	lenList := len(list)
 	for i := 0; i < lenList; i++ {
 		item := list[i]
-		list[i].Body, _ = services.GetReportContentTextSub(item.Body)
+		//list[i].Body, _ = services.GetReportContentTextSub(item.Body)
 		list[i].PublishDate = utils.StrTimeToTime(item.PublishDate).Format(utils.FormatDateTimeNoSecond) //时间字符串格式转时间格式
 		if strings.Contains(item.CategoryName, "研选") {
 			list[i].IsResearch = true

+ 1 - 0
models/article.go

@@ -92,6 +92,7 @@ type HomeArticle struct {
 	ExpertBackground string `description:"专家背景"`
 	IsResearch       bool   `description:"是否属于研选"`
 	Pv               int    `description:"PV"`
+	FirstImgUrl      string `description:"第一张图片"`
 }
 
 type ArticleDetail struct {

+ 4 - 15
models/article_history_record.go

@@ -63,12 +63,14 @@ func GetUserToArticleCount(uid, articleId int) (count int, err error) {
 type AddStopTimeRep struct {
 	ArticleId int `description:"文章ID"`
 	StopTime  int `description:"停留时间"`
+	OutType   int `description:"退出方式,1正常退出,2强制关闭"`
 }
 
 type AddStopTimeNewRep struct {
 	Id        int `description:"ID"`
 	ArticleId int `description:"文章ID"`
 	StopTime  int `description:"停留时间"`
+	OutType   int `description:"退出方式,1正常退出,2强制关闭"`
 }
 
 type ArticleDetailAddStopTimeRep struct {
@@ -78,21 +80,8 @@ type ArticleDetailAddStopTimeRep struct {
 
 func AddArticleStopTime(item *AddStopTimeNewRep) (err error) {
 	o := orm.NewOrm()
-	//o.Begin()
-	//defer func() {
-	//	if err == nil {
-	//		o.Commit()
-	//	} else {
-	//		o.Rollback()
-	//	}
-	//}()
-	sql := `UPDATE cygx_article_history_record SET stop_time = ? WHERE id =?`
-	_, err = o.Raw(sql, item.StopTime, item.Id).Exec()
-	if err != nil && err.Error() != utils.ErrNoRow() {
-		return
-	}
-	//sql = ` DELETE  FROM cygx_article_history_record  WHERE create_time > '2021-06-01 00:00:00' AND stop_time = 0`
-	//_, err = o.Raw(sql).Exec()
+	sql := `UPDATE cygx_article_history_record SET stop_time = ?,out_type = ? WHERE id =?`
+	_, err = o.Raw(sql, item.StopTime, item.OutType, item.Id).Exec()
 	return
 }