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
-92
View File
@@ -1,92 +0,0 @@
const mongoose = require('mongoose')
function image(img) {
return '/uploads/images/about/' + img
}
const AboutPageSchema = mongoose.Schema({
aboutPage_details: {
fa: {
page_title: String,
s1_title: String,
s1_caption: String,
s2_title: String,
s2_caption: String,
s2_imageCaption: String,
s3_title: String,
s3_caption: String,
s3_imageCaption: String,
s4_text: String,
last_section_title: String,
last_section_text: String
},
en: {
page_title: String,
s1_title: String,
s1_caption: String,
s2_title: String,
s2_caption: String,
s2_imageCaption: String,
s3_title: String,
s3_caption: String,
s3_imageCaption: String,
s4_text: String,
last_section_title: String,
last_section_text: String
},
de: {
page_title: String,
s1_title: String,
s1_caption: String,
s2_title: String,
s2_caption: String,
s2_imageCaption: String,
s3_title: String,
s3_caption: String,
s3_imageCaption: String,
s4_text: String,
last_section_title: String,
last_section_text: String
},
tr: {
page_title: String,
s1_title: String,
s1_caption: String,
s2_title: String,
s2_caption: String,
s2_imageCaption: String,
s3_title: String,
s3_caption: String,
s3_imageCaption: String,
s4_text: String,
last_section_title: String,
last_section_text: String
},
it: {
page_title: String,
s1_title: String,
s1_caption: String,
s2_title: String,
s2_caption: String,
s2_imageCaption: String,
s3_title: String,
s3_caption: String,
s3_imageCaption: String,
s4_text: String,
last_section_title: String,
last_section_text: String
}
},
page_hero: {type: String, get: image},
s2_image: {type: String, get: image},
s3_image: {type: String, get: image},
last_section_image: {type: String, get: image},
created_at: String,
updated_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
})
module.exports = mongoose.model('AboutPageContent', AboutPageSchema)
-13
View File
@@ -1,13 +0,0 @@
const mongoose = require('mongoose')
const BroadcastSchema = mongoose.Schema({
title: String,
message: String,
read: Array,
locale: String,
admin_id: String,
created_at: String
})
module.exports = mongoose.model('Broadcast', BroadcastSchema)
+1 -1
View File
@@ -6,7 +6,7 @@ const ContactPageMessageSchema = mongoose.Schema({
phone_number: String,
email: String,
message: String,
user_id: String,
reason: String,
read: {type: Boolean, default: false},
created_at: String
})
+15
View File
@@ -0,0 +1,15 @@
const mongoose = require('mongoose')
const ReasonSchema = mongoose.Schema({
reason_details: {
fa: {
reason: String
},
en: {
reason: String
}
},
created_at: String
})
module.exports = mongoose.model('ContactUsReason', ReasonSchema)
-19
View File
@@ -1,19 +0,0 @@
const mongoose = require('mongoose')
function image(file) {
return `/uploads/images/gallery/${file}`
}
const gallerySchema = mongoose.Schema({
image: {type: String, get: image},
created_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
})
gallerySchema.virtual('thumb').get(function () {
return '/uploads/images/gallery/thumb/thumb_' + this.image.split('gallery/')[1]
})
module.exports = mongoose.model('Gallery', gallerySchema)
+15
View File
@@ -0,0 +1,15 @@
const mongoose = require('mongoose')
function catalog(pdf) {
return '/uploads/pdf/' + pdf
}
const MainCatalogSchema = mongoose.Schema({
file: {type: String, get: catalog},
created_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
})
module.exports = mongoose.model('MainCatalog', MainCatalogSchema)
+33
View File
@@ -0,0 +1,33 @@
const mongoose = require('mongoose')
function image(file) {
return `/uploads/images/projects/${file}`
}
const ImagesSchema = mongoose.Schema({
image: {type: String, get: image},
created_at: String
}, {
toObject: {getters: true},
toJSON: {getters: true}
})
const ProjectSchema = mongoose.Schema({
images: [ImagesSchema],
project_details: {
fa: {
name: String,
description: String
},
en: {
name: String,
description: String
}
},
date: String,
created_at: String,
updated_at: String
})
module.exports = mongoose.model('Project', ProjectSchema)
+2 -9
View File
@@ -8,18 +8,11 @@ const SliderSchema = mongoose.Schema({
image: {type: String, get: image},
slider_details: {
fa: {
title: String,
caption: String
},
en: {
caption: String
},
de: {
caption: String
},
tr: {
caption: String
},
it: {
title: String,
caption: String
}
},
+1 -2
View File
@@ -4,10 +4,9 @@ const AdminSchema = mongoose.Schema({
name: String,
username: String,
password: String,
roles: Array,
created_at: String,
updated_at: String,
scope: String,
scope: {type: String, default: 'admin'},
token: String
})
-9
View File
@@ -7,15 +7,6 @@ const BlogCategorySchema = mongoose.Schema({
},
en: {
name: String
},
de: {
name: String
},
tr: {
name: String
},
it: {
name: String
}
},
created_at: String,
-15
View File
@@ -18,21 +18,6 @@ const BlogPostSchema = mongoose.Schema({
title: String,
description: String,
short_description: String
},
de: {
title: String,
description: String,
short_description: String
},
tr: {
title: String,
description: String,
short_description: String
},
it: {
title: String,
description: String,
short_description: String
}
},
created_at: String,
+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)
-11
View File
@@ -1,11 +0,0 @@
const mongoose = require('mongoose')
const Cart_ItemSchema = mongoose.Schema({
user_id: String,
product_id: String,
quantity: String,
created_at: String,
updated_at: String
})
module.exports = mongoose.model('Cart_Item', Cart_ItemSchema)
-30
View File
@@ -1,30 +0,0 @@
const mongoose = require('mongoose')
const StatusSchema = mongoose.Schema({
status: {
type: String,
enum: ['incomplete','processing', 'packing', 'sent','delivered'],
default: 'processing'
},
created_at: String
})
const Order_itemsSchema = mongoose.Schema({
product_id: String,
quantity: Number,
price: Number,
price_unit: String,
created_at: String
})
const OrderSchema = mongoose.Schema({
user_id: String,
number: Number,
address: Object,
statuses: [StatusSchema],
order_items: [Order_itemsSchema],
created_at: String,
updated_at: String
})
module.exports = mongoose.model('Order', OrderSchema)
-43
View File
@@ -1,43 +0,0 @@
const mongoose = require('mongoose')
const AddressSchema = mongoose.Schema({
country: String,
province: String,
city: String,
address: String,
postal_code: String,
plaque: String,
block_number: String,
receiver_first_name: String,
receiver_last_name: String,
receiver_mobile: String,
created_at: String
})
const UserSchema = mongoose.Schema({
first_name: String,
last_name: String,
type: {type: String, enum: ['personal', 'company'], default: 'personal'},
company_name: String,
email_personal: String,
email_company: String,
fb_id_personal: String,
fb_id_company: String,
ig_id_personal: String,
ig_id_company: String,
skype_id_personal: String,
skype_id_company: String,
addresses: [AddressSchema],
phone_number: String,
password: String,
confirmed: {type: Boolean, default: false},
confirmation_key: String,
scope: String,
token: String,
reset_pass_key: String,
created_at: String,
updated_at: String
})
module.exports = mongoose.model('User', UserSchema)