chore: add new route to get user of support plan
This commit is contained in:
+1
-2
@@ -65,7 +65,6 @@
|
||||
"nodemailer": "^6.10.1",
|
||||
"passport-jwt": "^4.0.1",
|
||||
"pg": "^8.14.1",
|
||||
"prom-client": "^15.1.3",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.2",
|
||||
"slugify": "^1.6.6",
|
||||
@@ -73,12 +72,12 @@
|
||||
"typeorm": "^0.3.22"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@commitlint/cli": "^19.8.0",
|
||||
"@commitlint/config-conventional": "^19.8.0",
|
||||
"@nestjs/cli": "^11.0.6",
|
||||
"@nestjs/schematics": "^11.0.5",
|
||||
"@nestjs/testing": "^11.0.20",
|
||||
"@types/bcrypt": "^5.0.2",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/node": "^20.17.30",
|
||||
"@types/nodemailer": "^6.4.17",
|
||||
|
||||
Generated
-3
@@ -113,9 +113,6 @@ importers:
|
||||
pg:
|
||||
specifier: ^8.14.1
|
||||
version: 8.14.1
|
||||
prom-client:
|
||||
specifier: ^15.1.3
|
||||
version: 15.1.3
|
||||
reflect-metadata:
|
||||
specifier: ^0.2.2
|
||||
version: 0.2.2
|
||||
|
||||
@@ -40,7 +40,6 @@ import { TicketsModule } from "./modules/tickets/tickets.module";
|
||||
import { UploaderModule } from "./modules/uploader/uploader.module";
|
||||
import { UsersModule } from "./modules/users/users.module";
|
||||
import { WalletsModule } from "./modules/wallets/wallets.module";
|
||||
import { MonitoringModule } from "./monitoring/monitoring.module";
|
||||
@Module({
|
||||
imports: [
|
||||
// TelegrafModule.forRootAsync(telegrafConfig()),
|
||||
@@ -60,7 +59,6 @@ import { MonitoringModule } from "./monitoring/monitoring.module";
|
||||
parts: 10,
|
||||
},
|
||||
}),
|
||||
MonitoringModule,
|
||||
AuthModule,
|
||||
UsersModule,
|
||||
TicketsModule,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { ApiPropertyOptional } from "@nestjs/swagger";
|
||||
import { IsString } from "class-validator";
|
||||
import { IsOptional } from "class-validator";
|
||||
|
||||
import { PaginationDto } from "../../../common/DTO/pagination.dto";
|
||||
import { CommonMessage } from "../../../common/enums/message.enum";
|
||||
|
||||
export class SearchSupportPlanUsersQueryDto extends PaginationDto {
|
||||
@IsOptional()
|
||||
@IsString({ message: CommonMessage.SEARCH_QUERY_STRING })
|
||||
@ApiPropertyOptional({ description: "Search query", example: "search query" })
|
||||
q?: string;
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import { InvoicesService } from "../../invoices/providers/invoices.service";
|
||||
import { UsersService } from "../../users/providers/users.service";
|
||||
import { CreateSupportPlanDto } from "../DTO/create-support-plan.dto";
|
||||
import { GetSupportPlanListQueryDto } from "../DTO/get-support-plan-list-query.dto";
|
||||
import { SearchSupportPlanUsersQueryDto } from "../DTO/search-support-plan-users-query.dto";
|
||||
import { UpdateSupportPlanDto } from "../DTO/update-support-plan-feature.dto";
|
||||
import { UserSupportPlanStatus } from "../enums/user-support-plan-status.enum";
|
||||
import { SupportPlanFeatureRepository } from "../repositories/support-plan-feature.repository";
|
||||
@@ -181,12 +182,9 @@ export class SupportPlansService {
|
||||
}
|
||||
|
||||
//***************************************** */
|
||||
async getUsersOfSupportPlan(supportPlanId: string) {
|
||||
const users = await this.userSupportPlanRepo.find({
|
||||
where: { supportPlan: { id: supportPlanId }, status: UserSupportPlanStatus.ACTIVE },
|
||||
relations: { user: true, supportPlan: true },
|
||||
});
|
||||
return users;
|
||||
async getSupportPlanUsers(supportPlanId: string, queryDto: SearchSupportPlanUsersQueryDto) {
|
||||
const [users, count] = await this.userSupportPlanRepo.getSupportPlanUsers(supportPlanId, queryDto);
|
||||
return { users, count, paginate: true };
|
||||
}
|
||||
//***************************************** */
|
||||
async upgradeSupportPlan(newPlanId: string, userId: string) {
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Injectable } from "@nestjs/common";
|
||||
import { InjectRepository } from "@nestjs/typeorm";
|
||||
import { Repository } from "typeorm";
|
||||
|
||||
import { PaginationUtils } from "../../utils/providers/pagination.utils";
|
||||
import { SearchSupportPlanUsersQueryDto } from "../DTO/search-support-plan-users-query.dto";
|
||||
import { UserSupportPlan } from "../entities/user-support-plan.entity";
|
||||
import { UserSupportPlanStatus } from "../enums/user-support-plan-status.enum";
|
||||
@Injectable()
|
||||
@@ -16,4 +18,15 @@ export class UserSupportPlanRepository extends Repository<UserSupportPlan> {
|
||||
});
|
||||
return userSupportPlan;
|
||||
}
|
||||
|
||||
async getSupportPlanUsers(supportPlanId: string, queryDto: SearchSupportPlanUsersQueryDto) {
|
||||
const { limit, skip } = PaginationUtils(queryDto);
|
||||
|
||||
return this.findAndCount({
|
||||
where: { supportPlan: { id: supportPlanId }, status: UserSupportPlanStatus.ACTIVE },
|
||||
relations: { user: true, supportPlan: true },
|
||||
take: limit,
|
||||
skip,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ApiOperation } from "@nestjs/swagger";
|
||||
|
||||
import { CreateSupportPlanDto } from "./DTO/create-support-plan.dto";
|
||||
import { GetSupportPlanListQueryDto } from "./DTO/get-support-plan-list-query.dto";
|
||||
import { SearchSupportPlanUsersQueryDto } from "./DTO/search-support-plan-users-query.dto";
|
||||
import { UpdateSupportPlanDto } from "./DTO/update-support-plan-feature.dto";
|
||||
import { SupportPlansService } from "./providers/support-plans.service";
|
||||
import { AdminRoute } from "../../common/decorators/admin.decorator";
|
||||
@@ -69,6 +70,14 @@ export class SupportPlansController {
|
||||
return this.supportPlansService.subscribeToSupportPlan(paramDto.id, userId);
|
||||
}
|
||||
|
||||
@AdminRoute()
|
||||
@PermissionsDec(PermissionEnum.SUPPORT_PLAN)
|
||||
@ApiOperation({ summary: "Get support plan users (admin)" })
|
||||
@Get(":id/users")
|
||||
getSupportPlanUsers(@Param() paramDto: ParamDto, @Query() queryDto: SearchSupportPlanUsersQueryDto) {
|
||||
return this.supportPlansService.getSupportPlanUsers(paramDto.id, queryDto);
|
||||
}
|
||||
|
||||
@ApiOperation({ summary: "Get user support plan of user" })
|
||||
@Get("user")
|
||||
getUserSupportPlanOfUser(@UserDec("id") userId: string) {
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { PrometheusModule } from "@willsoto/nestjs-prometheus";
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
PrometheusModule.register({
|
||||
defaultMetrics: {
|
||||
enabled: true,
|
||||
},
|
||||
defaultLabels: {
|
||||
application: "danak_dsc_api",
|
||||
},
|
||||
}),
|
||||
],
|
||||
})
|
||||
export class MonitoringModule {}
|
||||
Reference in New Issue
Block a user