package com.adealink.weparty.module.profile.data

import android.os.Parcelable
import com.adealink.frame.aab.util.getCompatString
import com.adealink.weparty.R
import com.google.gson.annotations.GsonNullable
import com.google.gson.annotations.Must
import com.google.gson.annotations.SerializedName
import kotlinx.parcelize.Parcelize

enum class Gender(val gender: Int) {
    UNKNOWN(0),//未定义
    FEMALE(2), //女性
    MALE(1); //男性

    fun getDesc(): String {
        return when (this) {
            UNKNOWN -> {
                getCompatString(R.string.common_unknown)
            }

            MALE -> {
                getCompatString(R.string.common_male)
            }

            FEMALE -> {
                getCompatString(R.string.common_female)
            }
        }
    }

    companion object {

        fun map(gender: Int?): Gender {
            return when (gender) {
                FEMALE.gender -> {
                    FEMALE
                }

                MALE.gender -> {
                    MALE
                }

                else -> {
                    UNKNOWN
                }
            }
        }

    }

}

@Parcelize
data class UserInfo(
    @SerializedName("userNo") val uid: String,
    @GsonNullable
    @SerializedName("nickname") var nickName: String? = null,
    @GsonNullable
    @SerializedName("avatar") var avatar: String? = null,
    @GsonNullable
    @SerializedName("age") var age: Int? = null,
    @GsonNullable
    @SerializedName("birthdayAt") var birthday: Long? = null,
    @GsonNullable
    @SerializedName("area") var area: String? = null,
    @GsonNullable
    @SerializedName("gender") var gender: Int? = null,
    @GsonNullable
    @SerializedName("intro") var intro: String? = null, //用户简介
    @GsonNullable
    @SerializedName("interest") var interest: List<String>? = null, //用户简介
    @GsonNullable
    @SerializedName("photos") var photos: List<String>? = null, //照片


    @GsonNullable
    @SerializedName("playmate") var playmate: Boolean? = null, //是否陪玩师
    @GsonNullable
    @SerializedName("languageNames") var languageNames: List<String>? = null, //用户会的语言列表
    @GsonNullable
    @SerializedName("star") var star: Float? = null, //评分
    @GsonNullable
    @SerializedName("skills") var skills: List<UserPlayMateSkill>? = null, //技能商品简易信息
    @GsonNullable
    @SerializedName("rated") var rated: Boolean? = null, //今天是否已打分

) : Parcelable {

    fun isComplete(): Boolean {
        //用户个人信息是否完整
//        return false
        return !nickName.isNullOrEmpty()
                && gender != null
    }

    fun isPlaymate() = playmate == true

    fun isCacheValid(newAttrSet: Set<UserConfigType>?): Boolean {
//        if (newAttrSet.isNullOrEmpty()) {
//            return true
//        }
//        if (attrSet.containsAll(UserConfigType.values().toSet())) {
//            return true
//        }
//        if (attrSet.containsAll(newAttrSet)) {
//            return true
//        }
//        return false
        return true
    }

    companion object {

        fun emptyUserInfo(uid: String, avatar: String): UserInfo {
            return UserInfo(uid = uid, avatar = avatar)
        }

    }
}

infix fun UserInfo.contentsTheSame(other: UserInfo?): Boolean {
    other ?: return false
    return this == other
}

@Parcelize
data class UserPlayMateSkill(
    @Must
    @SerializedName("id") var id: String, //技能商品id
    @SerializedName("name") var name: String, //技能商品品类名称
    @SerializedName("icon") var icon: String, //图标
    @SerializedName("price") var price: Float, //价格
    @SerializedName("unit") var unit: String, //单位
    @SerializedName("cover") var cover: String, //封面
    @SerializedName("orderCount") var orderCount: Long, //订单数量
) : Parcelable