// data/model/CallRecord.kt
package com.example.initiateaphonecallapp.data.model

import com.example.initiateaphonecallapp.enums.CallStatus
import java.text.SimpleDateFormat
import java.util.*

data class CallRecord(
    val id: String = UUID.randomUUID().toString(),
    val phoneNumber: String,
    val startTime: Date,
    val endTime: Date? = null,
    val duration: Long = 0, // 单位：秒
    val status: CallStatus = CallStatus.INITIATED,
    val audioFileName: String? = null,
    val audioFileUri: String? = null,
    val uploaded: Boolean = false,
    val uploadTime: Date? = null
) {
    val formattedDuration: String
        get() {
            if (duration <= 0) return "0秒"
            val minutes = duration / 60
            val seconds = duration % 60
            return if (minutes > 0) "${minutes}分${seconds}秒" else "${seconds}秒"
        }

    val formattedStartTime: String
        get() = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(startTime)

    val formattedEndTime: String
        get() = endTime?.let {
            SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault()).format(it)
        } ?: "进行中"
}

