package com.cheng.blzb.bean

import com.cheng.blzb.manager.UserConfigManager
import java.io.Serializable

class SearchOptionEntity(
    val title: String,
    val items: List<OptionItem>,
    var isChecked: Boolean = false
) : Serializable {
    class OptionItem(
        val id: Int = 0,
        val name: String = "",
        var isChecked: Boolean = false,

        var startTime: String = "",
        var endTime: String = ""
    ) : Serializable

    companion object {
        fun getAreaOptionList(): List<SearchOptionEntity> {
            val areaList = UserConfigManager.getAreaList()
            val list = mutableListOf<SearchOptionEntity>()
            list.add(SearchOptionEntity("全国地区", listOf(
                OptionItem(0, "全国", true)
            )))
            areaList.forEach { area ->
                val cityList = mutableListOf<OptionItem>()
                cityList.add(OptionItem(0, "全部"))
                area.children.forEach { city ->
                    cityList.add(OptionItem(city.id, city.name))
                }
                list.add(SearchOptionEntity(area.name, cityList))
            }
            return list
        }

        fun getTimeOptionList(): List<SearchOptionEntity> {
            val list = mutableListOf<SearchOptionEntity>()
            list.add(SearchOptionEntity("时间排序", listOf(
                OptionItem(0, "全部时间", true),
                OptionItem(1, "近三天"),
                OptionItem(2, "近七天"),
                OptionItem(3, "近一个月"),
                OptionItem(4, "近三个月"),
                OptionItem(5, "近一年")
            )))
            return list
        }

        fun getSortOptionList(): List<SearchOptionEntity> {
            val list = mutableListOf<SearchOptionEntity>()
            list.add(SearchOptionEntity("排序方式", listOf(
                OptionItem(0, "综合排序", true),
                OptionItem(1, "时间排序")
            )))
            return list
        }

        fun getTypeOptionList(): List<SearchOptionEntity> {
            val list = mutableListOf<SearchOptionEntity>()
            val typeList = mutableListOf<OptionItem>()
            typeList.add(OptionItem(0, "全部类型"))
            UserConfigManager.getBidTypes().forEach {
                typeList.add(OptionItem(it.id.toInt(), it.name))
            }
            list.add(SearchOptionEntity("信息类型", typeList))
            return list
        }
    }
}