Docs orders
This commit is contained in:
@@ -32,14 +32,23 @@ export class OrderController {
|
||||
}
|
||||
|
||||
public getByQueueId() {
|
||||
return this.controllerGenerator<{ correlation_id: string }, { correlation_id: string }>({
|
||||
return this.controllerGenerator<{ uuid: string }, { correlation_id: string }>({
|
||||
validator: uuidValidator,
|
||||
mapBody: (e) => ({ correlation_id: e.uuid }),
|
||||
useCase: this.orderUseCases.getByQueueId(),
|
||||
onError: (data, error) => { console.error(error) },
|
||||
onSuccess: (data) => console.log(data)
|
||||
})
|
||||
}
|
||||
|
||||
public getByQuery() {
|
||||
return this.controllerGenerator({
|
||||
validator: undefined,
|
||||
useCase: this.orderUseCases.getByQuery(),
|
||||
onError: (data, error) => { console.error(error) },
|
||||
onSuccess: (data) => console.log(data)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO:
|
||||
@@ -77,7 +86,7 @@ export class OrderController {
|
||||
})
|
||||
}
|
||||
|
||||
// 2. Transformacion del body
|
||||
// 2. Transformacion del body O => P
|
||||
let data: P = body;
|
||||
try {
|
||||
if (args.mapBody != undefined)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { PaginationArgs } from "#domain/common.js";
|
||||
import { OrderQuery } from "sim-shared/domain/Order.js";
|
||||
import { OrderRepository } from "sim-shared/infrastructure/OrderRepository.js";
|
||||
|
||||
|
||||
@@ -36,4 +37,10 @@ export class OrderUsecases {
|
||||
}
|
||||
}
|
||||
|
||||
// WIP
|
||||
public getByQuery() {
|
||||
return async (args: OrderQuery) => {
|
||||
return await this.orderRepository.getOrdersByQuery(args)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ const offerExists = <Validator<{ offer: string }>>{
|
||||
validationFunc: (a: { offer: string }) => offers.has(a.offer),
|
||||
}
|
||||
|
||||
const isUuidv7 = <Validator<{ correlation_id?: string }>>{
|
||||
field: "correlation_id",
|
||||
const isUuidv7 = <Validator<{ uuid?: string }>>{
|
||||
field: "uuid",
|
||||
errorMsg: "El uuid no es un uuidv7 valido",
|
||||
validationFunc: (a) => a.correlation_id != undefined && a.correlation_id.length < 36
|
||||
validationFunc: (a) => a.uuid != undefined && a.uuid.length < 36
|
||||
}
|
||||
|
||||
const definedId = <Validator<{ id?: number }>>{
|
||||
@@ -73,7 +73,7 @@ export const iccidValidator = new BodyValidator<{ iccid: string }>(
|
||||
]
|
||||
)
|
||||
|
||||
export const uuidValidator = new BodyValidator<{ correlation_id?: string }>([
|
||||
export const uuidValidator = new BodyValidator<{ uuid?: string }>([
|
||||
isUuidv7
|
||||
])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user