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 }) {
...
@@ -23,8 +23,17 @@ function Product({ match, location }) {
if
(
size
&&
color
)
{
if
(
size
&&
color
)
{
pushOptions
()
pushOptions
()
}
}
recommend
()
},
[
size
,
color
])
},
[
size
,
color
])
async
function
recommend
(){
try
{
const
response
=
await
axios
.
post
(
'
/api/order/recommend
'
)
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
function
handleClick
(
e
)
{
function
handleClick
(
e
)
{
const
box
=
e
.
target
.
parentNode
.
parentNode
const
box
=
e
.
target
.
parentNode
.
parentNode
box
.
style
.
display
=
"
none
"
box
.
style
.
display
=
"
none
"
...
...
server/controllers/order.controller.js
View file @
5151510f
...
@@ -35,28 +35,6 @@ const showorder = async (req, res) => {
...
@@ -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
)
=>
{
const
orderById
=
async
(
req
,
res
,
next
,
id
)
=>
{
try
{
try
{
const
user
=
await
User
.
findById
(
id
)
const
user
=
await
User
.
findById
(
id
)
...
@@ -71,4 +49,26 @@ const orderById = async (req, res, next, id) => {
...
@@ -71,4 +49,26 @@ const orderById = async (req, res, next, id) => {
}
}
}
}
export
default
{
addorder
,
showorder
,
orderById
,
Ordered
}
const
recommendPro
=
async
(
req
,
res
)
=>
{
\ No newline at end of file
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')
...
@@ -9,6 +9,9 @@ router.route('/addorder')
router
.
route
(
'
/showorder/:userId
'
)
router
.
route
(
'
/showorder/:userId
'
)
.
get
(
orderCtrl
.
showorder
)
.
get
(
orderCtrl
.
showorder
)
router
.
route
(
'
/recommend
'
)
.
post
(
orderCtrl
.
recommendPro
)
router
.
param
(
'
userId
'
,
orderCtrl
.
orderById
)
router
.
param
(
'
userId
'
,
orderCtrl
.
orderById
)
export
default
router
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