gxd-vue-library
Version:
依赖与element Ui插件库,聚福宝福利PC端插件库
119 lines (108 loc) • 3.36 kB
JavaScript
;
const basePath = require('./../path');
const fileHelper = require('./../fileHepler');
//获取用户自动配置map关系表
let config = {};
if(fileHelper.existFileSync(basePath.mapConfig)) {
config = require(basePath.mapConfig)
}
/**
* http://47.105.217.240:9520/doc-view-2.html
* @description 返回对应方法
* @type {{}}
*/
const methodMap = {
'create': 'POST',
'update': 'POST',
'delete': 'POST',
'get': 'GET',
'list':'GET',
'batchDelete': 'POST',
'batchUpdate': 'POST',
'download': 'GET',
'options' : 'GET',
'sort': 'POST',
'enable': 'POST',
'disable': 'POST',
'tree': 'GET',
'children': 'GET',
"updateColumns": 'POST'
};
/**
* http://47.105.217.240:9520/doc-view-2.html
* @description 设置请求参数发送类型
* @type {{}}
*/
const methodMapFormType = {
'create': 'application/json; charset=UTF-8',
'update': 'application/json; charset=UTF-8',
'delete': 'application/json; charset=UTF-8',
'get': 'application/json; charset=UTF-8',
'list':'application/json; charset=UTF-8',
'batchDelete': 'application/json; charset=UTF-8',
'batchUpdate': 'application/json; charset=UTF-8',
'download': 'application/json; charset=UTF-8',
'options' : 'application/json; charset=UTF-8',
'sort': 'application/json; charset=UTF-8',
'enable': 'application/json; charset=UTF-8',
'disable': 'application/json; charset=UTF-8',
'tree': 'application/json; charset=UTF-8',
'children': 'application/json; charset=UTF-8',
"updateColumns": 'application/json; charset=UTF-8'
};
/**
* @description 接口描述
* @type {{}}
*/
const methodTitleMap = {
'create': '新增@title@记录',
'update': '更新@title@记录(单条)',
'delete': '删除@title@记录(单条)',
'get': '获取@title@记录',
'list': '获取@title@列表记录',
'batchDelete': '批量删除@title@记录(多条)',
'batchUpdate': '批量更新@title@记录(多条)',
'download': '下载@title@记录',
'options': '获取@title@选项卡数据',
'sort': '更新@title@记录排序',
'enable': '更新@title@记录开启',
'disable': '更新@title@记录禁用',
'tree': '获取@title@树列表',
'children': '获取@title@子级列表',
"updateColumns": '更新@title@记录部分字段'
};
/**
* @description 接口对了的路径配置
* @type {{}}
*/
const methodPathMap = {
'create': '/create',
'update': '/update',
'delete': '/delete',
'get': '/get',
'list': '/list',
'batchDelete': '/batch-delete',
'batchUpdate': '/batch-update',
'download': '/download',
'options': '/options',
'sort': '/sort',
'enable': '/enable',
'disable': '/disable',
'tree': '/tree',
'children': '/children',
'updateColumns': '/update-columns',
};
/**
* @description 默认form参数格式类型
* @type {string}
*/
const defaultFormType = 'application/x-www-form-urlencoded; charset=UTF-8';
module.exports = {
methodMap: config.methodMap || methodMap ,
methodTitleMap: config.methodMap || methodTitleMap,
methodPathMap: config.methodPathMap || methodPathMap,
resultKey: config.resultKey === undefined ? 'result' : config.resultKey,
formType: Object.assign({},methodMapFormType, config.formType || {} ),
defaultFormType: config.defaultFormType || defaultFormType,
newMapRule: config.newMapRule || false, //是否启动新规则创建方法名字
};