TDD 작성

This commit is contained in:
2025-08-12 03:28:08 +09:00
parent 6033d59590
commit 107abc963f
156 changed files with 70906 additions and 642 deletions
+20
View File
@@ -1,3 +1,5 @@
import 'tie_breaker_option.dart';
class Club {
final String id;
final String name;
@@ -14,6 +16,9 @@ class Club {
final String? averageCalculationPeriod;
final DateTime? createdAt;
final DateTime? updatedAt;
/// 동점자 처리 옵션 우선순위 목록
final List<TieBreakerOption>? tieBreakerOptions;
Club({
this.id = '', // 기본값 빈 문자열로 설정
@@ -31,10 +36,23 @@ class Club {
this.averageCalculationPeriod,
this.createdAt,
this.updatedAt,
this.tieBreakerOptions,
});
// JSON 데이터로부터 Club 객체 생성
factory Club.fromJson(Map<String, dynamic> json) {
// 동점자 처리 옵션 변환
List<TieBreakerOption>? tieBreakerOptions;
if (json['tieBreakerOptions'] != null) {
try {
tieBreakerOptions = (json['tieBreakerOptions'] as List)
.map((option) => TieBreakerOption.fromString(option.toString()))
.toList();
} catch (e) {
tieBreakerOptions = [];
}
}
return Club(
id: json['id'] != null ? json['id'].toString() : '',
name: json['name'] ?? '',
@@ -51,6 +69,7 @@ class Club {
averageCalculationPeriod: json['averageCalculationPeriod'],
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null,
updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt']) : null,
tieBreakerOptions: tieBreakerOptions,
);
}
@@ -72,6 +91,7 @@ class Club {
'averageCalculationPeriod': averageCalculationPeriod,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
'tieBreakerOptions': tieBreakerOptions?.map((option) => option.toString().split('.').last).toList(),
};
}
}
+6
View File
@@ -16,6 +16,7 @@ class Member {
final String? status;
final DateTime? createdAt;
final DateTime? updatedAt;
final DateTime? birthDate; // 생년월일 추가
Member({
required this.id,
@@ -35,6 +36,7 @@ class Member {
this.status,
this.createdAt,
this.updatedAt,
this.birthDate,
});
// JSON 데이터로부터 Member 객체 생성
@@ -57,6 +59,7 @@ class Member {
status: json['status']?.toString(),
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt'].toString()) : null,
updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt'].toString()) : null,
birthDate: json['birthDate'] != null ? DateTime.parse(json['birthDate'].toString()) : null,
);
}
@@ -80,6 +83,7 @@ class Member {
'status': status,
'createdAt': createdAt?.toIso8601String(),
'updatedAt': updatedAt?.toIso8601String(),
'birthDate': birthDate?.toIso8601String(),
};
}
@@ -102,6 +106,7 @@ class Member {
String? status,
DateTime? createdAt,
DateTime? updatedAt,
DateTime? birthDate,
}) {
return Member(
id: id ?? this.id,
@@ -121,6 +126,7 @@ class Member {
status: status ?? this.status,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
birthDate: birthDate ?? this.birthDate,
);
}
}
+1
View File
@@ -15,6 +15,7 @@ class Participant {
final String? notes;
final DateTime? createdAt;
final DateTime? updatedAt;
String? memberType; // 회원 유형 필드 추가: '정회원', '준회원', '게스트' 등
Participant({
required this.id,
+7
View File
@@ -5,6 +5,7 @@ class Score {
final String clubId;
final List<int> frames;
final int totalScore;
final int? handicap; // 핸디캡 추가
final DateTime date;
final String? notes;
final String? participantName;
@@ -16,10 +17,14 @@ class Score {
required this.clubId,
required this.frames,
required this.totalScore,
this.handicap,
required this.date,
this.notes,
this.participantName,
});
// 핸디캡 포함 총점 계산
int get totalWithHandicap => totalScore + (handicap ?? 0);
factory Score.fromJson(Map<String, dynamic> json) {
return Score(
@@ -29,6 +34,7 @@ class Score {
clubId: json['clubId']?.toString() ?? '',
frames: json['frames'] != null ? List<int>.from(json['frames']) : [],
totalScore: json['totalScore'] ?? 0,
handicap: json['handicap'],
date: json['date'] != null ? DateTime.parse(json['date'].toString()) : DateTime.now(),
notes: json['notes']?.toString(),
participantName: json['participantName']?.toString(),
@@ -43,6 +49,7 @@ class Score {
'clubId': clubId,
'frames': frames,
'totalScore': totalScore,
'handicap': handicap,
'date': date.toIso8601String(),
'notes': notes,
'participantName': participantName,
+44
View File
@@ -0,0 +1,44 @@
/// 동점자 처리 옵션 열거형
enum TieBreakerOption {
/// 핸디캡을 적게 받은 사람이 우선(마이너스 포함)
lowerHandicap,
/// 같은 이벤트 내 게임 중 하이 점수와 로우 점수의 격차가 적은 사람이 우선
lowerScoreGap,
/// 연장자 우선
olderAge,
/// 기본값: 동점자 처리 없음 (동일 순위 표시)
none;
/// 열거형 값을 문자열로 변환
String toDisplayString() {
switch (this) {
case TieBreakerOption.lowerHandicap:
return '핸디캡이 적은 사람 우선';
case TieBreakerOption.lowerScoreGap:
return '점수 격차가 적은 사람 우선';
case TieBreakerOption.olderAge:
return '연장자 우선';
case TieBreakerOption.none:
return '동점자 처리 없음';
}
}
/// 문자열에서 열거형 값으로 변환
static TieBreakerOption fromString(String? value) {
if (value == null) return TieBreakerOption.none;
switch (value) {
case 'lowerHandicap':
return TieBreakerOption.lowerHandicap;
case 'lowerScoreGap':
return TieBreakerOption.lowerScoreGap;
case 'olderAge':
return TieBreakerOption.olderAge;
default:
return TieBreakerOption.none;
}
}
}