Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
831c811
feat: добавлены базовые Vue компоненты для проекта Pizza
Sep 21, 2025
d3b6ea2
feat: подключены статические данные и реализованы динамические списки
Sep 21, 2025
a3c05f7
feat: перенесены все стили из template в Vue компоненты
Sep 21, 2025
e392d56
fix: исправлены пути к изображениям в Vue компонентах
Sep 21, 2025
f38f4b6
feat: добавлены переиспользуемые компоненты в src/common/components
Sep 21, 2025
ba38184
feat: добавлен модульный конструктор пиццы с drag-and-drop
Sep 21, 2025
0a96956
feat: интеграция всех модульных компонентов в HomeView с реактивным с…
Sep 21, 2025
fb96727
3.5 Вынесены общие стили в common-components.scss и создан компонент …
Sep 28, 2025
9b88f46
3,14 Настройка vue-router с разными layouts и автоматическими шаблонами
Sep 28, 2025
ac4a26c
3,14 Исправлены SASS ошибки и запуск в Docker
Sep 28, 2025
8ccafd1
Наполнение страниц контентом из HTML шаблонов
Sep 28, 2025
480ff7c
4.74.7. Задание: добавление глобального хранилища в проект Vue-Pizza.
Oct 4, 2025
d92f67a
Delete frontend/src/stores/README.md
Vulkan21 Oct 4, 2025
ce6802f
4.11. Задание: создание состояний в хранилищах Vue-Pizza
Oct 4, 2025
dbbbc08
4.15. Задание: добавление геттеров хранилища в проект Vue-Pizza
Oct 4, 2025
4758149
4.20. Задание: добавление методов хранилища в проект Vue-Pizza
Oct 4, 2025
994f65f
feat: подключение хранилищ Pinia к компонентам Vue-Pizza
Oct 5, 2025
9c54612
5.11. Задание: создание сервисов в проекте Vue-Pizza
Nov 23, 2025
f942b0d
5.13. Задание: аутентификация и авторизация в проекте Vue-Pizza
Nov 23, 2025
9a699f3
5.15. Задание: замена мок-данных на данные с сервера в проекте Vue-Pizza
Nov 23, 2025
2897189
fix: исправлено дублирование стилей в AppHeader
Nov 23, 2025
ef18ca8
6.8. Задание: добавление анимаций в проект Vue-Pizza
Nov 23, 2025
35bc0a0
7.11. Задание: написание тестов для проекта Vue-Pizza
Nov 23, 2025
b96c886
fix: исправлен расчет цены пиццы (размер теперь множитель, а не слага…
Nov 27, 2025
b8bf66d
исправлены ошибки с адресами, заказами и историей пользователей
Dec 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions backend/src/controllers/address.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ import {
import {Address} from '../models';
import {AddressRepository} from '../repositories';
import {authenticate} from '@loopback/authentication';
import {inject} from '@loopback/core';
import {SecurityBindings, UserProfile} from '@loopback/security';

@authenticate('jwt')
export class AddressController {
constructor(
@repository(AddressRepository)
public addressRepository : AddressRepository,
@inject(SecurityBindings.USER)
private currentUserProfile: UserProfile,
) {}

@post('/addresses')
Expand All @@ -41,7 +45,6 @@ export class AddressController {
schema: {
example: {
name: "string",
userId: "string",
street: "string",
building: "string",
flat: "string",
Expand All @@ -51,9 +54,13 @@ export class AddressController {
},
},
})
address: Address,
address: Omit<Address, 'id' | 'userId'>,
): Promise<Address> {
return this.addressRepository.create(address);
const userId = this.currentUserProfile.id;
return this.addressRepository.create({
...address,
userId: userId,
});
}

@oas.visibility(OperationVisibility.UNDOCUMENTED)
Expand Down Expand Up @@ -81,8 +88,10 @@ export class AddressController {
},
})
async find(): Promise<Address[]> {
const addresses = await this.addressRepository.find();
return addresses.filter(address => !!address.userId);
const userId = this.currentUserProfile.id;
return this.addressRepository.find({
where: {userId: userId}
});
}

@oas.visibility(OperationVisibility.UNDOCUMENTED)
Expand Down
58 changes: 38 additions & 20 deletions backend/src/controllers/order.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import {
PizzaRepository
} from '../repositories';
import {authenticate} from "@loopback/authentication";
import {inject} from '@loopback/core';
import {SecurityBindings, UserProfile} from '@loopback/security';

