Authored by weiqingting

融合 4.7 部分

Too many changes to show.

To preserve performance only 10 of 10+ files are displayed.

... ... @@ -2,29 +2,29 @@ var request = require('request');
var _ = require('lodash');
var fs = require('fs');
var Iaccount=global.Register.system;
var Iaccount = global.Register.system;
var Utils={
createrMenus:function(data){
var Utils = {
createrMenus: function (data) {
var menu = [];
for(var key in data){
var v=data[key];
var item = {
title:v.menu_name,
for (var key in data) {
var v = data[key];
var item = {
title: v.menu_name,
}
if(v.parent_id === "0") {
if (v.parent_id === "0") {
item.parent = 'menu-template';
var itemSubs = [];
_.forEach(v.sub,function(val) {
_.forEach(v.sub, function (val) {
var sub = {
title:val.menu_name,
href:val.menu_url,
title: val.menu_name,
href: val.menu_url,
icon: 'list-alt'
}
itemSubs.push(sub);
});
item.menu = itemSubs;
}
menu.push(item);
... ... @@ -33,118 +33,105 @@ var Utils={
}
}
module.exports={
namespace:"common",
apis:{
login:function(req,callback){
var user = req.body.user;
var password = req.body.password;
var userInfo = {},result={code:400,message:"登录失败"};
//调用登陆
console.log(Iaccount.login);
return request.post({
url: Iaccount.login,
form:'["'+user+'","'+password+'",'+Iaccount.WEBSITE+']'
},function(error, httpResponse, rebody){
if (!error && httpResponse.statusCode == 200) {
var userData = JSON.parse(rebody).data;
console.log("登录接口成功");
userInfo = {
auth: userData,
uid: userData.pid,
name: userData.truename
};
//调用菜单
request.post({
url: Iaccount.getResourceByPid,
form: '[' + userData.pid + ',' + userData.role_id + ',' + Iaccount.WEBSITE + ']'
}, function (error1, httpResponse1, rebody1) {
if (!error1 && httpResponse1.statusCode == 200) {
userInfo.menu = Utils.createrMenus(JSON.parse(rebody1).data);
console.log("调用菜单成功,开始调用权限:"+Iaccount.allRight);
//调用权限
request.post({
url: Iaccount.allRight,
form: '[false]'
}, function (error2, httpResponse2, rebody2) {
console.log("调用权限");
if (!error2 && httpResponse2.statusCode == 200&&rebody2) {
userInfo.right = {};
JSON.parse(rebody2).data.forEach(function (data) {
if (data.platform_id == Iaccount.WEBSITE) {
userInfo.right[data.path] = true;
}
});
//获取店铺
console.log("店铺URL:"+Iaccount.getShopList);
request.post({
'url': Iaccount.getShopList,
'headers': {
"x-user-id": userInfo.uid
}
}, function (error3, httpResponse3, rebody3) {
console.log("获取店铺");
if (!error3 && httpResponse3.statusCode == 200) {
userInfo.shopList = [];
if (JSON.parse(rebody3).data) {
JSON.parse(rebody3).data.forEach(function (data, index) {
if (!index) {
userInfo.auth.shopName = data.shopName;
userInfo.auth.shopId = data.shopsId;
}
userInfo.shopList.push({
name: data.shopName,
id: data.shopsId
});
});
} else {
result = { code: 400, message: "该用户没有店铺" };
}
/*保存session 成功*/
req.session.user = userInfo;
console.log("保存session 成功");
request.post({
'url': Iaccount.url+'/login/sessions',
form: {
'account': user,
'password': password,
'refer': '%2Faccount%2Fprofile%2Fdisplay'
}
}, function (error4, httpResponse4, rebody4) {
if (!error4) {
var cookie = httpResponse4.caseless.dict["set-cookie"];
if (cookie && cookie.length > 0) {
req.session.gray = cookie[0];
}
result = { code: 200, message: "登录成功" }
return callback(null, result);
} else {
return callback(null, result);
}
});
} else {
console.log(error3);
return callback(null, result);
}
});
} else {
return callback(null, result);
}
module.exports = {
namespace: "common",
apis: {
Ilogin: {
title:'登录接口',
url: Iaccount.login,
form: '["{{user}}","{{password}}",{{website}}]',
params: {
user: { type: String },
password: { type: String },
website: {type:Number,default: Iaccount.WEBSITE}
}
},
getResourceByPid: {
title:'菜单接口',
url: Iaccount.getResourceByPid,
form: '[{{pid}},{{role_id}},{{website}}]',
params: {
pid: { type: Number },
role_id: { type: Number },
website: { type: Number, default: Iaccount.WEBSITE }
}
},
allRight: {
title: '获取权限',
url: Iaccount.allRight,
form: '[false]'
},
getShopList: {
title:'获取当前用户所有店铺',
url: Iaccount.getShopList,
form:true,
headers: {
"x-user-id": {type:Number}
}
},
sessionAsync: {
title:'与老系统session同步',
url: Iaccount.url + '/login/sessions',
outobj: "response",
form: {'account':'{{user}}','password':'{{password}}','refer': '%2Faccount%2Fprofile%2Fdisplay'},
params: {
user: { type: String },
password: { type: String }
}
},
login: function (req, callback, common) {
var userInfo = {},result = { code: 400, message: "登录失败" },isSuccess=false;
var user = req.body.user;
var password = req.body.password;
var errcallback = function (err) {
return callback(null, result);
}
common.Ilogin(user, password).allRight().sessionAsync(user, password).done(function (IloginRes,allRes,sesRes) {
var userData = IloginRes.data, cookie = sesRes.caseless.dict["set-cookie"];
userInfo = { auth: userData, uid: userData.pid, name: userData.truename, right: {},shopList:[]};
allRes.data.forEach(function (data) {
if (data.platform_id == Iaccount.WEBSITE) {
userInfo.right[data.path] = true;
}
});
common.getResourceByPid(userData.pid, userData.role_id)
.getShopList({ "@x-user-id": userInfo.uid }).done(function (getRRes, shopRes) {
userInfo.menu = Utils.createrMenus(getRRes.data);
if (shopRes.data) {
shopRes.data.forEach(function (data, index) {
if (!index) {
userInfo.auth.shopName = data.shopName;
userInfo.auth.shopId = data.shopsId;
}
userInfo.shopList.push({
name: data.shopName,
id: data.shopsId
});
} else {
return callback(null, result);
});
req.session.user = userInfo;
if (cookie && cookie.length > 0) {
req.session.gray = cookie[0];
result = { code: 200, message: "登录成功" };
}
});
} else {
} else {
result = { code: 400, message: "该用户没有店铺" };
}
return callback(null, result);
}
});
},
gray: function (req, callback){
},errcallback);
}, errcallback);
},
isUsedMenuAuth:{
title:'检查有没有权限',
url:Iaccount.isUsedMenuAuth,
form:'[{{pid}},{{role_id}},"{{path}}","","",' + Iaccount.WEBSITE + ']',
params:{
pid:{type:Number},
role_id:{type:Number},
path:{type:String}
}
},
gray: function (req, callback,common) {
var result = { code: 400, message: "没有权限" };
if (req.session && req.session.user) {
var user = req.session.user;
... ... @@ -157,30 +144,38 @@ module.exports={
'x-shop-id': user.auth.shopId
};
if (path && user.right[path]) {
request({
url: Iaccount.isUsedMenuAuth,
method: 'POST',
form: '[' + user.auth.pid + ',' + user.auth.role_id + ', "' + path + '", "", "", ' + Iaccount.WEBSITE + ']'
}, function (error, httpResponse, rebody) {
if (!error && httpResponse.statusCode == 200) {
result = { code: 200, message: "具有权限" };
return callback(error, result);
} else {
return callback(error, result);
}
common.isUsedMenuAuth(user.auth.pid,user.auth.role_id,path).done(function(isURes){
result = { code: 200, message: "具有权限" };
return callback(null, result);
},function(error){
return callback(error, result);
});
} else {
result = { code: 201, message: "不受权限控制" };
result = { code: 200, message: "不受权限控制" };
return callback(null, result);
}
} else {
return callback(null,result);
} else {
return callback(null, result);
}
},
changeShop: function (req, callback) {
IchangeShops:{
title:'调用老系统的切换店铺的接口',
url: Iaccount.changeShops + '?shops_id={{shops_id}}',
method:'GET',
outobj:'response',
headers: {
cookie: { type: String }
},
params: {
shops_id: { type: Number },
'@cookie': {type:String}
},
},
changeShop: function (req, callback,common) {
var shopId = Number(req.query.shops_id);
var cookie = req.session.gray;
var result = {code:500,message:"something wrong!"};
var result = { code: 500, message: "something wrong!" };
//设置当前的店铺信息
if (req.session.user && req.session.user.auth) {
... ... @@ -191,21 +186,14 @@ module.exports={
};
});
}
//调用老系统的切换店铺的接口
request.post({
'method': 'GET',
'headers': {
'cookie': cookie
},
'url': Iaccount.changeShops + '?shops_id=' + shopId
}, function (error, httpResponse, rebody) {
if (!error && httpResponse.statusCode == 200) {
common.IchangeShops(shopId,cookie).done(function(IchRes){
if(IchRes.statusCode == 200){
result = { code: 200, message: "success" };
return callback(null, result);
} else {
}else{
return callback(null, result);
}
});
}
}
}
\ No newline at end of file
}
}
\ No newline at end of file
... ...
... ... @@ -6,7 +6,7 @@ module.exports={
getShopBusinessOverview:{
title: "获取店铺的经营指标:一个自然日内有效订单商品件数、有效订单商品金额",
domain:"{bigdata}",
domain:"{{bigdata}}",
url: "/bigdata/getShopBusinessOverview",
params:{
dateId:{type:String}
... ... @@ -15,7 +15,7 @@ module.exports={
getShopBrandRank:{
title: "获取店铺的品牌排名,当前等级、排名、上升名词",
domain:"{bigdata}",
domain:"{{bigdata}}",
url: "/bigdata/getShopBrandRank",
params:{
dateId:{type:String}
... ... @@ -24,7 +24,7 @@ module.exports={
getOrdersGoodsAccountRptList:{
title:"对账结算",
domain:"{bigdata}",
domain:"{{bigdata}}",
url: "/shop/getOrdersGoodsAccountRptList"
},
... ... @@ -32,7 +32,7 @@ module.exports={
getOrdersGoodsRptList:{
title:'销售统计',
domain:'{bigdata}',
domain:'{{bigdata}}',
url:'/shop/getOrdersGoodsRptList',
params:{
page:{type:Number},
... ... @@ -51,7 +51,7 @@ module.exports={
getReturnGoodsRptList:{
title:'退货统计',
domain:'{bigdata}',
domain:'{{bigdata}}',
url:'/shop/getReturnGoodsRptList',
params:{
page:{type:Number},
... ... @@ -72,7 +72,7 @@ module.exports={
getStorageInRptList:{
title:'发货入库统计',
domain:'{bigdata}',
domain:'{{bigdata}}',
url:'/shop/getStorageInRptList',
params:{
page:{type:Number},
... ... @@ -89,7 +89,7 @@ module.exports={
getStorageOutRptList:{
title:'请退出库统计',
domain:'{bigdata}',
domain:'{{bigdata}}',
url:'/shop/getStorageOutRptList',
params:{
page:{type:Number},
... ... @@ -108,7 +108,7 @@ module.exports={
getStorageStatisticsList:{
title:"查询库存列表",
domain:"{bigdata}",
domain:"{{bigdata}}",
url:"/bigdata/getStorageStatisticsList",
params:{
page:{type:Number},
... ...
... ... @@ -28,7 +28,7 @@ var Iaccount = {
isUsedMenuAuth: oldSerDomain + '/service/account/v1/profile/authPath',
allRight: oldSerDomain + '/service/setting/v1/action/getAllAction',
getShopList: '{domain}/ShopsRest/queryShopsByAdminPid',
getShopList: '{{domain}}/ShopsRest/queryShopsByAdminPid',
// 灰度代理
url: 'http://shops.yohobuy.com',
... ...
... ... @@ -82,7 +82,6 @@ Controller.prototype.__define=function(method,router,view,apis,callback,clientmo
} else {
res.json(model);
}
return;
});
//调用接口获取数据
me.interfaces.require.apply(me.interfaces,[apis].concat(args));
... ... @@ -140,17 +139,14 @@ Controller.prototype.client=function(res,views,model,clientmodel){
ViewModel="<script>var ViewModel="+JSON.stringify(model)+";</script>";
var src="";
if(process.env.NODE_ENV==="production"){
src="http://cdn.yoho.cn/"+config.name+"/"+config.version;
html=html.replace(/\/static\/index\.min\.css/g,function($1){
return src+"/index.min.css";
src="http://cdn.yoho.cn/yohobuy-shops-fe/"+config.version;
html.replace(/\/static\/index\.min\.css/g,function($1){
return src+$1;
})
}else{
src="/static";
}
var script=['<script type="text/javascript" src="'+src+'/'+clientmodel+'/libs.js"></script>',
'<script type="text/javascript" src="'+src+'/'+clientmodel+'/'+ views+'.js"></script>'];
var script=['<script type="text/javascript" src="'+src+'/static/'+clientmodel+'/libs.js"></script>',
'<script type="text/javascript" src="'+src+'/static/'+clientmodel+'/'+ views+'.js"></script>'];
res.send(html+ViewModel+script.join(''));
}
}
... ...
var util = require('util');
var Emitter=require('events');
var Emitter = require('events');
var Request = require('request');
var async=require('async');
var async = require('async');
/*接口*/
var _ = require('lodash');
var Utils=require('./Utils');
var Utils = require('./Utils');
var Interfacer=function(config,app){
this.config=config;
this.CONSTS=app.get("Register");
this.config.domain=this.config.domain||app.get("Register").domain;
this.apis={};
Emitter.call(this);
var Interfacer = function (config, app) {
this.config = config;
this.CONSTS = app.get("Register");
this.config.domain = this.config.domain || app.get("Register").domain;
this.apis = {};
Emitter.call(this);
};
util.inherits(Interfacer,Emitter);
util.inherits(Interfacer, Emitter);
Interfacer.prototype.register = function(mos) {
var me=this,name=mos.namespace;
if(!name){
console.info(" Interfacer name can not empty");
}
for(var key in mos.apis){
var name_key=name+"_"+key;
if(me.isExisted(name_key)){
console.info("can not add repeat Interfacer key,please checkout");
}
/*需要进行验证判断*/
me.apis[name_key]=mos.apis[key];
}
Interfacer.prototype.register = function (mos) {
var me = this, name = mos.namespace;
if (!name) {
console.info(" Interfacer name can not empty");
}
for (var key in mos.apis) {
var name_key = name + "_" + key;
if (me.isExisted(name_key)) {
console.info("can not add repeat Interfacer key,please checkout");
}
/*需要进行验证判断*/
me.apis[name_key] = mos.apis[key];
}
};
Interfacer.prototype.isExisted=function(key){
return !!this.apis[key];
Interfacer.prototype.isExisted = function (key) {
return !!this.apis[key];
};
Interfacer.prototype.getInterfacerByNameSpace = function (namespace) {
var me = this;
if (!namespace) return {};
var apis = {}, len = namespace.length;
for (var key in me.apis) {
if (key.slice(0, len + 1) === namespace + "_") {
var name = key.slice(len + 1);
if (typeof me.apis[key] !== "function") {
apis[name] = me.apis[key];
}
}
}
return apis;
}
function __getArgs(str) {
var arr = str.toString().match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m)[1].split(',');
return (arr.length == 1 && arr[0] == "")?[]:arr;
}
function __requestApi(config, apiOpt, req, callback){
var me=this;
function __requestApi(config, apiOpt, req, callback) {
var me = this;
if (typeof apiOpt == "function") {
return apiOpt.call(0, req, function (err, result) {
req._yoheaders = req._yoheaders;
return callback(null, result);
});
}
var method = apiOpt.method || "POST";
var data={};
if(apiOpt.params&&(_.isArray(apiOpt.params)||_.isPlainObject(apiOpt.params))){
if(_.isArray(apiOpt.params)){
apiOpt.params.forEach(function(param){
var name=param.name;
if(req.param(name)){
if(param.type.toUpperCase()=="NUMBER"){
data[name]=Number(req.param(name));
}else{
data[name]=String(req.param(name));
}
}
});
}else
if(_.isPlainObject(apiOpt.params)){
for(var name in apiOpt.params){
var param=apiOpt.params[name];
if(param.default){
data[name]=param.type(param.default);
}
if(req.param(name)){
data[name]=param.type(req.param(name));
}
}
}
}
var options={
url: Utils.template((apiOpt.domain||config.domain)+apiOpt.url,me.CONSTS),
method:apiOpt.method,
//数据组装
qs: method.toUpperCase()=="GET"?data:undefined,
// form:apiOpt.method.toUpperCase()=="GET"?undefined:data//,
body: method.toUpperCase()=="GET"?undefined:JSON.stringify(data),
var args = __getArgs(apiOpt), o = {};
if (args.length > 2) {
args.slice(2).map(function (namespace) {
namespace = _.trim(namespace);
o[namespace] = {};
var apis = me.getInterfacerByNameSpace(namespace);
for (var action in apis) {
o[namespace][action] = (function (api, config, consts) {
var intermo = new Interfacer.create(api);
return function () {
var args = [].slice.call(arguments, 0), params = {};
intermo.apiOpt = api;
intermo.config = {
config: config,
consts: consts
};
if (args.length === 1 && _.isPlainObject(args[0])) {
intermo.req.param(args[0]);
} else {
api.params = api.params || {};
var os = Object.keys(api.params);
args.forEach(function (value, i) {
params[os[i]] = value;
});
intermo.req.param(params);
}
if (!this.queue) {
this.queue = [];
}
this.queue.push(intermo);
this.__proto__ = new queue();
return this;
};
})(apis[action], config, me.CONSTS);
}
});
}
var fns = [];
for (var i in o) {
fns.push(o[i]);
}
//return apiOpt.call(0, req, function (err, result) {
// req._yoheaders = req._yoheaders;
// return callback(null, result);
//});
return apiOpt.apply(0, [req, function (err, result) {
req._yoheaders = req._yoheaders;
return callback(null, result);
}].concat(fns));
}
var options = __requestOption(req, apiOpt, config, me.CONSTS);
Request(options, function (error, response, body) {
var _err_ = new Error();
if (error) {
console.info("Error [request]:" + options.title);
console.error(error);
return callback(error, null);
}
try {
if (response && response.statusCode === 200) {
var obj = JSON.parse(body)
if (!(typeof obj == "object")) {
_err_.message = "Error[json parse@" + options.title + "]:" + body;
console.info(_err_.message);
console.error(err);
return callback(_err_, null);
}
} else {
_err_.message = "Error[response state @" + options.title + "]:" + response;
console.info(_err_.message);
console.error(err);
return callback(_err_, null);
}
} catch (err) {
console.info("Error[response to json @" + options.title + "]");
console.info(response);
console.error(err);
return callback(err, null);
}
return callback(null, JSON.parse(body));
});
};
function __requestOption(req, apiOpt, config, consts) {
var method = (apiOpt.method || "POST").toLocaleUpperCase();
var data = {};
if (apiOpt.params && (_.isArray(apiOpt.params) || _.isPlainObject(apiOpt.params))) {
if (_.isArray(apiOpt.params)) {
//兼容 yo之前的模式 后期废弃
apiOpt.params.forEach(function (param) {
var name = param.name;
if (req.param(name)) {
if (param.type.toUpperCase() == "NUMBER") {
data[name] = Number(req.param(name));
} else {
data[name] = String(req.param(name));
}
}
});
} else
if (_.isPlainObject(apiOpt.params)) {
for (var name in apiOpt.params) {
if (req.param("@" + name)) {
continue;
}
var param = apiOpt.params[name];
if (param.default) {
data[name] = param.type(param.default);
}
if (req.param(name)) {
data[name] = param.type(req.param(name));
}
}
}
}
var options = { method: method };
options.title = apiOpt.title || '';
options.outobj = apiOpt.outobj || '';
if (options.method == "GET") {
apiOpt.query = true;
}
headers: apiOpt.headers||{
'Content-Type' : 'application/json'
}
};
if (req._yoheaders) {
options.headers= _.merge(options.headers, req._yoheaders);
if (/^https{0,1}:\/\//g.test(apiOpt.url)) {
options.url = apiOpt.url;
} else {
options.url = (apiOpt.domain || config.domain) + apiOpt.url;
}
if (/\{\{.*\}\}/.test(options.url)) {
var _qs = {};
if (apiOpt.query) {
_qs = data;
}
var a = _.merge(consts, _qs);
options.url=Utils.template(options.url, a);
}
if (apiOpt.form) {
if (typeof apiOpt.form === "string") {
options.form = Utils.template(apiOpt.form, data);
} else if (_.isPlainObject(apiOpt.form)) {
options.form = {};
for (var i in apiOpt.form) {
options.form[i] = Utils.template(apiOpt.form[i], data)
}
}
options.headers = {
'Content-Type' : 'application/x-www-form-urlencoded'
}
} if (apiOpt.query) {
//不做任何事
} else {
options.body = JSON.stringify(data);
options.headers = {
'Content-Type' : 'application/json'
}
}
if (apiOpt.headers && _.isPlainObject(apiOpt.headers)) {
options.headers = {};
for (var name in apiOpt.headers) {
var param = apiOpt.headers[name];
if (req.param("@" + name)) {
if (param.default) {
options.headers[name] = param.type(param.default);
}
if (req.param("@" + name)) {
options.headers[name] = param.type(req.param("@" + name));
}
}
}
}
if (req._yoheaders) {
options.headers = _.merge(options.headers, req._yoheaders);
}
console.log("*************************************");
console.log("Http", options.url, data, options.headers);
console.log("*************************************");
console.log("Http",options.url,data,options.headers);
console.log("*************************************");
return options;
}
Request(options,function(error, response, body){
var _err_=new Error();
if(error){
console.info("Request 请求错误");
console.error(error);
return callback(error,null);
}
try{
if(response && response.statusCode === 200){
var obj=JSON.parse(body)
if(!(typeof obj=="object")){
_err_.message="Error[json parse@"+apiOpt.title+"]:"+body;
return callback(_err_,null);
}
}else{
_err_.message="Error[response@"+apiOpt.title+"]:"+response.statusCode;
return callback(_err_,null);
}
}catch(err){
console.info("Request 内容转化JSON错误@"+apiOpt.title+"");
console.info(response);
console.error(err);
return callback(err,null);
}
return callback(null,JSON.parse(body));
});
};
/*
* {mos} 接口key 数组 比如[key1,key2] 后面可能要兼容字符串 比如 传key1
*/
Interfacer.prototype.require=function(mos,req,res,cb){
var me=this,funcs=[],names=[],errName=[];
mos.forEach(function(name){
if(me.apis.hasOwnProperty(name)){
names.push(name);
if(me.config.mock){
funcs.push(me.apis[name].output);
}else{
funcs.push(function(callback){
__requestApi.call(me,me.config,me.apis[name],req,callback);
});
}
}else{
errName.push(name);
}
});
Interfacer.prototype.require = function (mos, req, res, cb) {
var me = this, funcs = [], names = [], errName = [];
mos.forEach(function (name) {
if (me.apis.hasOwnProperty(name)) {
names.push(name);
if (me.config.mock) {
funcs.push(me.apis[name].output);
} else {
funcs.push(function (callback) {
__requestApi.call(me, me.config, me.apis[name], req, callback);
});
}
} else {
errName.push(name);
}
});
if (funcs.length != mos.length) {
var err = new Error();
err.message = "某个"+errName.join("->")+" 可能不存在!";
err.message = "某个" + errName.join("->") + " 可能不存在!";
cb(err, funcs, names);
return;
}
if(me.config.mock){
cb(null,funcs,names);
return;
}
async.parallel(funcs, function(err, results){
if(err){
console.info("Async Error");
console.error(err);
console.error(results);
return cb(err,results,names);
}
console.log(names);
return;
}
if (me.config.mock) {
cb(null, funcs, names);
return;
}
async.parallel(funcs, function (err, results) {
if (err) {
console.info("Async Error");
console.error(err);
console.error(results);
return cb(err, results, names);
}
return cb(null, results, names);
});
});
};
Interfacer.create = function (apis) {
return {
req: {
__params__: null,
param: function (value) {
if (typeof value == "object") {
this.__params__ = value;
} else {
return this.__params__[value];
}
}
},
apiOpt: null,
config: {},
error: function () {
}
}
}
function queue() { }
queue.prototype = {
done: function (success, fail) {
var that = this;
if (typeof success !== 'function') return;
var len = that.queue.length, watchlen = { len: len };
var args = new Array(3);
var wlen=Object.defineProperty({}, 'len', {
value: len,
writable: true,
enumerable: false,
configurable: true
});
for (var i = 0; i < len; i++) {
(function (queue,args) {
var options = __requestOption(queue.req, queue.apiOpt, queue.config.config, queue.config.consts);
__sendRequest(options, success, fail, wlen, i,args);
})(this.queue[i],args);
}
that.queue = null;
//var options = __requestOption(this.req, this.apiOpt);
//this.__sendRequest(options, success, fail);
return this;
},
}
function __sendRequest(options, success, fail,wlen,i,args) {
Request(options, function (error, response, body) {
var _err_ = new Error(), obj;
if (error) {
console.info("Error [request]:" + options.title);
console.error(error);
fail && fail(error);
return;
}
try {
if (response && response.statusCode === 200) {
if (!options.outobj) {
obj = JSON.parse(body)
if (!(typeof obj == "object")) {
_err_.message = "Error[json parse@" + options.title + "]:" + body;
console.info(_err_.message);
console.error(err);
fail && fail(_err_);
return;
}
} else {
obj = options.outobj.toLocaleUpperCase().indexOf("BODY")>-1?body:response;
}
} else {
_err_.message = "Error[response state @" + options.title + "]:" + response;
console.info(_err_.message);
console.error(err);
fail && fail(_err_);
return;
}
} catch (err) {
console.info("Error[response to json @" + options.title + "]");
console.info(response);
console.error(err);
fail && fail(err);
return;
}
args[i]=obj;
wlen.len--;
if (!wlen.len) {
success && success.apply(0, args)
}
return;
});
}
module.exports= Interfacer;
\ No newline at end of file
module.exports = Interfacer;
\ No newline at end of file
... ...
function Match(pattern,str) {
function Match(pattern,str) {
var step='/';
var keyReg=new RegExp('().*{}+?[]^$\\!','g');
... ...
... ... @@ -9,12 +9,12 @@
for (var key in args[1]) {
if (args[1][key] != undefined) {
var regkey = ((+key) == (+key)) ? "[" + key + "]" : key;
var reg = new RegExp("({" + regkey + "})", "g");
var reg = new RegExp("({{" + regkey + "}})", "g");
result = result.replace(reg, args[1][key]);
}
}
}
var reg = new RegExp("({.*})", "g");
var reg = new RegExp("({{.*}})", "g");
result = result.replace(reg, '');
}
}
... ...
label {
font-weight: normal;
margin-bottom: 5px !important;
color: #4a535e;
}
code {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
background: none;
padding: 0;
}
.lead {
color: #333;
}
blockquote p {
font-family: 'Georgia', sans-serif;
font-weight: 100;
color: #333;
}
blockquote .glyphicon,
blockquote .fa {
float: left;
margin-right: 10px;
font-size: 20px;
}
h4, .h4 {
line-height: 24px;
}
.row {
margin-left: -10px;
margin-right: -10px;
}
.col-xs-1, .col-xs-2,
.col-xs-3, .col-xs-4,
.col-xs-5, .col-xs-6,
.col-xs-7, .col-xs-8,
.col-xs-9, .col-xs-10,
.col-xs-11, .col-xs-12,
.col-sm-1, .col-sm-2,
.col-sm-3, .col-sm-4,
.col-sm-5, .col-sm-6,
.col-sm-7, .col-sm-8,
.col-sm-9, .col-sm-10,
.col-sm-11, .col-sm-12,
.col-md-1, .col-md-2,
.col-md-3, .col-md-4,
.col-md-5, .col-md-6,
.col-md-7, .col-md-8,
.col-md-9, .col-md-10,
.col-md-11, .col-md-12,
.col-lg-1, .col-lg-2,
.col-lg-3, .col-lg-4,
.col-lg-5, .col-lg-6,
.col-lg-7, .col-lg-8,
.col-lg-9, .col-lg-10,
.col-lg-11, .col-lg-12 {
padding-left: 10px;
padding-right: 10px;
}
.form-group::after {
clear: both;
display: block;
content: '';
}
.form-group .control-label {
margin-top: 3px;
}
.form-bordered .form-group {
margin: 0;
padding: 15px 10px;
border-top: 1px dotted #d3d7db;
}
.form-bordered .form-group:first-child {
border-top: 0;
}
.form-striped .form-group {
margin: 0;
padding: 15px 0;
}
.form-striped .form-group:nth-child(even) {
background: #fcfcfc;
}
.form-inline .form-group {
margin-right: 20px;
}
.form-inline .checkbox {
margin-right: 20px;
}
.form-control {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
padding: 10px;
height: auto;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
font-size: 13px;
}
.form-control:focus {
border-color: #999;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.input-sm {
font-size: 12px;
padding: 7px 10px;
height: auto;
margin-top: 3px;
}
.input-lg {
font-size: 18px;
padding: 12px 10px;
}
.btn {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
line-height: 21px;
-moz-transition: all 0.2s ease-out 0s;
-webkit-transition: all 0.2s ease-out 0s;
transition: all 0.2s ease-out 0s;
padding: 8px 15px;
border-width: 0;
}
.btn:focus {
outline: none;
}
.btn-sm {
padding: 5px 10px;
}
.btn-xs {
padding: 3px 10px;
font-size: 12px;
}
.btn-lg {
padding: 12px 20px;
}
.btn-default {
background: #e4e7ea;
color: #636e7b;
}
.btn-default-border {
border-width: 1px;
}
.btn-default:hover,
.btn-default:focus,
.btn-default:active,
.btn-default.active,
.open .dropdown-toggle.btn-default {
background: #d2d5d8;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.btn-primary:active,
.btn-primary.active,
.open .dropdown-toggle.btn-primary {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.btn-white {
background: #fff;
border: 1px solid #ccc;
color: #666;
}
.btn-white:hover,
.btn-white:focus,
.btn-white:active,
.btn-white.active,
.open .dropdown-toggle.btn-white {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
background: #f7f7f7;
}
.btn-default-alt {
border: 2px solid #999;
color: #999;
text-transform: uppercase;
font-weight: bold;
font-size: 12px;
}
.btn-default-alt:hover,
.btn-default-alt:active,
.btn-default-alt:focus {
border-color: #666;
color: #666;
}
.btn-primary-alt {
border: 2px solid #428BCA;
color: #428BCA;
text-transform: uppercase;
font-size: 12px;
}
.btn-primary-alt:hover,
.btn-primary-alt:active,
.btn-primary-alt:focus {
border-color: #357EBD;
color: #357EBD;
}
.btn-success-alt {
border: 2px solid #5CB85C;
color: #5CB85C;
text-transform: uppercase;
font-size: 12px;
}
.btn-success-alt:hover,
.btn-success-alt:active,
.btn-success-alt:focus {
border-color: #17a08c;
color: #17a08c;
}
.btn-warning-alt {
border: 2px solid #F0AD4E;
color: #F0AD4E;
text-transform: uppercase;
font-weight: bold;
font-size: 12px;
}
.btn-warning-alt:hover,
.btn-warning-alt:active,
.btn-warning-alt:focus {
border-color: #EEA236;
color: #EEA236;
}
.btn-danger-alt {
border: 2px solid #D9534F;
color: #D9534F;
text-transform: uppercase;
font-weight: bold;
font-size: 12px;
}
.btn-danger-alt:hover,
.btn-danger-alt:active,
.btn-danger-alt:focus {
color: #D43F3A;
}
.btn-info-alt {
border: 2px solid #5BC0DE;
color: #5BC0DE;
text-transform: uppercase;
font-weight: bold;
font-size: 12px;
}
.btn-info-alt:hover,
.btn-info-alt:active,
.btn-info-alt:focus {
border-color: #46B8DA;
color: #46B8DA;
}
.btn-group.open .dropdown-toggle {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.btn-group {
margin-bottom: 10px;
}
.btn-group > .btn,
.btn-group-vertical > .btn {
border-width: 1px;
}
.badge {
vertical-align: middle;
display: inline-block;
}
.badge-warning {
background-color: #ec8c04;
}
.badge-success {
background-color: #019a1e;
}
.nav-pills > li > a {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.breadcrumb > li + li:before {
padding: 0 3px;
}
.panel {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
position: relative;
}
.panel-heading,
.panel-footer {
background: #f7f7f7;
border-color: #ddd;
}
.panel-heading {
padding: 18px 20px 20px 20px;
position: relative;
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.panel-heading .panel-title {
line-height: normal;
}
.panel-default > .panel-heading {
border-color: #e7e7e7;
background-color: #f9f9f9;
}
.panel-heading-empty {
background: none;
border-bottom: 0;
}
.panel-heading p {
font-size: 12px;
margin-top: 5px;
margin-bottom: 0;
line-height: 18px;
}
.panel-btns {
position: absolute;
top: 10px;
right: 10px;
display: none;
}
.panel-btns a {
font-size: 11px;
color: #999;
padding: 3px 4px;
border: 1px solid #bbb;
line-height: 10px !important;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
display: inline-block;
}
.panel-btns a:hover {
text-decoration: none;
cursor: pointer;
color: #666;
border-color: #999;
}
.panel-btns a.minimize:active,
.panel-btns a.minimize:focus {
text-decoration: none;
}
.panel-body {
padding: 20px;
}
.panel-footer {
padding: 20px;
}
.panel-footer:after {
clear: both;
display: block;
content: '';
}
.panel-heading .nav-tabs {
margin-bottom: -20px;
border-bottom: 0;
}
.panel-heading .nav-tabs li {
margin-right: 5px;
}
.panel-heading .nav-tabs li a {
color: #666;
}
.panel-heading .nav-tabs li a:hover,
.panel-heading .nav-tabs li a:active,
.panel-heading .nav-tabs li a:focus {
background-color: #fff;
border-color: #fff;
border-bottom: 0;
color: #111;
}
.panel-heading .nav-tabs li.active a {
background: #fcfcfc;
color: #111;
}
.panel-heading .nav-tabs li.active a:hover,
.panel-heading .nav-tabs li.active a:active,
.panel-heading .nav-tabs li.active a:focus {
background: #fcfcfc;
color: #111;
border: 1px solid #ddd;
border-bottom-color: #fcfcfc;
}
.panel-heading .nav-justified {
margin-bottom: -21px;
}
.panel-heading .nav-justified li a {
border-bottom: 0;
}
.panel-default .panel-heading {
color: #41464d;
}
.panel-default .panel-heading p {
color: #77818e;
}
.panel-primary .panel-heading p {
opacity: 0.75;
}
.panel-primary .panel-heading p a {
color: #fff;
}
.panel-primary .panel-btns a {
border-color: #fff;
color: #fff;
opacity: 0.75;
}
.panel-success .panel-btns a {
color: #3c763d;
border-color: #3c763d;
opacity: 0.75;
}
.panel-info .panel-btns a {
color: #31708f;
border-color: #31708f;
opacity: 0.75;
}
.panel-warning .panel-btns a {
color: #8a6d3b;
border-color: #8a6d3b;
opacity: 0.75;
}
.panel-danger .panel-btns a {
color: #a94442;
border-color: #a94442;
opacity: 0.75;
}
.panel-primary .panel-btns a:hover,
.panel-success .panel-btns a:hover,
.panel-info .panel-btns a:hover,
.panel-warning .panel-btns a:hover,
.panel-danger .panel-btns a:hover {
opacity: 1;
}
.form-horizontal .control-label {
font-weight: normal;
}
.has-success .form-control,
.has-warning .form-control,
.has-error .form-control {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.has-success .form-control:focus,
.has-warning .form-control:focus,
.has-error .form-control:focus {
-moz-box-shadow: 5px 5px 0 rgba(12,12,12,0.05);
-webkit-box-shadow: 5px 5px 0 rgba(12,12,12,0.05);
box-shadow: 5px 5px 0 rgba(12,12,12,0.05);
}
.input-group-addon {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
font-size: 13px;
background-color: #f7f7f7;
}
.input-group-lg > .form-control,
.input-group-lg > .input-group-addon,
.input-group-lg > .input-group-btn > .btn {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
height: 46px;
}
.input-group-btn .btn {
line-height: 22.5px;
}
.input-group-btn > .btn,
.input-group-btn > .btn-group {
border-width: 1px;
}
.dropdown-menu {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
padding: 5px;
-moz-box-shadow: 3px 3px 0 rgba(12,12,12,0.03);
-webkit-box-shadow: 3px 3px 0 rgba(12,12,12,0.03);
box-shadow: 3px 3px 0 rgba(12,12,12,0.03);
margin-top: -1px;
}
.dropdown-menu li a {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
-moz-transition: all 0.2s ease-out 0s;
-webkit-transition: all 0.2s ease-out 0s;
transition: all 0.2s ease-out 0s;
}
.dropdown-menu > li > a {
padding: 7px 10px;
color: #666;
}
.dropdown-menu > li > a:hover {
background-color: #e7e7e7;
color: #333;
}
.dropdown-menu-sm > li {
font-size: 12px;
}
.tooltip-inner {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
}
.popover {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 1px 1px 2px rgba(0,0,0,0.05);
-webkit-box-shadow: 1px 1px 2px rgba(0,0,0,0.05);
box-shadow: 1px 1px 2px rgba(0,0,0,0.05);
padding: 0;
}
.popover-title {
-moz-border-radius: 3px 3px 0 0;
-webkit-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0;
font-size: 13px;
border-color: #ccc;
font-weight: 500;
line-height: 21px;
}
.popover.bottom > .arrow {
border-bottom-color: #ccc;
}
.popover.bottom > .arrow:after {
border-bottom-color: #f7f7f7;
}
.modal-dialog {
border: 0;
}
.modal-content {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
-moz-box-shadow: 0 5px 0 rgba(0,0,0,0.4);;
-webkit-box-shadow: 0 5px 0 rgba(0,0,0,0.4);;
box-shadow: 0 5px 0 rgba(0,0,0,0.4);
border: 0;
}
.modal-title {
font-size: 20px;
color: #333;
}
.modal-backdrop.in {
opacity: 0.65;
}
.alert {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.alert .close {
font-size: 16px;
}
.alert .alert-link {
font-weight: bold;
font-weight: normal;
}
.alert > p + p {
margin-top: 15px;
}
.alert > p + p .btn {
margin-right: 5px;
}
.label {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
padding: 4px 8px;
font-weight: normal;
font-size: 11px;
}
.badge-primary {
background-color: #428BCA;
}
.badge-warning {
background-color: #F0AD4E;
}
.badge-success {
background-color: #5CB85C;
}
.badge-danger {
background-color: #D9534F;
}
.badge-info {
background-color: #5BC0DE;
}
.progress {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
height: 15px;
margin-bottom: 15px;
}
.progress-bar {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.progress-sm {
height: 10px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
}
.progress-xs {
height: 5px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
}
.nav-tabs {
background: #eee;
border: 0;
-moz-border-radius: 3px 3px 0 0;
-webkit-border-radius: 3px 3px 0 0;
border-radius: 3px 3px 0 0;
border: 1px solid #ddd;
border-bottom: 0;
}
.nav-tabs > li > a {
border: 0;
padding: 14px 20px;
color: #666;
font-weight: 500;
font-size: 14px;
}
.nav-tabs > li > a:hover {
background: none;
color: #333;
}
.nav-tabs > li.active > a,
.nav-tabs > li.active > a:hover,
.nav-tabs > li.active > a:focus {
background-color: #fff;
margin-top: -1px;
}
.nav-tabs > li.active:first-child > a,
.nav-tabs > li.active:first-child > a:hover,
.nav-tabs > li.active:first-child > a:focus {
border-left: 0;
}
.nav-tabs > li.active:last-child > a,
.nav-tabs > li.active:last-child > a:hover,
.nav-tabs > li.active:last-child > a:focus {
border-right: 0;
}
.tab-content {
padding: 15px;
-moz-border-radius: 0 0 3px 3px;
-webkit-border-radius: 0 0 3px 3px;
border-radius: 0 0 3px 3px;
border: 1px solid #ddd;
border-top: 0;
}
.tab-pane address:last-child {
margin-bottom: 0;
}
.pagination > li:first-child > a,
.pagination > li:first-child > span {
border-bottom-left-radius: 3px;
border-top-left-radius: 3px;
}
.pagination > li:last-child > a,
.pagination > li:last-child > span {
border-bottom-right-radius: 3px;
border-top-right-radius: 3px;
}
.pagination > li > a,
.pagination > li > span {
color: #636e7b;
}
.pagination > li > a:hover,
.pagination > li > span:hover,
.pagination > li > a:focus,
.pagination > li > span:focus {
background-color: #e4e7ea;
}
.pagination-split li {
margin-left: 5px;
display: inline-block;
float: left;
}
.pagination-split li:first-child {
margin-left: 0;
}
.pagination-split li a {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
}
.pager li > a, .pager li > span {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
color: #636e7b;
}
.well {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
border: 0;
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
background-color: #e4e7ea;
}
.thumbnail {
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
padding: 5px;
}
.media-heading {
color: #333;
font-size: 14px;
font-weight: 500;
margin: 0;
}
.media-desc {
line-height: 20px;
display: block;
margin: 0;
}
.text-success {
color: #5CB85C;
}
.table thead > tr > th {
color: #444;
}
.table thead > tr > th,
.table tbody > tr > th,
.table tfoot > tr > th,
.table thead > tr > td,
.table tbody > tr > td,
.table tfoot > tr > td {
border-color: #ddd;
}
.table-striped > tbody > tr:nth-child(2n+1) > td,
.table-striped > tbody > tr:nth-child(2n+1) > th {
background-color: #f7f7f7;
}
.table thead .table-head-alt th {
text-transform: uppercase;
font-size: 12px;
}
.table tbody tr td .progress {
margin: 0;
}
.modal-footer {
margin-top: 0;
}
.modal-content .tab-content {
-moz-box-shadow: none;
-webkit-box-shadow: none;
box-shadow: none;
}
.list-group-item:first-child {
border-top-left-radius: 3px;
border-top-right-radius: 3px;
}
.list-group-item:last-child {
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}
ul.wysihtml5-toolbar {
margin: 0;
padding: 0;
display: block;
}
ul.wysihtml5-toolbar::after {
clear: both;
display: table;
content: "";
}
ul.wysihtml5-toolbar > li {
float: left;
display: list-item;
list-style: none;
margin: 0 5px 10px 0;
}
ul.wysihtml5-toolbar a[data-wysihtml5-command=bold] {
font-weight: bold;
}
ul.wysihtml5-toolbar a[data-wysihtml5-command=italic] {
font-style: italic;
}
ul.wysihtml5-toolbar a[data-wysihtml5-command=underline] {
text-decoration: underline;
}
ul.wysihtml5-toolbar a.btn.wysihtml5-command-active {
background-image: none;
-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);
background-color: #E6E6E6;
background-color: #D9D9D9;
outline: 0;
}
ul.wysihtml5-commands-disabled .dropdown-menu {
display: none !important;
}
ul.wysihtml5-toolbar div.wysihtml5-colors {
display:block;
width: 50px;
height: 20px;
margin-top: 2px;
margin-left: 5px;
position: absolute;
pointer-events: none;
}
ul.wysihtml5-toolbar a.wysihtml5-colors-title {
padding-left: 70px;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="black"] {
background: black !important;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="silver"] {
background: silver !important;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="gray"] {
background: gray !important;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="maroon"] {
background: maroon !important;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="red"] {
background: red !important;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="purple"] {
background: purple !important;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="green"] {
background: green !important;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="olive"] {
background: olive !important;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="navy"] {
background: navy !important;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="blue"] {
background: blue !important;
}
ul.wysihtml5-toolbar div[data-wysihtml5-command-value="orange"] {
background: orange !important;
}
This diff could not be displayed because it is too large.