From 59b1e2bb5f94426f5b27b0d05a9b8724bd9f14f1 Mon Sep 17 00:00:00 2001 From: ayame-git Date: Tue, 9 May 2017 05:44:08 +0300 Subject: [PATCH] autism --- model/torrent.go | 32 ++++++++++++++++---------------- util/search/search.go | 8 ++++---- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/model/torrent.go b/model/torrent.go index 21377669..1cc0b7f2 100644 --- a/model/torrent.go +++ b/model/torrent.go @@ -20,23 +20,23 @@ type Feed struct { } type Torrents struct { - Id uint `gorm:"column:torrent_id;primary_key"` - Name string `gorm:"column:torrent_name"` - Hash string `gorm:"column:torrent_hash"` - Category int `gorm:"column:category"` - Sub_Category int `gorm:"column:sub_category"` - Status int `gorm:"column:status"` - Date time.Time `gorm:"column:date"` - UploaderId uint `gorm:"column:uploader"` - Downloads int `gorm:"column:downloads"` - Stardom int `gorm:"column:stardom"` - Filesize int64 `gorm:"column:filesize"` - Description string `gorm:"column:description"` - WebsiteLink string `gorm:"column:website_link"` + Id uint `gorm:"column:torrent_id;primary_key"` + Name string `gorm:"column:torrent_name"` + Hash string `gorm:"column:torrent_hash"` + Category int `gorm:"column:category_od"` + Sub_Category int `gorm:"column:sub_category_id"` + Status int `gorm:"column:status_id"` + Date time.Time `gorm:"column:date"` + UploaderId uint `gorm:"column:uploader"` + Downloads int `gorm:"column:downloads"` + Stardom int `gorm:"column:stardom"` + Filesize int64 `gorm:"column:filesize"` + Description string `gorm:"column:description"` + WebsiteLink string `gorm:"column:website_link"` - Uploader *User `gorm:"ForeignKey:uploader"` - OldComments []OldComment `gorm:"ForeignKey:torrent_id"` - Comments []Comment `gorm:"ForeignKey:torrent_id"` + Uploader *User `gorm:"ForeignKey:uploader"` + OldComments []OldComment `gorm:"ForeignKey:torrent_id"` + Comments []Comment `gorm:"ForeignKey:torrent_id"` } /* We need JSON Object instead because of Magnet URL that is not in the database but generated dynamically */ diff --git a/util/search/search.go b/util/search/search.go index 53712371..6daa3f05 100644 --- a/util/search/search.go +++ b/util/search/search.go @@ -79,11 +79,11 @@ func SearchByQuery(r *http.Request, pagenum int) (SearchParam, []model.Torrents, parameters := torrentService.WhereParams{} conditions := []string{} if searchCatId != "" { - conditions = append(conditions, "category = ?") + conditions = append(conditions, "category_id = ?") parameters.Params = append(parameters.Params, searchCatId) } if searchSubCatId != "" { - conditions = append(conditions, "sub_category = ?") + conditions = append(conditions, "sub_category_id = ?") parameters.Params = append(parameters.Params, searchSubCatId) } if userId != "" { @@ -92,9 +92,9 @@ func SearchByQuery(r *http.Request, pagenum int) (SearchParam, []model.Torrents, } if search_param.Status != "" { if search_param.Status == "2" { - conditions = append(conditions, "status != ?") + conditions = append(conditions, "status_id != ?") } else { - conditions = append(conditions, "status = ?") + conditions = append(conditions, "status_id = ?") } parameters.Params = append(parameters.Params, search_param.Status) }