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

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

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