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 };