fix: warranty and brand detail

This commit is contained in:
morteza-mortezai
2025-09-28 11:44:59 +03:30
parent 9155bcc762
commit 55ef63196c
4 changed files with 7 additions and 7 deletions
@@ -93,7 +93,7 @@ export class AdminBrandController extends BaseController {
@ApiAuth() @ApiAuth()
@httpGet("/:id", Guard.authAdmin()) @httpGet("/:id", Guard.authAdmin())
public async getBrand(@requestParam("id") id: string) { 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 }); return this.response({ data });
} }
} }
@@ -66,7 +66,7 @@ export class AdminWarrantyController extends BaseController {
@ApiAuth() @ApiAuth()
@httpDelete("/:id", Guard.authAdmin()) @httpDelete("/:id", Guard.authAdmin())
public async getWarranty(@requestParam("id") id: string) { 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); return this.response(data);
} }
} }
+3 -3
View File
@@ -118,9 +118,9 @@ class BrandService {
return await this.brandRepo.getPendingBrandsCount(); return await this.brandRepo.getPendingBrandsCount();
} }
async getBrandDetail(id: number) { async getBrandDetail(id: string) {
const brand = await this.brandRepo.model.findOne({ _id: id }); const brand = await this.brandRepo.model.findOne({ _id: id, deleted: false }).populate("category");
if (brand) throw new BadRequestError(BrandMessage.Exist); if (!brand) throw new BadRequestError(BrandMessage.NotFound);
return { return {
brand, brand,
+2 -2
View File
@@ -62,8 +62,8 @@ class WarrantyService {
return await this.warrantyRepo.pendingWarranties(); return await this.warrantyRepo.pendingWarranties();
} }
async getWarranty(id: number) { async getWarranty(id: string) {
const warranty = await this.warrantyRepo.model.findById(id); const warranty = await this.warrantyRepo.model.findOne({ _id: id, deleted: false });
if (!warranty) throw new BadRequestError(CommonMessage.NotValidId); if (!warranty) throw new BadRequestError(CommonMessage.NotValidId);
return { return {