package com.adealink.weparty.profile.search.data

import com.adealink.frame.network.data.PageReq
import com.adealink.weparty.commonui.recycleview.diffutil.BaseListItemData
import com.adealink.weparty.module.room.data.RoomInfo
import com.google.gson.annotations.GsonNullable
import com.google.gson.annotations.SerializedName


data class SearchAllReq(
    @SerializedName("keyword") val keyword: String,
)

data class SearchAllRes(
    @GsonNullable
    @SerializedName("playmate") val playmate: List<SearchUserData>?,
    @GsonNullable
    @SerializedName("rooms") val rooms: List<RoomInfo>?,
)


data class SearchUserReq(
    @SerializedName("keyword") val keyword: String,
    @SerializedName("page") val page: PageReq
)

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


data class SearchRoomReq(
    @SerializedName("keyword") val keyword: String,
    @SerializedName("page") val page: PageReq
)

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


data class SearchUserData(
    @SerializedName("userNo") val uid: String,
    @GsonNullable
    @SerializedName("nickname") val nickName: String? = null,
    @GsonNullable
    @SerializedName("avatar") val avatar: String? = null,
    @GsonNullable
    @SerializedName("age") val age: Int? = null,
    @GsonNullable
    @SerializedName("birthdayAt") val birthdayAt: Long? = null,
    @GsonNullable
    @SerializedName("gender") val gender: Int? = null,

    @GsonNullable
    @SerializedName("follow") var follow: Boolean? = null, //是否关注
    @GsonNullable
    @SerializedName("fansCount") val fansCount: Int? = null, //粉丝人数
    @GsonNullable
    @SerializedName("online") val online: Boolean? = null //在线状态
)

data class SearchAllUserResultItemData(
    val result: List<SearchUserResultItemData>?
) : BaseListItemData

data class SearchAllRoomResultItemData(
    val result: List<SearchRoomResultItemData>?
) : BaseListItemData


data class SearchUserResultItemData(
    val data: SearchUserData
) : BaseListItemData {
    override fun areContentsTheSame(newItem: Any): Boolean {
        val new = newItem as? SearchUserResultItemData ?: return false
        return data.uid == new.data.uid
                && data.follow == new.data.follow
    }
}

data class SearchRoomResultItemData(
    val data: RoomInfo
) : BaseListItemData {
    override fun areContentsTheSame(newItem: Any): Boolean {
        val new = newItem as? SearchRoomResultItemData ?: return false
        return data.roomId == new.data.roomId
                && data.roomTitle == new.data.roomTitle
                && data.roomCover == new.data.roomCover
    }
}

data class SearchHistoryItemData(
    val keyword: String
) : BaseListItemData {
    override fun areContentsTheSame(newItem: Any): Boolean {
        val new = newItem as? SearchHistoryItemData ?: return false
        return keyword == new.keyword
    }
}


