add : super admin routes to get list and active/deactivate
Build and Deploy Docker Images / build_and_deploy (push) Has been cancelled

This commit is contained in:
2026-03-17 23:48:52 +03:30
parent f1d25b895a
commit 0c095b681c
3 changed files with 20 additions and 7 deletions
@@ -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()