Skip to content

Commit

Permalink
Merge pull request #436 from Alt-Org/feature/box-module-skeleton-431
Browse files Browse the repository at this point in the history
Add skeleton of box module
  • Loading branch information
MikhailDeriabin authored Feb 11, 2025
2 parents 307f1b0 + 967fc7b commit a7e9efe
Show file tree
Hide file tree
Showing 13 changed files with 560 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { FleaMarketModule } from './fleaMarket/fleaMarket.module';
import { VotingModule } from './voting/voting.module';
import { BullModule } from '@nestjs/bullmq';
import { DailyTasksModule } from './dailyTasks/dailyTasks.module';
import {BoxModule} from "./box/box.module";

// Set up database connection
const mongoUser = envVars.MONGO_USERNAME;
Expand Down Expand Up @@ -74,15 +75,17 @@ const redisPort = parseInt(envVars.REDIS_PORT);
VotingModule,

ClanInventoryModule,

ProfileModule,
SiteModule,

AuthModule,
AuthorizationModule,
GameAnalyticsModule,

RequestHelperModule
RequestHelperModule,

BoxModule
],
controllers: [AppController],
providers: [
Expand All @@ -91,4 +94,4 @@ const redisPort = parseInt(envVars.REDIS_PORT);
],
})
export class AppModule {
}
}
12 changes: 12 additions & 0 deletions src/box/box.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Body, Controller, Get, Param, Post, Put } from "@nestjs/common";
import {BoxService} from "./box.service";

@Controller('box')
export class BoxController {
public constructor(
private readonly service: BoxService,
) {
}


}
26 changes: 26 additions & 0 deletions src/box/box.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {Module} from '@nestjs/common';
import { MongooseModule } from '@nestjs/mongoose';
import {ModelName} from "../common/enum/modelName.enum";
import {BoxSchema} from "./schemas/box.schema";
import {GroupAdminSchema} from "./schemas/groupAdmin.schema";
import {BoxController} from "./box.controller";
import {BoxService} from "./box.service";

@Module({
imports: [
MongooseModule.forFeature([
{ name: ModelName.BOX, schema: BoxSchema },
{ name: ModelName.GROUP_ADMIN, schema: GroupAdminSchema }
])
],
controllers: [
BoxController
],
providers: [
BoxService
],
exports: [
BoxService
]
})
export class BoxModule {}
20 changes: 20 additions & 0 deletions src/box/box.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Injectable } from "@nestjs/common";
import { InjectModel } from "@nestjs/mongoose";
import { Model } from "mongoose";
import {Box, publicReferences} from "./schemas/box.schema";
import BasicService from "../common/service/basicService/BasicService";
import {BoxReference} from "./enum/BoxReference.enum";

@Injectable()
export class BoxService {
public constructor(
@InjectModel(Box.name) public readonly model: Model<Box>,
){
this.refsInModel = publicReferences;
this.basicService = new BasicService(model);
}

public readonly refsInModel: BoxReference[];
private readonly basicService: BasicService;

}
61 changes: 61 additions & 0 deletions src/box/dto/box.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import {Expose, Type} from "class-transformer";
import {ExtractField} from "../../common/decorator/response/ExtractField";
import {SessionStage} from "../enum/SessionStage.enum";
import {ObjectId} from "mongoose";
import {Tester} from "../schemas/tester.schema";
import {DailyTask} from "../../dailyTasks/dailyTasks.schema";

export class BoxDto {
@ExtractField()
@Expose()
_id:string;

@Expose()
adminPassword: string;

@Expose()
sessionStage: SessionStage;

@Expose()
testersSharedPassword: string | null;

@Expose()
boxRemovalTime: number;

@Expose()
sessionResetTime: number;


@Expose()
adminProfile_id: ObjectId;

@Expose()
adminPlayer_id: ObjectId;

@Expose()
clan_ids: ObjectId[];

@Expose()
soulHome_ids: ObjectId[];

@Expose()
room_ids: ObjectId[];

@Expose()
stock_ids: ObjectId[];


@Expose()
chat_id: ObjectId;

@Expose()
@Type(() => Tester)
testers: Tester[];

@Expose()
accountClaimersIds: string[];

@Expose()
@Type(() => DailyTask)
dailyTasks: DailyTask[];
}
77 changes: 77 additions & 0 deletions src/box/dto/createBox.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import {
IsArray,
IsEnum,
IsMongoId,
IsNumber, IsOptional,
IsString,
ValidateNested
} from "class-validator";
import {SessionStage} from "../enum/SessionStage.enum";
import { ObjectId } from "mongoose";
import { Tester } from "../schemas/tester.schema";
import {Type} from "class-transformer";
import {DailyTask} from "../../dailyTasks/dailyTasks.schema";


