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
fdb92c49
Commit
fdb92c49
authored
Jan 25, 2021
by
이재연
Browse files
Merge remote-tracking branch 'origin/ourMaster' into jaeyeon
parents
78491956
520cf554
Changes
24
Hide whitespace changes
Inline
Side-by-side
server/controllers/product.controller.js
View file @
fdb92c49
...
@@ -51,6 +51,7 @@ const getAll = async (req, res) => {
...
@@ -51,6 +51,7 @@ const getAll = async (req, res) => {
}
}
const
getlist
=
(
req
,
res
)
=>
{
const
getlist
=
(
req
,
res
)
=>
{
console
.
log
(
'
get list
'
)
try
{
try
{
res
.
json
(
req
.
productslist
)
res
.
json
(
req
.
productslist
)
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -58,43 +59,55 @@ const getlist = (req, res) => {
...
@@ -58,43 +59,55 @@ const getlist = (req, res) => {
}
}
}
}
const
categoryId
=
async
(
req
,
res
,
next
,
category
)
=>
{
const
subname
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
productslist
=
await
Product
.
find
({
main_category
:
category
})
console
.
log
(
"
last subname::: LET ME SEE
"
)
if
(
!
productslist
)
{
res
.
json
(
req
.
findsubname
)
res
.
status
(
404
).
send
(
'
상품을 찾을 수 없습니다.
'
)
}
req
.
productslist
=
productslist
next
()
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
'
상품을 불러오지 못했습니다.
'
)
res
.
status
(
500
).
send
(
'
상품을 불러오지 못했습니다.
'
)
}
}
}
}
const
subgetlist
=
(
req
,
res
)
=>
{
const
categoryId
=
async
(
req
,
res
,
next
,
category
)
=>
{
const
{
search
}
=
req
.
body
console
.
log
(
"
server search=
"
,
search
)
try
{
try
{
res
.
json
(
req
.
subproductslist
)
const
productslist
=
await
Product
.
find
({
main_category
:
category
})
// if (!productslist) {
// res.status(404).send('상품을 찾을 수 없습니다.')
// }
req
.
productslist
=
productslist
console
.
log
(
"
nononono
"
,
req
.
productslist
)
next
()
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
'
상품을 불러오지 못했습니다.
'
)
res
.
status
(
500
).
send
(
'
상품을 불러오지 못했습니다.
'
)
}
}
}
}
const
subcategoryId
=
async
(
req
,
res
,
next
,
sub
category
)
=>
{
const
subcategoryId
=
async
(
req
,
res
,
next
,
sub
name
)
=>
{
try
{
try
{
const
subproductslist
=
await
Product
.
find
({
sub_category
:
subcategory
})
console
.
log
(
"
Please===>>>
"
,
subname
)
if
(
!
subproductslist
)
{
const
findSubname
=
await
Product
.
find
({
sub_category
:
subname
})
res
.
status
(
404
).
send
(
'
상품을 찾을 수 없습니다.
'
)
console
.
log
(
"
findSubname111=
"
,
findSubname
)
if
(
!
findSubname
)
{
const
findSubname
=
{
_id
:
'
nothing
'
,
pro_name
:
'
상품준비중
'
,
price
:
0
,
main_imgUrl
:
''
}
console
.
log
(
"
findSubname2222=
"
,
findSubname
)
res
.
send
(
findSubname
)
}
}
req
.
subproductslist
=
subproductslist
res
.
send
(
findSubname
)
next
()
}
catch
(
error
)
{
}
catch
(
error
)
{
res
.
status
(
500
).
send
(
'
상품을 불러오지 못했습니다.
'
)
res
.
send
(
'
상품을 불러오지 못했습니다.
'
)
}
}
}
}
const
plusPurchase
=
async
(
req
,
res
)
=>
{
const
plusPurchase
=
async
(
req
,
res
)
=>
{
const
{
products
}
=
req
.
body
const
{
products
}
=
req
.
body
// console.log(products)
try
{
try
{
for
(
let
i
=
0
;
i
<
products
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
products
.
length
;
i
++
)
{
const
count
=
products
[
i
].
count
const
count
=
products
[
i
].
count
...
@@ -112,7 +125,6 @@ const plusPurchase = async (req, res) => {
...
@@ -112,7 +125,6 @@ const plusPurchase = async (req, res) => {
}
}
}
}
)
)
// console.log("i=", i)
}
}
res
.
send
(
"
구매수 늘리기, 재고수 줄이기 성공
"
)
res
.
send
(
"
구매수 늘리기, 재고수 줄이기 성공
"
)
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -120,4 +132,4 @@ const plusPurchase = async (req, res) => {
...
@@ -120,4 +132,4 @@ const plusPurchase = async (req, res) => {
}
}
}
}
export
default
{
imageUpload
,
regist
,
getToHome
,
getAll
,
categoryId
,
getlist
,
subcategoryId
,
sub
getlist
,
plusPurchase
}
export
default
{
imageUpload
,
regist
,
getToHome
,
getAll
,
categoryId
,
getlist
,
subcategoryId
,
sub
name
,
plusPurchase
}
server/controllers/user.controller.js
View file @
fdb92c49
...
@@ -32,7 +32,7 @@ const userById = async (req, res, next, id) => {
...
@@ -32,7 +32,7 @@ const userById = async (req, res, next, id) => {
const
signup
=
async
(
req
,
res
)
=>
{
const
signup
=
async
(
req
,
res
)
=>
{
const
{
name
,
number1
,
number2
,
id
,
password
,
tel
,
email
}
=
req
.
body
const
{
name
,
number1
,
number2
,
id
,
password
,
tel
,
email
}
=
req
.
body
console
.
log
(
"
whatup
"
,
req
.
body
)
console
.
log
(
"
whatup
"
,
req
.
body
)
try
{
try
{
if
(
!
isLength
(
password
,
{
min
:
8
,
max
:
15
}))
{
if
(
!
isLength
(
password
,
{
min
:
8
,
max
:
15
}))
{
return
res
.
status
(
422
).
send
(
'
비밀번호는 8-15자리로 입력해주세요.
'
)
return
res
.
status
(
422
).
send
(
'
비밀번호는 8-15자리로 입력해주세요.
'
)
...
...
server/routes/category.routes.js
View file @
fdb92c49
...
@@ -9,6 +9,4 @@ router.route('/main')
...
@@ -9,6 +9,4 @@ router.route('/main')
// router.route('/sub/:sub')
// router.route('/sub/:sub')
// .get(categoryCtrl.getSubCategory)
// .get(categoryCtrl.getSubCategory)
// router.param('sub',categoryCtrl.getsubId)
export
default
router
export
default
router
\ No newline at end of file
server/routes/product.routes.js
View file @
fdb92c49
...
@@ -16,16 +16,16 @@ router.route('/getproduct')
...
@@ -16,16 +16,16 @@ router.route('/getproduct')
router
.
route
(
'
/getproduct/all
'
)
router
.
route
(
'
/getproduct/all
'
)
.
get
(
productCtrl
.
getAll
)
.
get
(
productCtrl
.
getAll
)
router
.
route
(
'
/getproduct/:category
'
)
router
.
route
(
'
/getproduct/
main/
:category
'
)
.
get
(
productCtrl
.
getlist
)
.
get
(
productCtrl
.
getlist
)
router
.
route
(
'
/getproduct/
:subcategory
'
)
router
.
route
(
'
/getproduct/
sub/:subname
'
)
.
get
(
productCtrl
.
sub
getlist
)
.
get
(
productCtrl
.
sub
name
)
router
.
route
(
'
/pluspurchase
'
)
router
.
route
(
'
/pluspurchase
'
)
.
post
(
productCtrl
.
plusPurchase
)
.
post
(
productCtrl
.
plusPurchase
)
router
.
param
(
'
category
'
,
productCtrl
.
categoryId
)
router
.
param
(
'
category
'
,
productCtrl
.
categoryId
)
router
.
param
(
'
sub
category
'
,
productCtrl
.
subcategoryId
)
router
.
param
(
'
sub
name
'
,
productCtrl
.
subcategoryId
)
export
default
router
export
default
router
\ No newline at end of file
Prev
1
2
Next
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