diff --git a/pkg/service/script_policy.go b/pkg/service/script_policy.go index 4023c62..7e14939 100644 --- a/pkg/service/script_policy.go +++ b/pkg/service/script_policy.go @@ -52,25 +52,22 @@ func (svc *Service) CreateScriptPolicy(ctx context.Context, req *api.ScriptPolic // Get list of script policies. // // 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() - if request.Filter.IsSet() { - f := request.Filter.Value - if f.FromScriptHash.IsSet(){ - filter.AddNotNil("from_script_hash", f.FromScriptHash.Value) - } - if f.ToScriptID.IsSet(){ - filter.AddNotNil("to_script_id", f.ToScriptID.Value) - } - if f.Policy.IsSet(){ - filter.AddNotNil("policy", f.Policy.Value) - } + if params.FromScriptHash.IsSet(){ + filter.AddNotNil("from_script_hash", params.FromScriptHash.Value) + } + if params.ToScriptID.IsSet(){ + filter.AddNotNil("to_script_id", params.ToScriptID.Value) + } + if params.Policy.IsSet(){ + filter.AddNotNil("policy", params.Policy.Value) } items, err := svc.DB.ScriptPolicy().List(ctx, filter, model.Page{ - Number: request.Page.Number, - Size: request.Page.Size, + Number: params.Page, + Size: params.Limit, }) if err != nil { return nil, err diff --git a/pkg/service/submissions.go b/pkg/service/submissions.go index 7dccef3..5e2651a 100644 --- a/pkg/service/submissions.go +++ b/pkg/service/submissions.go @@ -67,25 +67,22 @@ func (svc *Service) GetSubmission(ctx context.Context, params api.GetSubmissionP // Get list of 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() - //fmt.Println(request) - if request.Filter.IsSet() { - f := request.Filter.Value - if f.DisplayName.IsSet(){ - filter.Add("display_name", f.DisplayName.Value) - } - if f.Creator.IsSet(){ - filter.Add("creator", f.Creator.Value) - } - if f.GameID.IsSet(){ - filter.Add("game_id", f.GameID.Value) - } + + if params.DisplayName.IsSet(){ + filter.Add("display_name", params.DisplayName.Value) + } + if params.Creator.IsSet(){ + filter.Add("creator", params.Creator.Value) + } + if params.GameID.IsSet(){ + filter.Add("game_id", params.GameID.Value) } items, err := svc.DB.Submissions().List(ctx, filter, model.Page{ - Number: request.Page.Number, - Size: request.Page.Size, + Number: params.Page, + Size: params.Limit, }) if err != nil { return nil, err