LCOV - code coverage report

Current view: | top level - lib/models - club_model.dart |  |  | Coverage | Total | Hit
Test: | lcov.info |  | Lines: | 90.2 % | 41 | 37
Test Date: | 2025-08-12 03:21:51 |  | Functions: | - | 0 | 0

                Line data    Source code

           1              : import 'tie_breaker_option.dart';
           2              :
           3              : class Club {
           4              :   final String id;
           5              :   final String name;
           6              :   final String? description;
           7              :   final String? logo;
           8              :   final String? address;
           9              :   final String? location;
          10              :   final String? phone;
          11              :   final String? email;
          12              :   final String? website;
          13              :   final int? memberCount;
          14              :   final String? ownerId;
          15              :   final int? femaleHandicap;
          16              :   final String? averageCalculationPeriod;
          17              :   final DateTime? createdAt;
          18              :   final DateTime? updatedAt;
          19              :
          20              :   /// 동점자 처리 옵션 우선순위 목록
          21              :   final List<TieBreakerOption>? tieBreakerOptions;
          22              :
          23            3 :   Club({
          24              :     this.id = '',  // 기본값 빈 문자열로 설정
          25              :     required this.name,
          26              :     this.description,
          27              :     this.logo,
          28              :     this.address,
          29              :     this.location,
          30              :     this.phone,
          31              :     this.email,
          32              :     this.website,
          33              :     this.memberCount,
          34              :     this.ownerId,
          35              :     this.femaleHandicap,
          36              :     this.averageCalculationPeriod,
          37              :     this.createdAt,
          38              :     this.updatedAt,
          39              :     this.tieBreakerOptions,
          40              :   });
          41              :
          42              :   // JSON 데이터로부터 Club 객체 생성
          43            3 :   factory Club.fromJson(Map<String, dynamic> json) {
          44              :     // 동점자 처리 옵션 변환
          45              :     List<TieBreakerOption>? tieBreakerOptions;
          46            3 :     if (json['tieBreakerOptions'] != null) {
          47              :       try {
          48            0 :         tieBreakerOptions = (json['tieBreakerOptions'] as List)
          49            0 :             .map((option) => TieBreakerOption.fromString(option.toString()))
          50            0 :             .toList();
          51              :       } catch (e) {
          52            0 :         tieBreakerOptions = [];
          53              :       }
          54              :     }
          55              :
          56            3 :     return Club(
          57            9 :       id: json['id'] != null ? json['id'].toString() : '',
          58            3 :       name: json['name'] ?? '',
          59            3 :       description: json['description'],
          60            3 :       logo: json['logo'],
          61            3 :       address: json['address'],
          62            3 :       location: json['location'],
          63            6 :       phone: json['phone'] ?? json['contact'], // contact 필드도 확인
          64            3 :       email: json['email'],
          65            3 :       website: json['website'],
          66            3 :       memberCount: json['memberCount'],
          67            6 :       ownerId: json['ownerId']?.toString(),
          68            6 :       femaleHandicap: json['femaleHandicap'] != null ? int.tryParse(json['femaleHandicap'].toString()) : null,
          69            3 :       averageCalculationPeriod: json['averageCalculationPeriod'],
          70            7 :       createdAt: json['createdAt'] != null ? DateTime.parse(json['createdAt']) : null,
          71            7 :       updatedAt: json['updatedAt'] != null ? DateTime.parse(json['updatedAt']) : null,
          72              :       tieBreakerOptions: tieBreakerOptions,
          73              :     );
          74              :   }
          75              :
          76              :   // Club 객체를 JSON으로 변환
          77            3 :   Map<String, dynamic> toJson() {
          78            3 :     return {
          79            3 :       'id': id,
          80            3 :       'name': name,
          81            3 :       'description': description,
          82            3 :       'logo': logo,
          83            3 :       'address': address,
          84            3 :       'location': location,
          85            3 :       'phone': phone,
          86            3 :       'email': email,
          87            3 :       'website': website,
          88            3 :       'memberCount': memberCount,
          89            3 :       'ownerId': ownerId,
          90            3 :       'femaleHandicap': femaleHandicap,
          91            3 :       'averageCalculationPeriod': averageCalculationPeriod,
          92            5 :       'createdAt': createdAt?.toIso8601String(),
          93            5 :       'updatedAt': updatedAt?.toIso8601String(),
          94            3 :       'tieBreakerOptions': tieBreakerOptions?.map((option) => option.toString().split('.').last).toList(),
          95              :     };
          96              :   }
          97              : }

Generated by: LCOV version 2.3.1-1