This commit is contained in:
dahyeon committed 2026-04-24 13:40:39 -07:00
1 parent a197185ad0
commit 30dfb7ce58
27 files changed
+1584 -45

No files matched your search

+85 -15
View File
@@ -19,6 +19,14 @@ export const MATCH_STATUSES: MatchStatus[] = [
export type TeamSide = 'blue' | 'red';
export const TEAM_SIDES: TeamSide[] = ['blue', 'red'];
export type CommunityRole = 'owner' | 'admin' | 'member';
export const COMMUNITY_ROLES: CommunityRole[] = ['owner', 'admin', 'member'];
export interface PositionPreference {
position: Position;
priority: number; // 1 = 최우선, 숫자가 작을수록 높은 우선순위
}
export type AuctionPhase =
| 'waiting'
| 'presenting'
@@ -119,15 +127,24 @@ export interface RiotAccount extends MongooseTimestamps {
// ===== User =====
export interface User extends MongooseTimestamps {
communityId: mongoose.Types.ObjectId;
role: CommunityRole;
kakaoTalkId?: string;
kakaoTalkNickname?: string;
discordId?: string;
discordNickname?: string;
riotAccounts: RiotAccount[];
preferredPositions: Position[];
preferredPositions: PositionPreference[];
isActivated: boolean;
}
export interface Community extends MongooseTimestamps {
name: string;
description: string;
ownerUserId: mongoose.Types.ObjectId;
}
export type CommunityDocument = HydratedDocument<Community>;
export type UserDocument = HydratedDocument<User>;
// ===== RiotMatch (Riot 원본 매치 아카이브) =====
@@ -152,7 +169,7 @@ export interface MatchParticipant {
gameName?: string;
tagLine?: string;
profileIconId?: number;
preferredPositions: Position[];
preferredPositions: PositionPreference[];
joinedAt: Date;
}
@@ -183,9 +200,10 @@ export interface MatchScheduleItem {
}
export interface Match extends MongooseTimestamps {
communityId: mongoose.Types.ObjectId;
title: string;
description: string;
map: string;
mapId: number; // Riot Match-V5 mapId (11=소환사의 협곡, 12=ARAM 등)
status: MatchStatus;
scheduledAt: Date;
maxParticipants: number;
@@ -208,7 +226,7 @@ export interface AuctionPlayerSnapshot {
gameName: string;
tagLine: string;
profileIconId: number;
preferredPositions: Position[];
preferredPositions: PositionPreference[];
tiers: TierInfo[];
masteries: ChampionMasteryEntry[];
recentStatsSummary?: RiotRecentStatsSummary;
@@ -230,7 +248,7 @@ export interface AuctionTeam {
export interface AuctionBid {
side: TeamSide;
amount: number;
bidderUserId?: mongoose.Types.ObjectId;
bidderUserId: mongoose.Types.ObjectId;
timestamp: Date;
}
@@ -252,6 +270,14 @@ export interface Auction extends MongooseTimestamps {
export type AuctionDocument = HydratedDocument<Auction>;
// ===== Sub-schemas =====
const PositionPreferenceSubSchema = new Schema<PositionPreference>(
{
position: { type: String, enum: POSITIONS, required: true },
priority: { type: Number, required: true, min: 1 },
},
{ _id: false },
);
const TierInfoSubSchema = new Schema<TierInfo>(
{
queueType: { type: String, required: true },
@@ -346,8 +372,34 @@ const RiotAccountSubSchema = new Schema<RiotAccount>(
},
);
export const CommunitySchema = new Schema<Community>(
{
name: { type: String, required: true },
description: { type: String, required: true, default: '' },
ownerUserId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
},
{
timestamps: true,
collection: 'community',
},
);
CommunitySchema.index({ name: 1 }, { unique: true });
CommunitySchema.index({ ownerUserId: 1 });
export const UserSchema = new Schema<User>(
{
communityId: {
type: Schema.Types.ObjectId,
ref: 'community',
required: true,
},
role: {
type: String,
enum: COMMUNITY_ROLES,
required: true,
default: 'member',
},
kakaoTalkId: { type: String },
kakaoTalkNickname: { type: String },
discordId: { type: String },
@@ -376,7 +428,7 @@ export const UserSchema = new Schema<User>(
],
},
preferredPositions: {
type: [{ type: String, enum: POSITIONS }],
type: [PositionPreferenceSubSchema],
required: true,
default: [],
},
@@ -388,9 +440,20 @@ export const UserSchema = new Schema<User>(
},
);
UserSchema.index({ kakaoTalkId: 1 }, { unique: true, sparse: true });
UserSchema.index({ discordId: 1 }, { unique: true, sparse: true });
UserSchema.index({ 'riotAccounts.puuid': 1 }, { unique: true, sparse: true });
UserSchema.index({ communityId: 1 });
UserSchema.index({ communityId: 1, role: 1 });
UserSchema.index(
{ communityId: 1, kakaoTalkId: 1 },
{ unique: true, sparse: true },
);
UserSchema.index(
{ communityId: 1, discordId: 1 },
{ unique: true, sparse: true },
);
UserSchema.index(
{ communityId: 1, 'riotAccounts.puuid': 1 },
{ unique: true, sparse: true },
);
export const RiotMatchSchema = new Schema<RiotMatch>(
{
@@ -419,7 +482,7 @@ const MatchParticipantSubSchema = new Schema<MatchParticipant>(
tagLine: { type: String },
profileIconId: { type: Number },
preferredPositions: {
type: [{ type: String, enum: POSITIONS }],
type: [PositionPreferenceSubSchema],
required: true,
default: [],
},
@@ -468,9 +531,14 @@ const MatchScheduleItemSubSchema = new Schema<MatchScheduleItem>(
export const MatchSchema = new Schema<Match>(
{
communityId: {
type: Schema.Types.ObjectId,
ref: 'community',
required: true,
},
title: { type: String, required: true },
description: { type: String, required: true, default: '' },
map: { type: String, required: true, default: '소환사의 협곡' },
mapId: { type: Number, required: true, default: 11 },
status: {
type: String,
enum: MATCH_STATUSES,
@@ -508,8 +576,8 @@ export const MatchSchema = new Schema<Match>(
},
);
MatchSchema.index({ scheduledAt: -1 });
MatchSchema.index({ status: 1, scheduledAt: -1 });
MatchSchema.index({ communityId: 1, scheduledAt: -1 });
MatchSchema.index({ communityId: 1, status: 1, scheduledAt: -1 });
MatchSchema.index({ title: 'text', description: 'text' });
const AuctionPlayerSnapshotSubSchema = new Schema<AuctionPlayerSnapshot>(
@@ -520,7 +588,7 @@ const AuctionPlayerSnapshotSubSchema = new Schema<AuctionPlayerSnapshot>(
tagLine: { type: String, required: true },
profileIconId: { type: Number, required: true, default: 0 },
preferredPositions: {
type: [{ type: String, enum: POSITIONS }],
type: [PositionPreferenceSubSchema],
required: true,
default: [],
},
@@ -562,7 +630,7 @@ const AuctionBidSubSchema = new Schema<AuctionBid>(
{
side: { type: String, enum: TEAM_SIDES, required: true },
amount: { type: Number, required: true },
bidderUserId: { type: Schema.Types.ObjectId, ref: 'user' },
bidderUserId: { type: Schema.Types.ObjectId, ref: 'user', required: true },
timestamp: { type: Date, required: true, default: Date.now },
},
{ _id: false },
@@ -604,6 +672,7 @@ export const AuctionSchema = new Schema<Auction>(
);
export const tournamentModelDefinitions: ModelDefinition[] = [
{ name: 'community', schema: CommunitySchema, schemaName: 'community' },
{ name: 'user', schema: UserSchema, schemaName: 'user' },
{ name: 'riotMatch', schema: RiotMatchSchema, schemaName: 'riotMatch' },
{ name: 'match', schema: MatchSchema, schemaName: 'match' },
@@ -611,6 +680,7 @@ export const tournamentModelDefinitions: ModelDefinition[] = [
];
export interface TournamentModelTypes {
community: Community;
user: User;
riotMatch: RiotMatch;
match: Match;