|
@ -75,12 +75,24 @@ function editModelManagement(opts) { |
|
|
const models = ctx.fs.dc.models; |
|
|
const models = ctx.fs.dc.models; |
|
|
const { id } = ctx.params; |
|
|
const { id } = ctx.params; |
|
|
const body = ctx.request.body; |
|
|
const body = ctx.request.body; |
|
|
await models.MetaModel.update( |
|
|
let modelFind = await models.MetaModel.findOne({ where: { id: id } }); |
|
|
body, |
|
|
const { attributeName, attributeCode } = ctx.request.body; |
|
|
{ where: { id: id, } } |
|
|
const { modelType } = modelFind; |
|
|
) |
|
|
const checkName = await models.MetaModel.findOne({ where: { id: { $not: id }, attributeName, modelType } }); |
|
|
ctx.status = 204; |
|
|
const checkCode = await models.MetaModel.findOne({ where: { id: { $not: id }, attributeCode, modelType } }); |
|
|
ctx.body = { message: '修改模型成功' } |
|
|
if (checkName || checkCode) { |
|
|
|
|
|
ctx.status = 400; |
|
|
|
|
|
ctx.body = { message: checkName ? '该属性名称已存在' : "该属性代码已存在" } |
|
|
|
|
|
} else { |
|
|
|
|
|
await models.MetaModel.update( |
|
|
|
|
|
body, |
|
|
|
|
|
{ where: { id: id, } } |
|
|
|
|
|
) |
|
|
|
|
|
ctx.status = 204; |
|
|
|
|
|
ctx.body = { message: '修改模型成功' } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.status = 400; |
|
|
ctx.status = 400; |
|
|