Merge branch 'develop' of git.dev.yoho.cn:platform/yohobuy-portal-fe into develop
Showing
2 changed files
with
21 additions
and
1 deletions
1 | var request = require('request'); | 1 | var request = require('request'); |
2 | var fs = require('fs'); | 2 | var fs = require('fs'); |
3 | +var ipaddr = require('ipaddr.js'); | ||
3 | var domain = require('../../config/common.js').domain; | 4 | var domain = require('../../config/common.js').domain; |
4 | //var domain = 'http://172.16.6.227:8083/yohobuy-platform-web'; //马力 | 5 | //var domain = 'http://172.16.6.227:8083/yohobuy-platform-web'; //马力 |
5 | //var domain = 'http://192.168.102.202:8088/platform'; | 6 | //var domain = 'http://192.168.102.202:8088/platform'; |
@@ -7,6 +8,9 @@ var domain = require('../../config/common.js').domain; | @@ -7,6 +8,9 @@ var domain = require('../../config/common.js').domain; | ||
7 | var env = process.env.NODE_ENV || 'development'; | 8 | var env = process.env.NODE_ENV || 'development'; |
8 | 9 | ||
9 | exports.uploadFile = function(req, res) { | 10 | exports.uploadFile = function(req, res) { |
11 | + if(req.session.user) { | ||
12 | + appendAdminInfo(req,req.session.user.auth); | ||
13 | + } | ||
10 | if (req.is("multipart/form-data")) { | 14 | if (req.is("multipart/form-data")) { |
11 | req.body.file = fs.createReadStream(req.files[req.body.filename].path); | 15 | req.body.file = fs.createReadStream(req.files[req.body.filename].path); |
12 | if (req.body.__type == "batch-import") { | 16 | if (req.body.__type == "batch-import") { |
@@ -34,4 +38,21 @@ exports.uploadFile = function(req, res) { | @@ -34,4 +38,21 @@ exports.uploadFile = function(req, res) { | ||
34 | message: "请求类型错误" | 38 | message: "请求类型错误" |
35 | }); | 39 | }); |
36 | } | 40 | } |
41 | +} | ||
42 | +/** | ||
43 | + * 附加管理员的信息 | ||
44 | + * @param {Request} req 请求对象 | ||
45 | + * @param {Number} uid 用户ID | ||
46 | + * @param {String} name 用户名 | ||
47 | + * @return {Object} 用户信息对象 | ||
48 | + */ | ||
49 | +function appendAdminInfo(req,auth) { | ||
50 | + var ipObject = ipaddr.process(req.ip).octets | ||
51 | + var ip = ipObject?ipObject.join('.'):req.ip; | ||
52 | + req._yoheaders = { | ||
53 | + 'x-user-id':auth.pid, | ||
54 | + 'x-user-name':auth.account, | ||
55 | + 'x-site-type':WEBSITE, | ||
56 | + 'x-client-ip':ip | ||
57 | + }; | ||
37 | } | 58 | } |
-
Please register or login to post a comment