package com.adealink.weparty.playmate.data

import com.adealink.weparty.module.playmate.data.SkillSettingData
import com.adealink.weparty.module.playmate.data.UserPlaymateCategoryData
import com.adealink.weparty.util.TimeHour
import com.adealink.weparty.util.WeekDay
import com.google.gson.annotations.SerializedName

data class PlaymateDetailReq(
    @SerializedName("id") val playmateId: String, //技能/商品ID
)

data class UserPlaymateCategoryReq(
    @SerializedName("id") val uid: String, //用户ID
)

data class UserPlaymateCategoryRes(
    @SerializedName("list") val list: List<UserPlaymateCategoryData>
)

data class SwitchBusinessReq(
    @SerializedName("open") val open: Boolean
)

data class BusinessTimeData(
    @SerializedName("timeRange") val timeRange: String, //时间范围格式:00:00-12:00,24小时制-0点到12点
    @SerializedName("weekNums") val weekDays: List<Int>, //1:周日，2:周一，3:周二，4:周三，5:周四，6:周五，7:周六
) {
    fun getTimeFromTo(): Pair<TimeHour, TimeHour>? {
        val split = timeRange.split("-")
        val fromStr = split.getOrNull(0)
        val toStr = split.getOrNull(1)
        if (split.isEmpty() || fromStr.isNullOrEmpty() || toStr.isNullOrEmpty()) {
            return null
        }
        val fromTime = TimeHour.map(fromStr)
        val toTime = TimeHour.map(toStr)
        if (fromTime == null || toTime == null) {
            return null
        }
        return Pair(fromTime, toTime)
    }

    fun getWeekDay(): List<WeekDay> {
        return weekDays.mapNotNull { day ->
            WeekDay.map(day)
        }
    }
}

data class SetupBusinessTimeReq(
    @SerializedName("timeRange") val timeRange: String? = null, //时间范围格式:00:00-12:00,24小时制-0点到12点
    @SerializedName("weekNums") val weekDays: List<Int>? = null, //1:周日，2:周一，3:周二，4:周三，5:周四，6:周五，7:周六
)


data class SkillSettingListReq(
    @SerializedName("open") val isOpen: Boolean?, //true: 查询已开启服务的技能列表
)

data class SkillSettingListRes(
    @SerializedName("list") val list: List<SkillSettingData>
)

data class GetSkillSwitchReq(
    @SerializedName("id") val playmateId: String,
)

data class SkillSwitchData(
    @SerializedName("open") val open: Boolean,
    @SerializedName("mainSkill") val mainSkill: Boolean? = null,
)

data class SwitchSkillReq(
    @SerializedName("skillId") val skillId: String,
    @SerializedName("open") val open: Boolean,
    @SerializedName("mainSkill") val mainSkill: Boolean? = null,
)