TDD 작성
This commit is contained in:
@@ -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(),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user