From 4658031c486f2ea16b1e1941eab1ef7a51c6da55 Mon Sep 17 00:00:00 2001 From: "huoyong.msb" Date: Thu, 19 Nov 2020 17:53:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20dev=20=E4=BF=AE=E5=A4=8D=E6=94=B9?= =?UTF-8?q?=E5=8A=A8=E8=BE=83=E5=A4=A7=E7=9A=84=E8=87=AA=E5=8A=A8=E5=A4=87?= =?UTF-8?q?=E4=BB=BD=EF=BC=8C=E5=BA=94=E5=A4=87=E4=BB=BD=E5=8E=9F=E5=A7=8B?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E8=80=8C=E4=B8=8D=E6=98=AF=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E7=8A=B6=E6=80=81=EF=BC=8C=E5=85=B6=E5=AE=83?= =?UTF-8?q?BUG=E4=BF=AE=E5=A4=8D=E7=AD=89=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/routes/repository.ts | 5 ++++- src/routes/utils/const.ts | 3 ++- src/service/migrate.ts | 2 +- src/service/redis.ts | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/routes/repository.ts b/src/routes/repository.ts index 5407adb..4a2f7c8 100644 --- a/src/routes/repository.ts +++ b/src/routes/repository.ts @@ -971,6 +971,7 @@ router.post('/properties/update', isLoggedIn, async (ctx, next) => { properties = Array.isArray(properties) ? properties : [properties] let itf = await Interface.findByPk(itfId) + if (!await AccessUtils.canUserAccess(ACCESS_TYPE.INTERFACE_SET, ctx.session.id, itfId)) { ctx.body = Consts.COMMON_ERROR_RES.ACCESS_DENY return @@ -1006,6 +1007,8 @@ router.post('/properties/update', isLoggedIn, async (ctx, next) => { const originalProperties = await Property.findAll({ where: { interfaceId: itfId } }) + const backupJSON = JSON.stringify({ "itf": itf, "properties": originalProperties }) + const deletedProperties = originalProperties.filter(x => existingPropertyIds.indexOf(x.id) === -1) const deletedPropertyLog: string[] = [] @@ -1082,7 +1085,7 @@ router.post('/properties/update', isLoggedIn, async (ctx, next) => { entityType: Consts.ENTITY_TYPE.INTERFACE, changeLog: `接口 ${itf.name}(${itf.url}) 参数变更: ${itfPropertiesChangeLog.join(LOG_SEPERATOR)}${needBackup ? ', 改动较大已备份数据。' : ''}`, userId: ctx.session.id, - ...needBackup ? { relatedJSONData: JSON.stringify({ "itf": itf, "properties": properties }) } : {}, + ...needBackup ? { relatedJSONData: backupJSON } : {}, }) } diff --git a/src/routes/utils/const.ts b/src/routes/utils/const.ts index 50689c9..be9d9d6 100644 --- a/src/routes/utils/const.ts +++ b/src/routes/utils/const.ts @@ -25,7 +25,8 @@ export enum ENTITY_TYPE { } export enum THEME_TEMPLATE_KEY { - RED = 'RED', // DEFAULT + INDIGO = 'INDIGO', // DEFAULT + RED = 'RED', BLACK = 'BLACK', BLUE = 'BLUE', GREEN = 'GREEN', diff --git a/src/service/migrate.ts b/src/service/migrate.ts index aa0924b..c2cc2e3 100644 --- a/src/service/migrate.ts +++ b/src/service/migrate.ts @@ -781,7 +781,7 @@ export default class MigrateService { const index = repository.modules.findIndex(item => { return ( item.id === mod.id && - item.interfaces.findIndex(it => (it.url || '').indexOf(url) >= 0) >= 0 + item.interfaces.findIndex(it => (it.url || '') === url) >= 0 ) // 已经存在接口 }) diff --git a/src/service/redis.ts b/src/service/redis.ts index 4ad2593..d175e46 100644 --- a/src/service/redis.ts +++ b/src/service/redis.ts @@ -13,7 +13,7 @@ export enum CACHE_KEY { } export const DEFAULT_CACHE_VAL = { - [CACHE_KEY.THEME_ID]: THEME_TEMPLATE_KEY.RED + [CACHE_KEY.THEME_ID]: THEME_TEMPLATE_KEY.INDIGO } export default class RedisService {