feat(source link): record downloads for redirected source link

pull/1519/head
HFO4 2 years ago
parent 8d7ecedf47
commit 1c25232b06

@ -23,6 +23,7 @@ func ValidateSourceLink() gin.HandlerFunc {
return return
} }
sourceLink.Downloaded()
c.Set("source_link", sourceLink) c.Set("source_link", sourceLink)
c.Next() c.Next()
} }

@ -39,3 +39,9 @@ func GetSourceLinkByID(id interface{}) (*SourceLink, error) {
return link, result.Error return link, result.Error
} }
// Viewed 增加访问次数
func (s *SourceLink) Downloaded() {
s.Downloads++
DB.Model(s).UpdateColumn("downloads", gorm.Expr("downloads + ?", 1))
}

Loading…
Cancel
Save