|
@ -43,6 +43,37 @@ async function edit (ctx, next) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function get (ctx) { |
|
|
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
|
|
try { |
|
|
|
|
|
const { limit, offset, orderBy, orderDirection } = ctx.query |
|
|
|
|
|
let findOption = { |
|
|
|
|
|
order: [ |
|
|
|
|
|
[orderBy || 'id', orderDirection || 'DESC'] |
|
|
|
|
|
] |
|
|
|
|
|
} |
|
|
|
|
|
if (limit) { |
|
|
|
|
|
findOption.limit = limit |
|
|
|
|
|
} |
|
|
|
|
|
if (offset) { |
|
|
|
|
|
findOption.offset = offset |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const res = await models.Nvr.findAll(findOption) |
|
|
|
|
|
const total = await models.Nvr.count() |
|
|
|
|
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
|
|
|
ctx.body = { |
|
|
|
|
|
total: total, |
|
|
|
|
|
data: res |
|
|
|
|
|
} |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
|
|
ctx.status = 400; |
|
|
|
|
|
ctx.body = {} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async function del (ctx, next) { |
|
|
async function del (ctx, next) { |
|
|
try { |
|
|
try { |
|
|
const models = ctx.fs.dc.models; |
|
|
const models = ctx.fs.dc.models; |
|
@ -64,5 +95,6 @@ async function del (ctx, next) { |
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|
edit, |
|
|
edit, |
|
|
|
|
|
get, |
|
|
del, |
|
|
del, |
|
|
}; |
|
|
}; |