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 { BusinessInterceptor } from "../../core/interceptors/business.interceptor";
|
||||||
import { SuperAdminRoute } from "../../common/decorators/super-admin.decorator";
|
import { SuperAdminRoute } from "../../common/decorators/super-admin.decorator";
|
||||||
import { FindBusinessesDto } from "./DTO/find-businesses.dto";
|
import { FindBusinessesDto } from "./DTO/find-businesses.dto";
|
||||||
|
import { BusinessAciveStatusDto } from "./DTO/business-active-status.dto";
|
||||||
|
|
||||||
@Controller("business")
|
@Controller("business")
|
||||||
export class BusinessesController {
|
export class BusinessesController {
|
||||||
@@ -61,6 +62,8 @@ export class BusinessesController {
|
|||||||
return this.businessesService.purchaseQuota(businessId, purchaseDto);
|
return this.businessesService.purchaseQuota(businessId, purchaseDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------- Super Admin Routes ----------------------
|
||||||
|
|
||||||
@Get("list")
|
@Get("list")
|
||||||
@AuthGuards()
|
@AuthGuards()
|
||||||
@SuperAdminRoute()
|
@SuperAdminRoute()
|
||||||
@@ -69,11 +72,11 @@ export class BusinessesController {
|
|||||||
return this.businessesService.findBusinesses(query)
|
return this.businessesService.findBusinesses(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch(":id/active/toggle")
|
@Patch(":id/active")
|
||||||
@AuthGuards()
|
@AuthGuards()
|
||||||
@SuperAdminRoute()
|
@SuperAdminRoute()
|
||||||
@ApiOperation({ summary: "Active/Deactive a businesse" })
|
@ApiOperation({ summary: "Activate/Deactivate businesse" })
|
||||||
toggleActiveness(@Param('id') id: string) {
|
updateActiveStatus(@Param('id') id: string, @Body() dto: BusinessAciveStatusDto) {
|
||||||
return this.businessesService.businessToggleActive(id)
|
return this.businessesService.updateBusinesStatus(id, dto.isActive)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,10 +171,10 @@ export class BusinessesService {
|
|||||||
|
|
||||||
//********************************************* */
|
//********************************************* */
|
||||||
|
|
||||||
async businessToggleActive(businessId: string) {
|
async updateBusinesStatus(businessId: string, isActive: boolean) {
|
||||||
const business = await this.getBusinessById(businessId)
|
const business = await this.getBusinessById(businessId)
|
||||||
|
|
||||||
business.isActive=!business.isActive
|
business.isActive = isActive
|
||||||
|
|
||||||
await this.em.flush()
|
await this.em.flush()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user