이벤트 개발완료
This commit is contained in:
@@ -53,12 +53,14 @@ class Event {
|
||||
startDate: json['startDate'] != null ? DateTime.parse(json['startDate'].toString()) : DateTime.now(),
|
||||
endDate: json['endDate'] != null ? DateTime.parse(json['endDate'].toString()) : null,
|
||||
location: json['location']?.toString(),
|
||||
type: json['type']?.toString(),
|
||||
// 서버는 eventType 키를 사용할 수 있으므로 보강
|
||||
type: (json['type'] ?? json['eventType'])?.toString(),
|
||||
status: json['status']?.toString(),
|
||||
maxParticipants: json['maxParticipants'],
|
||||
currentParticipants: json['currentParticipants'],
|
||||
gameCount: json['gameCount'],
|
||||
participantFee: json['participantFee'] != null ? double.tryParse(json['participantFee'].toString()) : null,
|
||||
// 참가비: 서버가 "0"/"0.00" 등으로 기본화할 수 있어 0은 null로 간주
|
||||
participantFee: Event._parseParticipantFeeOrNull(json['participantFee']),
|
||||
registrationDeadline: json['registrationDeadline'] != null ? DateTime.parse(json['registrationDeadline'].toString()) : null,
|
||||
publicHash: json['publicHash']?.toString(),
|
||||
accessPassword: json['accessPassword']?.toString(),
|
||||
@@ -69,6 +71,19 @@ class Event {
|
||||
);
|
||||
}
|
||||
|
||||
// 참가비 파싱 헬퍼: null/빈문자열/0/"0.00" 모두 null로 간주
|
||||
static double? _parseParticipantFeeOrNull(dynamic value) {
|
||||
if (value == null) return null;
|
||||
final s = value.toString().trim();
|
||||
if (s.isEmpty) return null;
|
||||
final d = double.tryParse(s);
|
||||
if (d == null) return null;
|
||||
// 0도 유효한 값으로 취급하여 표시되도록 그대로 반환
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Event 객체를 JSON으로 변환
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
|
||||
@@ -14,6 +14,7 @@ class Member {
|
||||
final String? memberType;
|
||||
final int? handicap;
|
||||
final String? status;
|
||||
final double? average;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
final DateTime? birthDate; // 생년월일 추가
|
||||
@@ -34,6 +35,7 @@ class Member {
|
||||
this.memberType,
|
||||
this.handicap,
|
||||
this.status,
|
||||
this.average,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.birthDate,
|
||||
@@ -57,6 +59,12 @@ class Member {
|
||||
memberType: json['memberType']?.toString(),
|
||||
handicap: json['handicap'] != null ? int.tryParse(json['handicap'].toString()) : null,
|
||||
status: json['status']?.toString(),
|
||||
average: () {
|
||||
final val = json['average'];
|
||||
if (val == null) return null;
|
||||
if (val is num) return val.toDouble();
|
||||
return double.tryParse(val.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,
|
||||
@@ -81,6 +89,7 @@ class Member {
|
||||
'memberType': memberType,
|
||||
'handicap': handicap,
|
||||
'status': status,
|
||||
'average': average,
|
||||
'createdAt': createdAt?.toIso8601String(),
|
||||
'updatedAt': updatedAt?.toIso8601String(),
|
||||
'birthDate': birthDate?.toIso8601String(),
|
||||
@@ -104,6 +113,7 @@ class Member {
|
||||
String? memberType,
|
||||
int? handicap,
|
||||
String? status,
|
||||
double? average,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
DateTime? birthDate,
|
||||
@@ -124,6 +134,7 @@ class Member {
|
||||
memberType: memberType ?? this.memberType,
|
||||
handicap: handicap ?? this.handicap,
|
||||
status: status ?? this.status,
|
||||
average: average ?? this.average,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
birthDate: birthDate ?? this.birthDate,
|
||||
|
||||
@@ -16,6 +16,9 @@ class Participant {
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
String? memberType; // 회원 유형 필드 추가: '정회원', '준회원', '게스트' 등
|
||||
final String? gender; // 성별 (서버 Member.gender에서 유추)
|
||||
final int? handicap; // 핸디캡 (서버 Member.handicap에서 유추)
|
||||
final double? average; // 백엔드에서 제공하는 동적 에버리지(옵션)
|
||||
|
||||
Participant({
|
||||
required this.id,
|
||||
@@ -34,11 +37,60 @@ class Participant {
|
||||
this.notes,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
this.gender,
|
||||
this.handicap,
|
||||
this.average,
|
||||
});
|
||||
|
||||
Participant copyWith({
|
||||
String? id,
|
||||
String? eventId,
|
||||
String? memberId,
|
||||
String? name,
|
||||
String? email,
|
||||
String? phoneNumber,
|
||||
String? status,
|
||||
DateTime? registeredAt,
|
||||
DateTime? confirmedAt,
|
||||
DateTime? cancelledAt,
|
||||
DateTime? attendedAt,
|
||||
bool? isPaid,
|
||||
double? paidAmount,
|
||||
String? notes,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
String? gender,
|
||||
int? handicap,
|
||||
double? average,
|
||||
String? memberType,
|
||||
}) {
|
||||
return Participant(
|
||||
id: id ?? this.id,
|
||||
eventId: eventId ?? this.eventId,
|
||||
memberId: memberId ?? this.memberId,
|
||||
name: name ?? this.name,
|
||||
email: email ?? this.email,
|
||||
phoneNumber: phoneNumber ?? this.phoneNumber,
|
||||
status: status ?? this.status,
|
||||
registeredAt: registeredAt ?? this.registeredAt,
|
||||
confirmedAt: confirmedAt ?? this.confirmedAt,
|
||||
cancelledAt: cancelledAt ?? this.cancelledAt,
|
||||
attendedAt: attendedAt ?? this.attendedAt,
|
||||
isPaid: isPaid ?? this.isPaid,
|
||||
paidAmount: paidAmount ?? this.paidAmount,
|
||||
notes: notes ?? this.notes,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
gender: gender ?? this.gender,
|
||||
handicap: handicap ?? this.handicap,
|
||||
average: average ?? this.average,
|
||||
// preserve mutable memberType even though not in ctor params order earlier
|
||||
)..memberType = memberType ?? this.memberType;
|
||||
}
|
||||
|
||||
// JSON 데이터로부터 Participant 객체 생성
|
||||
factory Participant.fromJson(Map<String, dynamic> json) {
|
||||
return Participant(
|
||||
final p = Participant(
|
||||
id: json['id']?.toString() ?? '',
|
||||
eventId: json['eventId']?.toString() ?? '',
|
||||
memberId: json['memberId']?.toString() ?? '',
|
||||
@@ -54,10 +106,29 @@ class Participant {
|
||||
// 서버는 paymentStatus('paid'|'unpaid')를 줄 수 있으므로 이를 isPaid로 변환
|
||||
isPaid: json['isPaid'] ?? (json['paymentStatus']?.toString().toLowerCase() == 'paid'),
|
||||
paidAmount: json['paidAmount'] != null ? double.tryParse(json['paidAmount'].toString()) : null,
|
||||
notes: json['notes']?.toString(),
|
||||
notes: (json['notes'] ?? json['comment'])?.toString(),
|
||||
createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt'].toString()) : null,
|
||||
updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt'].toString()) : null,
|
||||
gender: (json['gender'] ?? json['Member']?['gender'])?.toString(),
|
||||
handicap: () {
|
||||
final val = json['handicap'] ?? json['Member']?['handicap'];
|
||||
if (val == null) return null;
|
||||
if (val is num) return val.toInt();
|
||||
return int.tryParse(val.toString());
|
||||
}(),
|
||||
average: () {
|
||||
final val = json['average'] ?? json['Member']?['average'];
|
||||
if (val == null) return null;
|
||||
if (val is num) return val.toDouble();
|
||||
return double.tryParse(val.toString());
|
||||
}(),
|
||||
);
|
||||
// 회원 유형은 원시 enum 값을 유지하고, 표시 단계에서 매핑
|
||||
final rawType = (json['memberType'] ?? json['Member']?['memberType'])?.toString();
|
||||
if (rawType != null && rawType.isNotEmpty) {
|
||||
p.memberType = rawType;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
// Participant 객체를 JSON으로 변환
|
||||
@@ -77,8 +148,12 @@ class Participant {
|
||||
'isPaid': isPaid,
|
||||
'paidAmount': paidAmount,
|
||||
'notes': notes,
|
||||
'comment': notes,
|
||||
'createdAt': createdAt?.toIso8601String(),
|
||||
'updatedAt': updatedAt?.toIso8601String(),
|
||||
'gender': gender,
|
||||
'handicap': handicap,
|
||||
'average': average,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ class Score {
|
||||
final String memberId;
|
||||
final String eventId;
|
||||
final String clubId;
|
||||
final String? participantId; // 참가자 ID (백엔드 EventScore 필드)
|
||||
final List<int> frames;
|
||||
final int totalScore;
|
||||
final int? handicap; // 핸디캡 추가
|
||||
final int? gameNumber; // 게임 번호 (백엔드 EventScore 필드)
|
||||
final DateTime date;
|
||||
final String? notes;
|
||||
final String? participantName;
|
||||
@@ -15,9 +17,11 @@ class Score {
|
||||
required this.memberId,
|
||||
required this.eventId,
|
||||
required this.clubId,
|
||||
this.participantId,
|
||||
required this.frames,
|
||||
required this.totalScore,
|
||||
this.handicap,
|
||||
this.gameNumber,
|
||||
required this.date,
|
||||
this.notes,
|
||||
this.participantName,
|
||||
@@ -32,9 +36,19 @@ class Score {
|
||||
memberId: json['memberId']?.toString() ?? '',
|
||||
eventId: json['eventId']?.toString() ?? '',
|
||||
clubId: json['clubId']?.toString() ?? '',
|
||||
participantId: json['participantId']?.toString(),
|
||||
frames: json['frames'] != null ? List<int>.from(json['frames']) : [],
|
||||
totalScore: json['totalScore'] ?? 0,
|
||||
// 서버는 base 점수를 'score'로, 합계(핸디 포함)를 'totalScore'로 반환할 수 있음.
|
||||
// 앱 내부에서는 base 점수를 totalScore 필드에 저장하여 일관되게 사용하고,
|
||||
// 핸디 포함 합계는 getter(totalWithHandicap)로 계산한다.
|
||||
totalScore: (json['score'] ?? json['totalScore']) ?? 0,
|
||||
handicap: json['handicap'],
|
||||
gameNumber: () {
|
||||
final v = json['gameNumber'];
|
||||
if (v == null) return null;
|
||||
if (v is int) return v;
|
||||
return int.tryParse(v.toString());
|
||||
}(),
|
||||
date: json['date'] != null ? DateTime.parse(json['date'].toString()) : DateTime.now(),
|
||||
notes: json['notes']?.toString(),
|
||||
participantName: json['participantName']?.toString(),
|
||||
@@ -42,7 +56,7 @@ class Score {
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
final map = {
|
||||
'id': id,
|
||||
'memberId': memberId,
|
||||
'eventId': eventId,
|
||||
@@ -50,10 +64,15 @@ class Score {
|
||||
'frames': frames,
|
||||
'totalScore': totalScore,
|
||||
'handicap': handicap,
|
||||
'gameNumber': gameNumber,
|
||||
'date': date.toIso8601String(),
|
||||
'notes': notes,
|
||||
'participantName': participantName,
|
||||
};
|
||||
if (participantId != null) {
|
||||
map['participantId'] = participantId;
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user