init from origin + update
This commit is contained in:
15
server/routers/sugarbun/collections/adminstats.json
Normal file
15
server/routers/sugarbun/collections/adminstats.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{"status":"success",
|
||||
"adminstats":[
|
||||
{"id":1,"month":"Январь","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":100.5},
|
||||
{"id":2,"month":"Февраль","monthly_sales":110000,"monthly_orders":23,"monthly_revenue":120.4},
|
||||
{"id":3,"month":"Март","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":100.6},
|
||||
{"id":4,"month":"Апрель","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":102.3},
|
||||
{"id":5,"month":"Май","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":80.2},
|
||||
{"id":6,"month":"Июнь","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":150.6},
|
||||
{"id":7,"month":"Июль","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":130.2},
|
||||
{"id":8,"month":"Август","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":240.7},
|
||||
{"id":9,"month":"Сентябрь","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":180.4},
|
||||
{"id":10,"month":"Октбярь","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":100.44},
|
||||
{"id":11,"month":"Ноябрь","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":15.5},
|
||||
{"id":12,"month":"Декабрь","monthly_sales":85600,"monthly_orders":23,"monthly_revenue":21.7}
|
||||
]}
|
||||
229
server/routers/sugarbun/collections/cakeitem.json
Normal file
229
server/routers/sugarbun/collections/cakeitem.json
Normal file
@@ -0,0 +1,229 @@
|
||||
{
|
||||
"cakes": [
|
||||
{
|
||||
"title": "АйЛи",
|
||||
"image": "AiLi.png",
|
||||
"description": "Ванильный бисквит",
|
||||
"description1": "Ванильная пропитка",
|
||||
"description2": "Сливочно-сырный крем",
|
||||
"description3": "Клубничная прослойка",
|
||||
"price": "1600",
|
||||
"id": "cake"
|
||||
},
|
||||
{
|
||||
"title": "Лавандовый",
|
||||
"image": "Lavender.png",
|
||||
"description": "Лавандовый бисквит",
|
||||
"description1": "Черничная пропитка",
|
||||
"description2": "Сливочно-сырный крем",
|
||||
"description3": "Черничный соус",
|
||||
"price": "1700",
|
||||
"id": "cake1"
|
||||
},
|
||||
{
|
||||
"title": "Шоколадный с солёной карамелью ",
|
||||
"image": "Chocolate_with_salted caramel.png",
|
||||
"description": "Шоколадный бисквит",
|
||||
"description1": "Сливочно-сырный крем",
|
||||
"description2": "Соленая карамель",
|
||||
"description3": "Орехи и мягкий шоколадный ганаш",
|
||||
"price": "1700",
|
||||
"id": "cake2"
|
||||
},
|
||||
{
|
||||
"title": "Шоколадный трюфель",
|
||||
"image": "Chocolate_truffle.png",
|
||||
"description": "Шоколадный бисквит",
|
||||
"description1": "Ванильная пропитка",
|
||||
"description2": "Мягкий шоколадный ганаш",
|
||||
"description3": "",
|
||||
"price": "1700",
|
||||
"id": "cake3"
|
||||
},
|
||||
{
|
||||
"title": "Красный бархат с вишней",
|
||||
"image": "Red_velvet.png",
|
||||
"description": "Бисквит красный бархат",
|
||||
"description1": "Ягодная пропитка",
|
||||
"description2": "Сливочно-сырный крем",
|
||||
"description3": "Вишневый соус с кусочками вишни",
|
||||
"price": "1600",
|
||||
"id": "cake4"
|
||||
},
|
||||
{
|
||||
"title": "Фисташка-малина",
|
||||
"image": "Pistachio-raspberry.png",
|
||||
"description": "Фисташковый бисквит",
|
||||
"description1": "Сливочно-сырный крем",
|
||||
"description2": "Малиновый соус",
|
||||
"description3": "",
|
||||
"price": "1600",
|
||||
"id": "cake5"
|
||||
},
|
||||
{
|
||||
"title": "Морковный с облепиховой прослойкой",
|
||||
"image": "Carrot.png",
|
||||
"description": "Пряный морковный бисквит с орехами",
|
||||
"description1": "Облепиховая пропитка",
|
||||
"description2": "Сливочно-сырный крем",
|
||||
"description3": "Облепиховый соус",
|
||||
"price": "1700",
|
||||
"id": "cake6"
|
||||
},
|
||||
{
|
||||
"title": "Груша-дорблю",
|
||||
"image": "Pear-dorblu.png",
|
||||
"description": "Ванильный бисквит",
|
||||
"description1": "Томлёная с ванилью груша",
|
||||
"description2": "Сливочно-сырный крем",
|
||||
"description3": "Кедровые орехи",
|
||||
"price": "1700",
|
||||
"id": "cake7"
|
||||
},
|
||||
{
|
||||
"title": "Шоколадный медовый",
|
||||
"image": "Chocolate_honey.jpeg",
|
||||
"description": "Шоколадные медовые коржи",
|
||||
"description1": "Ванильное суфле",
|
||||
"description2": "Сметанный крем с добавлением грецких орехов",
|
||||
"description3": "",
|
||||
"price": "1600",
|
||||
"id": "cake8"
|
||||
},
|
||||
{
|
||||
"title": "Наполеон",
|
||||
"image": "Napoleon.png",
|
||||
"description": "Тонкие коржи из слоеного теста",
|
||||
"description1": "Пропитка из заварного крема на сливках",
|
||||
"description2": "",
|
||||
"description3": "",
|
||||
"price": "1700",
|
||||
"id": "cake9"
|
||||
},
|
||||
{
|
||||
"title": "Тропический",
|
||||
"image": "Tropical.png",
|
||||
"description": "Кокосовый бисквит",
|
||||
"description1": "Пропитка на кокосовом молоке",
|
||||
"description2": "Пюре из манго и маракуйи",
|
||||
"description3": "Сливочно-сырный крем с кокосовым муссом",
|
||||
"price": "1700",
|
||||
"id": "cake10"
|
||||
},
|
||||
{
|
||||
"title": "Маковый",
|
||||
"image": "Poppy.png",
|
||||
"description": "Маковый бисквит",
|
||||
"description1": "Пропитка абрикос-маракуйя",
|
||||
"description2": "Сливочно-сырный крем",
|
||||
"description3": "Прослойка из абрикоса и маракуйи",
|
||||
"price": "1700",
|
||||
"id": "cake11"
|
||||
},
|
||||
{
|
||||
"title": "Павлова",
|
||||
"image": "Pavlova.png",
|
||||
"description": "Воздушные коржи из меренги с мягкой серединкой",
|
||||
"description1": "Начинка апельсин-маракуйя",
|
||||
"description2": "Сливочно-сырный крем",
|
||||
"description3": "",
|
||||
"price": "1800",
|
||||
"id": "cake12"
|
||||
},
|
||||
{
|
||||
"title": "Чизкейк Нью-Йорк с солёной карамелью",
|
||||
"image": "New-york-cheesecake_with_salted_caramel.png",
|
||||
"description": "Песочная основа по оригинальному рецепту",
|
||||
"description1": "Нежный сырный слой под слоем тягучей соленой карамели",
|
||||
"description2": "",
|
||||
"description3": "",
|
||||
"price": "1600",
|
||||
"id": "cake13"
|
||||
},
|
||||
{
|
||||
"title": "Чизкейк Нью-Йорк",
|
||||
"image": "New-york-cheesecake.jpeg",
|
||||
"description": "Песочная основа по оригинальному рецепту",
|
||||
"description1": "Нежный сырный слой",
|
||||
"description2": "",
|
||||
"description3": "",
|
||||
"price": "1500",
|
||||
"id": "cake14"
|
||||
},
|
||||
{
|
||||
"title": "Чизкейк Сникерс",
|
||||
"image": "Cheesecake_Snickers.png",
|
||||
"description": "Песочно-шоколадная основа",
|
||||
"description1": "Сырный слой",
|
||||
"description2": "Соленая карамель с орехами",
|
||||
"description3": "Покрыт слоем настоящего шоколада",
|
||||
"price": "1600",
|
||||
"id": "cake15"
|
||||
},
|
||||
{
|
||||
"title": "Баноффи",
|
||||
"image": "Banoffi.png",
|
||||
"description": "Песочная основа",
|
||||
"description1": "Банановые кольца под слоем соленой карамели",
|
||||
"description2": "Воздушный крем-чиз",
|
||||
"description3": "",
|
||||
"price": "1600",
|
||||
"id": "cake16"
|
||||
},
|
||||
{
|
||||
"title": "Классический медовый с клюквой",
|
||||
"image": "Classic_honey.png",
|
||||
"description": "Недные медовые коржи",
|
||||
"description1": "Небольшая кислинка в виде клюквенной прослойки",
|
||||
"description2": "Ванильное суфле",
|
||||
"description3": "Сметанный крем",
|
||||
"price": "1600",
|
||||
"id": "cake17"
|
||||
}
|
||||
],
|
||||
|
||||
"desserts": [
|
||||
{
|
||||
"title": "Капкейк",
|
||||
"image": "Kapkeik.png",
|
||||
"description": "Нежный кекс с начинкой и кремовой шапочкой",
|
||||
"price": "160",
|
||||
"id": "des"
|
||||
},
|
||||
{
|
||||
"title": "Макарон",
|
||||
"image": "Makaron.png",
|
||||
"description": "Классический французский десерт из двух миндальных крышек и мягкой начинки",
|
||||
"price": "100",
|
||||
"id": "des1"
|
||||
},
|
||||
{
|
||||
"title": "Десерт Павлова",
|
||||
"image": "Pavlova_desert.png",
|
||||
"description": "Безе с мягкой сердцевиной внутри",
|
||||
"price": "240",
|
||||
"id": "des2"
|
||||
},
|
||||
{
|
||||
"title": "Трюфель",
|
||||
"image": "Truffel.png",
|
||||
"description": "Нежные конфеты на бельгийском шоколаде",
|
||||
"price": "80",
|
||||
"id": "des3"
|
||||
},
|
||||
{
|
||||
"title": "Кейк-ппс",
|
||||
"image": "Keyk-pops.png",
|
||||
"description": "Любимое лакомство детей. Пирожное картошка в новом исполнении",
|
||||
"price": "100",
|
||||
"id": "des4"
|
||||
},
|
||||
{
|
||||
"title": "Эклер",
|
||||
"image": "Ekler.png",
|
||||
"description": "Десерт на основе заварного теста с заварным кремом внутри",
|
||||
"price": "160",
|
||||
"id": "des5"
|
||||
}
|
||||
]
|
||||
}
|
||||
22
server/routers/sugarbun/collections/cakeshape.json
Normal file
22
server/routers/sugarbun/collections/cakeshape.json
Normal file
@@ -0,0 +1,22 @@
|
||||
[{
|
||||
"name": "Круг",
|
||||
"id": "sh1",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Квадрат",
|
||||
"id": "sh2",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Прямоугольник",
|
||||
"id": "sh3",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Овал",
|
||||
"id": "sh4",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Сложной формы",
|
||||
"id": "sh5",
|
||||
"available": true
|
||||
}
|
||||
]
|
||||
30
server/routers/sugarbun/collections/cakesweight.json
Normal file
30
server/routers/sugarbun/collections/cakesweight.json
Normal file
@@ -0,0 +1,30 @@
|
||||
[{
|
||||
"name": "1.5 кг",
|
||||
"id": "cw1",
|
||||
"available": true
|
||||
},{
|
||||
"name": "2 кг",
|
||||
"id": "cw2",
|
||||
"available": true
|
||||
},{
|
||||
"name": "3 кг",
|
||||
"id": "cw3",
|
||||
"available": true
|
||||
},{
|
||||
"name": "4 кг",
|
||||
"id": "cw4",
|
||||
"available": true
|
||||
},{
|
||||
"name": "5 кг",
|
||||
"id": "cw5",
|
||||
"available": true
|
||||
},{
|
||||
"name": "6 кг",
|
||||
"id": "cw6",
|
||||
"available": true
|
||||
},{
|
||||
"name": "7 кг",
|
||||
"id": "cw8",
|
||||
"available": true
|
||||
}
|
||||
]
|
||||
74
server/routers/sugarbun/collections/ingredients.json
Normal file
74
server/routers/sugarbun/collections/ingredients.json
Normal file
@@ -0,0 +1,74 @@
|
||||
[{
|
||||
"name": "Ванильный с клубникой",
|
||||
"id": "ing1",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Лавандовый",
|
||||
"id": "ing2",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Шоколадный с солёной карамелью, орехами и шоколадом",
|
||||
"id": "ing3",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Шоколадный трюфель",
|
||||
"id": "ing4",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Красный бархат с вишней",
|
||||
"id": "ing5",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Фисташка-малина",
|
||||
"id": "ing6",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Морковный с облепиховой прослойкой",
|
||||
"id": "ing7",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Груша-дорблю",
|
||||
"id": "ing8",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Классический медовый с клюквойм",
|
||||
"id": "ing9",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Шоколадный медовый",
|
||||
"id": "ing10",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Наполеон",
|
||||
"id": "ing11",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Тропический",
|
||||
"id": "ing12",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Маковый",
|
||||
"id": "ing13",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Павлова",
|
||||
"id": "ing14",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Чизкейк Нью-Йорк",
|
||||
"id": "ing15",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Чизкейк Нью-Йорк с соленой карамелью",
|
||||
"id": "ing16",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Чизкейк Сникерс",
|
||||
"id": "ing17",
|
||||
"available": true
|
||||
},{
|
||||
"name": "Баноффи",
|
||||
"id": "ing18",
|
||||
"available": true
|
||||
}
|
||||
]
|
||||
107
server/routers/sugarbun/controller.js
Normal file
107
server/routers/sugarbun/controller.js
Normal file
@@ -0,0 +1,107 @@
|
||||
const ObjectId = require('mongodb').ObjectID
|
||||
|
||||
const { getDB } = require('../../utils/mongo')
|
||||
|
||||
const ingredients = require('./collections/ingredients.json')
|
||||
const cakeshape = require('./collections/cakeshape.json')
|
||||
const cakesweight = require('./collections/cakesweight.json')
|
||||
const adminstats = require('./collections/adminstats.json')
|
||||
|
||||
const INGREDIENTS_COLLECTION = 'ingredients'
|
||||
const CAKESHAPE_COLLECTION = 'cakeshape'
|
||||
const CAKESWEIGHT_COLLECTION = 'cakeswaight'
|
||||
const ADMINSTATS_COLLECTION = 'adminstats'
|
||||
|
||||
let db = null
|
||||
|
||||
const connect = async () => {
|
||||
db = await getDB('sugarbundb')
|
||||
}
|
||||
|
||||
const init = async () => {
|
||||
await connect()
|
||||
const ingredientsCollection = db.collection(INGREDIENTS_COLLECTION)
|
||||
const findingredients = await ingredientsCollection.find({
|
||||
}).toArray()
|
||||
// console.log(findingredients)
|
||||
if (findingredients.length === 0) {
|
||||
await ingredientsCollection.insertMany(ingredients)
|
||||
}
|
||||
const cakeshapeCollection = db.collection(CAKESHAPE_COLLECTION)
|
||||
const findcakeshape = await cakeshapeCollection.find({
|
||||
}).toArray()
|
||||
if (findcakeshape.length === 0) {
|
||||
await cakeshapeCollection.insertMany(cakeshape)
|
||||
}
|
||||
const cakesweightCollection = db.collection(CAKESWEIGHT_COLLECTION)
|
||||
const findcakesweight = await cakesweightCollection.find({
|
||||
}).toArray()
|
||||
if (findcakesweight.length === 0) {
|
||||
await cakesweightCollection.insertMany(cakesweight)
|
||||
}
|
||||
const adminstatsCollection = db.collection(ADMINSTATS_COLLECTION)
|
||||
const findadminstats = await adminstatsCollection.find({
|
||||
}).toArray()
|
||||
if (findadminstats.length === 0) {
|
||||
await adminstatsCollection.insertMany(adminstats.adminstats)
|
||||
}
|
||||
}
|
||||
|
||||
init()
|
||||
|
||||
const getIngredients = async () => {
|
||||
if (db === null) throw new Error('no db connection')
|
||||
try {
|
||||
const ingredientsCollection = db.collection(INGREDIENTS_COLLECTION)
|
||||
const defaultIngredients = await ingredientsCollection.find({
|
||||
available: true,
|
||||
}).toArray()
|
||||
return (defaultIngredients)
|
||||
} catch (e) {
|
||||
throw new Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
const getCakeshape = async () => {
|
||||
if (db === null) throw new Error('no db connection')
|
||||
try {
|
||||
const cakeshapeCollection = db.collection(CAKESHAPE_COLLECTION)
|
||||
const defaultCakeshapes = await cakeshapeCollection.find({
|
||||
available: true,
|
||||
}).toArray()
|
||||
return (defaultCakeshapes)
|
||||
} catch (e) {
|
||||
throw new Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
const getCakesweight = async () => {
|
||||
if (db === null) throw new Error('no db connection')
|
||||
try {
|
||||
const cakesweightCollection = db.collection(CAKESWEIGHT_COLLECTION)
|
||||
const defaultCakesweights = await cakesweightCollection.find({
|
||||
available: true,
|
||||
}).toArray()
|
||||
return (defaultCakesweights)
|
||||
} catch (e) {
|
||||
throw new Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
const getStats = async () => {
|
||||
if (db === null) throw new Error('no db connection')
|
||||
try {
|
||||
const adminstatsCollection = db.collection(ADMINSTATS_COLLECTION)
|
||||
const defaultStats = await adminstatsCollection.find().toArray()
|
||||
return (defaultStats)
|
||||
} catch (e) {
|
||||
throw new Error(e)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getIngredients,
|
||||
getCakeshape,
|
||||
getCakesweight,
|
||||
getStats,
|
||||
}
|
||||
44
server/routers/sugarbun/index.js
Normal file
44
server/routers/sugarbun/index.js
Normal file
@@ -0,0 +1,44 @@
|
||||
const router = require('express').Router()
|
||||
const { getIngredients, getCakeshape, getCakesweight, getStats, getCakeitem } = require('./controller')
|
||||
|
||||
module.exports = router
|
||||
|
||||
router.get('/constructor/formitems', async (req, res) => {
|
||||
// получение данных из бэкенда
|
||||
const ingredient = (await getIngredients()).map((item) => ({
|
||||
...item,
|
||||
_id: undefined,
|
||||
}))
|
||||
const cakeshape = (await getCakeshape()).map((item) => ({
|
||||
...item,
|
||||
_id: undefined,
|
||||
}))
|
||||
const cakesweight = (await getCakesweight()).map((item) => ({
|
||||
...item,
|
||||
_id: undefined,
|
||||
}))
|
||||
res.send({
|
||||
ingredients: ingredient,
|
||||
cakeshapes: cakeshape,
|
||||
cakesweights: cakesweight,
|
||||
})
|
||||
})
|
||||
|
||||
router.get('/admin/adminstats', async (req, res) => {
|
||||
// получение данных из бэкенда
|
||||
const adminstat = (await getStats()).map((item) => ({
|
||||
...item,
|
||||
_id: undefined,
|
||||
}))
|
||||
res.send({
|
||||
adminstats: adminstat,
|
||||
})
|
||||
})
|
||||
router.post('/constructor/submit', (req, res) => {
|
||||
res.send()
|
||||
})
|
||||
|
||||
router.get('/menu/cakeitems', async (req, res) => {
|
||||
// получение данных из бэкенда
|
||||
res.send(require('./collections/cakeitem.json'))
|
||||
})
|
||||
Reference in New Issue
Block a user