feat: add get warranty detail

This commit is contained in:
morteza-mortezai
2025-09-28 11:32:16 +03:30
parent 521533dd04
commit 9155bcc762
2 changed files with 19 additions and 0 deletions
@@ -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);
}
}
+9
View File
@@ -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 };