back-end done

This commit is contained in:
Amir Mohamadi
2020-12-10 16:36:48 +03:30
parent 80a7abafb7
commit bc5e617778
92 changed files with 5217 additions and 3379 deletions
+49 -64
View File
@@ -4,37 +4,28 @@ function productImage(img) {
return '/uploads/images/products/' + img
}
function ProductImageGallery(img) {
return '/uploads/images/products/gallery/' + img
function productPDF(file) {
return '/uploads/pdf/' + file
}
const ProductFeatureSchema = mongoose.Schema({
fa: {
name: String,
value: String
},
en: {
name: String,
value: String
},
de: {
name: String,
value: String
},
tr: {
name: String,
value: String
},
it: {
name: String,
value: String
},
const ProductImageSchema = mongoose.Schema({
image: {type: String, get: productImage},
created_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
})
const ProductImageSchema = mongoose.Schema({
image: {type: String, get: ProductImageGallery},
const ProductPDFSchema = mongoose.Schema({
file: {type: String, get: productPDF},
pdf_details: {
fa: {
name: String
},
en: {
name: String
}
},
created_at: String
}, {
toObject: {getters: true},
@@ -42,53 +33,47 @@ const ProductImageSchema = mongoose.Schema({
})
const ProductSchema = mongoose.Schema({
image: {type: String, get: productImage},
stock: Number,
cover: {type: String, get: productImage},
images: [ProductImageSchema],
more_section_image1: {type: String, get: productImage},
more_section_image2: {type: String, get: productImage},
render_image1: {type: String, get: productImage},
render_image2: {type: String, get: productImage},
chart_image: {type: String, get: productImage},
pdf_files: [ProductPDFSchema],
category: String,
more_section: {type: Boolean, default: true},
download_section: {type: Boolean, default: true},
product_details: {
fa: {
name: String,
description: String,
price: {
type: Number,
default: 0
}
short_description: String,
page_title: String,
page_description: String,
more_title1: String,
more_description1: String,
more_title2: String,
more_description2: String,
render_caption1: String,
render_caption2: String,
chart_title: String,
chart_description: String
},
en: {
name: String,
description: String,
price: {
type: Number,
default: 0
}
},
de: {
name: String,
description: String,
price: {
type: Number,
default: 0
}
},
it: {
name: String,
description: String,
price: {
type: Number,
default: 0
}
},
tr: {
name: String,
description: String,
price: {
type: Number,
default: 0
}
short_description: String,
page_title: String,
page_description: String,
more_title1: String,
more_description1: String,
more_title2: String,
more_description2: String,
render_caption1: String,
render_caption2: String,
chart_title: String,
chart_description: String
}
},
product_features: [ProductFeatureSchema],
product_images: [ProductImageSchema],
created_at: String,
updated_at: String
}, {
+2 -25
View File
@@ -1,39 +1,16 @@
const mongoose = require('mongoose')
function image(img) {
return '/uploads/images/products/category/' + img
}
const ProductCategorySchema = mongoose.Schema({
image: {type: String, get: image},
cover: {type: String, get: image},
category_details: {
fa: {
name: String,
caption: String
name: String
},
en: {
name: String,
caption: String
},
de: {
name: String,
caption: String
},
tr: {
name: String,
caption: String
},
it: {
name: String,
caption: String
name: String
}
},
created_at: String,
updated_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
})
module.exports = mongoose.model('ProductCategory', ProductCategorySchema)