feat: add get brand detail

This commit is contained in:
morteza-mortezai
2025-09-28 11:20:03 +03:30
parent 7e344fd695
commit 521533dd04
2 changed files with 20 additions and 1 deletions
@@ -1,6 +1,6 @@
import rateLimit from "express-rate-limit";
import { inject } from "inversify";
import { controller, httpDelete, httpPatch, httpPost, requestBody, requestParam } from "inversify-express-utils";
import { controller, httpDelete, httpGet, httpPatch, httpPost, requestBody, requestParam } from "inversify-express-utils";
import { HttpStatus } from "../../../common";
import { BaseController } from "../../../common/base/controller";
@@ -86,4 +86,14 @@ export class AdminBrandController extends BaseController {
const data = await this.brandService.deleteById(id);
return this.response({ data });
}
@ApiOperation("get brand detail")
@ApiResponse("successful", HttpStatus.Ok)
@ApiParam("id", "id of brand")
@ApiAuth()
@httpGet("/:id", Guard.authAdmin())
public async getBrand(@requestParam("id") id: string) {
const data = await this.brandService.getBrandDetail(+id);
return this.response({ data });
}
}
+9
View File
@@ -117,6 +117,15 @@ class BrandService {
async getPendingBrandsCount() {
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);
return {
brand,
};
}
}
export { BrandService };