export class CreateBoxDto {
@IsString()
adminPassword: string;

@IsOptional()
@IsEnum(SessionStage)
sessionStage?: SessionStage;

@IsOptional()
@IsString()
testersSharedPassword?: string | null;

@IsNumber()
boxRemovalTime: number;

@IsNumber()
sessionResetTime: number;


@IsMongoId()
adminProfile_id: ObjectId;

@IsMongoId()
adminPlayer_id: ObjectId;

@IsArray()
@IsMongoId({ each: true })
clan_ids: ObjectId[];

@IsArray()
@IsMongoId({ each: true })
soulHome_ids: ObjectId[];

@IsArray()
@IsMongoId({ each: true })
room_ids: ObjectId[];

@IsArray()
@IsMongoId({ each: true })
stock_ids: ObjectId[];


@IsMongoId()
chat_id: ObjectId;

@IsOptional()
@IsArray()
@ValidateNested()
@Type(() => Tester)
testers?: Tester[];

@IsOptional()
@IsArray()
@IsString({ each: true })
accountClaimersIds?: string[];

@IsOptional()
@IsArray()
@ValidateNested()
@Type(() => DailyTask)
dailyTasks?: DailyTask[];
}
80 changes: 80 additions & 0 deletions src/box/dto/updateBox.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import {IsArray, IsEnum, IsMongoId, IsNumber, IsOptional, IsString, ValidateNested} from "class-validator";
import {SessionStage} from "../enum/SessionStage.enum";
import {ObjectId} from "mongoose";
import {Type} from "class-transformer";
import {Tester} from "../schemas/tester.schema";
import {DailyTask} from "../../dailyTasks/dailyTasks.schema";

export class UpdateBoxDto {
@IsMongoId()
_id: string;

@IsOptional()
@IsString()
adminPassword?: string;

@IsOptional()
@IsEnum(SessionStage)
sessionStage?: SessionStage;

@IsOptional()
@IsString()
testersSharedPassword?: string | null;

@IsOptional()
@IsNumber()
boxRemovalTime?: number;

@IsOptional()
@IsNumber()
sessionResetTime?: number;

@IsOptional()
@IsMongoId()
adminProfile_id?: ObjectId;

@IsOptional()
@IsMongoId()
adminPlayer_id?: ObjectId;

@IsOptional()
@IsArray()
@IsMongoId({ each: true })
clan_ids?: ObjectId[];

@IsOptional()
@IsArray()
@IsMongoId({ each: true })
soulHome_ids?: ObjectId[];

@IsOptional()
@IsArray()
@IsMongoId({ each: true })
room_ids?: ObjectId[];

@IsOptional()
@IsArray()
@IsMongoId({ each: true })
stock_ids?: ObjectId[];

@IsOptional()
@IsMongoId()
chat_id?: ObjectId;

@IsOptional()
@IsArray()
@ValidateNested()
@Type(() => Tester)
testers?: Tester[];

@IsOptional()
@IsArray()
@IsString({ each: true })
accountClaimersIds?: string[];

@IsOptional()
@IsArray()
@ValidateNested()
@Type(() => DailyTask)
dailyTasks?: DailyTask[];
}
16 changes: 16 additions & 0 deletions src/box/enum/BoxReference.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* All the references of the box collection
*/
export enum BoxReference {
ADMIN_PROFILE = 'AdminProfile',
ADMIN_PLAYER = 'AdminPlayer',
GROUP_ADMIN = 'GroupAdmin',
CLANS = 'Clans',
SOUL_HOMES = 'SoulHomes',
ROOMS = 'Rooms',
STOCKS = 'Stocks',
CHAT = 'CHAT',
TESTER_PROFILES = 'TesterProfiles',
TESTER_PLAYERS = 'TesterPlayers',
DAILY_TASKS = 'DailyTasks'
}
17 changes: 17 additions & 0 deletions src/box/enum/SessionStage.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Stage of testing session
*/
export enum SessionStage {
/**
* Stage 2. Preparing for testing
*/
PREPARING = 'Preparing',
/**
* Stage 3: Testing session is started
*/
TESTING = 'Testing',
/**
* Stage 4: Testing session is ended
*/
END = 'End'
}
Loading

0 comments on commit a7e9efe

Please sign in to comment.