From da023b667951a762d032edc5e354ccdac4fa1188 Mon Sep 17 00:00:00 2001 From: "peng.peng" Date: Thu, 29 Jun 2023 08:59:48 +0800 Subject: [PATCH] =?UTF-8?q?=EF=BC=88*=EF=BC=89=E6=8E=A5=E5=8F=A3=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/controllers/latestMetadata/index.js | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/api/app/lib/controllers/latestMetadata/index.js b/api/app/lib/controllers/latestMetadata/index.js index 350c725..cb7ef07 100644 --- a/api/app/lib/controllers/latestMetadata/index.js +++ b/api/app/lib/controllers/latestMetadata/index.js @@ -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) {