From 9155bcc762694abd3a09665b80c2514c60e7d088 Mon Sep 17 00:00:00 2001 From: morteza-mortezai Date: Sun, 28 Sep 2025 11:32:16 +0330 Subject: [PATCH] feat: add get warranty detail --- src/modules/admin/controllers/warranty.controller.ts | 10 ++++++++++ src/modules/warranty/warranty.service.ts | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/src/modules/admin/controllers/warranty.controller.ts b/src/modules/admin/controllers/warranty.controller.ts index 60372f0..f33e7e4 100644 --- a/src/modules/admin/controllers/warranty.controller.ts +++ b/src/modules/admin/controllers/warranty.controller.ts @@ -59,4 +59,14 @@ export class AdminWarrantyController extends BaseController { const data = await this.warrantyService.deleteById(+id); return this.response(data); } + + @ApiOperation("get warranty with its id") + @ApiResponse("successful", HttpStatus.Ok) + @ApiParam("id", "id of warranty") + @ApiAuth() + @httpDelete("/:id", Guard.authAdmin()) + public async getWarranty(@requestParam("id") id: string) { + const data = await this.warrantyService.getWarranty(+id); + return this.response(data); + } } diff --git a/src/modules/warranty/warranty.service.ts b/src/modules/warranty/warranty.service.ts index 17033a1..84e5349 100644 --- a/src/modules/warranty/warranty.service.ts +++ b/src/modules/warranty/warranty.service.ts @@ -61,6 +61,15 @@ class WarrantyService { async getPendingWarranties() { return await this.warrantyRepo.pendingWarranties(); } + + async getWarranty(id: number) { + const warranty = await this.warrantyRepo.model.findById(id); + if (!warranty) throw new BadRequestError(CommonMessage.NotValidId); + + return { + warranty, + }; + } } export { WarrantyService };