From 9b5515dcb8a0af3e0ead267a6eebf0dd42b651de Mon Sep 17 00:00:00 2001 From: ayame-git Date: Wed, 10 May 2017 23:31:15 +0300 Subject: [PATCH] :thinking: --- model/report.go | 4 ++-- router/viewTorrentHandler.go | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/model/report.go b/model/report.go index 30c77682..b3b6388d 100644 --- a/model/report.go +++ b/model/report.go @@ -10,8 +10,8 @@ type TorrentReport struct { TorrentID uint `gorm:"column:torrent_id"` UserID uint `gorm:"column:user_id"` - Torrent Torrent `gorm:"AssociationForeignKey:TorrentID;ForeignKey:torrent_id"` - User User `gorm:"AssociationForeignKey:UserID;ForeignKey:user_id"` + Torrent *Torrent `gorm:"AssociationForeignKey:TorrentID;ForeignKey:torrent_id"` + User *User `gorm:"AssociationForeignKey:UserID;ForeignKey:user_id"` } type TorrentReportJson struct { diff --git a/router/viewTorrentHandler.go b/router/viewTorrentHandler.go index ce185e86..29fed947 100644 --- a/router/viewTorrentHandler.go +++ b/router/viewTorrentHandler.go @@ -79,17 +79,14 @@ func ReportTorrentHandler(w http.ResponseWriter, r *http.Request) { idNum, err := strconv.Atoi(id) userID := currentUser.ID - //torrent, _ := torrentService.GetTorrentById(id) - - fmt.Println(userID) - fmt.Println(currentUser) + torrent, _ := torrentService.GetTorrentById(id) report := model.TorrentReport{ Description: r.FormValue("report_type"), TorrentID: uint(idNum), UserID: userID, - //Torrent: torrent, - //User: *currentUser, + Torrent: &torrent, + User: currentUser, } err = db.ORM.Create(&report).Error