From 467aa7ce2ea720e0bcd749aacb619c08978922a1 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 11 Aug 2022 09:34:32 +0800 Subject: [PATCH] app check --- .../app/lib/controllers/application/index.js | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/code/VideoAccess-VCMP/api/app/lib/controllers/application/index.js b/code/VideoAccess-VCMP/api/app/lib/controllers/application/index.js index 3e363ba..4295123 100644 --- a/code/VideoAccess-VCMP/api/app/lib/controllers/application/index.js +++ b/code/VideoAccess-VCMP/api/app/lib/controllers/application/index.js @@ -3,6 +3,32 @@ const fs = require('fs'); const moment = require('moment') const uuid = require('uuid'); +async function check (ctx) { + try { + const { models } = this.fs.dc; + const { appKey, appSecret } = this.request.body; + const existRes = await models.Application.findOne({ + where: { + appKey: appKey, + appSecret: appSecret, + } + }) + if (!existRes) { + throw '应用不存在' + } else if (existRes.forbidden) { + throw '应用已被禁用' + } + ctx.status = 204; + } catch (error) { + ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); + ctx.status = 400; + ctx.body = + typeof error == 'string' ? { + message: error + } : error + } +} + async function edit (ctx, next) { let errMsg = '创建应用失败' const transaction = await ctx.fs.dc.orm.transaction(); @@ -21,7 +47,7 @@ async function edit (ctx, next) { transaction }) } else { - + // 添加 const storageData = Object.assign({}, data, { appKey: uuid.v4(), @@ -51,6 +77,7 @@ async function edit (ctx, next) { module.exports = { + check, edit, get, }; \ No newline at end of file