|
|
@ -529,21 +529,20 @@ async function postMetadataResourceApplications(ctx) { |
|
|
|
try { |
|
|
|
const { resourceName, applyBy, resourceType, resourceId } = ctx.request.body; |
|
|
|
if (!resourceName || !applyBy || !resourceType || !resourceId) { |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { message: '参数不全,请重新申请资源' } |
|
|
|
} else { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const postOne = await models.ResourceConsumption.findOne({ |
|
|
|
where: { applyBy: applyBy, resourceName: resourceName, resourceId, resourceType, approve_remarks: null } |
|
|
|
}); |
|
|
|
if (postOne) { |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { message: '参数不全,请重新申请资源' } |
|
|
|
ctx.body = { message: '该用户已申请过该元数据资源' } |
|
|
|
} else { |
|
|
|
const models = ctx.fs.dc.models; |
|
|
|
const postOne = await models.ResourceConsumption.findOne({ |
|
|
|
where: { applyBy: applyBy, resourceName: resourceName, resourceId, resourceType, approve_remarks: null } |
|
|
|
}); |
|
|
|
if (postOne) { |
|
|
|
ctx.status = 400; |
|
|
|
ctx.body = { message: '该用户已申请过该元数据资源' } |
|
|
|
} else { |
|
|
|
await models.ResourceConsumption.create({ applyAt: moment(), approveState: '审批中', ...ctx.request.body }); |
|
|
|
ctx.body = { message: '申请资源成功' } |
|
|
|
ctx.status = 200; |
|
|
|
} |
|
|
|
await models.ResourceConsumption.create({ applyAt: moment(), approveState: '审批中', ...ctx.request.body }); |
|
|
|
ctx.body = { message: '申请资源成功' } |
|
|
|
ctx.status = 200; |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (error) { |
|
|
|