From 24d2a5fb44217dd9157cc197c0e74b03683a5262 Mon Sep 17 00:00:00 2001 From: Krzysztof Rudnicki Date: Thu, 30 May 2024 23:44:48 +0200 Subject: [PATCH] feat: filled controllers for all models --- .../historia-zamowien.controller.ts | 34 +- .../src/app/recenzja/recenzja.controller.ts | 34 +- .../app/restauracja/restauracja.controller.ts | 34 +- .../app/uzytkownik/uzytkownik.controller.ts | 34 +- .../app/zamowienie/zamowienie.controller.ts | 34 +- .../zamowione-danie.controller.ts | 34 +- .../src/app/znizka/znizka.controller.ts | 34 +- .../apps/frontend/src/app/app.component.html | 2 +- .../apps/frontend/src/app/app.component.ts | 3 +- .../frontend/src/app/nx-welcome.component.ts | 907 ------------------ 10 files changed, 226 insertions(+), 924 deletions(-) delete mode 100644 monorepo/apps/frontend/src/app/nx-welcome.component.ts diff --git a/monorepo/apps/backend/src/app/historia-zamowien/historia-zamowien.controller.ts b/monorepo/apps/backend/src/app/historia-zamowien/historia-zamowien.controller.ts index 72e15c9f..b89d06f7 100644 --- a/monorepo/apps/backend/src/app/historia-zamowien/historia-zamowien.controller.ts +++ b/monorepo/apps/backend/src/app/historia-zamowien/historia-zamowien.controller.ts @@ -1,4 +1,34 @@ -import { Controller } from '@nestjs/common'; +// 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 {} +export class HistoriaZamowienController { + constructor(private readonly historiaZamowienService: HistoriaZamowienService) {} + + @Get() + async findAll(): Promise { + return this.historiaZamowienService.findAll(); + } + + @Get(':id') + async findOne(@Param('id') id: string): Promise { + return this.historiaZamowienService.findOne(+id); + } + + @Post() + async create(@Body() data: { data_zamowienia: Date }): Promise { + return this.historiaZamowienService.create(data); + } + + @Put(':id') + async update(@Param('id') id: string, @Body() data: Partial): Promise { + return this.historiaZamowienService.update(+id, data); + } + + @Delete(':id') + async delete(@Param('id') id: string): Promise { + return this.historiaZamowienService.delete(+id); + } +} diff --git a/monorepo/apps/backend/src/app/recenzja/recenzja.controller.ts b/monorepo/apps/backend/src/app/recenzja/recenzja.controller.ts index 8a7856d4..29e50608 100644 --- a/monorepo/apps/backend/src/app/recenzja/recenzja.controller.ts +++ b/monorepo/apps/backend/src/app/recenzja/recenzja.controller.ts @@ -1,4 +1,34 @@ -import { Controller } from '@nestjs/common'; +// 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 {} +export class RecenzjaController { + constructor(private readonly recenzjaService: RecenzjaService) {} + + @Get() + async findAll(): Promise { + return this.recenzjaService.findAll(); + } + + @Get(':id') + async findOne(@Param('id') id: string): Promise { + return this.recenzjaService.findOne(+id); + } + + @Post() + async create(@Body() data: { tekst: string; wartosc: number; restauracjaId: number; uzytkownikId: number }): Promise { + return this.recenzjaService.create(data); + } + + @Put(':id') + async update(@Param('id') id: string, @Body() data: Partial): Promise { + return this.recenzjaService.update(+id, data); + } + + @Delete(':id') + async delete(@Param('id') id: string): Promise { + return this.recenzjaService.delete(+id); + } +} diff --git a/monorepo/apps/backend/src/app/restauracja/restauracja.controller.ts b/monorepo/apps/backend/src/app/restauracja/restauracja.controller.ts index 38bd072a..7ed27105 100644 --- a/monorepo/apps/backend/src/app/restauracja/restauracja.controller.ts +++ b/monorepo/apps/backend/src/app/restauracja/restauracja.controller.ts @@ -1,4 +1,34 @@ -import { Controller } from '@nestjs/common'; +// 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 {} +export class RestauracjaController { + constructor(private readonly restauracjaService: RestauracjaService) {} + + @Get() + async findAll(): Promise { + return this.restauracjaService.findAll(); + } + + @Get(':id') + async findOne(@Param('id') id: string): Promise { + return this.restauracjaService.findOne(+id); + } + + @Post() + async create(@Body() data: { adres: string }): Promise { + return this.restauracjaService.create(data); + } + + @Put(':id') + async update(@Param('id') id: string, @Body() data: Partial): Promise { + return this.restauracjaService.update(+id, data); + } + + @Delete(':id') + async delete(@Param('id') id: string): Promise { + return this.restauracjaService.delete(+id); + } +} diff --git a/monorepo/apps/backend/src/app/uzytkownik/uzytkownik.controller.ts b/monorepo/apps/backend/src/app/uzytkownik/uzytkownik.controller.ts index a6f07661..9e9d65ff 100644 --- a/monorepo/apps/backend/src/app/uzytkownik/uzytkownik.controller.ts +++ b/monorepo/apps/backend/src/app/uzytkownik/uzytkownik.controller.ts @@ -1,4 +1,34 @@ -import { Controller } from '@nestjs/common'; +// 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 {} +export class UzytkownikController { + constructor(private readonly uzytkownikService: UzytkownikService) {} + + @Get() + async findAll(): Promise { + return this.uzytkownikService.findAll(); + } + + @Get(':id') + async findOne(@Param('id') id: string): Promise { + return this.uzytkownikService.findOne(+id); + } + + @Post() + async create(@Body() data: { imie: string; nazwisko: string; adres: string; Historia_zamowienId: number }): Promise { + return this.uzytkownikService.create(data); + } + + @Put(':id') + async update(@Param('id') id: string, @Body() data: Partial): Promise { + return this.uzytkownikService.update(+id, data); + } + + @Delete(':id') + async delete(@Param('id') id: string): Promise { + return this.uzytkownikService.delete(+id); + } +} diff --git a/monorepo/apps/backend/src/app/zamowienie/zamowienie.controller.ts b/monorepo/apps/backend/src/app/zamowienie/zamowienie.controller.ts index 4bee2977..d585a6db 100644 --- a/monorepo/apps/backend/src/app/zamowienie/zamowienie.controller.ts +++ b/monorepo/apps/backend/src/app/zamowienie/zamowienie.controller.ts @@ -1,4 +1,34 @@ -import { Controller } from '@nestjs/common'; +// 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 {} +export class ZamowienieController { + constructor(private readonly zamowienieService: ZamowienieService) {} + + @Get() + async findAll(): Promise { + return this.zamowienieService.findAll(); + } + + @Get(':id') + async findOne(@Param('id') id: string): Promise { + return this.zamowienieService.findOne(+id); + } + + @Post() + async create(@Body() data: { status: string }): Promise { + return this.zamowienieService.create(data); + } + + @Put(':id') + async update(@Param('id') id: string, @Body() data: Partial): Promise { + return this.zamowienieService.update(+id, data); + } + + @Delete(':id') + async delete(@Param('id') id: string): Promise { + return this.zamowienieService.delete(+id); + } +} diff --git a/monorepo/apps/backend/src/app/zamowione-danie/zamowione-danie.controller.ts b/monorepo/apps/backend/src/app/zamowione-danie/zamowione-danie.controller.ts index 70fcf7a1..94a592e5 100644 --- a/monorepo/apps/backend/src/app/zamowione-danie/zamowione-danie.controller.ts +++ b/monorepo/apps/backend/src/app/zamowione-danie/zamowione-danie.controller.ts @@ -1,4 +1,34 @@ -import { Controller } from '@nestjs/common'; +// 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 {} +export class ZamowioneDanieController { + constructor(private readonly zamowioneDanieService: ZamowioneDanieService) {} + + @Get() + async findAll(): Promise { + return this.zamowioneDanieService.findAll(); + } + + @Get(':id') + async findOne(@Param('id') id: string): Promise { + return this.zamowioneDanieService.findOne(+id); + } + + @Post() + async create(@Body() data: { zamowienieId: number }): Promise { + return this.zamowioneDanieService.create(data); + } + + @Put(':id') + async update(@Param('id') id: string, @Body() data: Partial): Promise { + return this.zamowioneDanieService.update(+id, data); + } + + @Delete(':id') + async delete(@Param('id') id: string): Promise { + return this.zamowioneDanieService.delete(+id); + } +} diff --git a/monorepo/apps/backend/src/app/znizka/znizka.controller.ts b/monorepo/apps/backend/src/app/znizka/znizka.controller.ts index 246c9dc8..1f92cbcb 100644 --- a/monorepo/apps/backend/src/app/znizka/znizka.controller.ts +++ b/monorepo/apps/backend/src/app/znizka/znizka.controller.ts @@ -1,4 +1,34 @@ -import { Controller } from '@nestjs/common'; +// 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 {} +export class ZnizkaController { + constructor(private readonly znizkaService: ZnizkaService) {} + + @Get() + async findAll(): Promise { + return this.znizkaService.findAll(); + } + + @Get(':id') + async findOne(@Param('id') id: string): Promise { + return this.znizkaService.findOne(+id); + } + + @Post() + async create(@Body() data: { kod: string; wartosc: number; czy_dostepna: boolean; restauracjaId: number }): Promise { + return this.znizkaService.create(data); + } + + @Put(':id') + async update(@Param('id') id: string, @Body() data: Partial): Promise { + return this.znizkaService.update(+id, data); + } + + @Delete(':id') + async delete(@Param('id') id: string): Promise { + return this.znizkaService.delete(+id); + } +} diff --git a/monorepo/apps/frontend/src/app/app.component.html b/monorepo/apps/frontend/src/app/app.component.html index 0f4018b6..0680b43f 100644 --- a/monorepo/apps/frontend/src/app/app.component.html +++ b/monorepo/apps/frontend/src/app/app.component.html @@ -1 +1 @@ - + diff --git a/monorepo/apps/frontend/src/app/app.component.ts b/monorepo/apps/frontend/src/app/app.component.ts index 47191699..be5077ad 100644 --- a/monorepo/apps/frontend/src/app/app.component.ts +++ b/monorepo/apps/frontend/src/app/app.component.ts @@ -1,10 +1,9 @@ import { Component } from '@angular/core'; import { RouterModule } from '@angular/router'; -import { NxWelcomeComponent } from './nx-welcome.component'; @Component({ standalone: true, - imports: [NxWelcomeComponent, RouterModule], + imports: [RouterModule], selector: 'app-root', templateUrl: './app.component.html', styleUrl: './app.component.scss', diff --git a/monorepo/apps/frontend/src/app/nx-welcome.component.ts b/monorepo/apps/frontend/src/app/nx-welcome.component.ts deleted file mode 100644 index 08a58b07..00000000 --- a/monorepo/apps/frontend/src/app/nx-welcome.component.ts +++ /dev/null @@ -1,907 +0,0 @@ -import { Component, ViewEncapsulation } from '@angular/core'; -import { CommonModule } from '@angular/common'; - -@Component({ - selector: 'app-nx-welcome', - standalone: true, - imports: [CommonModule], - template: ` - - -
-
- -
-

- Hello there, - Welcome frontend 👋 -

-
- -
-
-

- - - - You're up and running -

- What's next? -
-
- - - -
-
- - - -
-

Next steps

-

Here are some things you can do with Nx:

-
- - - - - Add UI library - -
# Generate UI lib
-nx g @nx/angular:lib ui
-# Add a component
-nx g @nx/angular:component ui/src/lib/button
-
-
- - - - - View project details - -
nx show project frontend --web
-
-
- - - - - View interactive project graph - -
nx graph
-
-
- - - - - Run affected commands - -
# see what's been affected by changes
-nx affected:graph
-# run tests for current changes
-nx affected:test
-# run e2e tests for current changes
-nx affected:e2e
-
-
-

- Carefully crafted with - - - -

-
-
- `, - styles: [], - encapsulation: ViewEncapsulation.None, -}) -export class NxWelcomeComponent {}