add find business by slug
This commit is contained in:
@@ -16,6 +16,11 @@ import { ApiBearerAuth } from '@nestjs/swagger';
|
|||||||
export class BusinessController {
|
export class BusinessController {
|
||||||
constructor(private readonly businessService: BusinessService) { }
|
constructor(private readonly businessService: BusinessService) { }
|
||||||
|
|
||||||
|
@Get('public/business/:slug')
|
||||||
|
getBusinessBySlug(@Param('slug') slug: string) {
|
||||||
|
return this.businessService.findBySlugOrFail(slug)
|
||||||
|
}
|
||||||
|
|
||||||
@Get('super-admin/business/list')
|
@Get('super-admin/business/list')
|
||||||
@UseGuards(SuperAdminAuthGuard)
|
@UseGuards(SuperAdminAuthGuard)
|
||||||
findAll(@Query() dto: FindBusinessesDto) {
|
findAll(@Query() dto: FindBusinessesDto) {
|
||||||
|
|||||||
@@ -71,6 +71,14 @@ export class BusinessService {
|
|||||||
return business
|
return business
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findBySlugOrFail(slug: string) {
|
||||||
|
const business = await this.businessRepository.findOne({ slug })
|
||||||
|
if (!business) {
|
||||||
|
throw new NotFoundException("Business not found")
|
||||||
|
}
|
||||||
|
return business
|
||||||
|
}
|
||||||
|
|
||||||
async findByIdOrFail(businessId: string) {
|
async findByIdOrFail(businessId: string) {
|
||||||
const business = await this.businessRepository.findOne({ id: businessId }, { populate: ['admin'] })
|
const business = await this.businessRepository.findOne({ id: businessId }, { populate: ['admin'] })
|
||||||
if (!business) {
|
if (!business) {
|
||||||
|
|||||||
Reference in New Issue
Block a user