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",
|
"nodemailer": "^6.10.1",
|
||||||
"passport-jwt": "^4.0.1",
|
"passport-jwt": "^4.0.1",
|
||||||
"pg": "^8.14.1",
|
"pg": "^8.14.1",
|
||||||
"prom-client": "^15.1.3",
|
|
||||||
"reflect-metadata": "^0.2.2",
|
"reflect-metadata": "^0.2.2",
|
||||||
"rxjs": "^7.8.2",
|
"rxjs": "^7.8.2",
|
||||||
"slugify": "^1.6.6",
|
"slugify": "^1.6.6",
|
||||||
@@ -73,12 +72,12 @@
|
|||||||
"typeorm": "^0.3.22"
|
"typeorm": "^0.3.22"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bcrypt": "^5.0.2",
|
|
||||||
"@commitlint/cli": "^19.8.0",
|
"@commitlint/cli": "^19.8.0",
|
||||||
"@commitlint/config-conventional": "^19.8.0",
|
"@commitlint/config-conventional": "^19.8.0",
|
||||||
"@nestjs/cli": "^11.0.6",
|
"@nestjs/cli": "^11.0.6",
|
||||||
"@nestjs/schematics": "^11.0.5",
|
"@nestjs/schematics": "^11.0.5",
|
||||||
"@nestjs/testing": "^11.0.20",
|
"@nestjs/testing": "^11.0.20",
|
||||||
|
"@types/bcrypt": "^5.0.2",
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^29.5.14",
|
||||||
"@types/node": "^20.17.30",
|
"@types/node": "^20.17.30",
|
||||||
"@types/nodemailer": "^6.4.17",
|
"@types/nodemailer": "^6.4.17",
|
||||||
|
|||||||
Generated
-3
@@ -113,9 +113,6 @@ importers:
|
|||||||
pg:
|
pg:
|
||||||
specifier: ^8.14.1
|
specifier: ^8.14.1
|
||||||
version: 8.14.1
|
version: 8.14.1
|
||||||
prom-client:
|
|
||||||
specifier: ^15.1.3
|
|
||||||
version: 15.1.3
|
|
||||||
reflect-metadata:
|
reflect-metadata:
|
||||||
specifier: ^0.2.2
|
specifier: ^0.2.2
|
||||||
version: 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 { UploaderModule } from "./modules/uploader/uploader.module";
|
||||||
import { UsersModule } from "./modules/users/users.module";
|
import { UsersModule } from "./modules/users/users.module";
|
||||||
import { WalletsModule } from "./modules/wallets/wallets.module";
|
import { WalletsModule } from "./modules/wallets/wallets.module";
|
||||||
import { MonitoringModule } from "./monitoring/monitoring.module";
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
// TelegrafModule.forRootAsync(telegrafConfig()),
|
// TelegrafModule.forRootAsync(telegrafConfig()),
|
||||||
@@ -60,7 +59,6 @@ import { MonitoringModule } from "./monitoring/monitoring.module";
|
|||||||
parts: 10,
|
parts: 10,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
MonitoringModule,
|
|
||||||
AuthModule,
|
AuthModule,
|
||||||
UsersModule,
|
UsersModule,
|
||||||
TicketsModule,
|
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 { UsersService } from "../../users/providers/users.service";
|
||||||
import { CreateSupportPlanDto } from "../DTO/create-support-plan.dto";
|
import { CreateSupportPlanDto } from "../DTO/create-support-plan.dto";
|
||||||
import { GetSupportPlanListQueryDto } from "../DTO/get-support-plan-list-query.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 { UpdateSupportPlanDto } from "../DTO/update-support-plan-feature.dto";
|
||||||
import { UserSupportPlanStatus } from "../enums/user-support-plan-status.enum";
|
import { UserSupportPlanStatus } from "../enums/user-support-plan-status.enum";
|
||||||
import { SupportPlanFeatureRepository } from "../repositories/support-plan-feature.repository";
|
import { SupportPlanFeatureRepository } from "../repositories/support-plan-feature.repository";
|
||||||
@@ -181,12 +182,9 @@ export class SupportPlansService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//***************************************** */
|
//***************************************** */
|
||||||
async getUsersOfSupportPlan(supportPlanId: string) {
|
async getSupportPlanUsers(supportPlanId: string, queryDto: SearchSupportPlanUsersQueryDto) {
|
||||||
const users = await this.userSupportPlanRepo.find({
|
const [users, count] = await this.userSupportPlanRepo.getSupportPlanUsers(supportPlanId, queryDto);
|
||||||
where: { supportPlan: { id: supportPlanId }, status: UserSupportPlanStatus.ACTIVE },
|
return { users, count, paginate: true };
|
||||||
relations: { user: true, supportPlan: true },
|
|
||||||
});
|
|
||||||
return users;
|
|
||||||
}
|
}
|
||||||
//***************************************** */
|
//***************************************** */
|
||||||
async upgradeSupportPlan(newPlanId: string, userId: string) {
|
async upgradeSupportPlan(newPlanId: string, userId: string) {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ import { Injectable } from "@nestjs/common";
|
|||||||
import { InjectRepository } from "@nestjs/typeorm";
|
import { InjectRepository } from "@nestjs/typeorm";
|
||||||
import { Repository } from "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 { UserSupportPlan } from "../entities/user-support-plan.entity";
|
||||||
import { UserSupportPlanStatus } from "../enums/user-support-plan-status.enum";
|
import { UserSupportPlanStatus } from "../enums/user-support-plan-status.enum";
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@@ -16,4 +18,15 @@ export class UserSupportPlanRepository extends Repository<UserSupportPlan> {
|
|||||||
});
|
});
|
||||||
return 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 { CreateSupportPlanDto } from "./DTO/create-support-plan.dto";
|
||||||
import { GetSupportPlanListQueryDto } from "./DTO/get-support-plan-list-query.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 { UpdateSupportPlanDto } from "./DTO/update-support-plan-feature.dto";
|
||||||
import { SupportPlansService } from "./providers/support-plans.service";
|
import { SupportPlansService } from "./providers/support-plans.service";
|
||||||
import { AdminRoute } from "../../common/decorators/admin.decorator";
|
import { AdminRoute } from "../../common/decorators/admin.decorator";
|
||||||
@@ -69,6 +70,14 @@ export class SupportPlansController {
|
|||||||
return this.supportPlansService.subscribeToSupportPlan(paramDto.id, userId);
|
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" })
|
@ApiOperation({ summary: "Get user support plan of user" })
|
||||||
@Get("user")
|
@Get("user")
|
||||||
getUserSupportPlanOfUser(@UserDec("id") userId: string) {
|
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