提交 2d109825 authored 作者: ch's avatar ch

加密前调接口获取替换key

上级 4bd25459
import baseX from 'base-x'; import baseX from 'base-x';
import { isEmpty, template } from 'lodash';
import { apiRequest } from '../utils/request';
var BASE16 = '0123456789abcdef'; var BASE16 = '0123456789abcdef';
var bs16 = baseX(BASE16); var bs16 = baseX(BASE16);
...@@ -27,18 +28,23 @@ const encryptApiList = [ ...@@ -27,18 +28,23 @@ const encryptApiList = [
{ {
api: 'DataColumnApi/getLabels', api: 'DataColumnApi/getLabels',
key: ['allValues'], key: ['allValues'],
query: true,
setNull: true,
}, },
{ {
api: 'DataColumnApi/getSqlOptions', api: 'DataColumnApi/getSqlOptions',
key: ['allValues'], key: ['allValues'],
query: true,
}, },
{ {
api: 'DataColumnApi/getSqlLabels', api: 'DataColumnApi/getSqlLabels',
key: ['allValues'], key: ['allValues'],
query: true,
}, },
{ {
api: 'DataColumnApi/getSqlData', api: 'DataColumnApi/getSqlData',
key: ['allValues', 'sqlKey'], key: ['allValues', 'sqlKey'],
query: true,
}, },
{ {
api: 'DataRightApi/add', api: 'DataRightApi/add',
...@@ -85,14 +91,39 @@ const encryptApiList = [ ...@@ -85,14 +91,39 @@ const encryptApiList = [
key: ['content'], key: ['content'],
}, },
] ]
export async function giveBase16EnCode(datas, url) { // 全局加解密函数.
export function giveBase16EnCode(datas, url) { // 全局加解密函数.
if (url && typeof url === 'string') { if (url && typeof url === 'string') {
for(let item of encryptApiList){ for (let item of encryptApiList) {
if(url.indexOf(item.api) > -1){ if (url.indexOf(item.api) > -1) {
for(let g of item.key){ for (let g of item.key) {
if (g == "allValues") {
if (item.setNull) {
datas.allValues = "{}";
} else {
if (item.query) {
if (datas.sqlKey.length < 13) {
const response = await apiRequest("/SqlManageEntityApi/findParamsKey", { sqlKey: datas.sqlKey });
if (response.length == 0) {
datas.allValues = "{}";
} else {
const x = JSON.parse(allValues);
const y = {};
for (var i in response) {
if (x[i]) {
y[i] = x[i]
}
datas.allValues = JSON.stringify(y);
}
}
} else {
datas.allValues = "{}";
}
}
}
datas = giveKey(g, datas); datas = giveKey(g, datas);
} }
}
return datas; return datas;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论