69 lines
2.8 KiB
Go
69 lines
2.8 KiB
Go
package datastore
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
|
)
|
|
|
|
var (
|
|
ErrNotExist = errors.New("resource does not exist")
|
|
ErroNoRowsAffected = errors.New("query did not affect any rows")
|
|
ErrInvalidListSort = errors.New("invalid list sort parameter [1,2,3,4]")
|
|
)
|
|
|
|
type ListSort uint32
|
|
const (
|
|
ListSortDisabled ListSort = 0
|
|
ListSortDisplayNameAscending ListSort = 1
|
|
ListSortDisplayNameDescending ListSort = 2
|
|
ListSortDateAscending ListSort = 3
|
|
ListSortDateDescending ListSort = 4
|
|
)
|
|
|
|
type Datastore interface {
|
|
Mapfixes() Mapfixes
|
|
Submissions() Submissions
|
|
Scripts() Scripts
|
|
ScriptPolicy() ScriptPolicy
|
|
}
|
|
|
|
type Mapfixes interface {
|
|
Get(ctx context.Context, id int64) (model.Mapfix, error)
|
|
GetList(ctx context.Context, id []int64) ([]model.Mapfix, error)
|
|
Create(ctx context.Context, smap model.Mapfix) (model.Mapfix, error)
|
|
Update(ctx context.Context, id int64, values OptionalMap) error
|
|
IfStatusThenUpdate(ctx context.Context, id int64, statuses []model.MapfixStatus, values OptionalMap) error
|
|
IfStatusThenUpdateAndGet(ctx context.Context, id int64, statuses []model.MapfixStatus, values OptionalMap) (model.Mapfix, error)
|
|
Delete(ctx context.Context, id int64) error
|
|
List(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort) ([]model.Mapfix, error)
|
|
}
|
|
|
|
type Submissions interface {
|
|
Get(ctx context.Context, id int64) (model.Submission, error)
|
|
GetList(ctx context.Context, id []int64) ([]model.Submission, error)
|
|
Create(ctx context.Context, smap model.Submission) (model.Submission, error)
|
|
Update(ctx context.Context, id int64, values OptionalMap) error
|
|
IfStatusThenUpdate(ctx context.Context, id int64, statuses []model.SubmissionStatus, values OptionalMap) error
|
|
IfStatusThenUpdateAndGet(ctx context.Context, id int64, statuses []model.SubmissionStatus, values OptionalMap) (model.Submission, error)
|
|
Delete(ctx context.Context, id int64) error
|
|
List(ctx context.Context, filters OptionalMap, page model.Page, sort ListSort) ([]model.Submission, error)
|
|
}
|
|
|
|
type Scripts interface {
|
|
Get(ctx context.Context, id int64) (model.Script, error)
|
|
Create(ctx context.Context, smap model.Script) (model.Script, error)
|
|
Update(ctx context.Context, id int64, values OptionalMap) error
|
|
Delete(ctx context.Context, id int64) error
|
|
List(ctx context.Context, filters OptionalMap, page model.Page) ([]model.Script, error)
|
|
}
|
|
|
|
type ScriptPolicy interface {
|
|
Get(ctx context.Context, id int64) (model.ScriptPolicy, error)
|
|
GetFromHash(ctx context.Context, hash uint64) (model.ScriptPolicy, error)
|
|
Create(ctx context.Context, smap model.ScriptPolicy) (model.ScriptPolicy, error)
|
|
Update(ctx context.Context, id int64, values OptionalMap) error
|
|
Delete(ctx context.Context, id int64) error
|
|
List(ctx context.Context, filters OptionalMap, page model.Page) ([]model.ScriptPolicy, error)
|
|
}
|