From f95677d503a26cfc8831d82a666b39300f59cb3d Mon Sep 17 00:00:00 2001 From: Alvar San Martin Date: Tue, 21 Apr 2026 12:50:54 +0200 Subject: [PATCH] Error pageNOS --- .../aplication/SimNOS.controller.ts | 29 ++++++++----------- .../aplication/SimNOS.usecases.ts | 5 +++- .../infrastructure/NosRepository.ts | 10 +++++-- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/packages/sim-consumidor-nos/aplication/SimNOS.controller.ts b/packages/sim-consumidor-nos/aplication/SimNOS.controller.ts index dfcf690..2e89350 100644 --- a/packages/sim-consumidor-nos/aplication/SimNOS.controller.ts +++ b/packages/sim-consumidor-nos/aplication/SimNOS.controller.ts @@ -136,10 +136,11 @@ export class SimNosController { console.log(usecaseRes) if (usecaseRes.error != undefined) { res.status(500).json(usecaseRes) + return; } else { res.send(usecaseRes.data) + return; } - return; } res.status(200).json(validateBody) @@ -149,29 +150,23 @@ export class SimNosController { public selectPageREST() { return async (req: Request, res: Response) => { - const { query } = req - const body = { - iccid: query.iccid as string + const { offset, limit, filter, orderBy } = req.query + const params = { + offset: (offset != undefined) ? Number(offset) : undefined, + limit: (limit != undefined) ? Number(limit) : undefined, + filter: (filter != undefined) ? String(filter) : undefined, + orderBy: (orderBy != undefined) ? String(orderBy) : undefined } - console.log("Evento page", body) - /* - const validateBody = iccidValidator.validate(body); + console.log("Evento page", params) - if (validateBody.error != undefined) { - res.status(402).json(validateBody) - return; - } - */ - const iccid: string | string[] = body.iccid - - console.log("ICCID", iccid) - - const usecaseRes = await this.uscases.selectPage({ iccid }) + const usecaseRes = await this.uscases.selectPage(params) if (usecaseRes.error != undefined) { res.status(500).json(usecaseRes) + return; } else { res.status(200).send(usecaseRes.data) + return; } res.status(200).json({ ok: "true" }) diff --git a/packages/sim-consumidor-nos/aplication/SimNOS.usecases.ts b/packages/sim-consumidor-nos/aplication/SimNOS.usecases.ts index aca4794..37b07fc 100644 --- a/packages/sim-consumidor-nos/aplication/SimNOS.usecases.ts +++ b/packages/sim-consumidor-nos/aplication/SimNOS.usecases.ts @@ -64,7 +64,10 @@ export class SimNosUsecases { } public async selectPage(args: { - + offset?: number, + limit?: number, + filter?: string, + orderBy?: string }) { const res = await this.nosRepository.getLinePage(args) return res diff --git a/packages/sim-consumidor-nos/infrastructure/NosRepository.ts b/packages/sim-consumidor-nos/infrastructure/NosRepository.ts index b6cc1b4..fe4f27c 100644 --- a/packages/sim-consumidor-nos/infrastructure/NosRepository.ts +++ b/packages/sim-consumidor-nos/infrastructure/NosRepository.ts @@ -52,6 +52,12 @@ export class NosRepository { } } + /** + * El metodo de NOS de paginar las lineas + * maximo por pagina 100, default 25 + * no devuelve el offset ni el numero de elementos restantes + * hay que llevar la cuenta + */ public async getLinePage(args: { limit?: number, offset?: number, @@ -62,8 +68,8 @@ export class NosRepository { const LIMIT = 100 const options = { - limit: LIMIT, - offset: 0, + limit: args.limit ?? LIMIT, + offset: args.offset ?? 0, filter: args.filter, orderBy: args.orderBy }