feat: add get brand detail
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import rateLimit from "express-rate-limit";
|
import rateLimit from "express-rate-limit";
|
||||||
import { inject } from "inversify";
|
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 { HttpStatus } from "../../../common";
|
||||||
import { BaseController } from "../../../common/base/controller";
|
import { BaseController } from "../../../common/base/controller";
|
||||||
@@ -86,4 +86,14 @@ export class AdminBrandController extends BaseController {
|
|||||||
const data = await this.brandService.deleteById(id);
|
const data = await this.brandService.deleteById(id);
|
||||||
return this.response({ data });
|
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 });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,15 @@ class BrandService {
|
|||||||
async getPendingBrandsCount() {
|
async getPendingBrandsCount() {
|
||||||
return await this.brandRepo.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 };
|
export { BrandService };
|
||||||
|
|||||||
Reference in New Issue
Block a user