提交 0f2901b8 authored 作者: 钟是志's avatar 钟是志

加密函数剥离出来在最外层处理

上级 0878a4bc
......@@ -7,7 +7,6 @@
import { apiRequest } from '../request';
import { getOneStopConfig, isJSON } from '@/baseComponent/utils';
import { Base16Encode } from '@/webPublic/one_stop_public/Base16';
const giveValue = (x) => {
if (x && x.rows) {
......@@ -204,9 +203,6 @@ const handleAudit = (info) => {
};
const handleSqlData = (info) => {
if(info.sqlKey){
info.sqlKey = Base16Encode(info.sqlKey);
}
return apiRequest('/DataColumnApi/getSqlData', info).then((x) => {
if (x) {
return x;
......
import baseX from 'base-x';
import { connect } from 'dva';
var BASE16 = '0123456789abcdef';
var bs16 = baseX(BASE16);
......@@ -10,3 +10,87 @@ export function Base16Encode(value) {
if (is_open_base14) return value ? bs16.encode(new Buffer(value)) : null;
return value;
}
const giveKey = (key, datas) => {
if (datas && datas[key]) {
datas[key] = Base16Encode(datas[key]);
}
return datas;
};
export function giveBase16EnCode(datas, url) {
if (url) {
if (url.indexOf('DataColumnApi/getOptions') > -1) {
return giveKey('filterSql', datas);
}
if (url.indexOf('DataRightApi/add') > -1) {
return giveKey('filterSql', datas);
}
if (url.indexOf('DataRightApi/addBatch') > -1) {
return giveKey('filterSql', datas);
}
if (url.indexOf('DataColumnApi/getLabels') > -1) {
return giveKey('allValues', datas);
}
if (url.indexOf('DataColumnApi/getSqlOptions') > -1) {
return giveKey('allValues', datas);
}
if (url.indexOf('DataColumnApi/getSqlLabels') > -1) {
return giveKey('allValues', datas);
}
if (url.indexOf('DataColumnApi/getSqlData') > -1) {
datas = giveKey('allValues', datas);
return giveKey('sqlKey', datas);
}
if (url.indexOf('DataObjApi/add') > -1) {
return giveKey('sqlScript', datas);
}
if (url.indexOf('UserApi/getPage') > -1) {
return giveKey('addSignSql', datas);
}
if (url.indexOf('DataObjApi/getFormDataList') > -1) {
return giveKey('custom', datas);
}
if (url.indexOf('DataObjApi/getFormDataPage') > -1) {
datas = giveKey('custom', datas);
return giveKey('sql', datas);
}
if (url.indexOf('UnifiedAppFormApi/examineProcess') > -1) {
return giveKey('taskForm', datas);
}
if (url.indexOf('UnifiedAppFormApi/saveDraft') > -1) {
return giveKey('content', datas);
}
if (url.indexOf('UnifiedAppFormApi/startProcess') > -1) {
return giveKey('content', datas);
}
if (url.indexOf('UnifiedAppFormApi/startProcessByService') > -1) {
return giveKey('content', datas);
}
if (url.indexOf('UnifiedAppFormApi/getHandleUser') > -1) {
return giveKey('content', datas);
}
// if (url.indexOf('UnifiedServicePatternApi/updateForm') > -1) {
// return giveKey('content', datas);
// }
}
return datas;
}
......@@ -3,15 +3,6 @@ import {isJSON} from '@/webPublic/one_stop_public/copy';
import {uaaRequest} from '@/webPublic/one_stop_public/utils/request';
import {Modal, message, Spin} from 'antd';
import {deepCopy} from "@/webPublic/one_stop_public/utils/myutils";
import { Base16Encode } from '@/webPublic/one_stop_public/Base16';
let uaaRequestDiy = (url, data, options = {}) => {
if(data && data.sqlKey && url.indexOf('/DataColumnApi/getSqlData') > -1){
data.sqlKey = Base16Encode(data.sqlKey);
}
return uaaRequest(url, data, options = {});
}
export default function prepareShow(postData = {} , content = '') { // 模板挂载前执行的公式
let agg = deepCopy(postData);
......@@ -22,7 +13,7 @@ export default function prepareShow(postData = {} , content = '') { // 模板挂
let p = { // 函数参数
message,
Modal,
uaaRequest: uaaRequestDiy,
uaaRequest,
userNowInfo:
(isJSON(localStorage.getItem('user')) && JSON.parse(localStorage.getItem('user'))) ||
{},
......
......@@ -426,7 +426,7 @@ class TreeList extends React.Component {
window.removeEventListener('resize', this.resize);
}
custom = this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null;
custom = this.props.value ? JSON.stringify(this.props.value) : null;
componentWillReceiveProps(nextProps) {
const b = nextProps.value || {};
......@@ -442,7 +442,7 @@ class TreeList extends React.Component {
this.columns = nextProps.value.columns;
}
this.custom = Base16Encode(JSON.stringify(b));
this.custom = JSON.stringify(b);
if (nextProps.value.getPage) {
this.getPage(params, null, nextProps.value.getPage);
} else {
......@@ -588,7 +588,7 @@ class TreeList extends React.Component {
});
}
};
sqlBs16 = Base16Encode(this.props.sql);
sqlBs16 = this.props.sql;
getPage = (params, values, callPage, callback) => {
if (this.columns == null || this.columns.length == 0) {
return;
......
......@@ -398,18 +398,7 @@ class FormList extends React.Component {
window.removeEventListener('resize', this.resize);
}
custom = this.props.value ? Base16Encode(JSON.stringify(this.props.value)) : null;
// componentDidUpdate(prevProps, prevState) {
// console.log(this.props?.value?.columns, prevProps?.props?.value?.columns);
// if(this.props?.value && this.props?.value?.columns !== prevProps?.props?.value?.columns){
// if (Number(this.props.objCode) === 1) {
// this.initColumn();
// }
// }
// return null;
// }
custom = this.props.value ? JSON.stringify(this.props.value) : null;
componentWillReceiveProps(nextProps) {
const b = nextProps.value || {};
......@@ -419,7 +408,7 @@ class FormList extends React.Component {
const jsonb = JSON.stringify(b);
const jsona = JSON.stringify(a);
this.custom = Base16Encode(jsonb);
this.custom = jsonb;
if (jsona != jsonb) {
let params = {
pageNo: b.pageNo ? b.pageNo : 1,
......@@ -657,7 +646,7 @@ class FormList extends React.Component {
});
}
};
sqlBs16 = Base16Encode(this.props.sql);
sqlBs16 = this.props.sql;
getPage = (params, values, callPage, pageNo) => {
......
import { apiRequest } from '../utils/request';
import { Base16Encode } from '../Base16/index';
const api = '/DataColumnApi';
export default {
......@@ -72,9 +71,6 @@ export default {
if (callback) callback(response);
},
*getOptions({ payload, callback }, { call, put }) {
if (payload.filterSql) {
payload.filterSql = Base16Encode(payload.filterSql);
}
const response = yield call(apiRequest, api + '/getOptions', payload);
if (!response) {
yield put({ type: 'nom' });
......@@ -88,9 +84,6 @@ export default {
if (callback) callback(response);
},
*getLabels({ payload, callback }, { call, put }) {
if (payload.allValues) {
payload.allValues = Base16Encode(payload.allValues);
}
const response = yield call(apiRequest, api + '/getLabels', payload);
if (!response) {
yield put({ type: 'nom' });
......@@ -104,9 +97,6 @@ export default {
if (callback) callback(response);
},
*getSqlOptions({ payload, callback }, { call, put }) {
if (payload.allValues) {
payload.allValues = Base16Encode(payload.allValues);
}
const response = yield call(apiRequest, api + '/getSqlOptions', payload);
if (!response) {
yield put({ type: 'nom' });
......@@ -120,9 +110,6 @@ export default {
if (callback) callback(response);
},
*getSqlLabels({ payload, callback }, { call, put }) {
if (payload.allValues) {
payload.allValues = Base16Encode(payload.allValues);
}
const response = yield call(apiRequest, api + '/getSqlLabels', payload);
if (!response) {
......@@ -137,12 +124,7 @@ export default {
if (callback) callback(response);
},
*getSqlData({ payload, callback }, { call, put }) {
if (payload.sqlKey) {
payload.sqlKey = Base16Encode(payload.sqlKey);
}
if (payload.allValues) {
payload.allValues = Base16Encode(payload.allValues);
}
const response = yield call(apiRequest, api + '/getSqlData', payload);
if (!response) {
yield put({ type: 'nom' });
......
import { apiRequest } from '../utils/request';
const api = '/DataObjApi';
import { Base16Encode } from '../Base16/index';
export default {
namespace: 'DataObj',
......@@ -148,9 +145,6 @@ export default {
if (callback) callback(response);
},
*add({ payload, callback }, { call, put }) {
if (payload.sqlScript) {
payload.sqlScript = Base16Encode(payload.sqlScript);
}
const response = yield call(apiRequest, api + '/add', payload);
if (!response) {
yield put({ type: 'nom' });
......
import { apiRequest } from '../utils/request';
import { Base16Encode } from '../Base16/index';
const api = '/DataRightApi';
......@@ -19,9 +18,6 @@ export default {
if (callback) callback();
},
*add({ payload, callback }, { call, put }) {
if (payload.filterSql) {
payload.filterSql = Base16Encode(payload.filterSql);
}
const response = yield call(apiRequest, api + '/add', payload);
if (!response) {
yield put({ type: 'nom' });
......@@ -35,9 +31,6 @@ export default {
if (callback) callback(response);
},
*addBatch({ payload, callback }, { call, put }) {
if (payload.filterSql) {
payload.filterSql = Base16Encode(payload.filterSql);
}
const response = yield call(apiRequest, api + '/addBatch', payload);
if (!response) {
yield put({ type: 'nom' });
......
......@@ -4,7 +4,6 @@
* 事务相关接口
*/
import { uaaRequest } from '../utils/request';
import { Base16Encode } from '../Base16/index';
import prepareShow from "@/webPublic/one_stop_public/Table/prepareShow";
import {deepCopy} from "@/webPublic/one_stop_public/utils/myutils";
......@@ -125,9 +124,6 @@ const myCollect = {
* @param {examineMap} 审核内容
*/
*getExamineProcess({ payload, callback }, { call, put }) {
if (payload.taskForm) {
payload.taskForm = Base16Encode(payload.taskForm);
}
let response = yield call(uaaRequest, `${api}/examineProcess`, {
...payload,
});
......@@ -198,9 +194,6 @@ const myCollect = {
* @param {title} 表单标题
*/
*saveDraft({ payload, callback }, { call, put }) {
if (payload.content) {
payload.content = Base16Encode(payload.content);
}
const response = yield call(uaaRequest, `${api}/saveDraft`, {
...payload,
});
......@@ -220,9 +213,6 @@ const myCollect = {
* @param {title} 表单标题
*/
*startProcess({ payload, callback }, { call, put }) {
if (payload.content) {
payload.content = Base16Encode(payload.content);
}
const response = yield call(uaaRequest, `${api}/startProcess`, {
...payload,
});
......@@ -235,9 +225,6 @@ const myCollect = {
}
},
*startProcessByService({ payload, callback }, { call, put }) {
if (payload.content) {
payload.content = Base16Encode(payload.content);
}
const response = yield call(uaaRequest, `${api}/startProcessByService`, {
...payload,
});
......@@ -250,9 +237,6 @@ const myCollect = {
}
},
*getHandleUser({ payload, callback }, { call, put }) {
if (payload.content) {
payload.content = Base16Encode(payload.content);
}
const response = yield call(uaaRequest, `${api}/getHandleUser`, {
...payload,
});
......
......@@ -51,7 +51,7 @@ import { extend } from 'umi-request';
import Highlighter from 'react-highlight-words';
import Signature from '../Signature';
import { changeToDraftState, deepCopy, preHandle } from '../utils/myutils';
import { Base16Encode } from '../Base16/index';
import { giveBase16EnCode } from '../Base16/index';
import { getToken } from '../utils/token';
import { formulaList } from '../excelInitFuc/functionList';
import FilePreview from '../filePreview';
......@@ -452,7 +452,7 @@ export default class tableCom extends Component {
dispatch({
type: 'DataColumn/getSqlData',
payload: { sqlKey: Base16Encode(sqlKey), allValues },
payload: { sqlKey, allValues },
callback: list => {
const x = {
list: list,
......@@ -904,12 +904,11 @@ export default class tableCom extends Component {
...this.props.defaultValues[this.props.formKey],
...options,
});
const pp = { sqlKey: Base16Encode(sqlKey), params, allValues: Base16Encode(allValues) };
let pp = { sqlKey, params, allValues, };
if (getToken() != null) {
pp.token = getToken();
}
console.log(pp, '0000002222');
pp = giveBase16EnCode(pp, url);
umiRequest(url, {
data: pp,
......
......@@ -14,7 +14,7 @@ import {
import { openToast } from '../location/Notification';
import { showToast } from '../location/Toast';
import { offline } from '../location/Toast';
import { Base16Encode } from "@/webPublic/one_stop_public/Base16";
import { giveBase16EnCode } from "@/webPublic/one_stop_public/Base16";
const codeMessage = {
200: '服务器成功返回请求的数据。',
......@@ -117,6 +117,8 @@ const loginUmiRequest = extend({
const getUrl = url => (url.startsWith('/') ? url : '/' + url);
export const request = (url, data, options = {}) => {
data = giveBase16EnCode(url, data);
let version =
localStorage.getItem('version') && localStorage.getItem('version') !== 'undefined'
? JSON.parse(localStorage.getItem('version'))
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论