Error pageNOS
This commit is contained in:
@@ -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" })
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user