-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #436 from Alt-Org/feature/box-module-skeleton-431
Add skeleton of box module
- Loading branch information
Showing
13 changed files
with
560 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) { | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} |
Oops, something went wrong.