Commit edcdd9e2 authored by 이재연's avatar 이재연
Browse files

aaaa

parent 1c292013
......@@ -25,8 +25,19 @@ function Product({ match, location }) {
pushOptions()
// console.log(cart)
}
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"
......
......@@ -45,7 +45,7 @@ function ProductsRegist() {
}, [])
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)
}, [product])
......@@ -140,7 +140,6 @@ function ProductsRegist() {
return (
<Container>
{console.log(product)}
<Row className="justify-content-md-center">
<Col md={8} className="border p-1" style={{ background: '#F7F3F3' }}>
{error && <Alert variant="danger" className="text-center">{error}</Alert>}
......
......@@ -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}
......@@ -11,6 +11,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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment