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
6549ba7e
Commit
6549ba7e
authored
Jan 12, 2021
by
kusang96
Browse files
dd
parent
7cb7c566
Changes
22
Show whitespace changes
Inline
Side-by-side
server/routes/product.routes.js
View file @
6549ba7e
import
express
from
"
express
"
;
import
express
from
"
express
"
;
import
path
from
'
path
'
;
import
multer
from
'
multer
'
;
import
productCtrl
from
'
../controllers/product.controller.js
'
;
import
productCtrl
from
'
../controllers/product.controller.js
'
;
// process.cwd() + '/client/public/image'
const
router
=
express
.
Router
()
const
router
=
express
.
Router
()
const
upload
=
multer
({
storage
:
multer
.
diskStorage
({
destination
(
req
,
file
,
cb
)
{
cb
(
null
,
'
uploads/
'
);
},
// 저장 경로 변경
filename
(
req
,
file
,
cb
)
{
cb
(
null
,
new
Date
().
valueOf
()
+
path
.
extname
(
file
.
originalname
));
},
// 파일명 변경
}),
});
router
.
route
(
'
/regist
'
)
router
.
route
(
'
/regist
'
)
.
post
(
productCtrl
.
regist
)
.
post
(
productCtrl
.
imageUpload
,
productCtrl
.
regist
)
// upload.array('main_image'),
export
default
router
export
default
router
\ No newline at end of file
server/schemas/Product.js
View file @
6549ba7e
import
mongoose
from
'
mongoose
'
import
mongoose
,
{
mongo
}
from
'
mongoose
'
const
{
String
,
Number
,
Array
}
=
mongoose
.
Schema
.
Types
const
{
String
,
Number
}
=
mongoose
.
Schema
.
Types
const
productschema
=
new
mongoose
.
Schema
({
pro_name
:
{
type
:
String
,
required
:
true
}
})
const
ProductSchema
=
new
mongoose
.
Schema
({
const
ProductSchema
=
new
mongoose
.
Schema
({
pro_name
:
{
pro_name
:
{
...
@@ -25,20 +32,19 @@ const ProductSchema = new mongoose.Schema({
...
@@ -25,20 +32,19 @@ const ProductSchema = new mongoose.Schema({
required
:
true
,
required
:
true
,
},
},
sub_category
:
{
sub_category
:
{
type
:
Array
,
type
:
[
String
]
,
required
:
true
,
required
:
true
,
},
},
description
:
{
description
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
,
},
},
main_im
age
:
{
main_im
gUrl
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
true
},
},
detail_image
:
{
detail_imgUrls
:
{
type
:
String
,
type
:
[
String
]
required
:
true
,
}
}
},
{
},
{
timestamps
:
true
timestamps
:
true
...
...
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