feat: add get warranty detail
This commit is contained in:
@@ -59,4 +59,14 @@ export class AdminWarrantyController extends BaseController {
|
|||||||
const data = await this.warrantyService.deleteById(+id);
|
const data = await this.warrantyService.deleteById(+id);
|
||||||
return this.response(data);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,15 @@ class WarrantyService {
|
|||||||
async getPendingWarranties() {
|
async getPendingWarranties() {
|
||||||
return await this.warrantyRepo.pendingWarranties();
|
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 };
|
export { WarrantyService };
|
||||||
|
|||||||
Reference in New Issue
Block a user