export class OrderController {
constructor(
Expand All @@ -38,6 +40,8 @@ export class OrderController {
public pizzaIngredientRepository : PizzaIngredientRepository,
@repository(PizzaRepository)
public pizzaRepository : PizzaRepository,
@inject(SecurityBindings.USER, {optional: true})
private currentUserProfile?: UserProfile,
) {}

@post('/orders')
Expand All @@ -60,6 +64,7 @@ export class OrderController {
"userId": "string",
"phone": "+7 999-999-99-99",
"address": {
"name": "string",
"street": "string",
"building": "string",
"flat": "string",
Expand Down Expand Up @@ -99,29 +104,34 @@ export class OrderController {
let addressId = address?.id;
// if it is a new address
if (address && !addressId) {
const name = `ул.${address.street}, д.${address.building}, кв.${address.flat}`;
const newAddress = await this.addressRepository.create({...address, name, userId});
const newAddress = await this.addressRepository.create({...address, userId});
addressId = newAddress.id;
}
const newOrder = await this.orderRepository.create({...orderToSave, addressId});
for (const pizza of pizzas) {
const { ingredients, ...pizzaToSave } = pizza;
const newPizza = await this.pizzaRepository.create({
...pizzaToSave,
orderId: newOrder.id
});
for (const ingredient of ingredients) {
await this.pizzaIngredientRepository.create({
...ingredient,
pizzaId: newPizza.id
})
if (pizzas && Array.isArray(pizzas)) {
for (const pizza of pizzas) {
const { ingredients, ...pizzaToSave } = pizza;
const newPizza = await this.pizzaRepository.create({
...pizzaToSave,
orderId: newOrder.id
});
if (ingredients && Array.isArray(ingredients)) {
for (const ingredient of ingredients) {
await this.pizzaIngredientRepository.create({
...ingredient,
pizzaId: newPizza.id
})
}
}
}
}
for (const item of misc) {
await this.miscOrderRepository.create({
...item,
orderId: newOrder.id
})
if (misc && Array.isArray(misc)) {
for (const item of misc) {
await this.miscOrderRepository.create({
...item,
orderId: newOrder.id
})
}
}
return newOrder;
}
Expand Down Expand Up @@ -195,7 +205,16 @@ export class OrderController {
},
})
async find(): Promise<Order[]> {
const userId = this.currentUserProfile?.id;

if (!userId) {
throw new Error('User not authenticated');
}

const filter = {
"where": {
"userId": String(userId)
},
"include": [
{
"relation": "orderPizzas",
Expand All @@ -215,8 +234,7 @@ export class OrderController {
}
]
}
const orders = await this.orderRepository.find(filter);
return orders.filter(order => !!order.userId);
return await this.orderRepository.find(filter);
}

@oas.visibility(OperationVisibility.UNDOCUMENTED)
Expand Down
49 changes: 37 additions & 12 deletions backend/src/factory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,48 @@ const populateMisc = (
};

export default async function load(app: Application) {
const usersPromises = users.map(async user => populateUsers(user, await app.getRepository(UserRepository)))
await Promise.all(usersPromises);
const doughRepository = await app.getRepository(DoughRepository);
const ingredientRepository = await app.getRepository(IngredientRepository);
const sauceRepository = await app.getRepository(SauceRepository);
const sizeRepository = await app.getRepository(SizeRepository);
const miscRepository = await app.getRepository(MiscRepository);
const userRepository = await app.getRepository(UserRepository);

const doughPromises = pizza.dough.map(async dough => populateDough(dough, await app.getRepository(DoughRepository)))
await Promise.all(doughPromises);
const existingDough = await doughRepository.count();
if (existingDough.count === 0) {
const doughPromises = pizza.dough.map(async dough => populateDough(dough, doughRepository))
await Promise.all(doughPromises);
}

const ingredientsPromises = pizza.ingredients.map(async ing => populateIngredients(ing, await app.getRepository(IngredientRepository)))
await Promise.all(ingredientsPromises);
const existingIngredients = await ingredientRepository.count();
if (existingIngredients.count === 0) {
const ingredientsPromises = pizza.ingredients.map(async ing => populateIngredients(ing, ingredientRepository))
await Promise.all(ingredientsPromises);
}

const saucesPromises = pizza.sauces.map(async sauce => populateSauces(sauce, await app.getRepository(SauceRepository)))
await Promise.all(saucesPromises);
const existingSauces = await sauceRepository.count();
if (existingSauces.count === 0) {
const saucesPromises = pizza.sauces.map(async sauce => populateSauces(sauce, sauceRepository))
await Promise.all(saucesPromises);
}

const sizesPromises = pizza.sizes.map(async size => populateSizes(size, await app.getRepository(SizeRepository)))
await Promise.all(sizesPromises);
const existingSizes = await sizeRepository.count();
if (existingSizes.count === 0) {
const sizesPromises = pizza.sizes.map(async size => populateSizes(size, sizeRepository))
await Promise.all(sizesPromises);
}

const miscPromises = misc.map(async m => populateMisc(m, await app.getRepository(MiscRepository)))
await Promise.all(miscPromises);
const existingMisc = await miscRepository.count();
if (existingMisc.count === 0) {
const miscPromises = misc.map(async m => populateMisc(m, miscRepository))
await Promise.all(miscPromises);
}

const existingUsers = await userRepository.count();
if (existingUsers.count === 0) {
const usersPromises = users.map(async user => populateUsers(user, userRepository))
await Promise.all(usersPromises);
}

console.log('Dummy data is populated')
}
6 changes: 6 additions & 0 deletions backend/src/models/order.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ export class Order extends Entity {
})
phone?: String;

@property({
type: 'string',
required: false,
})
comment?: string;

@property({
type: 'array',
required: false,
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3'

services:
db:
image: postgres
Expand Down
35 changes: 0 additions & 35 deletions frontend/README.md

This file was deleted.

Loading