Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
shopping-mall
Commits
5151510f
Commit
5151510f
authored
Jan 27, 2021
by
kusang96
Browse files
Merge remote-tracking branch 'origin/jaeyeon' into kimpen
parents
be29f536
edcdd9e2
Changes
3
Show whitespace changes
Inline
Side-by-side
client/src/Pages/Product.js
View file @
5151510f
...
...
@@ -23,8 +23,17 @@ function Product({ match, location }) {
if
(
size
&&
color
)
{
pushOptions
()
}
recommend
()
},
[
size
,
color
])
async
function
recommend
(){
try
{
const
response
=
await
axios
.
post
(
'
/api/order/recommend
'
)
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
function
handleClick
(
e
)
{
const
box
=
e
.
target
.
parentNode
.
parentNode
box
.
style
.
display
=
"
none
"
...
...
server/controllers/order.controller.js
View file @
5151510f
...
...
@@ -35,28 +35,6 @@ const showorder = async (req, res) => {
}
}
const
recommendPro
=
async
(
req
,
res
)
=>
{
const
{
productId
}
=
req
.
body
console
.
log
(
productId
)
try
{
const
findedorder
=
await
Order
.
find
({
'
products.productId
'
:
productId
})
console
.
log
(
'
findedouder=
'
,
findedorder
)
const
recommend
=
await
const
recommend
=
await
Order
.
aggregate
([
// { $project: {}},
{
$match
:
{
"
products
"
:{
"
productId
"
:
productId
}}},
{
$group
:
{
_id
:
"
$products.productId
"
,
num_tutorial
:
{
$sum
:
1
}
}
}
])
console
.
log
(
'
recommend=
'
,
recommend
)
}
catch
(
error
)
{
}
}
const
orderById
=
async
(
req
,
res
,
next
,
id
)
=>
{
try
{
const
user
=
await
User
.
findById
(
id
)
...
...
@@ -71,4 +49,26 @@ const orderById = async (req, res, next, id) => {
}
}
export
default
{
addorder
,
showorder
,
orderById
,
Ordered
}
\ No newline at end of file
const
recommendPro
=
async
(
req
,
res
)
=>
{
try
{
const
recommend
=
await
Order
.
aggregate
([
{
"
$unwind
"
:
"
$products
"
},
// {
// $match:{'products.productId':'600e2fcc8afbb038487cc8fa'}
// },
{
$group
:
{
_id
:
'
$products.productId
'
,
num_total
:{
$sum
:
1
}
}
}
])
console
.
log
(
recommend
)
}
catch
(
error
)
{
console
.
log
(
error
)
res
.
status
(
500
).
send
(
'
추천 실패
'
)
}
}
export
default
{
addorder
,
showorder
,
orderById
,
Ordered
,
recommendPro
}
\ No newline at end of file
server/routes/order.routes.js
View file @
5151510f
...
...
@@ -9,6 +9,9 @@ router.route('/addorder')
router
.
route
(
'
/showorder/:userId
'
)
.
get
(
orderCtrl
.
showorder
)
router
.
route
(
'
/recommend
'
)
.
post
(
orderCtrl
.
recommendPro
)
router
.
param
(
'
userId
'
,
orderCtrl
.
orderById
)
export
default
router
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment