diff --git a/api/app/lib/controllers/patrolManage/patrolRecord.js b/api/app/lib/controllers/patrolManage/patrolRecord.js index 204177a..2f57216 100644 --- a/api/app/lib/controllers/patrolManage/patrolRecord.js +++ b/api/app/lib/controllers/patrolManage/patrolRecord.js @@ -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 + } \ No newline at end of file diff --git a/api/app/lib/routes/patrolManage/patrolRecord.js b/api/app/lib/routes/patrolManage/patrolRecord.js index 0e82885..376cad3 100644 --- a/api/app/lib/routes/patrolManage/patrolRecord.js +++ b/api/app/lib/routes/patrolManage/patrolRecord.js @@ -9,4 +9,12 @@ module.exports = function (app, router, opts) { app.fs.api.logAttr['POST/patrolRecord/add'] = { content: '新增巡检记录', visible: true } router.post('/patrolRecord/add', patrolRecord.addPatrolRecord); + + app.fs.api.logAttr['POST/patrolRecord/issue/handle'] = { content: '增加维修处理计划', visible: true }; + router.post('/patrolRecord/issue/handle', patrolRecord.addPatrolRecordIssueHandle(opts)) + + + // 修改维修处理计划 + app.fs.api.logAttr['PUT/patrolRecord/issue/handle/:id'] = { content: '修改维修处理计划', visible: true }; + router.put('/patrolRecord/issue/handle/:id', patrolRecord.editPatrolRecordIssueHandle(opts)) }; \ No newline at end of file