pull/275/head
Bosn 7 years ago
parent 314c3a303e
commit 96181a6d5a

@ -549,6 +549,43 @@ router.post('/interface/update', async (ctx, next) => {
})
})
router.post('/interface/move', async (ctx) => {
const OP_MOVE = 1
const OP_COPY = 2
const { modId, itfId, op } = ctx.request.body
const itf = await Interface.findById(itfId)
if (op === OP_MOVE) {
itf.moduleId = modId
await itf.save()
} else if (op === OP_COPY) {
const { id, name, ...otherProps } = itf.dataValues
const newItf = await Interface.create({
name: name + '副本',
...otherProps,
moduleId: modId,
})
const properties = await Property.findAll({
where: {
interfaceId: itf.id,
}
})
for (const property of properties) {
const { id, ...props } = property.dataValues
await Property.create({
...props,
interfaceId: newItf.id,
moduleId: modId,
})
}
}
ctx.body = {
data: {
isOk: true,
}
}
})
router.get('/interface/remove', async (ctx, next) => {
let { id } = ctx.query
let result = await Interface.destroy({ where: { id } })

Loading…
Cancel
Save