Merge branch 'feature/change-erp-api' into 'master'
切换php接口到java接口 切换php接口到java接口 See merge request !22
Showing
8 changed files
with
96 additions
and
28 deletions
@@ -18,7 +18,7 @@ var Utils = { | @@ -18,7 +18,7 @@ var Utils = { | ||
18 | var item = { | 18 | var item = { |
19 | title: v.menu_name, | 19 | title: v.menu_name, |
20 | } | 20 | } |
21 | - if (v.parent_id === "0") { | 21 | + if (v.parent_id === 0) { |
22 | item.parent = 'menu-template'; | 22 | item.parent = 'menu-template'; |
23 | var itemSubs = []; | 23 | var itemSubs = []; |
24 | _.forEach(v.sub, function (val) { | 24 | _.forEach(v.sub, function (val) { |
@@ -53,22 +53,26 @@ module.exports = { | @@ -53,22 +53,26 @@ module.exports = { | ||
53 | }, | 53 | }, |
54 | getResourceByPid: { | 54 | getResourceByPid: { |
55 | title:'菜单接口', | 55 | title:'菜单接口', |
56 | - url: Iaccount.getResourceByPid, | ||
57 | - form: '[{{pid}},{{role_id}},{{website}}]', | 56 | + // url: Iaccount.getResourceByPid, |
57 | + url: Iaccount.getResourceByPidEx, | ||
58 | + // form: '[{{pid}},{{role_id}},{{website}}]', | ||
58 | params: { | 59 | params: { |
59 | pid: { type: Number }, | 60 | pid: { type: Number }, |
60 | - role_id: { type: Number }, | ||
61 | - website: { type: Number, default: Iaccount.WEBSITE } | 61 | + // role_id: { type: Number }, |
62 | + // website: { type: Number, default: Iaccount.WEBSITE } | ||
63 | + platform_id: { type: Number, default: Iaccount.WEBSITE } | ||
62 | } | 64 | } |
63 | }, | 65 | }, |
64 | allRight: { | 66 | allRight: { |
65 | title: '获取权限', | 67 | title: '获取权限', |
66 | - url: Iaccount.allRight, | 68 | + // url: Iaccount.allRight, |
69 | + url: Iaccount.allRightEx, | ||
67 | form: '[false]' | 70 | form: '[false]' |
68 | }, | 71 | }, |
69 | sessionAsync: { | 72 | sessionAsync: { |
70 | title:'与老系统session同步', | 73 | title:'与老系统session同步', |
71 | - url: Iaccount.url + '/account/login/sessions', | 74 | + // url: Iaccount.url + '/account/login/sessions', |
75 | + url: Iaccount.erpUrl + '/account/login/session', | ||
72 | outobj: "response", | 76 | outobj: "response", |
73 | form: {'account':'{{user}}','password':'{{password}}','refer': '{{refer}}'}, | 77 | form: {'account':'{{user}}','password':'{{password}}','refer': '{{refer}}'}, |
74 | params: { | 78 | params: { |
@@ -86,6 +90,15 @@ module.exports = { | @@ -86,6 +90,15 @@ module.exports = { | ||
86 | type:{ type: Number, default : 1 } | 90 | type:{ type: Number, default : 1 } |
87 | } | 91 | } |
88 | }, | 92 | }, |
93 | + queryProfilePurviewPaths: { | ||
94 | + title: '获取当前账号所有授权的权限', | ||
95 | + url: Iaccount.queryProfilePurviewPaths, | ||
96 | + params: { | ||
97 | + pid: { type: Number }, | ||
98 | + role_id: { type: Number }, | ||
99 | + platform_id: { type: Number, default: Iaccount.WEBSITE } | ||
100 | + } | ||
101 | + }, | ||
89 | login: function (req, callback, common) { | 102 | login: function (req, callback, common) { |
90 | 103 | ||
91 | console.log("begin enter login function --------------------------------------------------------------------------------------" + req); | 104 | console.log("begin enter login function --------------------------------------------------------------------------------------" + req); |
@@ -144,9 +157,8 @@ module.exports = { | @@ -144,9 +157,8 @@ module.exports = { | ||
144 | result.passwd_time = IloginRes.data.pwdExpirationDays; | 157 | result.passwd_time = IloginRes.data.pwdExpirationDays; |
145 | 158 | ||
146 | userInfo = { auth: userData, uid: userData.pid, name: userData.truename, role: userData.roleName, right: {},shopList:[],brands:[]}; | 159 | userInfo = { auth: userData, uid: userData.pid, name: userData.truename, role: userData.roleName, right: {},shopList:[],brands:[]}; |
147 | - common.queryAllAuth(userData.pid).getResourceByPid(userData.pid, userData.role_id).done(function (allAuthResp, getRRes) { | 160 | + common.queryAllAuth(userData.pid).getResourceByPid(userData.pid).queryProfilePurviewPaths(userData.pid, userData.role_id).done(function (allAuthResp, getRRes, allPPRes) { |
148 | console.log("enter common queryAllAuth, allAuthResp: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^1^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", allAuthResp.data.brand.list); | 161 | console.log("enter common queryAllAuth, allAuthResp: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^1^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^", allAuthResp.data.brand.list); |
149 | - | ||
150 | if(true){ | 162 | if(true){ |
151 | var arrList = []; | 163 | var arrList = []; |
152 | console.log("enter common queryAllAuth, allAuthResp list: ******************************************************************" + (JSON.stringify(allAuthResp.data.brand.list) == "{}")); | 164 | console.log("enter common queryAllAuth, allAuthResp list: ******************************************************************" + (JSON.stringify(allAuthResp.data.brand.list) == "{}")); |
@@ -163,15 +175,23 @@ module.exports = { | @@ -163,15 +175,23 @@ module.exports = { | ||
163 | 175 | ||
164 | console.log("userInfo.brands set success ; userInfo.brands is " + userInfo.brands + "(" + (typeof userInfo.brands==="string") + ")" + "*******"); | 176 | console.log("userInfo.brands set success ; userInfo.brands is " + userInfo.brands + "(" + (typeof userInfo.brands==="string") + ")" + "*******"); |
165 | } | 177 | } |
166 | - | ||
167 | - allRes.data.forEach(function (data) { | ||
168 | - if (data.platform_id == Iaccount.WEBSITE) { | ||
169 | - userInfo.right[data.path] = true; | 178 | + _.forEach(allRes.data, item => { |
179 | + if (item.platform_id == Iaccount.WEBSITE ){ | ||
180 | + userInfo.right[item.path] = true; | ||
170 | } | 181 | } |
171 | }); | 182 | }); |
183 | + // allRes.data.forEach(function (data) { | ||
184 | + // if (data.platform_id == Iaccount.WEBSITE) { | ||
185 | + // userInfo.right[data.path] = true; | ||
186 | + // } | ||
187 | + // }); | ||
172 | 188 | ||
189 | + //组织用户的菜单(切换了新接口) | ||
173 | userInfo.menu = Utils.createrMenus(getRRes.data); | 190 | userInfo.menu = Utils.createrMenus(getRRes.data); |
174 | 191 | ||
192 | + //获取用户的所有权限(原为每次根据访问路径去请求接口,现改成将用户所有访问的路径都保存到session中) lzhy 2020-08-04 | ||
193 | + userInfo.purviewPaths = _.get(allPPRes, 'data', []); | ||
194 | + | ||
175 | // 如果是要过期,则需要提示用户密码要过期 | 195 | // 如果是要过期,则需要提示用户密码要过期 |
176 | console.log("enter getResourceByPid, passwd_time: " + result.passwd_time); | 196 | console.log("enter getResourceByPid, passwd_time: " + result.passwd_time); |
177 | if (result.passwd_time != undefined && result.passwd_time > 0) { | 197 | if (result.passwd_time != undefined && result.passwd_time > 0) { |
@@ -230,19 +250,25 @@ module.exports = { | @@ -230,19 +250,25 @@ module.exports = { | ||
230 | 'x-client-ip': req.ip, | 250 | 'x-client-ip': req.ip, |
231 | 'x-user-brands':typeof user.brands==="string"?user.brands: user.brands.join(',') | 251 | 'x-user-brands':typeof user.brands==="string"?user.brands: user.brands.join(',') |
232 | }; | 252 | }; |
253 | + | ||
233 | if (path && user.right[path]) { | 254 | if (path && user.right[path]) { |
234 | - common.isUsedMenuAuth(user.auth.pid,user.auth.role_id,path).done(function(isURes){ | ||
235 | - result = { code: 200, message: "具有权限" }; | ||
236 | - if(isURes.data){ | ||
237 | - result={code:isURes.data.code,message:isURes.data.errmsg}; | ||
238 | - } | ||
239 | - console.log("return result: " + JSON.stringify(isURes)); | ||
240 | - console.log("code 200, result: " + JSON.stringify(result)); | ||
241 | - return callback(null, result); | ||
242 | - },function(error){ | ||
243 | - console.log("error: " + error); | ||
244 | - return callback(error, result); | ||
245 | - }); | 255 | + // 改成从缓存中读取用户所有的授权路径进行判断 |
256 | + if(_.indexOf(req.session.user.purviewPaths, path) > -1){ | ||
257 | + result = { code: 200, message: "具有权限" }; | ||
258 | + } | ||
259 | + return callback(null, result); | ||
260 | + // common.isUsedMenuAuth(user.auth.pid,user.auth.role_id,path).done(function(isURes){ | ||
261 | + // result = { code: 200, message: "具有权限" }; | ||
262 | + // if(isURes.data){ | ||
263 | + // result={code:isURes.data.code,message:isURes.data.errmsg}; | ||
264 | + // } | ||
265 | + // console.log("return result: " + JSON.stringify(isURes)); | ||
266 | + // console.log("code 200, result: " + JSON.stringify(result)); | ||
267 | + // return callback(null, result); | ||
268 | + // },function(error){ | ||
269 | + // console.log("error: " + error); | ||
270 | + // return callback(error, result); | ||
271 | + // }); | ||
246 | } else { | 272 | } else { |
247 | result = { code: 200, message: "不受权限控制" }; | 273 | result = { code: 200, message: "不受权限控制" }; |
248 | console.log(result); | 274 | console.log(result); |
code/apps/outLink/controllers/outlink.js
0 → 100644
1 | +const md5 = require("md5"); | ||
2 | +module.exports = function (app) { | ||
3 | + app.get("/out/links/index", "outLink.OutLink", function (req, res) { | ||
4 | + const secretKey = 'yoho9646yoho9646'; | ||
5 | + const url = req.query.url; | ||
6 | + const outLinkUrl = url.indexOf('?') > -1 ? url + '&pid=' + req.session.user.auth.pid : outLinkUrl + '&pid=' + req.session.user.auth.pid; | ||
7 | + const pidMd5 = md5(req.session.user.auth.pid + secretKey); | ||
8 | + this.$extend = { | ||
9 | + outLinkUrl: outLinkUrl + '&pidMd5=' + pidMd5 + '&' + new Date().getTime() | ||
10 | + } | ||
11 | + }); | ||
12 | + | ||
13 | + app.get("/iframe/links/index", "outLink.Iframe", function (req, res) { | ||
14 | + const outLinkUrl = req.query.url; | ||
15 | + this.$extend = { | ||
16 | + outLinkUrl: outLinkUrl.indexOf('?') > -1 ? outLinkUrl + '&code=iframe' : outLinkUrl + '?code=iframe' | ||
17 | + } | ||
18 | + }); | ||
19 | +} |
code/apps/outLink/views/Iframe.html
0 → 100644
code/apps/outLink/views/OutLink.html
0 → 100644
@@ -28,19 +28,22 @@ var Iaccount = { | @@ -28,19 +28,22 @@ var Iaccount = { | ||
28 | login: oldSerDomain + '/service/account/v1/Profile/login', | 28 | login: oldSerDomain + '/service/account/v1/Profile/login', |
29 | loginEx: javaErpDomain + '/erp-gateway-web/account/profile/login', | 29 | loginEx: javaErpDomain + '/erp-gateway-web/account/profile/login', |
30 | getResourceByPid: oldSerDomain + '/service/account/v1/Profile/getMenuByPid', | 30 | getResourceByPid: oldSerDomain + '/service/account/v1/Profile/getMenuByPid', |
31 | + getResourceByPidEx : javaErpDomain + '/erp-gateway-web/account/menu/query_by_pid', // 切换根据获取用户菜单接口为java接口 | ||
31 | getAllResByWebsite: oldSerDomain + '/service/setting/v1/menu/getAllMenu', | 32 | getAllResByWebsite: oldSerDomain + '/service/setting/v1/menu/getAllMenu', |
32 | changeShops: 'http://shops.yohobuy.com/index/ajaxshop', | 33 | changeShops: 'http://shops.yohobuy.com/index/ajaxshop', |
33 | isUsedMenuAuth: oldSerDomain + '/service/account/v1/profile/authPath', | 34 | isUsedMenuAuth: oldSerDomain + '/service/account/v1/profile/authPath', |
34 | allRight: oldSerDomain + '/service/setting/v1/action/getAllAction', | 35 | allRight: oldSerDomain + '/service/setting/v1/action/getAllAction', |
35 | - | 36 | + allRightEx: javaErpDomain + '/erp-gateway-web/account/action/query_simple_all', // 切换根据获取所有权限接口为java接口 |
36 | getShopList: '{{domain}}/ShopsRest/queryShopsByAdminPid', | 37 | getShopList: '{{domain}}/ShopsRest/queryShopsByAdminPid', |
37 | 38 | ||
38 | // 灰度代理 | 39 | // 灰度代理 |
39 | url: 'http://admin.portal.yohobuy.com', | 40 | url: 'http://admin.portal.yohobuy.com', |
41 | + erpUrl: 'http://erp.yohobuy.com', | ||
40 | sessionKeep: '/account/profile/display', | 42 | sessionKeep: '/account/profile/display', |
41 | timeout: 10000, | 43 | timeout: 10000, |
42 | 44 | ||
43 | - queryAllAuth : javaErpDomain + '/erp-gateway-web/account/profileDataEntitlement/queryAllAuth' | 45 | + queryAllAuth: javaErpDomain + '/erp-gateway-web/account/profileDataEntitlement/queryAllAuth', |
46 | + queryProfilePurviewPaths: javaErpDomain + '/erp-gateway-web/account/action/queryProfilePurviewsPaths' //获取当前登录用户所有授权的权限路径 | ||
44 | }; | 47 | }; |
45 | 48 | ||
46 | 49 | ||
@@ -118,6 +121,9 @@ if(process.env.NODE_ENV!="coding"){ | @@ -118,6 +121,9 @@ if(process.env.NODE_ENV!="coding"){ | ||
118 | apiCofig.EnvConst.yohoSearch="http://192.168.102.216:8080/yohosearch"; | 121 | apiCofig.EnvConst.yohoSearch="http://192.168.102.216:8080/yohosearch"; |
119 | Iaccount.loginEx = "http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/profile/login"; | 122 | Iaccount.loginEx = "http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/profile/login"; |
120 | Iaccount.queryAllAuth = "http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/profileDataEntitlement/queryAllAuth"; | 123 | Iaccount.queryAllAuth = "http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/profileDataEntitlement/queryAllAuth"; |
124 | + Iaccount.allRightEx = 'http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/action/query_simple_all'; // 切换根据获取所有权限接口为java接口 | ||
125 | + Iaccount.getResourceByPidEx = 'http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/menu/query_by_pid'; // 切换根据获取所有权限接口为java接口 | ||
126 | + Iaccount.queryProfilePurviewPaths = 'http://gateway.erp.yohoops.org:9098/erp-gateway-web/account/action/queryProfilePurviewsPaths' //获取当前登录用户所有授权的权限路径 | ||
121 | } | 127 | } |
122 | 128 | ||
123 | /*测试环境*/ | 129 | /*测试环境*/ |
@@ -126,6 +132,9 @@ if(process.env.NODE_ENV==="test"){ | @@ -126,6 +132,9 @@ if(process.env.NODE_ENV==="test"){ | ||
126 | apiCofig.EnvConst.yohoSearch=process.env.TEST_SEARCH||"http://10.66.100.4:8080/yohosearch"; | 132 | apiCofig.EnvConst.yohoSearch=process.env.TEST_SEARCH||"http://10.66.100.4:8080/yohosearch"; |
127 | Iaccount.loginEx = "http://qrest.yohobuy.com:9098/erp-gateway-web/account/profile/login"; | 133 | Iaccount.loginEx = "http://qrest.yohobuy.com:9098/erp-gateway-web/account/profile/login"; |
128 | Iaccount.queryAllAuth = "http://qrest.yohobuy.com:9098/erp-gateway-web/account/profileDataEntitlement/queryAllAuth"; | 134 | Iaccount.queryAllAuth = "http://qrest.yohobuy.com:9098/erp-gateway-web/account/profileDataEntitlement/queryAllAuth"; |
135 | + Iaccount.allRightEx = 'http://qrest.yohobuy.com:9098/erp-gateway-web/account/action/query_simple_all'; // 切换根据获取所有权限接口为java接口 | ||
136 | + Iaccount.getResourceByPidEx = 'http://qrest.yohobuy.com:9098/erp-gateway-web/account/menu/query_by_pid'; // 切换根据获取所有权限接口为java接口 | ||
137 | + Iaccount.queryProfilePurviewPaths = 'http://qrest.yohobuy.com:9098/erp-gateway-web/account/action/queryProfilePurviewsPaths' //获取当前登录用户所有授权的权限路径 | ||
129 | } | 138 | } |
130 | 139 | ||
131 | /*灰度环境*/ | 140 | /*灰度环境*/ |
@@ -134,6 +143,9 @@ if(process.env.NODE_ENV==="gray"){ | @@ -134,6 +143,9 @@ if(process.env.NODE_ENV==="gray"){ | ||
134 | apiCofig.EnvConst.yohoSearch="http://search.yohoops.org/yohosearch"; | 143 | apiCofig.EnvConst.yohoSearch="http://search.yohoops.org/yohosearch"; |
135 | Iaccount.loginEx = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profile/login"; | 144 | Iaccount.loginEx = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profile/login"; |
136 | Iaccount.queryAllAuth = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profileDataEntitlement/queryAllAuth"; | 145 | Iaccount.queryAllAuth = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profileDataEntitlement/queryAllAuth"; |
146 | + Iaccount.allRightEx = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/action/query_simple_all'; // 切换根据获取所有权限接口为java接口 | ||
147 | + Iaccount.getResourceByPidEx = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/menu/query_by_pid'; // 切换根据获取所有权限接口为java接口 | ||
148 | + Iaccount.queryProfilePurviewPaths = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/action/queryProfilePurviewsPaths' //获取当前登录用户所有授权的权限路径 | ||
137 | } | 149 | } |
138 | /*线上环境*/ | 150 | /*线上环境*/ |
139 | if(process.env.NODE_ENV==="production"){ | 151 | if(process.env.NODE_ENV==="production"){ |
@@ -141,5 +153,8 @@ if(process.env.NODE_ENV==="production"){ | @@ -141,5 +153,8 @@ if(process.env.NODE_ENV==="production"){ | ||
141 | apiCofig.EnvConst.yohoSearch="http://search.yohoops.org/yohosearch"; | 153 | apiCofig.EnvConst.yohoSearch="http://search.yohoops.org/yohosearch"; |
142 | Iaccount.loginEx = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profile/login"; | 154 | Iaccount.loginEx = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profile/login"; |
143 | Iaccount.queryAllAuth = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profileDataEntitlement/queryAllAuth"; | 155 | Iaccount.queryAllAuth = "http://gateway.erp.yohoops.org/erp-gateway-web/account/profileDataEntitlement/queryAllAuth"; |
156 | + Iaccount.allRightEx = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/action/query_simple_all'; // 切换根据获取所有权限接口为java接口 | ||
157 | + Iaccount.getResourceByPidEx = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/menu/query_by_pid'; // 切换根据获取所有权限接口为java接口 | ||
158 | + Iaccount.queryProfilePurviewPaths = 'http://gateway.erp.yohoops.org/erp-gateway-web/account/action/queryProfilePurviewsPaths' //获取当前登录用户所有授权的权限路径 | ||
144 | } | 159 | } |
145 | module.exports = require('./libs/App')(apiCofig); | 160 | module.exports = require('./libs/App')(apiCofig); |
1 | { | 1 | { |
2 | "name": "yohobuy-portal-fe", | 2 | "name": "yohobuy-portal-fe", |
3 | - "version": "5.0.2", | 3 | + "version": "5.0.3", |
4 | "description": "Construction of the presentation layer solution is based on express, handlebars", | 4 | "description": "Construction of the presentation layer solution is based on express, handlebars", |
5 | "main": "app.js", | 5 | "main": "app.js", |
6 | "scripts": { | 6 | "scripts": { |
-
Please register or login to post a comment