Browse Source

维修处理上报 修改接口提交

master
peng.peng 2 years ago
parent
commit
7f5875172b
  1. 45
      api/app/lib/controllers/patrolManage/patrolRecord.js
  2. 8
      api/app/lib/routes/patrolManage/patrolRecord.js

45
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 = { module.exports = {
findPatrolRecord, findPatrolRecord,
addPatrolRecord, addPatrolRecord,
addPatrolRecordIssueHandle,
editPatrolRecordIssueHandle
} }

8
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 } app.fs.api.logAttr['POST/patrolRecord/add'] = { content: '新增巡检记录', visible: true }
router.post('/patrolRecord/add', patrolRecord.addPatrolRecord); 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))
}; };
Loading…
Cancel
Save