refactor: remove feedback
- removed for now so I can focus on the primary objectives
This commit is contained in:
parent
cb9cc47245
commit
7ed1e05284
3 changed files with 0 additions and 84 deletions
|
|
@ -1,61 +0,0 @@
|
|||
package postgres
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"gitlab.mareshq.com/hq/backoffice/backoffice-api/pkg/training"
|
||||
)
|
||||
|
||||
type FeedbackRepository struct {
|
||||
db *sql.DB
|
||||
}
|
||||
|
||||
func NewFeedbackRepository(db *sql.DB) *FeedbackRepository {
|
||||
return &FeedbackRepository{db: db}
|
||||
}
|
||||
|
||||
func (r *FeedbackRepository) Get(id training.FeedbackID) (*training.Feedback, error) {
|
||||
var f training.Feedback
|
||||
err := r.db.QueryRow("SELECT * FROM feedback WHERE id = $1", id).Scan(&f.ID, &f.AttendeeID, &f.Rating, &f.Comment, &f.IsAnonymous, &f.IsSharingAllowed)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &f, nil
|
||||
}
|
||||
|
||||
func (r *FeedbackRepository) FindAll() ([]training.Feedback, error) {
|
||||
rows, err := r.db.Query("SELECT * FROM feedback")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
var feedbacks []training.Feedback
|
||||
for rows.Next() {
|
||||
var f training.Feedback
|
||||
err := rows.Scan(&f.ID, &f.AttendeeID, &f.Rating, &f.Comment, &f.IsAnonymous, &f.IsSharingAllowed)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
feedbacks = append(feedbacks, f)
|
||||
}
|
||||
|
||||
return feedbacks, nil
|
||||
}
|
||||
|
||||
func (r *FeedbackRepository) Create(f *training.Feedback) error {
|
||||
_, err := r.db.Exec("INSERT INTO feedback (id, attendee_id, rating, comment, is_anonymous, is_sharing_allowed) VALUES ($1, $2, $3, $4, $5, $6)", f.ID, f.AttendeeID, f.Rating, f.Comment, f.IsAnonymous, f.IsSharingAllowed)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *FeedbackRepository) Update(f *training.Feedback) error {
|
||||
_, err := r.db.Exec("UPDATE feedback SET attendee_id = $2, rating = $3, comment = $4, is_anonymous = $5, is_sharing_allowed = $6 WHERE id = $1", f.ID, f.AttendeeID, f.Rating, f.Comment, f.IsAnonymous, f.IsSharingAllowed)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *FeedbackRepository) Delete(id training.FeedbackID) error {
|
||||
_, err := r.db.Exec("DELETE FROM feedback WHERE id = $1", id)
|
||||
return err
|
||||
}
|
||||
Reference in a new issue