feat(api): add auction service
This commit is contained in:
1 parent
b4be06ae83
commit
b12f44424e
5 files changed
+1877
No files matched your search
@@ -0,0 +1,93 @@
|
||||
import { Type } from 'class-transformer';
|
||||
import {
|
||||
ArrayMaxSize,
|
||||
ArrayMinSize,
|
||||
IsArray,
|
||||
IsEnum,
|
||||
IsInt,
|
||||
IsMongoId,
|
||||
IsOptional,
|
||||
Max,
|
||||
Min,
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { AUCTION_TOP_TIER_THRESHOLDS } from '../../global/database/schema';
|
||||
|
||||
export type AuctionTopTierThreshold =
|
||||
(typeof AUCTION_TOP_TIER_THRESHOLDS)[number];
|
||||
|
||||
class CaptainAssignmentDto {
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
teamIndex!: number;
|
||||
|
||||
@IsMongoId()
|
||||
userId!: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(100)
|
||||
@Max(100000)
|
||||
initialPoints?: number;
|
||||
}
|
||||
|
||||
export class StartAuctionDto {
|
||||
@IsArray()
|
||||
@ArrayMinSize(2)
|
||||
@ArrayMaxSize(16)
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => CaptainAssignmentDto)
|
||||
captains!: CaptainAssignmentDto[];
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(100)
|
||||
@Max(100000)
|
||||
initialPoints?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsEnum(AUCTION_TOP_TIER_THRESHOLDS)
|
||||
topTierThreshold?: AuctionTopTierThreshold;
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ArrayMaxSize(100)
|
||||
@IsMongoId({ each: true })
|
||||
manualTopTierUserIds?: string[];
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(5)
|
||||
maxTimerSeconds?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
@Min(0)
|
||||
bidExtensionSeconds?: number;
|
||||
}
|
||||
|
||||
export class PlaceBidDto {
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
teamIndex!: number;
|
||||
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
amount!: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsMongoId()
|
||||
bidderUserId?: string;
|
||||
}
|
||||
|
||||
export class SoldDto {
|
||||
@IsOptional()
|
||||
@IsEnum(['TOP', 'JGL', 'MID', 'ADC', 'SUP'])
|
||||
assignedPosition?: 'TOP' | 'JGL' | 'MID' | 'ADC' | 'SUP';
|
||||
}
|
||||
|
||||
export class UndoAuctionDto {
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
sequence!: number;
|
||||
}
|
||||
Reference in new issue
Block a user