package kr.lunaticbum.back.lun.model

import kr.lunaticbum.back.lun.configs.GlobalEnvironment
import lombok.Getter

@Getter
class RequestModel {
    var type : String? = null
    var key : String? = null
    var data : String? = null

    fun getKeyword() = key ?: ""

    fun extractData() : String {
        data?.let {
            val reqString = data?.split(GlobalEnvironment.padding(getKeyword()))
            val nb = arrayListOf<String>()
            val na = arrayListOf<String>()
            reqString?.get(0)?.replace(GlobalEnvironment.padding(getKeyword()),"")?.split("")?.toList()?.let { na.addAll(it) }
            reqString?.get(1)?.replace(GlobalEnvironment.padding(getKeyword()),"")?.split("")?.toList()?.let { nb.addAll(it) }
            val max = nb.size + na.size
            val fullData = arrayListOf<String>()
            for (idx in 0..max) { if (idx % 2 == 0) { if (nb.size > 0) { fullData.add(nb.removeLast()) } } else { if (na.size > 0) { fullData.add(na.removeLast()) } } }
            return fullData.joinToString("")
        }
        return ""
    }
}


@Getter
class ReportModel {
    var name : String? = null
    var email : String? = null
    var message : String? = null
}