diff --git a/src/modules/admin/controllers/brand.controller.ts b/src/modules/admin/controllers/brand.controller.ts index 91fc884..8e2ed11 100644 --- a/src/modules/admin/controllers/brand.controller.ts +++ b/src/modules/admin/controllers/brand.controller.ts @@ -93,7 +93,7 @@ export class AdminBrandController extends BaseController { @ApiAuth() @httpGet("/:id", Guard.authAdmin()) public async getBrand(@requestParam("id") id: string) { - const data = await this.brandService.getBrandDetail(+id); + const data = await this.brandService.getBrandDetail(id); return this.response({ data }); } } diff --git a/src/modules/admin/controllers/warranty.controller.ts b/src/modules/admin/controllers/warranty.controller.ts index f33e7e4..fea2d84 100644 --- a/src/modules/admin/controllers/warranty.controller.ts +++ b/src/modules/admin/controllers/warranty.controller.ts @@ -66,7 +66,7 @@ export class AdminWarrantyController extends BaseController { @ApiAuth() @httpDelete("/:id", Guard.authAdmin()) public async getWarranty(@requestParam("id") id: string) { - const data = await this.warrantyService.getWarranty(+id); + const data = await this.warrantyService.getWarranty(id); return this.response(data); } } diff --git a/src/modules/brand/brand.service.ts b/src/modules/brand/brand.service.ts index fa8bc0a..ecfa5a6 100644 --- a/src/modules/brand/brand.service.ts +++ b/src/modules/brand/brand.service.ts @@ -118,9 +118,9 @@ class BrandService { return await this.brandRepo.getPendingBrandsCount(); } - async getBrandDetail(id: number) { - const brand = await this.brandRepo.model.findOne({ _id: id }); - if (brand) throw new BadRequestError(BrandMessage.Exist); + async getBrandDetail(id: string) { + const brand = await this.brandRepo.model.findOne({ _id: id, deleted: false }).populate("category"); + if (!brand) throw new BadRequestError(BrandMessage.NotFound); return { brand, diff --git a/src/modules/warranty/warranty.service.ts b/src/modules/warranty/warranty.service.ts index 84e5349..08270ac 100644 --- a/src/modules/warranty/warranty.service.ts +++ b/src/modules/warranty/warranty.service.ts @@ -62,8 +62,8 @@ class WarrantyService { return await this.warrantyRepo.pendingWarranties(); } - async getWarranty(id: number) { - const warranty = await this.warrantyRepo.model.findById(id); + async getWarranty(id: string) { + const warranty = await this.warrantyRepo.model.findOne({ _id: id, deleted: false }); if (!warranty) throw new BadRequestError(CommonMessage.NotValidId); return {