Error pageNOS
This commit is contained in:
@@ -136,10 +136,11 @@ export class SimNosController {
|
|||||||
console.log(usecaseRes)
|
console.log(usecaseRes)
|
||||||
if (usecaseRes.error != undefined) {
|
if (usecaseRes.error != undefined) {
|
||||||
res.status(500).json(usecaseRes)
|
res.status(500).json(usecaseRes)
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
res.send(usecaseRes.data)
|
res.send(usecaseRes.data)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).json(validateBody)
|
res.status(200).json(validateBody)
|
||||||
@@ -149,29 +150,23 @@ export class SimNosController {
|
|||||||
|
|
||||||
public selectPageREST() {
|
public selectPageREST() {
|
||||||
return async (req: Request, res: Response) => {
|
return async (req: Request, res: Response) => {
|
||||||
const { query } = req
|
const { offset, limit, filter, orderBy } = req.query
|
||||||
const body = {
|
const params = {
|
||||||
iccid: query.iccid as string
|
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)
|
console.log("Evento page", params)
|
||||||
/*
|
|
||||||
const validateBody = iccidValidator.validate(body);
|
|
||||||
|
|
||||||
if (validateBody.error != undefined) {
|
const usecaseRes = await this.uscases.selectPage(params)
|
||||||
res.status(402).json(validateBody)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
const iccid: string | string[] = body.iccid
|
|
||||||
|
|
||||||
console.log("ICCID", iccid)
|
|
||||||
|
|
||||||
const usecaseRes = await this.uscases.selectPage({ iccid })
|
|
||||||
|
|
||||||
if (usecaseRes.error != undefined) {
|
if (usecaseRes.error != undefined) {
|
||||||
res.status(500).json(usecaseRes)
|
res.status(500).json(usecaseRes)
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
res.status(200).send(usecaseRes.data)
|
res.status(200).send(usecaseRes.data)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).json({ ok: "true" })
|
res.status(200).json({ ok: "true" })
|
||||||
|
|||||||
@@ -64,7 +64,10 @@ export class SimNosUsecases {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async selectPage(args: {
|
public async selectPage(args: {
|
||||||
|
offset?: number,
|
||||||
|
limit?: number,
|
||||||
|
filter?: string,
|
||||||
|
orderBy?: string
|
||||||
}) {
|
}) {
|
||||||
const res = await this.nosRepository.getLinePage(args)
|
const res = await this.nosRepository.getLinePage(args)
|
||||||
return res
|
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: {
|
public async getLinePage(args: {
|
||||||
limit?: number,
|
limit?: number,
|
||||||
offset?: number,
|
offset?: number,
|
||||||
@@ -62,8 +68,8 @@ export class NosRepository {
|
|||||||
|
|
||||||
const LIMIT = 100
|
const LIMIT = 100
|
||||||
const options = {
|
const options = {
|
||||||
limit: LIMIT,
|
limit: args.limit ?? LIMIT,
|
||||||
offset: 0,
|
offset: args.offset ?? 0,
|
||||||
filter: args.filter,
|
filter: args.filter,
|
||||||
orderBy: args.orderBy
|
orderBy: args.orderBy
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user