|
|
@ -113,21 +113,21 @@ function deleteOrganization(opts) { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const { id } = ctx.params; |
|
|
|
|
|
|
|
// const checkName1 = await models.MetadataDatabase.findOne({ where: { createBy: id } });
|
|
|
|
// const checkName2 = await models.MetadataFile.findOne({ where: { createBy: id } });
|
|
|
|
const checkName1 = await models.User.findOne({ where: { orgId: id } }); |
|
|
|
const checkName2 = await models.ResourceCatalog.findOne({ where: { orgId: id } }); |
|
|
|
// const checkName3 = await models.MetadataRestapi.findOne({ where: { createBy: id } });
|
|
|
|
// if (checkName1 || checkName2 || checkName3) {
|
|
|
|
// ctx.status = 400;
|
|
|
|
// ctx.body = { message: '该机构下存在依赖资源无法删除!' }
|
|
|
|
// } else {
|
|
|
|
await models.Organization.destroy({ |
|
|
|
where: { |
|
|
|
id: id |
|
|
|
} |
|
|
|
}) |
|
|
|
ctx.status = 204; |
|
|
|
ctx.body = { message: '删除机构成功' } |
|
|
|
// }
|
|
|
|
if (checkName1 || checkName2) { |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { message: '该机构下存在依赖资源无法删除!' } |
|
|
|
} else { |
|
|
|
await models.Organization.destroy({ |
|
|
|
where: { |
|
|
|
id: id |
|
|
|
} |
|
|
|
}) |
|
|
|
ctx.status = 204; |
|
|
|
ctx.body = { message: '删除机构成功' } |
|
|
|
} |
|
|
|
|
|
|
|
} catch (error) { |
|
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
|