From 7f5875172b1f28eb899257f8dda676e3ef6c62ee Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Mon, 27 Feb 2023 16:48:06 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=B4=E4=BF=AE=E5=A4=84=E7=90=86=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5=20=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/patrolManage/patrolRecord.js | 45 +++++++++++++++++++ .../lib/routes/patrolManage/patrolRecord.js | 8 ++++ 2 files changed, 53 insertions(+) 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