me business
This commit is contained in:
@@ -1,37 +1,53 @@
|
|||||||
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, Query } from '@nestjs/common';
|
import {
|
||||||
|
Controller, Get, Post, Body, Patch, Param,
|
||||||
|
Delete, UseGuards, Query
|
||||||
|
} from '@nestjs/common';
|
||||||
import { BusinessService } from './business.service';
|
import { BusinessService } from './business.service';
|
||||||
import { SetupBusinessDto } from './dto/setup-business.dto';
|
import { SetupBusinessDto } from './dto/setup-business.dto';
|
||||||
import { SuperAdminAuthGuard } from '../auth/guards/superAdminAuth.guard';
|
import { SuperAdminAuthGuard } from '../auth/guards/superAdminAuth.guard';
|
||||||
import { FindBusinessesDto } from './dto/find-businesses.dto';
|
import { FindBusinessesDto } from './dto/find-businesses.dto';
|
||||||
import { UpdateBusinessDto } from './dto/update-business.dto';
|
import { UpdateBusinessDto } from './dto/update-business.dto';
|
||||||
|
import { AdminAuthGuard } from '../auth/guards/adminAuth.guard';
|
||||||
|
import { BusinessId } from 'src/common/decorators';
|
||||||
|
|
||||||
@Controller('super-admin/business')
|
@Controller('super-admin/business')
|
||||||
@UseGuards(SuperAdminAuthGuard)
|
|
||||||
export class BusinessController {
|
export class BusinessController {
|
||||||
constructor(private readonly businessService: BusinessService) { }
|
constructor(private readonly businessService: BusinessService) { }
|
||||||
|
|
||||||
@Get('list')
|
@Get('list')
|
||||||
|
@UseGuards(SuperAdminAuthGuard)
|
||||||
findAll(@Query() dto: FindBusinessesDto) {
|
findAll(@Query() dto: FindBusinessesDto) {
|
||||||
return this.businessService.findAll(dto);
|
return this.businessService.findAll(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get(':id')
|
@Get(':id')
|
||||||
|
@UseGuards(SuperAdminAuthGuard)
|
||||||
findOne(@Param('id') id: string) {
|
findOne(@Param('id') id: string) {
|
||||||
return this.businessService.findByIdOrFail(id);
|
return this.businessService.findByIdOrFail(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch(':id')
|
@Patch(':id')
|
||||||
|
@UseGuards(SuperAdminAuthGuard)
|
||||||
update(@Param('id') id: string, @Body() updateBusinessDto: UpdateBusinessDto) {
|
update(@Param('id') id: string, @Body() updateBusinessDto: UpdateBusinessDto) {
|
||||||
return this.businessService.update(id, updateBusinessDto);
|
return this.businessService.update(id, updateBusinessDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('setup')
|
@Post('setup')
|
||||||
|
@UseGuards(SuperAdminAuthGuard)
|
||||||
create(@Body() dto: SetupBusinessDto) {
|
create(@Body() dto: SetupBusinessDto) {
|
||||||
return this.businessService.setupAccount(dto);
|
return this.businessService.setupAccount(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
|
@UseGuards(SuperAdminAuthGuard)
|
||||||
remove(@Param('id') id: string) {
|
remove(@Param('id') id: string) {
|
||||||
return this.businessService.hardDelete(id);
|
return this.businessService.hardDelete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get('me')
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
me(@BusinessId() businessId: string) {
|
||||||
|
return this.businessService.findByIdOrFail(businessId)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user