|
|
@ -169,7 +169,52 @@ async function addPatrolRecord(ctx, next) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 新建维修处理计划成功
|
|
|
|
function addPatrolRecordIssueHandle(opts) { |
|
|
|
return async function (ctx, next) { |
|
|
|
|
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
try { |
|
|
|
let rslt = ctx.request.body; |
|
|
|
await models.PatrolRecordIssueHandle.create(Object.assign({}, rslt)) |
|
|
|
ctx.status = 204; |
|
|
|
ctx.body = { message: '新建维修处理计划成功' } |
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { message: '新建修处理计划失败' } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 修改维修处理计划
|
|
|
|
function editPatrolRecordIssueHandle(opts) { |
|
|
|
return async function (ctx, next) { |
|
|
|
|
|
|
|
try { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const { id } = ctx.params; |
|
|
|
const body = ctx.request.body; |
|
|
|
await models.PatrolRecordIssueHandle.update( |
|
|
|
body, |
|
|
|
{ where: { id: id, } } |
|
|
|
) |
|
|
|
ctx.status = 204; |
|
|
|
ctx.body = { message: '修改维修处理计划成功' } |
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { message: '修改维修处理计划失败' } |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
|
findPatrolRecord, |
|
|
|
addPatrolRecord, |
|
|
|
addPatrolRecordIssueHandle, |
|
|
|
editPatrolRecordIssueHandle |
|
|
|
|
|
|
|
} |