mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 15:23:11 +02:00
Add 'Programming/BD2/' from commit 'ec90ad34d5729cc958437073107feb5d76ba73f7'
git-subtree-dir: Programming/BD2 git-subtree-mainline:4b5b8e44e8git-subtree-split:ec90ad34d5
This commit is contained in:
commit
7861d69ae9
BIN
Programming/BD2/.nx/cache/18.3.4-nx.linux-x64-gnu.node
vendored
Normal file
BIN
Programming/BD2/.nx/cache/18.3.4-nx.linux-x64-gnu.node
vendored
Normal file
Binary file not shown.
BIN
Programming/BD2/Dokumentacja_BD2.pdf
Normal file
BIN
Programming/BD2/Dokumentacja_BD2.pdf
Normal file
Binary file not shown.
13
Programming/BD2/monorepo/.editorconfig
Normal file
13
Programming/BD2/monorepo/.editorconfig
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Editor configuration, see http://editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
max_line_length = off
|
||||||
|
trim_trailing_whitespace = false
|
||||||
1
Programming/BD2/monorepo/.eslintignore
Normal file
1
Programming/BD2/monorepo/.eslintignore
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules
|
||||||
42
Programming/BD2/monorepo/.eslintrc.json
Normal file
42
Programming/BD2/monorepo/.eslintrc.json
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"ignorePatterns": ["**/*"],
|
||||||
|
"plugins": ["@nx"],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||||
|
"rules": {
|
||||||
|
"@nx/enforce-module-boundaries": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"enforceBuildableLibDependency": true,
|
||||||
|
"allow": [],
|
||||||
|
"depConstraints": [
|
||||||
|
{
|
||||||
|
"sourceTag": "*",
|
||||||
|
"onlyDependOnLibsWithTags": ["*"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.ts", "*.tsx"],
|
||||||
|
"extends": ["plugin:@nx/typescript"],
|
||||||
|
"rules": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.js", "*.jsx"],
|
||||||
|
"extends": ["plugin:@nx/javascript"],
|
||||||
|
"rules": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.spec.ts", "*.spec.tsx", "*.spec.js", "*.spec.jsx"],
|
||||||
|
"env": {
|
||||||
|
"jest": true
|
||||||
|
},
|
||||||
|
"rules": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
42
Programming/BD2/monorepo/.gitignore
vendored
Normal file
42
Programming/BD2/monorepo/.gitignore
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# compiled output
|
||||||
|
dist
|
||||||
|
tmp
|
||||||
|
/out-tsc
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules
|
||||||
|
|
||||||
|
# IDEs and editors
|
||||||
|
/.idea
|
||||||
|
.project
|
||||||
|
.classpath
|
||||||
|
.c9/
|
||||||
|
*.launch
|
||||||
|
.settings/
|
||||||
|
*.sublime-workspace
|
||||||
|
|
||||||
|
# IDE - VSCode
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/settings.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
# misc
|
||||||
|
/.sass-cache
|
||||||
|
/connect.lock
|
||||||
|
/coverage
|
||||||
|
/libpeerconnection.log
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
testem.log
|
||||||
|
/typings
|
||||||
|
|
||||||
|
# System Files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
.nx/cache
|
||||||
|
.angular
|
||||||
5
Programming/BD2/monorepo/.prettierignore
Normal file
5
Programming/BD2/monorepo/.prettierignore
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Add files here to ignore them from prettier formatting
|
||||||
|
/dist
|
||||||
|
/coverage
|
||||||
|
/.nx/cache
|
||||||
|
.angular
|
||||||
3
Programming/BD2/monorepo/.prettierrc
Normal file
3
Programming/BD2/monorepo/.prettierrc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"singleQuote": true
|
||||||
|
}
|
||||||
12
Programming/BD2/monorepo/.vscode/extensions.json
vendored
Normal file
12
Programming/BD2/monorepo/.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"nrwl.angular-console",
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"firsttris.vscode-jest-runner",
|
||||||
|
"angular.ng-template",
|
||||||
|
"wesbos.theme-cobalt2",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"wix.vscode-import-cost",
|
||||||
|
"prisma.prisma"
|
||||||
|
]
|
||||||
|
}
|
||||||
1
Programming/BD2/monorepo/apps/backend/.env_template
Normal file
1
Programming/BD2/monorepo/apps/backend/.env_template
Normal file
@ -0,0 +1 @@
|
|||||||
|
DATABASE_URL="postgresql://postgres:password@localhost:5432/mydb?schema=public"
|
||||||
18
Programming/BD2/monorepo/apps/backend/.eslintrc.json
Normal file
18
Programming/BD2/monorepo/apps/backend/.eslintrc.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"extends": ["../../.eslintrc.json"],
|
||||||
|
"ignorePatterns": ["!**/*"],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||||
|
"rules": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.ts", "*.tsx"],
|
||||||
|
"rules": {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.js", "*.jsx"],
|
||||||
|
"rules": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
3
Programming/BD2/monorepo/apps/backend/.gitignore
vendored
Normal file
3
Programming/BD2/monorepo/apps/backend/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
# Keep environment variables out of version control
|
||||||
|
.env
|
||||||
11
Programming/BD2/monorepo/apps/backend/jest.config.ts
Normal file
11
Programming/BD2/monorepo/apps/backend/jest.config.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
export default {
|
||||||
|
displayName: 'backend',
|
||||||
|
preset: '../../jest.preset.js',
|
||||||
|
testEnvironment: 'node',
|
||||||
|
transform: {
|
||||||
|
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
||||||
|
},
|
||||||
|
moduleFileExtensions: ['ts', 'js', 'html'],
|
||||||
|
coverageDirectory: '../../coverage/apps/backend',
|
||||||
|
};
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "example_table" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"name" VARCHAR(100),
|
||||||
|
"created_at" TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "example_table_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "HelloWorld" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"message" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "HelloWorld_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the `HelloWorld` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- You are about to drop the `example_table` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "HelloWorld";
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "example_table";
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Restauracja" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"adres" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Restauracja_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Recencja" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"tekst" TEXT NOT NULL,
|
||||||
|
"wartosc" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Recencja_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Uzytkownik" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"imie" TEXT NOT NULL,
|
||||||
|
"nazwisko" TEXT NOT NULL,
|
||||||
|
"adres" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Uzytkownik_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Historia_zamowien" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"data_zamowienia" TIMESTAMP(3) NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Historia_zamowien_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Danie" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"cena" INTEGER NOT NULL,
|
||||||
|
"kategoria" TEXT NOT NULL,
|
||||||
|
"nazwa" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Danie_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Zamowione_danie" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Zamowione_danie_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Zamowienie" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"status" TEXT NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Zamowienie_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Znizka" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"kod" TEXT NOT NULL,
|
||||||
|
"wartosc" INTEGER NOT NULL,
|
||||||
|
"czy_dostepna" BOOLEAN NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Znizka_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- A unique constraint covering the columns `[zamowienieId]` on the table `Zamowione_danie` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
- Added the required column `zamowienieId` to the `Zamowione_danie` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Zamowione_danie" ADD COLUMN "zamowienieId" INTEGER NOT NULL;
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "_DanieZamowione_danie" (
|
||||||
|
"A" INTEGER NOT NULL,
|
||||||
|
"B" INTEGER NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "_DanieZamowione_danie_AB_unique" ON "_DanieZamowione_danie"("A", "B");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "_DanieZamowione_danie_B_index" ON "_DanieZamowione_danie"("B");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Zamowione_danie_zamowienieId_key" ON "Zamowione_danie"("zamowienieId");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Zamowione_danie" ADD CONSTRAINT "Zamowione_danie_zamowienieId_fkey" FOREIGN KEY ("zamowienieId") REFERENCES "Zamowienie"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "_DanieZamowione_danie" ADD CONSTRAINT "_DanieZamowione_danie_A_fkey" FOREIGN KEY ("A") REFERENCES "Danie"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "_DanieZamowione_danie" ADD CONSTRAINT "_DanieZamowione_danie_B_fkey" FOREIGN KEY ("B") REFERENCES "Zamowione_danie"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
Warnings:
|
||||||
|
|
||||||
|
- You are about to drop the `Recencja` table. If the table is not empty, all the data it contains will be lost.
|
||||||
|
- A unique constraint covering the columns `[Historia_zamowienId]` on the table `Uzytkownik` will be added. If there are existing duplicate values, this will fail.
|
||||||
|
- Added the required column `Historia_zamowienId` to the `Uzytkownik` table without a default value. This is not possible if the table is not empty.
|
||||||
|
- Added the required column `restauracjaId` to the `Znizka` table without a default value. This is not possible if the table is not empty.
|
||||||
|
|
||||||
|
*/
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Uzytkownik" ADD COLUMN "Historia_zamowienId" INTEGER NOT NULL;
|
||||||
|
|
||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Znizka" ADD COLUMN "restauracjaId" INTEGER NOT NULL;
|
||||||
|
|
||||||
|
-- DropTable
|
||||||
|
DROP TABLE "Recencja";
|
||||||
|
|
||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "Recenzja" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"tekst" TEXT NOT NULL,
|
||||||
|
"wartosc" INTEGER NOT NULL,
|
||||||
|
"restauracjaId" INTEGER NOT NULL,
|
||||||
|
"uzytkownikId" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
CONSTRAINT "Recenzja_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE UNIQUE INDEX "Uzytkownik_Historia_zamowienId_key" ON "Uzytkownik"("Historia_zamowienId");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Recenzja" ADD CONSTRAINT "Recenzja_restauracjaId_fkey" FOREIGN KEY ("restauracjaId") REFERENCES "Restauracja"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Recenzja" ADD CONSTRAINT "Recenzja_uzytkownikId_fkey" FOREIGN KEY ("uzytkownikId") REFERENCES "Uzytkownik"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Uzytkownik" ADD CONSTRAINT "Uzytkownik_Historia_zamowienId_fkey" FOREIGN KEY ("Historia_zamowienId") REFERENCES "Historia_zamowien"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "Znizka" ADD CONSTRAINT "Znizka_restauracjaId_fkey" FOREIGN KEY ("restauracjaId") REFERENCES "Restauracja"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
# Please do not edit this file manually
|
||||||
|
# It should be added in your version-control system (i.e. Git)
|
||||||
|
provider = "postgresql"
|
||||||
71
Programming/BD2/monorepo/apps/backend/prisma/schema.prisma
Normal file
71
Programming/BD2/monorepo/apps/backend/prisma/schema.prisma
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
}
|
||||||
|
|
||||||
|
datasource db {
|
||||||
|
provider = "postgresql"
|
||||||
|
url = env("DATABASE_URL")
|
||||||
|
}
|
||||||
|
|
||||||
|
model Restauracja {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
adres String
|
||||||
|
znizkas Znizka[] @relation("RestauracjaZnizka")
|
||||||
|
recenzjas Recenzja[] @relation("RestauracjaRecenzja")
|
||||||
|
}
|
||||||
|
|
||||||
|
model Recenzja {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
tekst String
|
||||||
|
wartosc Int
|
||||||
|
restauracjaId Int
|
||||||
|
uzytkownikId Int
|
||||||
|
restauracja Restauracja @relation("RestauracjaRecenzja", fields: [restauracjaId], references: [id])
|
||||||
|
uzytkownik Uzytkownik @relation("UzytkownikRecenzja", fields: [uzytkownikId], references: [id])
|
||||||
|
}
|
||||||
|
|
||||||
|
model Uzytkownik {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
imie String
|
||||||
|
nazwisko String
|
||||||
|
adres String
|
||||||
|
Historia_zamowienId Int @unique
|
||||||
|
recenzjas Recenzja[] @relation("UzytkownikRecenzja")
|
||||||
|
historia_zamowien Historia_zamowien @relation("HistoriaRelation", fields: [Historia_zamowienId], references: [id])
|
||||||
|
}
|
||||||
|
|
||||||
|
model Historia_zamowien {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
data_zamowienia DateTime
|
||||||
|
HistoriaUzytkownik Uzytkownik? @relation("HistoriaRelation")
|
||||||
|
}
|
||||||
|
|
||||||
|
model Danie {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
cena Int
|
||||||
|
kategoria String
|
||||||
|
nazwa String
|
||||||
|
zamowioneDanias Zamowione_danie[] @relation("DanieZamowione_danie")
|
||||||
|
}
|
||||||
|
|
||||||
|
model Zamowione_danie {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
zamowienie Zamowienie @relation(fields: [zamowienieId], references: [id])
|
||||||
|
zamowienieId Int @unique
|
||||||
|
danias Danie[] @relation("DanieZamowione_danie")
|
||||||
|
}
|
||||||
|
|
||||||
|
model Zamowienie {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
status String
|
||||||
|
zamowioneDanie Zamowione_danie?
|
||||||
|
}
|
||||||
|
|
||||||
|
model Znizka {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
kod String
|
||||||
|
wartosc Int
|
||||||
|
czy_dostepna Boolean
|
||||||
|
restauracjaId Int
|
||||||
|
restauracja Restauracja @relation("RestauracjaZnizka", fields: [restauracjaId], references: [id])
|
||||||
|
}
|
||||||
24
Programming/BD2/monorepo/apps/backend/project.json
Normal file
24
Programming/BD2/monorepo/apps/backend/project.json
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "backend",
|
||||||
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||||
|
"sourceRoot": "apps/backend/src",
|
||||||
|
"projectType": "application",
|
||||||
|
"tags": [],
|
||||||
|
"targets": {
|
||||||
|
"serve": {
|
||||||
|
"executor": "@nx/js:node",
|
||||||
|
"defaultConfiguration": "development",
|
||||||
|
"options": {
|
||||||
|
"buildTarget": "backend:build"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"development": {
|
||||||
|
"buildTarget": "backend:build:development"
|
||||||
|
},
|
||||||
|
"production": {
|
||||||
|
"buildTarget": "backend:build:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
|
||||||
|
import { AppController } from './app.controller';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
|
||||||
|
describe('AppController', () => {
|
||||||
|
let app: TestingModule;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
app = await Test.createTestingModule({
|
||||||
|
controllers: [AppController],
|
||||||
|
providers: [AppService],
|
||||||
|
}).compile();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getData', () => {
|
||||||
|
it('should return "Hello API"', () => {
|
||||||
|
const appController = app.get<AppController>(AppController);
|
||||||
|
expect(appController.getData()).toEqual({ message: 'Hello API' });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
import { Controller, Get } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
import { FakeDataService } from './fake-data/fake-data.service';
|
||||||
|
|
||||||
|
@Controller()
|
||||||
|
export class AppController {
|
||||||
|
constructor(private readonly appService: AppService,
|
||||||
|
private readonly fakeDataService: FakeDataService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
@Get('generate-fake-data')
|
||||||
|
async generateFakeData() {
|
||||||
|
await this.fakeDataService.generateFakeData();
|
||||||
|
return { message: 'Fake data generated successfully' };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
getData() {
|
||||||
|
return this.appService.getData();
|
||||||
|
}
|
||||||
|
}
|
||||||
31
Programming/BD2/monorepo/apps/backend/src/app/app.module.ts
Normal file
31
Programming/BD2/monorepo/apps/backend/src/app/app.module.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { AppController } from './app.controller';
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
import { DatabaseModule } from './database/database.module';
|
||||||
|
import { RestauracjaModule } from './restauracja/restauracja.module';
|
||||||
|
import { RecenzjaModule } from './recenzja/recenzja.module';
|
||||||
|
import { UzytkownikModule } from './uzytkownik/uzytkownik.module';
|
||||||
|
import { HistoriaZamowienModule } from './historia-zamowien/historia-zamowien.module';
|
||||||
|
import { DanieModule } from './danie/danie.module';
|
||||||
|
import { ZamowioneDanieModule } from './zamowione-danie/zamowione-danie.module';
|
||||||
|
import { ZamowienieModule } from './zamowienie/zamowienie.module';
|
||||||
|
import { ZnizkaModule } from './znizka/znizka.module';
|
||||||
|
import { FakeDataService } from './fake-data/fake-data.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
imports: [
|
||||||
|
DatabaseModule,
|
||||||
|
RestauracjaModule,
|
||||||
|
RecenzjaModule,
|
||||||
|
UzytkownikModule,
|
||||||
|
HistoriaZamowienModule,
|
||||||
|
DanieModule,
|
||||||
|
ZamowioneDanieModule,
|
||||||
|
ZamowienieModule,
|
||||||
|
ZnizkaModule,
|
||||||
|
],
|
||||||
|
controllers: [AppController],
|
||||||
|
providers: [AppService, FakeDataService],
|
||||||
|
})
|
||||||
|
export class AppModule {}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
import { Test } from '@nestjs/testing';
|
||||||
|
|
||||||
|
import { AppService } from './app.service';
|
||||||
|
|
||||||
|
describe('AppService', () => {
|
||||||
|
let service: AppService;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
const app = await Test.createTestingModule({
|
||||||
|
providers: [AppService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = app.get<AppService>(AppService);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getData', () => {
|
||||||
|
it('should return "Hello API"', () => {
|
||||||
|
expect(service.getData()).toEqual({ message: 'Hello API' });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class AppService {
|
||||||
|
getData(): { message: string } {
|
||||||
|
return { message: 'Hello API' };
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { DanieController } from './danie.controller';
|
||||||
|
|
||||||
|
describe('DanieController', () => {
|
||||||
|
let controller: DanieController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [DanieController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<DanieController>(DanieController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
import { Controller, Get, Post, Put, Delete, Param, Body } from '@nestjs/common';
|
||||||
|
import { DanieService } from './danie.service';
|
||||||
|
import { Danie } from '@prisma/client';
|
||||||
|
|
||||||
|
@Controller('danie')
|
||||||
|
export class DanieController {
|
||||||
|
constructor(private readonly danieService: DanieService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
async findAll(): Promise<Danie[]> {
|
||||||
|
return this.danieService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findOne(@Param('id') id: string): Promise<Danie | null> {
|
||||||
|
return this.danieService.findOne(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async create(@Body() data: { cena: number; kategoria: string; nazwa: string }): Promise<Danie> {
|
||||||
|
return this.danieService.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put(':id')
|
||||||
|
async update(@Param('id') id: string, @Body() data: Partial<Danie>): Promise<Danie> {
|
||||||
|
return this.danieService.update(+id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async delete(@Param('id') id: string): Promise<Danie> {
|
||||||
|
return this.danieService.delete(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { DanieService } from './danie.service';
|
||||||
|
import { DanieController } from './danie.controller';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [DanieService, DatabaseService],
|
||||||
|
controllers: [DanieController],
|
||||||
|
})
|
||||||
|
export class DanieModule {}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { DanieService } from './danie.service';
|
||||||
|
|
||||||
|
describe('DanieService', () => {
|
||||||
|
let service: DanieService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [DanieService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<DanieService>(DanieService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { Danie } from '@prisma/client';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class DanieService {
|
||||||
|
constructor(private prisma: DatabaseService) {}
|
||||||
|
|
||||||
|
async findAll(): Promise<Danie[]> {
|
||||||
|
return this.prisma.danie.findMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: number): Promise<Danie | null> {
|
||||||
|
return this.prisma.danie.findUnique({
|
||||||
|
where: { id },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: { cena: number; kategoria: string; nazwa: string }): Promise<Danie> {
|
||||||
|
return this.prisma.danie.create({
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: number, data: Partial<Danie>): Promise<Danie> {
|
||||||
|
return this.prisma.danie.update({
|
||||||
|
where: { id },
|
||||||
|
data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(id: number): Promise<Danie> {
|
||||||
|
return this.prisma.danie.delete({
|
||||||
|
where: { id },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { DatabaseController } from './database.controller';
|
||||||
|
|
||||||
|
describe('DatabaseController', () => {
|
||||||
|
let controller: DatabaseController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [DatabaseController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<DatabaseController>(DatabaseController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
import { Controller } from '@nestjs/common';
|
||||||
|
|
||||||
|
@Controller('database')
|
||||||
|
export class DatabaseController {}
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { DatabaseController } from './database.controller';
|
||||||
|
import { DatabaseService } from './database.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [DatabaseController],
|
||||||
|
providers: [DatabaseService],
|
||||||
|
exports: [DatabaseService]
|
||||||
|
})
|
||||||
|
export class DatabaseModule {}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { DatabaseService } from './database.service';
|
||||||
|
|
||||||
|
describe('DatabaseService', () => {
|
||||||
|
let service: DatabaseService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [DatabaseService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<DatabaseService>(DatabaseService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
||||||
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class DatabaseService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
||||||
|
async onModuleInit() {
|
||||||
|
await this.$connect();
|
||||||
|
}
|
||||||
|
|
||||||
|
async onModuleDestroy() {
|
||||||
|
await this.$disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { FakeDataService } from './fake-data.service';
|
||||||
|
|
||||||
|
describe('FakeDataService', () => {
|
||||||
|
let service: FakeDataService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [FakeDataService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<FakeDataService>(FakeDataService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,90 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { faker } from '@faker-js/faker';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class FakeDataService {
|
||||||
|
constructor(private prisma: DatabaseService) {}
|
||||||
|
|
||||||
|
async generateFakeData() {
|
||||||
|
// Generate fake Restauracja
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
await this.prisma.restauracja.create({
|
||||||
|
data: {
|
||||||
|
adres: faker.location.streetAddress(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate fake Uzytkownik and Historia_zamowien
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
const historia = await this.prisma.historia_zamowien.create({
|
||||||
|
data: {
|
||||||
|
data_zamowienia: faker.date.past(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.prisma.uzytkownik.create({
|
||||||
|
data: {
|
||||||
|
imie: faker.person.firstName(),
|
||||||
|
nazwisko: faker.person.lastName(),
|
||||||
|
adres: faker.location.streetAddress(),
|
||||||
|
Historia_zamowienId: historia.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate fake Danie
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
await this.prisma.danie.create({
|
||||||
|
data: {
|
||||||
|
cena: faker.number.int({ min: 10, max: 100 }),
|
||||||
|
kategoria: faker.commerce.department(),
|
||||||
|
nazwa: faker.commerce.productName(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate fake Zamowienie and Zamowione_danie
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
const zamowienie = await this.prisma.zamowienie.create({
|
||||||
|
data: {
|
||||||
|
status: faker.helpers.arrayElement(['Pending', 'Completed', 'Cancelled']),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
await this.prisma.zamowione_danie.create({
|
||||||
|
data: {
|
||||||
|
zamowienieId: zamowienie.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate fake Znizka
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
const restauracja = await this.prisma.restauracja.findFirst();
|
||||||
|
await this.prisma.znizka.create({
|
||||||
|
data: {
|
||||||
|
kod: faker.string.alphanumeric(10),
|
||||||
|
wartosc: faker.number.int({ min: 10, max: 50 }),
|
||||||
|
czy_dostepna: faker.datatype.boolean(),
|
||||||
|
restauracjaId: restauracja.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate fake Recenzja
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
const restauracja = await this.prisma.restauracja.findFirst();
|
||||||
|
const uzytkownik = await this.prisma.uzytkownik.findFirst();
|
||||||
|
await this.prisma.recenzja.create({
|
||||||
|
data: {
|
||||||
|
tekst: faker.lorem.sentences(),
|
||||||
|
wartosc: faker.number.int({ min: 1, max: 5 }),
|
||||||
|
restauracjaId: restauracja.id,
|
||||||
|
uzytkownikId: uzytkownik.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { HistoriaZamowienController } from './historia-zamowien.controller';
|
||||||
|
|
||||||
|
describe('HistoriaZamowienController', () => {
|
||||||
|
let controller: HistoriaZamowienController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [HistoriaZamowienController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<HistoriaZamowienController>(
|
||||||
|
HistoriaZamowienController
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
// src/historia-zamowien/historia-zamowien.controller.ts
|
||||||
|
import { Controller, Get, Post, Put, Delete, Param, Body } from '@nestjs/common';
|
||||||
|
import { HistoriaZamowienService } from './historia-zamowien.service';
|
||||||
|
import { Historia_zamowien } from '@prisma/client';
|
||||||
|
|
||||||
|
@Controller('historia-zamowien')
|
||||||
|
export class HistoriaZamowienController {
|
||||||
|
constructor(private readonly historiaZamowienService: HistoriaZamowienService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
async findAll(): Promise<Historia_zamowien[]> {
|
||||||
|
return this.historiaZamowienService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findOne(@Param('id') id: string): Promise<Historia_zamowien | null> {
|
||||||
|
return this.historiaZamowienService.findOne(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async create(@Body() data: { data_zamowienia: Date }): Promise<Historia_zamowien> {
|
||||||
|
return this.historiaZamowienService.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put(':id')
|
||||||
|
async update(@Param('id') id: string, @Body() data: Partial<Historia_zamowien>): Promise<Historia_zamowien> {
|
||||||
|
return this.historiaZamowienService.update(+id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async delete(@Param('id') id: string): Promise<Historia_zamowien> {
|
||||||
|
return this.historiaZamowienService.delete(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { HistoriaZamowienService } from './historia-zamowien.service';
|
||||||
|
import { DatabaseModule } from '../database/database.module';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { HistoriaZamowienController } from './historia-zamowien.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [HistoriaZamowienService, DatabaseService],
|
||||||
|
controllers: [HistoriaZamowienController],
|
||||||
|
})
|
||||||
|
export class HistoriaZamowienModule {}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { HistoriaZamowienService } from './historia-zamowien.service';
|
||||||
|
|
||||||
|
describe('HistoriaZamowienService', () => {
|
||||||
|
let service: HistoriaZamowienService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [HistoriaZamowienService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<HistoriaZamowienService>(HistoriaZamowienService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
// src/historia-zamowien/historia-zamowien.service.ts
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { Historia_zamowien } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class HistoriaZamowienService {
|
||||||
|
constructor(private prisma: DatabaseService) {}
|
||||||
|
|
||||||
|
async findAll(): Promise<Historia_zamowien[]> {
|
||||||
|
return this.prisma.historia_zamowien.findMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: number): Promise<Historia_zamowien | null> {
|
||||||
|
return this.prisma.historia_zamowien.findUnique({ where: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: { data_zamowienia: Date }): Promise<Historia_zamowien> {
|
||||||
|
return this.prisma.historia_zamowien.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: number, data: Partial<Historia_zamowien>): Promise<Historia_zamowien> {
|
||||||
|
return this.prisma.historia_zamowien.update({ where: { id }, data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(id: number): Promise<Historia_zamowien> {
|
||||||
|
return this.prisma.historia_zamowien.delete({ where: { id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { RecenzjaController } from './recenzja.controller';
|
||||||
|
|
||||||
|
describe('RecenzjaController', () => {
|
||||||
|
let controller: RecenzjaController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [RecenzjaController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<RecenzjaController>(RecenzjaController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
// src/recenzja/recenzja.controller.ts
|
||||||
|
import { Controller, Get, Post, Put, Delete, Param, Body } from '@nestjs/common';
|
||||||
|
import { RecenzjaService } from './recenzja.service';
|
||||||
|
import { Recenzja } from '@prisma/client';
|
||||||
|
|
||||||
|
@Controller('recenzja')
|
||||||
|
export class RecenzjaController {
|
||||||
|
constructor(private readonly recenzjaService: RecenzjaService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
async findAll(): Promise<Recenzja[]> {
|
||||||
|
return this.recenzjaService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findOne(@Param('id') id: string): Promise<Recenzja | null> {
|
||||||
|
return this.recenzjaService.findOne(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async create(@Body() data: { tekst: string; wartosc: number; restauracjaId: number; uzytkownikId: number }): Promise<Recenzja> {
|
||||||
|
return this.recenzjaService.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put(':id')
|
||||||
|
async update(@Param('id') id: string, @Body() data: Partial<Recenzja>): Promise<Recenzja> {
|
||||||
|
return this.recenzjaService.update(+id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async delete(@Param('id') id: string): Promise<Recenzja> {
|
||||||
|
return this.recenzjaService.delete(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { RecenzjaService } from './recenzja.service';
|
||||||
|
import { DatabaseModule } from '../database/database.module';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { RecenzjaController } from './recenzja.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [RecenzjaService, DatabaseService],
|
||||||
|
exports: [RecenzjaService],
|
||||||
|
controllers: [RecenzjaController],
|
||||||
|
})
|
||||||
|
export class RecenzjaModule {}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { RecenzjaService } from './recenzja.service';
|
||||||
|
|
||||||
|
describe('RecenzjaService', () => {
|
||||||
|
let service: RecenzjaService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [RecenzjaService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<RecenzjaService>(RecenzjaService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
// src/recenzja/recenzja.service.ts
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { Recenzja } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class RecenzjaService {
|
||||||
|
constructor(private prisma: DatabaseService) {}
|
||||||
|
|
||||||
|
async findAll(): Promise<Recenzja[]> {
|
||||||
|
return this.prisma.recenzja.findMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: number): Promise<Recenzja | null> {
|
||||||
|
return this.prisma.recenzja.findUnique({ where: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: { tekst: string; wartosc: number; restauracjaId: number; uzytkownikId: number }): Promise<Recenzja> {
|
||||||
|
return this.prisma.recenzja.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: number, data: Partial<Recenzja>): Promise<Recenzja> {
|
||||||
|
return this.prisma.recenzja.update({ where: { id }, data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(id: number): Promise<Recenzja> {
|
||||||
|
return this.prisma.recenzja.delete({ where: { id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { RestauracjaController } from './restauracja.controller';
|
||||||
|
|
||||||
|
describe('RestauracjaController', () => {
|
||||||
|
let controller: RestauracjaController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [RestauracjaController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<RestauracjaController>(RestauracjaController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
// src/restauracja/restauracja.controller.ts
|
||||||
|
import { Controller, Get, Post, Put, Delete, Param, Body } from '@nestjs/common';
|
||||||
|
import { RestauracjaService } from './restauracja.service';
|
||||||
|
import { Restauracja } from '@prisma/client';
|
||||||
|
|
||||||
|
@Controller('restauracja')
|
||||||
|
export class RestauracjaController {
|
||||||
|
constructor(private readonly restauracjaService: RestauracjaService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
async findAll(): Promise<Restauracja[]> {
|
||||||
|
console.log(`restauracja all`);
|
||||||
|
return this.restauracjaService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findOne(@Param('id') id: string): Promise<Restauracja | null> {
|
||||||
|
return this.restauracjaService.findOne(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async create(@Body() data: { adres: string }): Promise<Restauracja> {
|
||||||
|
return this.restauracjaService.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put(':id')
|
||||||
|
async update(@Param('id') id: string, @Body() data: Partial<Restauracja>): Promise<Restauracja> {
|
||||||
|
return this.restauracjaService.update(+id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async delete(@Param('id') id: string): Promise<Restauracja> {
|
||||||
|
return this.restauracjaService.delete(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { RestauracjaService } from './restauracja.service';
|
||||||
|
import { DatabaseModule } from '../database/database.module';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { RestauracjaController } from './restauracja.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [RestauracjaService, DatabaseService],
|
||||||
|
imports: [DatabaseModule],
|
||||||
|
controllers: [RestauracjaController],
|
||||||
|
})
|
||||||
|
export class RestauracjaModule {}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { RestauracjaService } from './restauracja.service';
|
||||||
|
|
||||||
|
describe('RestauracjaService', () => {
|
||||||
|
let service: RestauracjaService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [RestauracjaService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<RestauracjaService>(RestauracjaService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
// src/restauracja/restauracja.service.ts
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { Restauracja } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class RestauracjaService {
|
||||||
|
constructor(private prisma: DatabaseService) {}
|
||||||
|
|
||||||
|
async findAll(): Promise<Restauracja[]> {
|
||||||
|
return this.prisma.restauracja.findMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: number): Promise<Restauracja | null> {
|
||||||
|
return this.prisma.restauracja.findUnique({ where: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: { adres: string }): Promise<Restauracja> {
|
||||||
|
return this.prisma.restauracja.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: number, data: Partial<Restauracja>): Promise<Restauracja> {
|
||||||
|
return this.prisma.restauracja.update({ where: { id }, data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(id: number): Promise<Restauracja> {
|
||||||
|
return this.prisma.restauracja.delete({ where: { id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { UzytkownikController } from './uzytkownik.controller';
|
||||||
|
|
||||||
|
describe('UzytkownikController', () => {
|
||||||
|
let controller: UzytkownikController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [UzytkownikController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<UzytkownikController>(UzytkownikController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
// src/uzytkownik/uzytkownik.controller.ts
|
||||||
|
import { Controller, Get, Post, Put, Delete, Param, Body } from '@nestjs/common';
|
||||||
|
import { UzytkownikService } from './uzytkownik.service';
|
||||||
|
import { Uzytkownik } from '@prisma/client';
|
||||||
|
|
||||||
|
@Controller('uzytkownik')
|
||||||
|
export class UzytkownikController {
|
||||||
|
constructor(private readonly uzytkownikService: UzytkownikService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
async findAll(): Promise<Uzytkownik[]> {
|
||||||
|
return this.uzytkownikService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findOne(@Param('id') id: string): Promise<Uzytkownik | null> {
|
||||||
|
return this.uzytkownikService.findOne(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async create(@Body() data: { imie: string; nazwisko: string; adres: string; Historia_zamowienId: number }): Promise<Uzytkownik> {
|
||||||
|
return this.uzytkownikService.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put(':id')
|
||||||
|
async update(@Param('id') id: string, @Body() data: Partial<Uzytkownik>): Promise<Uzytkownik> {
|
||||||
|
return this.uzytkownikService.update(+id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async delete(@Param('id') id: string): Promise<Uzytkownik> {
|
||||||
|
return this.uzytkownikService.delete(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { UzytkownikService } from './uzytkownik.service';
|
||||||
|
import { DatabaseModule } from '../database/database.module';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { UzytkownikController } from './uzytkownik.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [UzytkownikService, DatabaseService],
|
||||||
|
controllers: [UzytkownikController],
|
||||||
|
})
|
||||||
|
export class UzytkownikModule {}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { UzytkownikService } from './uzytkownik.service';
|
||||||
|
|
||||||
|
describe('UzytkownikService', () => {
|
||||||
|
let service: UzytkownikService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [UzytkownikService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<UzytkownikService>(UzytkownikService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
// src/uzytkownik/uzytkownik.service.ts
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { Uzytkownik } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UzytkownikService {
|
||||||
|
constructor(private prisma: DatabaseService) {}
|
||||||
|
|
||||||
|
async findAll(): Promise<Uzytkownik[]> {
|
||||||
|
return this.prisma.uzytkownik.findMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: number): Promise<Uzytkownik | null> {
|
||||||
|
return this.prisma.uzytkownik.findUnique({ where: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: { imie: string; nazwisko: string; adres: string; Historia_zamowienId: number }): Promise<Uzytkownik> {
|
||||||
|
return this.prisma.uzytkownik.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: number, data: Partial<Uzytkownik>): Promise<Uzytkownik> {
|
||||||
|
return this.prisma.uzytkownik.update({ where: { id }, data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(id: number): Promise<Uzytkownik> {
|
||||||
|
return this.prisma.uzytkownik.delete({ where: { id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ZamowienieController } from './zamowienie.controller';
|
||||||
|
|
||||||
|
describe('ZamowienieController', () => {
|
||||||
|
let controller: ZamowienieController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [ZamowienieController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<ZamowienieController>(ZamowienieController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
// src/zamowienie/zamowienie.controller.ts
|
||||||
|
import { Controller, Get, Post, Put, Delete, Param, Body } from '@nestjs/common';
|
||||||
|
import { ZamowienieService } from './zamowienie.service';
|
||||||
|
import { Zamowienie } from '@prisma/client';
|
||||||
|
|
||||||
|
@Controller('zamowienie')
|
||||||
|
export class ZamowienieController {
|
||||||
|
constructor(private readonly zamowienieService: ZamowienieService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
async findAll(): Promise<Zamowienie[]> {
|
||||||
|
return this.zamowienieService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findOne(@Param('id') id: string): Promise<Zamowienie | null> {
|
||||||
|
return this.zamowienieService.findOne(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async create(@Body() data: { status: string }): Promise<Zamowienie> {
|
||||||
|
return this.zamowienieService.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put(':id')
|
||||||
|
async update(@Param('id') id: string, @Body() data: Partial<Zamowienie>): Promise<Zamowienie> {
|
||||||
|
return this.zamowienieService.update(+id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async delete(@Param('id') id: string): Promise<Zamowienie> {
|
||||||
|
return this.zamowienieService.delete(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ZamowienieService } from './zamowienie.service';
|
||||||
|
import { DatabaseModule } from '../database/database.module';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { ZamowienieController } from './zamowienie.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [ZamowienieService, DatabaseService],
|
||||||
|
controllers: [ZamowienieController],
|
||||||
|
})
|
||||||
|
export class ZamowienieModule {}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ZamowienieService } from './zamowienie.service';
|
||||||
|
|
||||||
|
describe('ZamowienieService', () => {
|
||||||
|
let service: ZamowienieService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [ZamowienieService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<ZamowienieService>(ZamowienieService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
// src/zamowienie/zamowienie.service.ts
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { Zamowienie } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ZamowienieService {
|
||||||
|
constructor(private prisma: DatabaseService) {}
|
||||||
|
|
||||||
|
async findAll(): Promise<Zamowienie[]> {
|
||||||
|
return this.prisma.zamowienie.findMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: number): Promise<Zamowienie | null> {
|
||||||
|
return this.prisma.zamowienie.findUnique({ where: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: { status: string }): Promise<Zamowienie> {
|
||||||
|
return this.prisma.zamowienie.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: number, data: Partial<Zamowienie>): Promise<Zamowienie> {
|
||||||
|
return this.prisma.zamowienie.update({ where: { id }, data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(id: number): Promise<Zamowienie> {
|
||||||
|
return this.prisma.zamowienie.delete({ where: { id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ZamowioneDanieController } from './zamowione-danie.controller';
|
||||||
|
|
||||||
|
describe('ZamowioneDanieController', () => {
|
||||||
|
let controller: ZamowioneDanieController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [ZamowioneDanieController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<ZamowioneDanieController>(ZamowioneDanieController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
// src/zamowione-danie/zamowione-danie.controller.ts
|
||||||
|
import { Controller, Get, Post, Put, Delete, Param, Body } from '@nestjs/common';
|
||||||
|
import { ZamowioneDanieService } from './zamowione-danie.service';
|
||||||
|
import { Zamowione_danie } from '@prisma/client';
|
||||||
|
|
||||||
|
@Controller('zamowione-danie')
|
||||||
|
export class ZamowioneDanieController {
|
||||||
|
constructor(private readonly zamowioneDanieService: ZamowioneDanieService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
async findAll(): Promise<Zamowione_danie[]> {
|
||||||
|
return this.zamowioneDanieService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findOne(@Param('id') id: string): Promise<Zamowione_danie | null> {
|
||||||
|
return this.zamowioneDanieService.findOne(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async create(@Body() data: { zamowienieId: number }): Promise<Zamowione_danie> {
|
||||||
|
return this.zamowioneDanieService.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put(':id')
|
||||||
|
async update(@Param('id') id: string, @Body() data: Partial<Zamowione_danie>): Promise<Zamowione_danie> {
|
||||||
|
return this.zamowioneDanieService.update(+id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async delete(@Param('id') id: string): Promise<Zamowione_danie> {
|
||||||
|
return this.zamowioneDanieService.delete(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ZamowioneDanieService } from './zamowione-danie.service';
|
||||||
|
import { DatabaseModule } from '../database/database.module';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { ZamowioneDanieController } from './zamowione-danie.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [ZamowioneDanieService, DatabaseService],
|
||||||
|
controllers: [ZamowioneDanieController],
|
||||||
|
})
|
||||||
|
export class ZamowioneDanieModule {}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ZamowioneDanieService } from './zamowione-danie.service';
|
||||||
|
|
||||||
|
describe('ZamowioneDanieService', () => {
|
||||||
|
let service: ZamowioneDanieService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [ZamowioneDanieService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<ZamowioneDanieService>(ZamowioneDanieService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
// src/zamowione-danie/zamowione-danie.service.ts
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { Zamowione_danie } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ZamowioneDanieService {
|
||||||
|
constructor(private prisma: DatabaseService) {}
|
||||||
|
|
||||||
|
async findAll(): Promise<Zamowione_danie[]> {
|
||||||
|
return this.prisma.zamowione_danie.findMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: number): Promise<Zamowione_danie | null> {
|
||||||
|
return this.prisma.zamowione_danie.findUnique({ where: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: { zamowienieId: number }): Promise<Zamowione_danie> {
|
||||||
|
return this.prisma.zamowione_danie.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: number, data: Partial<Zamowione_danie>): Promise<Zamowione_danie> {
|
||||||
|
return this.prisma.zamowione_danie.update({ where: { id }, data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(id: number): Promise<Zamowione_danie> {
|
||||||
|
return this.prisma.zamowione_danie.delete({ where: { id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ZnizkaController } from './znizka.controller';
|
||||||
|
|
||||||
|
describe('ZnizkaController', () => {
|
||||||
|
let controller: ZnizkaController;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
controllers: [ZnizkaController],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
controller = module.get<ZnizkaController>(ZnizkaController);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(controller).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,34 @@
|
|||||||
|
// src/znizka/znizka.controller.ts
|
||||||
|
import { Controller, Get, Post, Put, Delete, Param, Body } from '@nestjs/common';
|
||||||
|
import { ZnizkaService } from './znizka.service';
|
||||||
|
import { Znizka } from '@prisma/client';
|
||||||
|
|
||||||
|
@Controller('znizka')
|
||||||
|
export class ZnizkaController {
|
||||||
|
constructor(private readonly znizkaService: ZnizkaService) {}
|
||||||
|
|
||||||
|
@Get()
|
||||||
|
async findAll(): Promise<Znizka[]> {
|
||||||
|
return this.znizkaService.findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get(':id')
|
||||||
|
async findOne(@Param('id') id: string): Promise<Znizka | null> {
|
||||||
|
return this.znizkaService.findOne(+id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post()
|
||||||
|
async create(@Body() data: { kod: string; wartosc: number; czy_dostepna: boolean; restauracjaId: number }): Promise<Znizka> {
|
||||||
|
return this.znizkaService.create(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Put(':id')
|
||||||
|
async update(@Param('id') id: string, @Body() data: Partial<Znizka>): Promise<Znizka> {
|
||||||
|
return this.znizkaService.update(+id, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Delete(':id')
|
||||||
|
async delete(@Param('id') id: string): Promise<Znizka> {
|
||||||
|
return this.znizkaService.delete(+id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { ZnizkaService } from './znizka.service';
|
||||||
|
import { DatabaseModule } from '../database/database.module';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { ZnizkaController } from './znizka.controller';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
providers: [ZnizkaService, DatabaseService],
|
||||||
|
controllers: [ZnizkaController],
|
||||||
|
})
|
||||||
|
export class ZnizkaModule {}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import { Test, TestingModule } from '@nestjs/testing';
|
||||||
|
import { ZnizkaService } from './znizka.service';
|
||||||
|
|
||||||
|
describe('ZnizkaService', () => {
|
||||||
|
let service: ZnizkaService;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const module: TestingModule = await Test.createTestingModule({
|
||||||
|
providers: [ZnizkaService],
|
||||||
|
}).compile();
|
||||||
|
|
||||||
|
service = module.get<ZnizkaService>(ZnizkaService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be defined', () => {
|
||||||
|
expect(service).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
// src/znizka/znizka.service.ts
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { DatabaseService } from '../database/database.service';
|
||||||
|
import { Znizka } from '@prisma/client';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ZnizkaService {
|
||||||
|
constructor(private prisma: DatabaseService) {}
|
||||||
|
|
||||||
|
async findAll(): Promise<Znizka[]> {
|
||||||
|
return this.prisma.znizka.findMany();
|
||||||
|
}
|
||||||
|
|
||||||
|
async findOne(id: number): Promise<Znizka | null> {
|
||||||
|
return this.prisma.znizka.findUnique({ where: { id } });
|
||||||
|
}
|
||||||
|
|
||||||
|
async create(data: { kod: string; wartosc: number; czy_dostepna: boolean; restauracjaId: number }): Promise<Znizka> {
|
||||||
|
return this.prisma.znizka.create({ data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(id: number, data: Partial<Znizka>): Promise<Znizka> {
|
||||||
|
return this.prisma.znizka.update({ where: { id }, data });
|
||||||
|
}
|
||||||
|
|
||||||
|
async delete(id: number): Promise<Znizka> {
|
||||||
|
return this.prisma.znizka.delete({ where: { id } });
|
||||||
|
}
|
||||||
|
}
|
||||||
23
Programming/BD2/monorepo/apps/backend/src/main.ts
Normal file
23
Programming/BD2/monorepo/apps/backend/src/main.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* This is not a production server yet!
|
||||||
|
* This is only a minimal backend to get started.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Logger } from '@nestjs/common';
|
||||||
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
|
||||||
|
import { AppModule } from './app/app.module';
|
||||||
|
|
||||||
|
async function bootstrap() {
|
||||||
|
const app = await NestFactory.create(AppModule);
|
||||||
|
app.enableCors();
|
||||||
|
const globalPrefix = 'api';
|
||||||
|
app.setGlobalPrefix(globalPrefix);
|
||||||
|
const port = process.env.PORT || 3000;
|
||||||
|
await app.listen(port);
|
||||||
|
Logger.log(
|
||||||
|
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstrap();
|
||||||
12
Programming/BD2/monorepo/apps/backend/tsconfig.app.json
Normal file
12
Programming/BD2/monorepo/apps/backend/tsconfig.app.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../../dist/out-tsc",
|
||||||
|
"module": "commonjs",
|
||||||
|
"types": ["node"],
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"target": "es2021"
|
||||||
|
},
|
||||||
|
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
|
||||||
|
"include": ["src/**/*.ts"]
|
||||||
|
}
|
||||||
16
Programming/BD2/monorepo/apps/backend/tsconfig.json
Normal file
16
Programming/BD2/monorepo/apps/backend/tsconfig.json
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.base.json",
|
||||||
|
"files": [],
|
||||||
|
"include": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.app.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.spec.json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Programming/BD2/monorepo/apps/backend/tsconfig.spec.json
Normal file
14
Programming/BD2/monorepo/apps/backend/tsconfig.spec.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "../../dist/out-tsc",
|
||||||
|
"module": "commonjs",
|
||||||
|
"types": ["jest", "node"]
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"jest.config.ts",
|
||||||
|
"src/**/*.test.ts",
|
||||||
|
"src/**/*.spec.ts",
|
||||||
|
"src/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
19
Programming/BD2/monorepo/apps/backend/webpack.config.js
Normal file
19
Programming/BD2/monorepo/apps/backend/webpack.config.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
const { NxWebpackPlugin } = require('@nx/webpack');
|
||||||
|
const { join } = require('path');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
output: {
|
||||||
|
path: join(__dirname, '../../dist/apps/my-nest-app'),
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
new NxWebpackPlugin({
|
||||||
|
target: 'node',
|
||||||
|
compiler: 'tsc',
|
||||||
|
main: './src/main.ts',
|
||||||
|
tsConfig: './tsconfig.app.json',
|
||||||
|
assets: ['./src/assets'],
|
||||||
|
optimization: false,
|
||||||
|
outputHashing: 'none',
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
36
Programming/BD2/monorepo/apps/frontend/.eslintrc.json
Normal file
36
Programming/BD2/monorepo/apps/frontend/.eslintrc.json
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{
|
||||||
|
"extends": ["../../.eslintrc.json"],
|
||||||
|
"ignorePatterns": ["!**/*"],
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"files": ["*.ts"],
|
||||||
|
"extends": [
|
||||||
|
"plugin:@nx/angular",
|
||||||
|
"plugin:@angular-eslint/template/process-inline-templates"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"@angular-eslint/directive-selector": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"type": "attribute",
|
||||||
|
"prefix": "app",
|
||||||
|
"style": "camelCase"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"@angular-eslint/component-selector": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"type": "element",
|
||||||
|
"prefix": "app",
|
||||||
|
"style": "kebab-case"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"files": ["*.html"],
|
||||||
|
"extends": ["plugin:@nx/angular-template"],
|
||||||
|
"rules": {}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
22
Programming/BD2/monorepo/apps/frontend/jest.config.ts
Normal file
22
Programming/BD2/monorepo/apps/frontend/jest.config.ts
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
export default {
|
||||||
|
displayName: 'frontend',
|
||||||
|
preset: '../../jest.preset.js',
|
||||||
|
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
|
||||||
|
coverageDirectory: '../../coverage/apps/frontend',
|
||||||
|
transform: {
|
||||||
|
'^.+\\.(ts|mjs|js|html)$': [
|
||||||
|
'jest-preset-angular',
|
||||||
|
{
|
||||||
|
tsconfig: '<rootDir>/tsconfig.spec.json',
|
||||||
|
stringifyContentPathRegex: '\\.(html|svg)$',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
|
||||||
|
snapshotSerializers: [
|
||||||
|
'jest-preset-angular/build/serializers/no-ng-attributes',
|
||||||
|
'jest-preset-angular/build/serializers/ng-snapshot',
|
||||||
|
'jest-preset-angular/build/serializers/html-comment',
|
||||||
|
],
|
||||||
|
};
|
||||||
91
Programming/BD2/monorepo/apps/frontend/project.json
Normal file
91
Programming/BD2/monorepo/apps/frontend/project.json
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
{
|
||||||
|
"name": "frontend",
|
||||||
|
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||||
|
"projectType": "application",
|
||||||
|
"prefix": "app",
|
||||||
|
"sourceRoot": "apps/frontend/src",
|
||||||
|
"tags": [],
|
||||||
|
"targets": {
|
||||||
|
"build": {
|
||||||
|
"executor": "@angular-devkit/build-angular:browser",
|
||||||
|
"outputs": [
|
||||||
|
"{options.outputPath}"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"outputPath": "dist/apps/frontend",
|
||||||
|
"index": "apps/frontend/src/index.html",
|
||||||
|
"main": "apps/frontend/src/main.ts",
|
||||||
|
"polyfills": [
|
||||||
|
"zone.js"
|
||||||
|
],
|
||||||
|
"tsConfig": "apps/frontend/tsconfig.app.json",
|
||||||
|
"inlineStyleLanguage": "scss",
|
||||||
|
"assets": [
|
||||||
|
"apps/frontend/src/favicon.ico",
|
||||||
|
"apps/frontend/src/assets"
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"@angular/material/prebuilt-themes/azure-blue.css",
|
||||||
|
"apps/frontend/src/styles.scss"
|
||||||
|
],
|
||||||
|
"scripts": []
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"budgets": [
|
||||||
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "500kb",
|
||||||
|
"maximumError": "1mb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "anyComponentStyle",
|
||||||
|
"maximumWarning": "2kb",
|
||||||
|
"maximumError": "4kb"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputHashing": "all"
|
||||||
|
},
|
||||||
|
"development": {
|
||||||
|
"buildOptimizer": false,
|
||||||
|
"optimization": false,
|
||||||
|
"vendorChunk": true,
|
||||||
|
"extractLicenses": false,
|
||||||
|
"sourceMap": true,
|
||||||
|
"namedChunks": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultConfiguration": "production"
|
||||||
|
},
|
||||||
|
"serve": {
|
||||||
|
"executor": "@angular-devkit/build-angular:dev-server",
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"buildTarget": "frontend:build:production"
|
||||||
|
},
|
||||||
|
"development": {
|
||||||
|
"buildTarget": "frontend:build:development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultConfiguration": "development"
|
||||||
|
},
|
||||||
|
"extract-i18n": {
|
||||||
|
"executor": "@angular-devkit/build-angular:extract-i18n",
|
||||||
|
"options": {
|
||||||
|
"buildTarget": "frontend:build"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"executor": "@nx/eslint:lint"
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"executor": "@nx/jest:jest",
|
||||||
|
"outputs": [
|
||||||
|
"{workspaceRoot}/coverage/{projectRoot}"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"jestConfig": "apps/frontend/jest.config.ts"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
<div class="home-container">
|
||||||
|
<mat-toolbar color="primary">
|
||||||
|
<button mat-button [matMenuTriggerFor]="menu">
|
||||||
|
<mat-icon> menu </mat-icon>
|
||||||
|
<span> Menu </span>
|
||||||
|
</button>
|
||||||
|
<span class="spacer"></span>
|
||||||
|
<span>Smaczne.pl</span>
|
||||||
|
<mat-menu #menu="matMenu">
|
||||||
|
@for(item of menuItems; track item) {
|
||||||
|
<button mat-menu-item [routerLink]="item.path">
|
||||||
|
<mat-icon>{{ item.icon }}</mat-icon>
|
||||||
|
<span>{{ item.title }}</span>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
</mat-menu>
|
||||||
|
</mat-toolbar>
|
||||||
|
</div>
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
.home-container {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-toolbar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.spacer {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-menu-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-menu-item mat-icon {
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
import { AppComponent } from './app.component';
|
||||||
|
import { NxWelcomeComponent } from './nx-welcome.component';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
|
||||||
|
describe('AppComponent', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [AppComponent, NxWelcomeComponent, RouterTestingModule],
|
||||||
|
}).compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render title', () => {
|
||||||
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
|
fixture.detectChanges();
|
||||||
|
const compiled = fixture.nativeElement as HTMLElement;
|
||||||
|
expect(compiled.querySelector('h1')?.textContent).toContain(
|
||||||
|
'Welcome frontend'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should have as title 'frontend'`, () => {
|
||||||
|
const fixture = TestBed.createComponent(AppComponent);
|
||||||
|
const app = fixture.componentInstance;
|
||||||
|
expect(app.title).toEqual('frontend');
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
import {MatGridListModule} from '@angular/material/grid-list';
|
||||||
|
import {MatCardModule} from '@angular/material/card';
|
||||||
|
import { MatButtonModule } from '@angular/material/button'
|
||||||
|
import {MatTabsModule} from '@angular/material/tabs';
|
||||||
|
import {MatMenuModule} from '@angular/material/menu';
|
||||||
|
import { MatToolbarModule } from '@angular/material/toolbar'
|
||||||
|
import { MatIconModule } from '@angular/material/icon'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
standalone: true,
|
||||||
|
imports: [RouterModule, MatGridListModule, MatCardModule, MatButtonModule, MatTabsModule, MatMenuModule, MatToolbarModule,
|
||||||
|
MatIconModule
|
||||||
|
],
|
||||||
|
selector: 'app-root',
|
||||||
|
templateUrl: './app.component.html',
|
||||||
|
styleUrl: './app.component.scss',
|
||||||
|
})
|
||||||
|
export class AppComponent {
|
||||||
|
title = 'frontend';
|
||||||
|
|
||||||
|
menuItems = [
|
||||||
|
{ title: 'Danie', path: '/danie', icon: 'restaurant' },
|
||||||
|
{ title: 'Historia Zamówien', path: '/historia-zamowien', icon: 'history' },
|
||||||
|
{ title: 'Recenzja', path: '/recenzja', icon: 'rate_review' },
|
||||||
|
{ title: 'Restauracja', path: '/restauracja', icon: 'store' },
|
||||||
|
{ title: 'Użytkownik', path: '/uzytkownik', icon: 'person' },
|
||||||
|
{ title: 'Zamówienie', path: '/zamowienie', icon: 'receipt' },
|
||||||
|
{ title: 'Zamówione Danie', path: '/zamowione-danie', icon: 'local_dining' },
|
||||||
|
{ title: 'Zniżka', path: '/znizka', icon: 'local_offer' }
|
||||||
|
];
|
||||||
|
|
||||||
|
activeLink = this.menuItems[0].path;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
import { ApplicationConfig } from '@angular/core';
|
||||||
|
import { provideRouter } from '@angular/router';
|
||||||
|
import { appRoutes } from './app.routes';
|
||||||
|
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
||||||
|
|
||||||
|
export const appConfig: ApplicationConfig = {
|
||||||
|
providers: [provideRouter(appRoutes), provideAnimationsAsync()],
|
||||||
|
};
|
||||||
20
Programming/BD2/monorepo/apps/frontend/src/app/app.routes.ts
Normal file
20
Programming/BD2/monorepo/apps/frontend/src/app/app.routes.ts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { Route } from '@angular/router';
|
||||||
|
import { RestauracjaComponent } from './restauracja/restauracja.component';
|
||||||
|
import { RecenzjaComponent } from './recenzja/recenzja.component';
|
||||||
|
import { UzytkownikComponent } from './uzytkownik/uzytkownik.component';
|
||||||
|
import { ZamowienieComponent } from './zamowienie/zamowienie.component';
|
||||||
|
import { ZamowioneDanieComponent } from './zamowione-danie/zamowione-danie.component';
|
||||||
|
import { ZnizkaComponent } from './znizka/znizka.component';
|
||||||
|
import { HistoriaZamowienComponent } from './historia-zamowien/historia-zamowien.component';
|
||||||
|
import { DanieComponent } from './danie/danie.component';
|
||||||
|
|
||||||
|
export const appRoutes: Route[] = [
|
||||||
|
{path: 'restauracja', component: RestauracjaComponent},
|
||||||
|
{path: 'uzytkownik', component: UzytkownikComponent},
|
||||||
|
{path: 'zamowienie', component: ZamowienieComponent},
|
||||||
|
{path: 'zamowione-danie', component: ZamowioneDanieComponent},
|
||||||
|
{path: 'znizka', component: ZnizkaComponent},
|
||||||
|
{path: 'historia-zamowien', component: HistoriaZamowienComponent},
|
||||||
|
{path: 'danie', component: DanieComponent},
|
||||||
|
{path: 'recenzja', component: RecenzjaComponent}
|
||||||
|
];
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
<!-- src/app/danie/danie.component.html -->
|
||||||
|
<div>
|
||||||
|
<h2>Dania List</h2>
|
||||||
|
<ul>
|
||||||
|
<li *ngFor="let danie of dania">
|
||||||
|
{{ danie.nazwa }} - {{ danie.kategoria }} - {{ danie.cena }} PLN
|
||||||
|
<button (click)="startEdit(danie)">Edit</button>
|
||||||
|
<button (click)="deleteDanie(danie.id!)">Delete</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Create Danie</h2>
|
||||||
|
<input [(ngModel)]="newDanie.nazwa" placeholder="Nazwa">
|
||||||
|
<input [(ngModel)]="newDanie.kategoria" placeholder="Kategoria">
|
||||||
|
<input [(ngModel)]="newDanie.cena" placeholder="Cena" type="number">
|
||||||
|
<button (click)="createDanie()">Create</button>
|
||||||
|
|
||||||
|
<div *ngIf="editDanie">
|
||||||
|
<h2>Edit Danie</h2>
|
||||||
|
<input [(ngModel)]="editDanie.nazwa" placeholder="Nazwa">
|
||||||
|
<input [(ngModel)]="editDanie.kategoria" placeholder="Kategoria">
|
||||||
|
<input [(ngModel)]="editDanie.cena" placeholder="Cena" type="number">
|
||||||
|
<button (click)="updateDanie()">Update</button>
|
||||||
|
<button (click)="cancelEdit()">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { DanieComponent } from './danie.component';
|
||||||
|
|
||||||
|
describe('DanieComponent', () => {
|
||||||
|
let component: DanieComponent;
|
||||||
|
let fixture: ComponentFixture<DanieComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [DanieComponent],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(DanieComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
// src/app/danie/danie.component.ts
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
interface Danie {
|
||||||
|
id?: number;
|
||||||
|
cena: number;
|
||||||
|
kategoria: string;
|
||||||
|
nazwa: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-danie',
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, HttpClientModule, FormsModule],
|
||||||
|
templateUrl: './danie.component.html',
|
||||||
|
styleUrl: './danie.component.css',
|
||||||
|
})
|
||||||
|
export class DanieComponent {
|
||||||
|
dania: Danie[] = [];
|
||||||
|
newDanie: Danie = { cena: 0, kategoria: '', nazwa: '' };
|
||||||
|
editDanie: Danie | null = null;
|
||||||
|
private apiUrl = 'http://localhost:3000/api/danie';
|
||||||
|
|
||||||
|
constructor(private http: HttpClient) { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.loadDania();
|
||||||
|
}
|
||||||
|
|
||||||
|
loadDania(): void {
|
||||||
|
this.http.get<Danie[]>(this.apiUrl).subscribe(data => {
|
||||||
|
this.dania = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createDanie(): void {
|
||||||
|
this.http.post<Danie>(this.apiUrl, this.newDanie).subscribe(data => {
|
||||||
|
this.dania.push(data);
|
||||||
|
this.newDanie = { cena: 0, kategoria: '', nazwa: '' };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDanie(): void {
|
||||||
|
if (this.editDanie && this.editDanie.id) {
|
||||||
|
this.http.put<Danie>(`${this.apiUrl}/${this.editDanie.id}`, this.editDanie).subscribe(data => {
|
||||||
|
this.loadDania();
|
||||||
|
this.editDanie = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteDanie(id: number): void {
|
||||||
|
this.http.delete<Danie>(`${this.apiUrl}/${id}`).subscribe(() => {
|
||||||
|
this.dania = this.dania.filter(d => d.id !== id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
startEdit(danie: Danie): void {
|
||||||
|
this.editDanie = { ...danie };
|
||||||
|
}
|
||||||
|
|
||||||
|
cancelEdit(): void {
|
||||||
|
this.editDanie = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
<!-- src/app/historia-zamowien/historia-zamowien.component.html -->
|
||||||
|
<div>
|
||||||
|
<h2>Historia Zamowien List</h2>
|
||||||
|
<ul>
|
||||||
|
<li *ngFor="let historia of historiaZamowien">
|
||||||
|
{{ historia.data_zamowienia }}
|
||||||
|
<button (click)="startEdit(historia)">Edit</button>
|
||||||
|
<button (click)="deleteHistoriaZamowien(historia.id!)">Delete</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Create Historia Zamowien</h2>
|
||||||
|
<input [(ngModel)]="newHistoriaZamowien.data_zamowienia" placeholder="Data Zamowienia" type="date">
|
||||||
|
<button (click)="createHistoriaZamowien()">Create</button>
|
||||||
|
|
||||||
|
<div *ngIf="editHistoriaZamowien">
|
||||||
|
<h2>Edit Historia Zamowien</h2>
|
||||||
|
<input [(ngModel)]="editHistoriaZamowien.data_zamowienia" placeholder="Data Zamowienia" type="date">
|
||||||
|
<button (click)="updateHistoriaZamowien()">Update</button>
|
||||||
|
<button (click)="cancelEdit()">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { HistoriaZamowienComponent } from './historia-zamowien.component';
|
||||||
|
|
||||||
|
describe('HistoriaZamowienComponent', () => {
|
||||||
|
let component: HistoriaZamowienComponent;
|
||||||
|
let fixture: ComponentFixture<HistoriaZamowienComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [HistoriaZamowienComponent],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(HistoriaZamowienComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
// src/app/historia-zamowien/historia-zamowien.component.ts
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
interface HistoriaZamowien {
|
||||||
|
id?: number;
|
||||||
|
data_zamowienia: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-historia-zamowien',
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, HttpClientModule, FormsModule],
|
||||||
|
templateUrl: './historia-zamowien.component.html',
|
||||||
|
styleUrl: './historia-zamowien.component.css',
|
||||||
|
})
|
||||||
|
export class HistoriaZamowienComponent {
|
||||||
|
historiaZamowien: HistoriaZamowien[] = [];
|
||||||
|
newHistoriaZamowien: HistoriaZamowien = { data_zamowienia: '' };
|
||||||
|
editHistoriaZamowien: HistoriaZamowien | null = null;
|
||||||
|
private apiUrl = 'http://localhost:3000/api/historia-zamowien';
|
||||||
|
|
||||||
|
constructor(private http: HttpClient) { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.loadHistoriaZamowien();
|
||||||
|
}
|
||||||
|
|
||||||
|
loadHistoriaZamowien(): void {
|
||||||
|
this.http.get<HistoriaZamowien[]>(this.apiUrl).subscribe(data => {
|
||||||
|
this.historiaZamowien = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createHistoriaZamowien(): void {
|
||||||
|
this.http.post<HistoriaZamowien>(this.apiUrl, this.newHistoriaZamowien).subscribe(data => {
|
||||||
|
this.historiaZamowien.push(data);
|
||||||
|
this.newHistoriaZamowien = { data_zamowienia: '' };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateHistoriaZamowien(): void {
|
||||||
|
if (this.editHistoriaZamowien && this.editHistoriaZamowien.id) {
|
||||||
|
this.http.put<HistoriaZamowien>(`${this.apiUrl}/${this.editHistoriaZamowien.id}`, this.editHistoriaZamowien).subscribe(data => {
|
||||||
|
this.loadHistoriaZamowien();
|
||||||
|
this.editHistoriaZamowien = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteHistoriaZamowien(id: number): void {
|
||||||
|
this.http.delete<HistoriaZamowien>(`${this.apiUrl}/${id}`).subscribe(() => {
|
||||||
|
this.historiaZamowien = this.historiaZamowien.filter(h => h.id !== id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
startEdit(historia: HistoriaZamowien): void {
|
||||||
|
this.editHistoriaZamowien = { ...historia };
|
||||||
|
}
|
||||||
|
|
||||||
|
cancelEdit(): void {
|
||||||
|
this.editHistoriaZamowien = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
<!-- src/app/recenzja/recenzja.component.html -->
|
||||||
|
<div>
|
||||||
|
<h2>Recenzja List</h2>
|
||||||
|
<ul>
|
||||||
|
<li *ngFor="let recenzja of recenzje">
|
||||||
|
<strong>{{ recenzja.wartosc }}</strong> - {{ recenzja.tekst }} (Restauracja ID: {{ recenzja.restauracjaId }}, Uzytkownik ID: {{ recenzja.uzytkownikId }})
|
||||||
|
<button (click)="startEdit(recenzja)">Edit</button>
|
||||||
|
<button (click)="deleteRecenzja(recenzja.id!)">Delete</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>Create Recenzja</h2>
|
||||||
|
<textarea [(ngModel)]="newRecenzja.tekst" placeholder="Tekst"></textarea>
|
||||||
|
<input [(ngModel)]="newRecenzja.wartosc" placeholder="Wartosc" type="number">
|
||||||
|
<input [(ngModel)]="newRecenzja.restauracjaId" placeholder="Restauracja ID" type="number">
|
||||||
|
<input [(ngModel)]="newRecenzja.uzytkownikId" placeholder="Uzytkownik ID" type="number">
|
||||||
|
<button (click)="createRecenzja()">Create</button>
|
||||||
|
|
||||||
|
<div *ngIf="editRecenzja">
|
||||||
|
<h2>Edit Recenzja</h2>
|
||||||
|
<textarea [(ngModel)]="editRecenzja.tekst" placeholder="Tekst"></textarea>
|
||||||
|
<input [(ngModel)]="editRecenzja.wartosc" placeholder="Wartosc" type="number">
|
||||||
|
<input [(ngModel)]="editRecenzja.restauracjaId" placeholder="Restauracja ID" type="number">
|
||||||
|
<input [(ngModel)]="editRecenzja.uzytkownikId" placeholder="Uzytkownik ID" type="number">
|
||||||
|
<button (click)="updateRecenzja()">Update</button>
|
||||||
|
<button (click)="cancelEdit()">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { RecenzjaComponent } from './recenzja.component';
|
||||||
|
|
||||||
|
describe('RecenzjaComponent', () => {
|
||||||
|
let component: RecenzjaComponent;
|
||||||
|
let fixture: ComponentFixture<RecenzjaComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [RecenzjaComponent],
|
||||||
|
}).compileComponents();
|
||||||
|
|
||||||
|
fixture = TestBed.createComponent(RecenzjaComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { HttpClient, HttpClientModule } from '@angular/common/http';
|
||||||
|
import { CommonModule } from '@angular/common';
|
||||||
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
|
interface Recenzja {
|
||||||
|
id?: number;
|
||||||
|
tekst: string;
|
||||||
|
wartosc: number;
|
||||||
|
restauracjaId: number;
|
||||||
|
uzytkownikId: number;
|
||||||
|
}
|
||||||
|
@Component({
|
||||||
|
selector: 'app-recenzja',
|
||||||
|
standalone: true,
|
||||||
|
imports: [CommonModule, FormsModule, HttpClientModule],
|
||||||
|
templateUrl: './recenzja.component.html',
|
||||||
|
styleUrl: './recenzja.component.css',
|
||||||
|
})
|
||||||
|
export class RecenzjaComponent {
|
||||||
|
recenzje: Recenzja[] = [];
|
||||||
|
newRecenzja: Recenzja = { tekst: '', wartosc: 0, restauracjaId: 0, uzytkownikId: 0 };
|
||||||
|
editRecenzja: Recenzja | null = null;
|
||||||
|
private apiUrl = 'http://localhost:3000/api/recenzja';
|
||||||
|
|
||||||
|
constructor(private http: HttpClient) { }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
this.loadRecenzje();
|
||||||
|
}
|
||||||
|
|
||||||
|
loadRecenzje(): void {
|
||||||
|
this.http.get<Recenzja[]>(this.apiUrl).subscribe(data => {
|
||||||
|
this.recenzje = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
createRecenzja(): void {
|
||||||
|
this.http.post<Recenzja>(this.apiUrl, this.newRecenzja).subscribe(data => {
|
||||||
|
this.recenzje.push(data);
|
||||||
|
this.newRecenzja = { tekst: '', wartosc: 0, restauracjaId: 0, uzytkownikId: 0 };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRecenzja(): void {
|
||||||
|
if (this.editRecenzja && this.editRecenzja.id) {
|
||||||
|
this.http.put<Recenzja>(`${this.apiUrl}/${this.editRecenzja.id}`, this.editRecenzja).subscribe(data => {
|
||||||
|
this.loadRecenzje();
|
||||||
|
this.editRecenzja = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteRecenzja(id: number): void {
|
||||||
|
this.http.delete<Recenzja>(`${this.apiUrl}/${id}`).subscribe(() => {
|
||||||
|
this.recenzje = this.recenzje.filter(r => r.id !== id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
startEdit(recenzja: Recenzja): void {
|
||||||
|
this.editRecenzja = { ...recenzja };
|
||||||
|
}
|
||||||
|
|
||||||
|
cancelEdit(): void {
|
||||||
|
this.editRecenzja = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user