add : super admin routes to get list and active/deactivate
Build and Deploy Docker Images / build_and_deploy (push) Has been cancelled
Build and Deploy Docker Images / build_and_deploy (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { ApiProperty } from "@nestjs/swagger";
|
||||
import { IsBoolean, IsNotEmpty } from "class-validator";
|
||||
|
||||
|
||||
export class BusinessAciveStatusDto {
|
||||
@IsNotEmpty()
|
||||
@IsBoolean()
|
||||
@ApiProperty()
|
||||
isActive: boolean;
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import { BusinessDec } from "../../common/decorators/business.decorator";
|
||||
import { BusinessInterceptor } from "../../core/interceptors/business.interceptor";
|
||||
import { SuperAdminRoute } from "../../common/decorators/super-admin.decorator";
|
||||
import { FindBusinessesDto } from "./DTO/find-businesses.dto";
|
||||
import { BusinessAciveStatusDto } from "./DTO/business-active-status.dto";
|
||||
|
||||
@Controller("business")
|
||||
export class BusinessesController {
|
||||
@@ -61,6 +62,8 @@ export class BusinessesController {
|
||||
return this.businessesService.purchaseQuota(businessId, purchaseDto);
|
||||
}
|
||||
|
||||
//-------------------- Super Admin Routes ----------------------
|
||||
|
||||
@Get("list")
|
||||
@AuthGuards()
|
||||
@SuperAdminRoute()
|
||||
@@ -69,11 +72,11 @@ export class BusinessesController {
|
||||
return this.businessesService.findBusinesses(query)
|
||||
}
|
||||
|
||||
@Patch(":id/active/toggle")
|
||||
@Patch(":id/active")
|
||||
@AuthGuards()
|
||||
@SuperAdminRoute()
|
||||
@ApiOperation({ summary: "Active/Deactive a businesse" })
|
||||
toggleActiveness(@Param('id') id: string) {
|
||||
return this.businessesService.businessToggleActive(id)
|
||||
@ApiOperation({ summary: "Activate/Deactivate businesse" })
|
||||
updateActiveStatus(@Param('id') id: string, @Body() dto: BusinessAciveStatusDto) {
|
||||
return this.businessesService.updateBusinesStatus(id, dto.isActive)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,17 +164,17 @@ export class BusinessesService {
|
||||
return this.quotaPurchaseService.purchaseQuota(business, purchaseDto);
|
||||
}
|
||||
//********************************************* */
|
||||
|
||||
|
||||
async findBusinesses(query: FindBusinessesDto) {
|
||||
return this.businessRepository.findAllPaginated(query)
|
||||
}
|
||||
|
||||
//********************************************* */
|
||||
|
||||
async businessToggleActive(businessId: string) {
|
||||
async updateBusinesStatus(businessId: string, isActive: boolean) {
|
||||
const business = await this.getBusinessById(businessId)
|
||||
|
||||
business.isActive=!business.isActive
|
||||
business.isActive = isActive
|
||||
|
||||
await this.em.flush()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user