From 0fa43f7d9c92c178a1845d9c665eb45b7bcffebc Mon Sep 17 00:00:00 2001 From: sdraris Date: Tue, 9 Sep 2025 15:13:02 +0200 Subject: [PATCH] remoed base service + base controller (cause of conflitcts) --- src/common/base.controller.ts | 33 --------------------------------- src/common/base.service.ts | 28 ---------------------------- 2 files changed, 61 deletions(-) delete mode 100644 src/common/base.controller.ts delete mode 100644 src/common/base.service.ts diff --git a/src/common/base.controller.ts b/src/common/base.controller.ts deleted file mode 100644 index d1d3224..0000000 --- a/src/common/base.controller.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Body, Delete, Get, Param, Patch, Post } from "@nestjs/common"; -import { BaseService } from "./base.service"; -import type { DeepPartial, ObjectLiteral } from "typeorm"; -import type { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity.js"; - -export class BaseController { - constructor(protected readonly service: BaseService) { } - - @Get() - getAll(relations: string[] = []) { - return this.service.findAll(relations); - } - - @Get(':id') - getOne(@Param('id') id: string) { - return this.service.findOne(id); - } - - @Post() - create(@Body() data: DeepPartial) { - return this.service.create(data); - } - - @Patch(':id') - update(@Param('id') id: string, @Body() data: QueryDeepPartialEntity) { - return this.service.update(id, data); - } - - @Delete(':id') - delete(@Param('id') id: string) { - return this.service.delete(id); - } -} \ No newline at end of file diff --git a/src/common/base.service.ts b/src/common/base.service.ts deleted file mode 100644 index 90917b4..0000000 --- a/src/common/base.service.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { DeepPartial, ObjectLiteral, Repository } from "typeorm"; -import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity.js"; - -export class BaseService { - constructor(protected readonly repo: Repository) { } - - findAll(relations: string[] = []) { - return this.repo.find({ relations }); - } - - findOne(id: string, relations: string[] = []) { - return this.repo.findOne({ where: { id } as any, relations }); - } - - create(data: DeepPartial) { - const entity = this.repo.create(data); - return this.repo.save(entity); - } - - async update(id: string, data: QueryDeepPartialEntity) { - await this.repo.update(id, data); - return this.findOne(id); - } - - delete(id: string) { - return this.repo.delete(id); - } -} \ No newline at end of file