Files
customer-service/lib/customer_service/customer/queries.ex
HaimKortovich 6fe6df4723
All checks were successful
Build and Publish / build-release (push) Successful in 1m8s
fix customer and quick lead
2026-05-15 14:43:25 -05:00

19 lines
583 B
Elixir

defmodule CustomerService.Customer.Queries do
import Ecto.Query
alias CustomerService.Projections.Customer
alias CustomerService.Repo
def list_by_org(org_id, params \\ %{}) when is_binary(org_id) do
base = from(c in Customer, where: c.org_id == ^org_id)
Flop.validate_and_run(base, params, for: Customer)
end
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
end
end