feat: dev 修复改动较大的自动备份,应备份原始状态而不是修改后的状态,其它BUG修复等等

pull/781/head
huoyong.msb 4 years ago
parent 10b1cb3abd
commit 4658031c48

@ -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 } : {},
})
}

@ -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',

@ -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
) // 已经存在接口
})

@ -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 {

Loading…
Cancel
Save