add calculation module and fix many bugs

This commit is contained in:
Amir Mohamadi
2021-01-27 18:51:06 +03:30
parent 9433eb84ac
commit 08a17401aa
70 changed files with 7133 additions and 5528 deletions
+68 -63
View File
@@ -1,84 +1,89 @@
const mongoose = require('mongoose')
function productImage(img) {
return '/uploads/images/products/' + img
if (img) return '/uploads/images/products/' + img
}
function productPDF(file) {
return '/uploads/pdf/' + file
if (file) return '/uploads/pdf/' + file
}
const ProductImageSchema = mongoose.Schema({
image: {type: String, get: productImage},
created_at: String
image: {type: String, get: productImage},
created_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
toObject: {getters: true},
toJSON: {getters: true}
})
const ProductPDFSchema = mongoose.Schema({
file: {type: String, get: productPDF},
pdf_details: {
fa: {
name: String
},
en: {
name: String
}
},
created_at: String
file: {
fa: {type: String, get: productPDF},
en: {type: String, get: productPDF}
},
pdf_details: {
fa: {
name: String
},
en: {
name: String
}
},
created_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
toObject: {getters: true},
toJSON: {getters: true}
})
const ProductSchema = mongoose.Schema({
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,
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,
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
}
},
created_at: String,
updated_at: String
cover: {type: String, get: productImage},
thumb: {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},
favorite: {type: Boolean, default: false},
product_details: {
fa: {
name: String,
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,
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
}
},
created_at: String,
updated_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
toObject: {getters: true},
toJSON: {getters: true}
})