|
|
@ -221,23 +221,35 @@ async function banned (ctx) { |
|
|
|
} |
|
|
|
|
|
|
|
async function del (ctx) { |
|
|
|
const transaction = await ctx.fs.dc.orm.transaction(); |
|
|
|
try { |
|
|
|
const { models } = ctx.fs.dc; |
|
|
|
const { cameraId } = ctx.query |
|
|
|
const { cameraId } = ctx.params |
|
|
|
const { token } = ctx.fs.api |
|
|
|
|
|
|
|
await models.cameraId.destroy({ |
|
|
|
await models.CameraAbilityBind.destroy({ |
|
|
|
where: { |
|
|
|
cameraId: cameraId |
|
|
|
}, |
|
|
|
transaction |
|
|
|
}) |
|
|
|
|
|
|
|
await models.Camera.destroy({ |
|
|
|
where: { |
|
|
|
id: cameraId |
|
|
|
} |
|
|
|
}, |
|
|
|
transaction |
|
|
|
}) |
|
|
|
|
|
|
|
if (cameraId.length) { |
|
|
|
await ctx.app.fs.axyRequest.delete('vcmp/camera/project', { query: { token, cameraId: cameraId.join(',') } }) |
|
|
|
|
|
|
|
if (cameraId) { |
|
|
|
await ctx.app.fs.axyRequest.delete('vcmp/camera/project', { query: { token, cameraId: cameraId } }) |
|
|
|
} |
|
|
|
|
|
|
|
await transaction.commit(); |
|
|
|
ctx.status = 204; |
|
|
|
} catch (error) { |
|
|
|
await transaction.rollback(); |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = {} |
|
|
|