🎨 修改文章获取接口

This commit is contained in:
loser 2023-12-11 18:56:34 +08:00
parent 28055e99c9
commit cb7bce5cef

View File

@ -36,11 +36,14 @@ func (a ArticleService) GetArticleById(id, userId string) (article *common.Artic
err = global.GVA_DB.Where("id = ?", id).First(&article).Error err = global.GVA_DB.Where("id = ?", id).First(&article).Error
err = global.GVA_DB.Table("articles").Where("id = ?", id).Update("reading_num", gorm.Expr("reading_num + ?", 1)).Error err = global.GVA_DB.Table("articles").Where("id = ?", id).Update("reading_num", gorm.Expr("reading_num + ?", 1)).Error
if userId != "" {
// 判断是否收藏 // 判断是否收藏
var favorite app.Favorite var favorite app.Favorite
err = global.GVA_DB.Where("wz_id = ? AND user_id = ?", id, userId).First(&favorite).Error global.GVA_DB.Where("wz_id = ? AND user_id = ?", id, userId).First(&favorite)
if favorite.ID != 0 { if favorite.ID != 0 {
article.IsFavorite = 1 article.IsFavorite = 1
} }
}
return return
} }