From 6198c4a618ab6928c566baa8931976513d4b8df8 Mon Sep 17 00:00:00 2001 From: ayame-git Date: Wed, 10 May 2017 23:24:06 +0300 Subject: [PATCH] fixed dup renchon on report --- model/report.go | 2 +- router/viewTorrentHandler.go | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/model/report.go b/model/report.go index ae158448..30c77682 100644 --- a/model/report.go +++ b/model/report.go @@ -11,7 +11,7 @@ type TorrentReport struct { UserID uint `gorm:"column:user_id"` Torrent Torrent `gorm:"AssociationForeignKey:TorrentID;ForeignKey:torrent_id"` - User User `gorm:"AssociationForeignKey:UserID;ForeignKey:ID"` + User User `gorm:"AssociationForeignKey:UserID;ForeignKey:user_id"` } type TorrentReportJson struct { diff --git a/router/viewTorrentHandler.go b/router/viewTorrentHandler.go index e9fab112..ce185e86 100644 --- a/router/viewTorrentHandler.go +++ b/router/viewTorrentHandler.go @@ -79,16 +79,18 @@ func ReportTorrentHandler(w http.ResponseWriter, r *http.Request) { idNum, err := strconv.Atoi(id) userID := currentUser.ID - torrent, _ := torrentService.GetTorrentById(id) + //torrent, _ := torrentService.GetTorrentById(id) + + fmt.Println(userID) + fmt.Println(currentUser) report := model.TorrentReport{ Description: r.FormValue("report_type"), TorrentID: uint(idNum), UserID: userID, - Torrent: torrent, - User: *currentUser, + //Torrent: torrent, + //User: *currentUser, } - fmt.Println(report) err = db.ORM.Create(&report).Error if err != nil {