diff --git a/src/modules/admin/controllers/brand.controller.ts b/src/modules/admin/controllers/brand.controller.ts index 719a73a..91fc884 100644 --- a/src/modules/admin/controllers/brand.controller.ts +++ b/src/modules/admin/controllers/brand.controller.ts @@ -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 }); + } } diff --git a/src/modules/brand/brand.service.ts b/src/modules/brand/brand.service.ts index 9b4a899..fa8bc0a 100644 --- a/src/modules/brand/brand.service.ts +++ b/src/modules/brand/brand.service.ts @@ -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 };