File tree Expand file tree Collapse file tree 3 files changed +9
-0
lines changed Expand file tree Collapse file tree 3 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -799,6 +799,7 @@ CREATE TABLE IF NOT EXISTS `download` (
799
799
` is_recommend` tinyint unsigned NOT NULL DEFAULT 0 COMMENT ' 是否推荐(推荐的高亮显示)' ,
800
800
` category` tinyint unsigned NOT NULL DEFAULT 0 COMMENT ' 0-Archived versions; 1-Stable versions; 2-Unstable versions;' ,
801
801
` seq` int unsigned NOT NULL DEFAULT 0 COMMENT ' 排序,越大越靠前' ,
802
+ ` times` int unsigned NOT NULl DEFAULT 0 COMMENT ' 下载次数' ,
802
803
` created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ,
803
804
PRIMARY KEY (` id` )
804
805
) ENGINE= InnoDB DEFAULT CHARSET= utf8 COMMENT ' 下载信息表' ;
Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ var filenameReg = regexp.MustCompile(`\d+\.\d[a-z\.]*\d+`)
84
84
func (self DownloadController ) FetchGoInstallPackage (ctx echo.Context ) error {
85
85
filename := ctx .Param ("filename" )
86
86
87
+ go logic .DefaultDownload .RecordDLTimes (ctx , filename )
88
+
87
89
officalUrl := GoStoragePrefix + filename
88
90
resp , err := self .headWithTimeout (officalUrl )
89
91
if err == nil && resp .StatusCode == http .StatusOK {
Original file line number Diff line number Diff line change @@ -29,3 +29,9 @@ func (DownloadLogic) FindAll(ctx context.Context) []*model.Download {
29
29
30
30
return downloads
31
31
}
32
+
33
+ func (DownloadLogic ) RecordDLTimes (ctx context.Context , filename string ) error {
34
+ MasterDB .Where ("filename=?" , filename ).Incr ("times" , 1 ).Update (new (model.Download ))
35
+
36
+ return nil
37
+ }
You can’t perform that action at this time.
0 commit comments