2024-11-26 21:36:40 +00:00
|
|
|
package datastore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
2024-11-26 23:30:58 +00:00
|
|
|
"git.itzana.me/strafesnet/maps-service/pkg/model"
|
2024-11-26 21:36:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2024-12-12 22:29:20 +00:00
|
|
|
ErrNotExist = errors.New("resource does not exist")
|
2024-12-11 23:38:26 +00:00
|
|
|
ErroNoRowsAffected = errors.New("query did not affect any rows")
|
2024-11-26 21:36:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Datastore interface {
|
2024-11-26 23:30:58 +00:00
|
|
|
Submissions() Submissions
|
2024-12-05 01:27:49 +00:00
|
|
|
Scripts() Scripts
|
|
|
|
ScriptPolicy() ScriptPolicy
|
2024-11-26 21:36:40 +00:00
|
|
|
}
|
|
|
|
|
2024-11-26 23:30:58 +00:00
|
|
|
type Submissions interface {
|
|
|
|
Get(ctx context.Context, id int64) (model.Submission, error)
|
2024-11-27 23:14:50 +00:00
|
|
|
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
|
2024-11-28 02:57:42 +00:00
|
|
|
IfStatusThenUpdate(ctx context.Context, id int64, statuses []model.Status, values OptionalMap) error
|
2024-11-29 23:52:44 +00:00
|
|
|
IfStatusThenUpdateAndGet(ctx context.Context, id int64, statuses []model.Status, values OptionalMap) (model.Submission, error)
|
2024-11-27 23:14:50 +00:00
|
|
|
Delete(ctx context.Context, id int64) error
|
|
|
|
List(ctx context.Context, filters OptionalMap, page model.Page) ([]model.Submission, error)
|
2024-11-26 21:36:40 +00:00
|
|
|
}
|
2024-12-05 01:27:49 +00:00
|
|
|
|
|
|
|
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
|
2024-12-18 23:22:23 +00:00
|
|
|
List(ctx context.Context, filters OptionalMap, page model.Page) ([]model.Script, error)
|
2024-12-05 01:27:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ScriptPolicy interface {
|
|
|
|
Get(ctx context.Context, id int64) (model.ScriptPolicy, error)
|
2024-12-07 02:19:26 +00:00
|
|
|
GetFromHash(ctx context.Context, hash uint64) (model.ScriptPolicy, error)
|
2024-12-05 01:27:49 +00:00
|
|
|
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
|
2024-12-14 06:15:05 +00:00
|
|
|
List(ctx context.Context, filters OptionalMap, page model.Page) ([]model.ScriptPolicy, error)
|
2024-12-05 01:27:49 +00:00
|
|
|
}
|