package gc.mda.kcg.domain.analysis;

import java.math.BigDecimal;
import java.time.OffsetDateTime;
import java.util.Map;

/**
 * vessel_analysis_results 응답 DTO.
 * 프론트엔드에서 필요한 핵심 필드만 포함.
 */
public record VesselAnalysisResponse(
        Long id,
        String mmsi,
        OffsetDateTime analyzedAt,
        // 분류
        String vesselType,
        BigDecimal confidence,
        BigDecimal fishingPct,
        String season,
        // 위치
        Double lat,
        Double lon,
        String zoneCode,
        BigDecimal distToBaselineNm,
        // 행동
        String activityState,
        // 위협
        Boolean isDark,
        Integer gapDurationMin,
        String darkPattern,
        BigDecimal spoofingScore,
        Integer speedJumpCount,
        // 환적
        Boolean transshipSuspect,
        String transshipPairMmsi,
        Integer transshipDurationMin,
        // 선단
        Integer fleetClusterId,
        String fleetRole,
        Boolean fleetIsLeader,
        // 위험도
        Integer riskScore,
        String riskLevel,
        // 확장
        String gearCode,
        String gearJudgment,
        String permitStatus,
        // features
        Map<String, Object> features
) {
    public static VesselAnalysisResponse from(VesselAnalysisResult e) {
        return new VesselAnalysisResponse(
                e.getId(),
                e.getMmsi(),
                e.getAnalyzedAt(),
                e.getVesselType(),
                e.getConfidence(),
                e.getFishingPct(),
                e.getSeason(),
                e.getLat(),
                e.getLon(),
                e.getZoneCode(),
                e.getDistToBaselineNm(),
                e.getActivityState(),
                e.getIsDark(),
                e.getGapDurationMin(),
                e.getDarkPattern(),
                e.getSpoofingScore(),
                e.getSpeedJumpCount(),
                e.getTransshipSuspect(),
                e.getTransshipPairMmsi(),
                e.getTransshipDurationMin(),
                e.getFleetClusterId(),
                e.getFleetRole(),
                e.getFleetIsLeader(),
                e.getRiskScore(),
                e.getRiskLevel(),
                e.getGearCode(),
                e.getGearJudgment(),
                e.getPermitStatus(),
                e.getFeatures()
        );
    }
}
