47 lines
1.0 KiB
TypeScript
47 lines
1.0 KiB
TypeScript
import { OrderQuery } from "sim-shared/domain/Order.js";
|
|
import { PaginationArgs } from "sim-shared/domain/PaginationArgs.js";
|
|
import { OrderRepository } from "sim-shared/infrastructure/OrderRepository.js";
|
|
|
|
|
|
export class OrderUsecases {
|
|
private orderRepository: OrderRepository;
|
|
constructor(args: {
|
|
orderRepository: OrderRepository
|
|
}
|
|
) {
|
|
this.orderRepository = args.orderRepository
|
|
}
|
|
|
|
public getById() {
|
|
return async (args: {
|
|
id: number
|
|
}) => {
|
|
const order = await this.orderRepository.getOrderById(args)
|
|
return order
|
|
}
|
|
}
|
|
|
|
public getByQueueId() {
|
|
return async (args: {
|
|
correlation_id: string
|
|
}) => {
|
|
const order = await this.orderRepository.getOrderByQueueId(args)
|
|
return order
|
|
}
|
|
}
|
|
|
|
public getPending() {
|
|
return async (args: PaginationArgs & {
|
|
}) => {
|
|
return await this.orderRepository.getPendingOrders(args)
|
|
}
|
|
}
|
|
|
|
// WIP
|
|
public getByQuery() {
|
|
return async (args: OrderQuery) => {
|
|
return await this.orderRepository.getOrdersByQuery(args)
|
|
}
|
|
}
|
|
}
|