partition by org_id and add auth
All checks were successful
Build and Publish / build-release (push) Successful in 3m7s
All checks were successful
Build and Publish / build-release (push) Successful in 3m7s
This commit is contained in:
@@ -2,12 +2,13 @@ defmodule CustomerService.Customer.Queries do
|
||||
alias CustomerService.Projections.Customer
|
||||
alias CustomerService.Repo
|
||||
|
||||
def list_customers(params \\ %{}) do
|
||||
def list_by_org(org_id, params \\ %{}) when is_binary(org_id) do
|
||||
params = Map.put(params, :org_id, org_id)
|
||||
Flop.validate_and_run(Customer, params, for: Customer)
|
||||
end
|
||||
|
||||
def get_customer(id) do
|
||||
case Repo.get(Customer, id) do
|
||||
def get_by_org(org_id, customer_id) when is_binary(org_id) and is_binary(customer_id) do
|
||||
case Repo.get_by(Customer, org_id: org_id, customer_id: customer_id) do
|
||||
nil -> {:error, :not_found}
|
||||
customer -> {:ok, customer}
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user