66 lines
2.3 KiB
Go
66 lines
2.3 KiB
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
dbgen "github.com/SamuelTariku/FortuneBet-Backend/gen/db"
|
|
)
|
|
|
|
type ReportedIssueRepository interface {
|
|
CreateReportedIssue(ctx context.Context, arg dbgen.CreateReportedIssueParams) (dbgen.ReportedIssue, error)
|
|
ListReportedIssues(ctx context.Context, limit, offset int32) ([]dbgen.ReportedIssue, error)
|
|
ListReportedIssuesByUser(ctx context.Context, userID int64, limit, offset int32) ([]dbgen.ReportedIssue, error)
|
|
CountReportedIssues(ctx context.Context) (int64, error)
|
|
CountReportedIssuesByUser(ctx context.Context, userID int64) (int64, error)
|
|
UpdateReportedIssueStatus(ctx context.Context, id int64, status string) error
|
|
DeleteReportedIssue(ctx context.Context, id int64) error
|
|
}
|
|
|
|
type ReportedIssueRepo struct {
|
|
store *Store
|
|
}
|
|
|
|
func NewReportedIssueRepository(store *Store) ReportedIssueRepository {
|
|
return &ReportedIssueRepo{store: store}
|
|
}
|
|
|
|
func (s *ReportedIssueRepo) CreateReportedIssue(ctx context.Context, arg dbgen.CreateReportedIssueParams) (dbgen.ReportedIssue, error) {
|
|
return s.store.queries.CreateReportedIssue(ctx, arg)
|
|
}
|
|
|
|
func (s *ReportedIssueRepo) ListReportedIssues(ctx context.Context, limit, offset int32) ([]dbgen.ReportedIssue, error) {
|
|
params := dbgen.ListReportedIssuesParams{
|
|
Limit: limit,
|
|
Offset: offset,
|
|
}
|
|
return s.store.queries.ListReportedIssues(ctx, params)
|
|
}
|
|
|
|
func (s *ReportedIssueRepo) ListReportedIssuesByUser(ctx context.Context, userID int64, limit, offset int32) ([]dbgen.ReportedIssue, error) {
|
|
params := dbgen.ListReportedIssuesByUserParams{
|
|
UserID: userID,
|
|
Limit: limit,
|
|
Offset: offset,
|
|
}
|
|
return s.store.queries.ListReportedIssuesByUser(ctx, params)
|
|
}
|
|
|
|
func (s *ReportedIssueRepo) CountReportedIssues(ctx context.Context) (int64, error) {
|
|
return s.store.queries.CountReportedIssues(ctx)
|
|
}
|
|
|
|
func (s *ReportedIssueRepo) CountReportedIssuesByUser(ctx context.Context, userID int64) (int64, error) {
|
|
return s.store.queries.CountReportedIssuesByUser(ctx, userID)
|
|
}
|
|
|
|
func (s *ReportedIssueRepo) UpdateReportedIssueStatus(ctx context.Context, id int64, status string) error {
|
|
return s.store.queries.UpdateReportedIssueStatus(ctx, dbgen.UpdateReportedIssueStatusParams{
|
|
ID: id,
|
|
Status: status,
|
|
})
|
|
}
|
|
|
|
func (s *ReportedIssueRepo) DeleteReportedIssue(ctx context.Context, id int64) error {
|
|
return s.store.queries.DeleteReportedIssue(ctx, id)
|
|
}
|