Authored by lzhy

1、将平台端的部分原php接口切换成java接口

2、将原平台的iframe 和 outlink 功能迁移到本项目中
... ... @@ -18,7 +18,7 @@ var Utils = {
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) {
... ... @@ -53,22 +53,26 @@ module.exports = {
},
getResourceByPid: {
title:'菜单接口',
url: Iaccount.getResourceByPid,
form: '[{{pid}},{{role_id}},{{website}}]',
// url: Iaccount.getResourceByPid,
url: Iaccount.getResourceByPidEx,
// form: '[{{pid}},{{role_id}},{{website}}]',
params: {
pid: { type: Number },
role_id: { type: Number },
website: { type: Number, default: Iaccount.WEBSITE }
// role_id: { type: Number },
// website: { type: Number, default: Iaccount.WEBSITE }
platform_id: { type: Number, default: Iaccount.WEBSITE }
}
},
allRight: {
title: '获取权限',
url: Iaccount.allRight,
// url: Iaccount.allRight,
url: Iaccount.allRightEx,
form: '[false]'
},
sessionAsync: {
title:'与老系统session同步',
url: Iaccount.url + '/account/login/sessions',
// url: Iaccount.url + '/account/login/sessions',
url: Iaccount.erpUrl + '/account/login/session',
outobj: "response",
form: {'account':'{{user}}','password':'{{password}}','refer': '{{refer}}'},
params: {
... ... @@ -86,6 +90,15 @@ module.exports = {
type:{ type: Number, default : 1 }
}
},
queryProfilePurviewPaths: {
title: '获取当前账号所有授权的权限',
url: Iaccount.queryProfilePurviewPaths,
params: {
pid: { type: Number },
role_id: { type: Number },
platform_id: { type: Number, default: Iaccount.WEBSITE }
}
},
login: function (req, callback, common) {
console.log("begin enter login function --------------------------------------------------------------------------------------" + req);
... ... @@ -144,9 +157,8 @@ module.exports = {
result.passwd_time = IloginRes.data.pwdExpirationDays;
userInfo = { auth: userData, uid: userData.pid, name: userData.truename, role: userData.roleName, right: {},shopList:[],brands:[]};
common.queryAllAuth(userData.pid).getResourceByPid(userData.pid, userData.role_id).done(function (allAuthResp, getRRes) {
common.queryAllAuth(userData.pid).getResourceByPid(userData.pid).queryProfilePurviewPaths(userData.pid, userData.role_id).done(function (allAuthResp, getRRes, allPPRes) {
console.log("enter common queryAllAuth, allAuthResp: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^1^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", allAuthResp.data.brand.list);
if(true){
var arrList = [];
console.log("enter common queryAllAuth, allAuthResp list: ******************************************************************" + (JSON.stringify(allAuthResp.data.brand.list) == "{}"));
... ... @@ -163,15 +175,23 @@ module.exports = {
console.log("userInfo.brands set success ; userInfo.brands is " + userInfo.brands + "(" + (typeof userInfo.brands==="string") + ")" + "*******");
}
allRes.data.forEach(function (data) {
if (data.platform_id == Iaccount.WEBSITE) {
userInfo.right[data.path] = true;
_.forEach(allRes.data, item => {
if (item.platform_id == Iaccount.WEBSITE ){
userInfo.right[item.path] = true;
}
});
})
// allRes.data.forEach(function (data) {
// if (data.platform_id == Iaccount.WEBSITE) {
// userInfo.right[data.path] = true;
// }
// });
//组织用户的菜单(切换了新接口)
userInfo.menu = Utils.createrMenus(getRRes.data);
//获取用户的所有权限(原为每次根据访问路径去请求接口,现改成将用户所有访问的路径都保存到session中) lzhy 2020-08-04
userInfo.purviewPaths = _.get(allPPRes, 'data', []);
// 如果是要过期,则需要提示用户密码要过期
console.log("enter getResourceByPid, passwd_time: " + result.passwd_time);
if (result.passwd_time != undefined && result.passwd_time > 0) {
... ... @@ -230,19 +250,25 @@ module.exports = {
'x-client-ip': req.ip,
'x-user-brands':typeof user.brands==="string"?user.brands: user.brands.join(',')
};
if (path && user.right[path]) {
common.isUsedMenuAuth(user.auth.pid,user.auth.role_id,path).done(function(isURes){
result = { code: 200, message: "具有权限" };
if(isURes.data){
result={code:isURes.data.code,message:isURes.data.errmsg};
}
console.log("return result: " + JSON.stringify(isURes));
console.log("code 200, result: " + JSON.stringify(result));
return callback(null, result);
},function(error){
console.log("error: " + error);
return callback(error, result);
});
// 改成从缓存中读取用户所有的授权路径进行判断
if(_.indexOf(req.session.user.purviewPaths, path) > -1){
result = { code: 200, message: "具有权限" };
}
return callback(null, result);
// common.isUsedMenuAuth(user.auth.pid,user.auth.role_id,path).done(function(isURes){
// result = { code: 200, message: "具有权限" };
// if(isURes.data){
// result={code:isURes.data.code,message:isURes.data.errmsg};
// }
// console.log("return result: " + JSON.stringify(isURes));
// console.log("code 200, result: " + JSON.stringify(result));
// return callback(null, result);
// },function(error){
// console.log("error: " + error);
// return callback(error, result);
// });
} else {
result = { code: 200, message: "不受权限控制" };
console.log(result);
... ...
const md5 = require("md5");
module.exports = function (app) {
app.get("/out/links/index", "outLink.OutLink", function (req, res) {
const secretKey = 'yoho9646yoho9646';
const url = req.query.url;
const outLinkUrl = url.indexOf('?') > -1 ? url + '&pid=' + req.session.user.auth.pid : outLinkUrl + '&pid=' + req.session.user.auth.pid;
const pidMd5 = md5(req.session.user.auth.pid + secretKey);
this.$extend = {
outLinkUrl: outLinkUrl + '&pidMd5=' + pidMd5 + '&' + new Date().getTime()
}
});
app.get("/iframe/links/index", "outLink.Iframe", function (req, res) {
const outLinkUrl = req.query.url;
this.$extend = {
outLinkUrl: outLinkUrl.indexOf('?') > -1 ? outLinkUrl + '&code=iframe' : outLinkUrl + '?code=iframe'
}
});
}
... ...
<%include '../../common/views/__ui/header'%>
<iframe src="<% outLinkUrl %>" name="iframepage" id="iframepage" frameborder="0" scrolling="yes" width="100%" height="100%;"></iframe>
... ...
<%include '../../common/views/__ui/header'%>
<iframe src="<%outLinkUrl%>" name="iframepage" id="iframepage" frameborder="0" scrolling="no" width="100%" height="100%;"></iframe>
\ No newline at end of file
... ...
... ... @@ -28,19 +28,22 @@ var Iaccount = {
login: oldSerDomain + '/service/account/v1/Profile/login',
loginEx: javaErpDomain + '/erp-gateway-web/account/profile/login',
getResourceByPid: oldSerDomain + '/service/account/v1/Profile/getMenuByPid',
getResourceByPidEx : javaErpDomain + '/erp-gateway-web/account/menu/query_by_pid', // 切换根据获取用户菜单接口为java接口
getAllResByWebsite: oldSerDomain + '/service/setting/v1/menu/getAllMenu',
changeShops: 'http://shops.yohobuy.com/index/ajaxshop',
isUsedMenuAuth: oldSerDomain + '/service/account/v1/profile/authPath',
allRight: oldSerDomain + '/service/setting/v1/action/getAllAction',
allRightEx: javaErpDomain + '/erp-gateway-web/account/action/query_simple_all', // 切换根据获取所有权限接口为java接口
getShopList: '{{domain}}/ShopsRest/queryShopsByAdminPid',
// 灰度代理
url: 'http://admin.portal.yohobuy.com',
erpUrl: 'http://erp.yohobuy.com',
sessionKeep: '/account/profile/display',
timeout: 10000,
queryAllAuth : javaErpDomain + '/erp-gateway-web/account/profileDataEntitlement/queryAllAuth'
queryAllAuth: javaErpDomain + '/erp-gateway-web/account/profileDataEntitlement/queryAllAuth',
queryProfilePurviewPaths: javaErpDomain + '/erp-gateway-web/account/action/queryProfilePurviewsPaths' //获取当前登录用户所有授权的权限路径
};
... ... @@ -118,6 +121,9 @@ if(process.env.NODE_ENV!="coding"){
apiCofig.EnvConst.yohoSearch="http://192.168.102.216:8080/yohosearch";
Iaccount.loginEx = "http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/profile/login";
Iaccount.queryAllAuth = "http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/profileDataEntitlement/queryAllAuth";
Iaccount.allRightEx = 'http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/action/query_simple_all'; // 切换根据获取所有权限接口为java接口
Iaccount.getResourceByPidEx = 'http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/menu/query_by_pid'; // 切换根据获取所有权限接口为java接口
Iaccount.queryProfilePurviewPaths = 'http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/action/queryProfilePurviewsPaths' //获取当前登录用户所有授权的权限路径
}
/*测试环境*/
... ... @@ -126,6 +132,9 @@ if(process.env.NODE_ENV==="test"){
apiCofig.EnvConst.yohoSearch=process.env.TEST_SEARCH||"http://10.66.100.4:8080/yohosearch";
Iaccount.loginEx = "http://qrest.yohobuy.com:9098/erp-gateway-web/account/profile/login";
Iaccount.queryAllAuth = "http://qrest.yohobuy.com:9098/erp-gateway-web/account/profileDataEntitlement/queryAllAuth";
Iaccount.allRightEx = 'http://qrest.yohobuy.com:9098/erp-gateway-web/account/action/query_simple_all'; // 切换根据获取所有权限接口为java接口
Iaccount.getResourceByPidEx = 'http://qrest.yohobuy.com:9098/erp-gateway-web/account/menu/query_by_pid'; // 切换根据获取所有权限接口为java接口
Iaccount.queryProfilePurviewPaths = 'http://qrest.yohobuy.com:9098/erp-gateway-web/account/action/queryProfilePurviewsPaths' //获取当前登录用户所有授权的权限路径
}
/*灰度环境*/
... ... @@ -134,6 +143,9 @@ if(process.env.NODE_ENV==="gray"){
apiCofig.EnvConst.yohoSearch="http://search.yohoops.org/yohosearch";
Iaccount.loginEx = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profile/login";
Iaccount.queryAllAuth = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profileDataEntitlement/queryAllAuth";
Iaccount.allRightEx = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/action/query_simple_all'; // 切换根据获取所有权限接口为java接口
Iaccount.getResourceByPidEx = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/menu/query_by_pid'; // 切换根据获取所有权限接口为java接口
Iaccount.queryProfilePurviewPaths = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/action/queryProfilePurviewsPaths' //获取当前登录用户所有授权的权限路径
}
/*线上环境*/
if(process.env.NODE_ENV==="production"){
... ... @@ -141,5 +153,8 @@ if(process.env.NODE_ENV==="production"){
apiCofig.EnvConst.yohoSearch="http://search.yohoops.org/yohosearch";
Iaccount.loginEx = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profile/login";
Iaccount.queryAllAuth = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profileDataEntitlement/queryAllAuth";
Iaccount.allRightEx = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/action/query_simple_all'; // 切换根据获取所有权限接口为java接口
Iaccount.getResourceByPidEx = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/menu/query_by_pid'; // 切换根据获取所有权限接口为java接口
Iaccount.queryProfilePurviewPaths = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/action/queryProfilePurviewsPaths' //获取当前登录用户所有授权的权限路径
}
module.exports = require('./libs/App')(apiCofig);
\ No newline at end of file
... ...
var $ = require('jquery');
$('#iframepage').css('height',$(window).height()-65);
\ No newline at end of file
... ...
var $ = require('jquery');
$('#iframepage').css('height',$(window).height()-65);
\ No newline at end of file
... ...