diff --git a/cmd/web/routes.go b/cmd/web/routes.go index 17a8140..81c8b17 100644 --- a/cmd/web/routes.go +++ b/cmd/web/routes.go @@ -33,6 +33,7 @@ func (app *application) routes() http.Handler { mux.Handle("GET /guestbooks/{id}/dashboard", protected.ThenFunc(app.getGuestbookDashboard)) mux.Handle("GET /guestbooks/{id}/dashboard/comments", protected.ThenFunc(app.getGuestbookComments)) mux.Handle("GET /guestbooks/{id}/comments/create", protected.ThenFunc(app.getGuestbookCommentCreate)) + mux.Handle("GET /guestbooks/{id}/dashboard/comments/queue", protected.ThenFunc(app.getCommentQueue)) return standard.Then(mux) diff --git a/internal/models/guestbookcomment.go b/internal/models/guestbookcomment.go index 6d37450..05442f5 100644 --- a/internal/models/guestbookcomment.go +++ b/internal/models/guestbookcomment.go @@ -102,3 +102,14 @@ func (m *GuestbookCommentModel) GetQueue(guestbookId int64) ([]GuestbookComment, } return comments, nil } + +func (m *GuestbookCommentModel) UpdateComment(comment *GuestbookComment) error { + stmt := `UPDATE guestbook_comments (CommentText, PageUrl, IsPublished, IsDeleted) + VALUES (?, ?, ?, ?) + WHERE Id = ?` + _, err := m.DB.Exec(stmt, comment.CommentText, comment.PageUrl, comment.IsPublished, comment.IsDeleted, comment.ID) + if err != nil { + return err + } + return nil +}