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
edcdd9e2
Commit
edcdd9e2
authored
Jan 27, 2021
by
이재연
Browse files
aaaa
parent
1c292013
Changes
4
Show whitespace changes
Inline
Side-by-side
client/src/Pages/Product.js
View file @
edcdd9e2
...
@@ -25,8 +25,19 @@ function Product({ match, location }) {
...
@@ -25,8 +25,19 @@ function Product({ match, location }) {
pushOptions
()
pushOptions
()
// console.log(cart)
// console.log(cart)
}
}
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
"
...
...
client/src/Pages/ProductRegist.js
View file @
edcdd9e2
...
@@ -45,7 +45,7 @@ function ProductsRegist() {
...
@@ -45,7 +45,7 @@ function ProductsRegist() {
},
[])
},
[])
useEffect
(()
=>
{
useEffect
(()
=>
{
const
isProduct
=
Object
.
values
(
product
).
every
(
el
=>
{
console
.
log
(
"
el=
"
,
el
);
Boolean
(
el
)
})
const
isProduct
=
Object
.
values
(
product
).
every
(
el
=>
{
Boolean
(
el
)
})
isProduct
?
setDisabled
(
false
)
:
setDisabled
(
true
)
isProduct
?
setDisabled
(
false
)
:
setDisabled
(
true
)
},
[
product
])
},
[
product
])
...
@@ -140,7 +140,6 @@ function ProductsRegist() {
...
@@ -140,7 +140,6 @@ function ProductsRegist() {
return
(
return
(
<
Container
>
<
Container
>
{
console
.
log
(
product
)}
<
Row
className
=
"
justify-content-md-center
"
>
<
Row
className
=
"
justify-content-md-center
"
>
<
Col
md
=
{
8
}
className
=
"
border p-1
"
style
=
{{
background
:
'
#F7F3F3
'
}}
>
<
Col
md
=
{
8
}
className
=
"
border p-1
"
style
=
{{
background
:
'
#F7F3F3
'
}}
>
{
error
&&
<
Alert
variant
=
"
danger
"
className
=
"
text-center
"
>
{
error
}
<
/Alert>
}
{
error
&&
<
Alert
variant
=
"
danger
"
className
=
"
text-center
"
>
{
error
}
<
/Alert>
}
...
...
server/controllers/order.controller.js
View file @
edcdd9e2
...
@@ -54,4 +54,27 @@ const orderById = async (req, res, next, id) => {
...
@@ -54,4 +54,27 @@ const orderById = async (req, res, next, id) => {
}
}
}
}
export
default
{
addorder
,
showorder
,
orderById
,
Ordered
}
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
}
server/routes/order.routes.js
View file @
edcdd9e2
...
@@ -11,6 +11,9 @@ router.route('/addorder')
...
@@ -11,6 +11,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