Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
htoo
5 years ago
Commit
9cb17aa71026bf984ba223dd38cd4136dfb8bc94
1 parent
024fd3bf
hotfix(home): support multi file and auth user
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
15 deletions
apps/common/controllers/upload.js
apps/common/router.js
apps/common/controllers/upload.js
View file @
9cb17aa
...
...
@@ -48,22 +48,31 @@ const uploadImg = (req, res, next) => {
});
}
yohoApi
.
postFile
(
''
,
{
bucket
:
req
.
body
.
bucket
,
file
:
req
.
body
.
files
[
0
],
uid
:
req
.
user
.
uid
.
toString
(),
method
:
'yoho.fileupload'
}).
then
(
function
(
result
)
{
if
(
result
&&
result
.
code
===
200
)
{
const
images
=
[
utils
.
getUploadImgAbsoluteUrl
(
_
.
get
(
result
,
'data'
),
req
.
body
.
bucket
)];
Promise
.
all
(
req
.
body
.
files
.
map
(
f
=>
{
return
yohoApi
.
postFile
(
''
,
{
bucket
:
req
.
body
.
bucket
,
file
:
f
,
uid
:
req
.
user
.
uid
.
toString
(),
method
:
'yoho.fileupload'
});
})
).
then
(
result
=>
{
const
images
=
result
.
reduce
((
t
,
r
)
=>
{
if
(
r
&&
r
.
data
&&
r
.
code
===
200
)
{
t
.
push
(
utils
.
getUploadImgAbsoluteUrl
(
_
.
get
(
r
,
'data'
),
req
.
body
.
bucket
));
}
return
t
;
},
[]);
result
.
data
=
{
res
.
json
({
code
:
200
,
data
:
{
images
,
imagesList
:
images
};
}
res
.
json
(
result
);
imageList
:
images
},
message
:
'上传成功'
});
}).
catch
(
next
);
};
...
...
apps/common/router.js
View file @
9cb17aa
...
...
@@ -18,11 +18,12 @@ const erp2goods = require(`${cRoot}/erp2goods`);
const
getBanner
=
require
(
`
$
{
cRoot
}
/getBanner`
)
;
const
passport
=
require
(
`
$
{
cRoot
}
/passport`
)
;
const
suggestFeedBack
=
require
(
`
$
{
cRoot
}
/suggestFeedBack`
)
;
const
auth
=
require
(
`
$
{
global
.
middleware
}
/auth`
)
;
router
.
get
(
'/recentReview'
,
rvCtrl
.
index
);
// 最近浏览
router
.
post
(
'/getRecommend'
,
rvCtrl
.
getRecommend
);
// 为你优选
router
.
post
(
'/upload/image'
,
multipartMiddleware
,
uploadCtrl
.
uploadImg
);
router
.
post
(
'/upload/image'
,
auth
,
multipartMiddleware
,
uploadCtrl
.
uploadImg
);
router
.
get
(
'/erp2goods'
,
erp2goods
.
find
);
...
...
Please
register
or
login
to post a comment