submissions: flatten list query params
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
76d36bea5c
commit
a94ae5d61e
@ -52,25 +52,22 @@ func (svc *Service) CreateScriptPolicy(ctx context.Context, req *api.ScriptPolic
|
|||||||
// Get list of script policies.
|
// Get list of script policies.
|
||||||
//
|
//
|
||||||
// GET /script-policy
|
// GET /script-policy
|
||||||
func (svc *Service) ListScriptPolicy(ctx context.Context, request *api.ListScriptPolicyReq) ([]api.ScriptPolicy, error) {
|
func (svc *Service) ListScriptPolicy(ctx context.Context, params api.ListScriptPolicyParams) ([]api.ScriptPolicy, error) {
|
||||||
filter := datastore.Optional()
|
filter := datastore.Optional()
|
||||||
|
|
||||||
if request.Filter.IsSet() {
|
if params.FromScriptHash.IsSet(){
|
||||||
f := request.Filter.Value
|
filter.AddNotNil("from_script_hash", params.FromScriptHash.Value)
|
||||||
if f.FromScriptHash.IsSet(){
|
}
|
||||||
filter.AddNotNil("from_script_hash", f.FromScriptHash.Value)
|
if params.ToScriptID.IsSet(){
|
||||||
}
|
filter.AddNotNil("to_script_id", params.ToScriptID.Value)
|
||||||
if f.ToScriptID.IsSet(){
|
}
|
||||||
filter.AddNotNil("to_script_id", f.ToScriptID.Value)
|
if params.Policy.IsSet(){
|
||||||
}
|
filter.AddNotNil("policy", params.Policy.Value)
|
||||||
if f.Policy.IsSet(){
|
|
||||||
filter.AddNotNil("policy", f.Policy.Value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
items, err := svc.DB.ScriptPolicy().List(ctx, filter, model.Page{
|
items, err := svc.DB.ScriptPolicy().List(ctx, filter, model.Page{
|
||||||
Number: request.Page.Number,
|
Number: params.Page,
|
||||||
Size: request.Page.Size,
|
Size: params.Limit,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -67,25 +67,22 @@ func (svc *Service) GetSubmission(ctx context.Context, params api.GetSubmissionP
|
|||||||
// Get list of submissions.
|
// Get list of submissions.
|
||||||
//
|
//
|
||||||
// GET /submissions
|
// GET /submissions
|
||||||
func (svc *Service) ListSubmissions(ctx context.Context, request *api.ListSubmissionsReq) ([]api.Submission, error) {
|
func (svc *Service) ListSubmissions(ctx context.Context, params api.ListSubmissionsParams) ([]api.Submission, error) {
|
||||||
filter := datastore.Optional()
|
filter := datastore.Optional()
|
||||||
//fmt.Println(request)
|
|
||||||
if request.Filter.IsSet() {
|
if params.DisplayName.IsSet(){
|
||||||
f := request.Filter.Value
|
filter.Add("display_name", params.DisplayName.Value)
|
||||||
if f.DisplayName.IsSet(){
|
}
|
||||||
filter.Add("display_name", f.DisplayName.Value)
|
if params.Creator.IsSet(){
|
||||||
}
|
filter.Add("creator", params.Creator.Value)
|
||||||
if f.Creator.IsSet(){
|
}
|
||||||
filter.Add("creator", f.Creator.Value)
|
if params.GameID.IsSet(){
|
||||||
}
|
filter.Add("game_id", params.GameID.Value)
|
||||||
if f.GameID.IsSet(){
|
|
||||||
filter.Add("game_id", f.GameID.Value)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
items, err := svc.DB.Submissions().List(ctx, filter, model.Page{
|
items, err := svc.DB.Submissions().List(ctx, filter, model.Page{
|
||||||
Number: request.Page.Number,
|
Number: params.Page,
|
||||||
Size: request.Page.Size,
|
Size: params.Limit,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user