이벤트 개발완료

This commit is contained in:
2025-10-23 22:04:03 +09:00
parent ce1aee67d6
commit cd0e139b5e
48 changed files with 7855 additions and 3459 deletions
+36 -14
View File
@@ -23,11 +23,39 @@ class EventCsvParser {
};
}
final headers = _parseCsvLine(lines.first)
.map((e) => e.trim().toLowerCase())
final headersRaw = _parseCsvLine(lines.first);
final headers = headersRaw
.map((e) => e.trim())
.toList();
if (!headers.contains('title') || !headers.contains('startdate')) {
// 한글 헤더를 영문 키로 정규화하기 위한 매핑
String _normalizeHeader(String raw) {
final v = raw.trim().toLowerCase();
// 공백 제거 버전도 별도로 준비
final vn = v.replaceAll(' ', '');
// 한국어 -> 영문 매핑
if (v == '제목') return 'title';
if (v == '시작일') return 'startDate';
if (v == '종료일') return 'endDate';
if (v == '설명') return 'description';
if (v == '장소') return 'location';
if (v == '상태') return 'status';
if (v == '유형') return 'type';
if (v == '게임 수' || vn == '게임수') return 'gameCount';
if (v == '참가비') return 'participantFee';
if (v == '신청마감' || v == '신청 마감') return 'registrationDeadline';
if (v == '최대 참가자' || vn == '최대참가자') return 'maxParticipants';
// 기존 영문 키들 정규화
if (vn == 'maxparticipants') return 'maxParticipants';
if (vn == 'startdate') return 'startDate';
if (vn == 'enddate') return 'endDate';
return raw.trim();
}
final normalizedHeaders = headers.map(_normalizeHeader).toList();
if (!normalizedHeaders.contains('title') || !normalizedHeaders.contains('startDate')) {
return {
'processedRows': 0,
'validEvents': <Map<String, dynamic>>[],
@@ -52,26 +80,20 @@ class EventCsvParser {
processedRows++;
final event = <String, dynamic>{};
for (var j = 0; j < headers.length && j < row.length; j++) {
final header = headers[j];
for (var j = 0; j < normalizedHeaders.length && j < row.length; j++) {
final header = normalizedHeaders[j];
var value = row[j].trim();
// 헤더 정규화
var normalizedHeader = header;
if (header == 'maxparticipants') normalizedHeader = 'maxParticipants';
if (header == 'startdate') normalizedHeader = 'startDate';
if (header == 'enddate') normalizedHeader = 'endDate';
if (normalizedHeader == 'startDate' || normalizedHeader == 'endDate') {
if (header == 'startDate' || header == 'endDate') {
// 날짜 문자열은 그대로 전달하고, 화면/서버 측에서 ISO 변환/검증 처리
// 비어있으면 startDate는 필수, endDate는 null
if (normalizedHeader == 'startDate') {
if (header == 'startDate') {
event['startDate'] = value.isEmpty ? DateTime.now().toIso8601String() : value;
} else {
event['endDate'] = value.isEmpty ? null : value;
}
} else {
event[normalizedHeader] = value.isEmpty ? null : value;
event[header] = value.isEmpty ? null : value;
}
}