package com.adealink.weparty.playmate.data

import com.adealink.weparty.module.playmate.data.SayWelcomeData
import com.adealink.weparty.module.playmate.data.SkillSettingData
import com.adealink.weparty.module.playmate.data.UserPlaymateCategoryData
import com.adealink.weparty.module.room.data.RoomInfo
import com.adealink.weparty.util.TimeHour
import com.adealink.weparty.util.WeekDay
import com.google.gson.annotations.GsonNullable
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:周六
    @SerializedName("autoWelcomeOpen") val autoWelcomeOpen: Boolean, //自动打招呼开关
) {
    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,
)

data class UserPushListRes(
    @SerializedName("list") val list: List<UserPushListData>,
    @GsonNullable
    @SerializedName("next") val next: String?
)

data class UserPushListData(
    @SerializedName("userNo") val uid: String,
    @SerializedName("avatar") val avatar: String, //头像
    @SerializedName("nickname") val nickname: String, //昵称
    @SerializedName("age") val age: Int = 0, //年龄
    @SerializedName("gender") val gender: Int = 0, //性别
    @SerializedName("online") val online: Boolean, //
    @SerializedName("newRegister") val newRegister: Boolean, //是否新注册
    @SerializedName("contacted") var contacted: Boolean, //是否已私聊
)


data class EnableAutoWelcomeReq(
    @SerializedName("autoWelcomeOpen") val enable: Boolean
)

data class WelcomeListRes(
    @SerializedName("list") val list: List<SayWelcomeData>
)

data class AddWelcomeReq(
    @SerializedName("type") val type: Int,//0:text, 1:voice

    @GsonNullable
    @SerializedName("textContent") val text: String? = null,

    @GsonNullable
    @SerializedName("voiceUrl") val voice: String? = null,
    @SerializedName("voiceDuration") val duration: Int? = null,
)

data class DeleteWelcomeReq(
    @SerializedName("id") val id: String
)

data class UpdateWelcomeReq(
    @SerializedName("id") val id: String,
    @SerializedName("type") val type: Int,//0:text, 1:voice

    @GsonNullable
    @SerializedName("textContent") val text: String? = null,

    @GsonNullable
    @SerializedName("voiceUrl") val voice: String? = null,
    @SerializedName("voiceDuration") val duration: Int? = null,
)

data class WelcomeReplayReq(
    @SerializedName("userNo") val uid: String
)

data class ReportUserPushChatReq(
    @SerializedName("userNo") val uid: String
)

data class PlaymateUserPushQuotaReq(
    @SerializedName("userNo") val uid: String
)

data class PlaymateUserPushQuotaRes(
    @SerializedName("userQuotaCount") val userQuotaCount: Int,
    @SerializedName("playmateQuotaCount") val playmateQuotaCount: Int
) {
    fun isQuotaAvailable(): Boolean {
        return userQuotaCount > 0 && playmateQuotaCount > 0
    }
}

data class IsRoomAvailableRes(
    @SerializedName("result") val available: Boolean,
)

data class AvailableRoomRes(
    @SerializedName("room") val room: RoomInfo,
)