Browse Source

(*)接口优化

master
peng.peng 2 years ago
parent
commit
da023b6679
  1. 25
      api/app/lib/controllers/latestMetadata/index.js

25
api/app/lib/controllers/latestMetadata/index.js

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

Loading…
Cancel
Save