package com.tourism.webadmin.back.model;

import com.baomidou.mybatisplus.annotation.*;
import com.tourism.webadmin.back.model.constant.IsSaleByLandlord;
import com.tourism.webadmin.back.model.constant.IsOnSale;
import com.tourism.webadmin.back.model.constant.IsSoleDwelling;
import com.tourism.common.core.util.MyCommonUtil;
import com.tourism.common.core.upload.UploadStoreTypeEnum;
import com.tourism.common.core.annotation.*;
import com.tourism.common.core.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
import java.util.List;

/**
 * 买卖房屋信息管理实体对象。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "tour_house_sale_info")
public class TourHouseSaleInfo extends BaseModel {

    /**
     * 主键。
     */
    @TableId(value = "id")
    private Long id;

    /**
     * 所属地区类型。
     */
    @TableField(value = "area_id")
    private Long areaId;

    /**
     * 是否房东自售 0不是 1是。
     */
    @TableField(value = "is_sale_by_landlord")
    private Integer isSaleByLandlord;

    /**
     * 房源类型 0新房 1二手房。
     */
    @TableField(value = "house_source_type")
    private Integer houseSourceType;

    /**
     * 总价。
     */
    @TableField(value = "total_price")
    private BigDecimal totalPrice;

    /**
     * 厅室类型。
     */
    @TableField(value = "office_type")
    private Integer officeType;

    /**
     * 面积。
     */
    @TableField(value = "area")
    private Integer area;

    /**
     * 房屋类型 别墅、公寓...。
     */
    @TableField(value = "house_type")
    private Integer houseType;

    /**
     * 朝向类型。
     */
    @TableField(value = "orientation")
    private Integer orientation;

    /**
     * 所在楼层。
     */
    @TableField(value = "current_floor")
    private Integer currentFloor;

    /**
     * 装修类型。
     */
    @TableField(value = "decoration")
    private Integer decoration;

    /**
     * 房龄。
     */
    @TableField(value = "house_age")
    private Integer houseAge;

    /**
     * 楼盘名称/所属小区。
     */
    @TableField(value = "community_name")
    private String communityName;

    /**
     * 地址。
     */
    @TableField(value = "address")
    private String address;

    /**
     * 均价。
     */
    @TableField(value = "average_price")
    private BigDecimal averagePrice;

    /**
     * 货币单位。
     */
    @TableField(value = "currency")
    private String currency;

    /**
     * 所属区域。
     */
    @TableField(value = "region")
    private String region;

    /**
     * 首页封面图。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "cover_url")
    private String coverUrl;

    /**
     * 是否在售 0待售 1在售。
     */
    @TableField(value = "is_on_sale")
    private Integer isOnSale;

    /**
     * 房屋标题。
     */
    @TableField(value = "house_title")
    private String houseTitle;

    /**
     * 总楼层。
     */
    @TableField(value = "total_floor")
    private Integer totalFloor;

    /**
     * 建造年份。
     */
    @TableField(value = "year_of_build")
    private Date yearOfBuild;

    /**
     * 房屋标签。
     */
    @TableField(value = "tag")
    private String tag;

    /**
     * 竣工年份。
     */
    @TableField(value = "year_of_finish")
    private Date yearOfFinish;

    /**
     * 开发商id。
     */
    @TableField(value = "developers_id")
    private Long developersId;

    /**
     * 二维码。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "code")
    private String code;

    /**
     * 联系电话。
     */
    @TableField(value = "mobile")
    private String mobile;

    /**
     * 产权性质。
     */
    @TableField(value = "property_right_nature")
    private String propertyRightNature;

    /**
     * 产权年限。
     */
    @TableField(value = "term_of_ownership")
    private String termOfOwnership;

    /**
     * 物业类型。
     */
    @TableField(value = "property_type")
    private String propertyType;

    /**
     * 房本年限。
     */
    @TableField(value = "house_principal_life")
    private String housePrincipalLife;

    /**
     * 是否唯一住房 0是 1不是。
     */
    @TableField(value = "is_sole_dwelling")
    private Integer isSoleDwelling;

    /**
     * 发布公司。
     */
    @TableField(value = "publishing_company")
    private String publishingCompany;

    /**
     * 营业执照。
     */
    @TableField(value = "business_license")
    private String businessLicense;

    /**
     * 发布日期。
     */
    @TableField(value = "release_date")
    private Date releaseDate;

    /**
     * 开盘时间。
     */
    @TableField(value = "opening_time")
    private Date openingTime;

    /**
     * 交房时间。
     */
    @TableField(value = "handing_time")
    private Date handingTime;

    /**
     * 周边配套描述。
     */
    @TableField(value = "surrounding_support")
    private String surroundingSupport;

    /**
     * 小区介绍。
     */
    @TableField(value = "plot_introduction")
    private String plotIntroduction;

    /**
     * 逻辑删除标记字段(1: 正常 -1: 已删除)。
     */
    @TableLogic
    @TableField(value = "data_state")
    private Integer dataState;

    /**
     * 热度值。
     */
    @TableField(value = "hot_value")
    private Integer hotValue;

    /**
     * 房屋图集。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "house_url")
    private String houseUrl;

    /**
     * 周边配套图集。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "surroundings_url")
    private String surroundingsUrl;

    /**
     * 小区介绍图集。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "introduction_url")
    private String introductionUrl;

    /**
     * totalPrice 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private BigDecimal totalPriceStart;

    /**
     * totalPrice 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private BigDecimal totalPriceEnd;

    /**
     * area 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private Integer areaStart;

    /**
     * area 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private Integer areaEnd;

    /**
     * currentFloor 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private Integer currentFloorStart;

    /**
     * currentFloor 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private Integer currentFloorEnd;

    /**
     * houseAge 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private Integer houseAgeStart;

    /**
     * houseAge 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private Integer houseAgeEnd;

    @TableField(exist = false)
    private String openingTimeEnd;

    /**
     * handingTime 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private String handingTimeStart;

    /**
     * handingTime 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private String handingTimeEnd;

    /**
     * hotValue 范围过滤起始值(>=)。
     */
    @TableField(exist = false)
    private Integer hotValueStart;

    /**
     * hotValue 范围过滤结束值(<=)。
     */
    @TableField(exist = false)
    private Integer hotValueEnd;

    /**
     * community_name / address LIKE搜索字符串。
     */
    @TableField(exist = false)
    private String searchString;

    public void setSearchString(String searchString) {
        this.searchString = MyCommonUtil.replaceSqlWildcard(searchString);
    }

    /**
     * TourHouseFiles 的一对多关联表数据对象。
     * 通常在一对多的关联中，我们基于从表数据过滤主表数据，此时需要先对从表数据进行嵌套子查询过滤，并将从表过滤数据列表集成到该字段。
     */
    @RelationOneToMany(
            masterIdField = "id",
            slaveModelClass = TourHouseFiles.class,
            slaveIdField = "tourHouseId")
    @TableField(exist = false)
    private List<TourHouseFiles> tourHouseFilesList;

    @RelationOneToOne(
            masterIdField = "developersId",
            slaveModelClass = TourHouseDevelopersType.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TourHouseDevelopersType tourHouseDevelopersType;

    @RelationDict(
            masterIdField = "areaId",
            slaveModelClass = TourHouseAreaMenu.class,
            slaveIdField = "id",
            slaveNameField = "levelName")
    @TableField(exist = false)
    private Map<String, Object> areaIdDictMap;

    @RelationDict(
            masterIdField = "developersId",
            equalOneToOneRelationField = "tourHouseDevelopersType",
            slaveModelClass = TourHouseDevelopersType.class,
            slaveIdField = "id",
            slaveNameField = "name")
    @TableField(exist = false)
    private Map<String, Object> developersIdDictMap;

    @RelationConstDict(
            masterIdField = "isSaleByLandlord",
            constantDictClass = IsSaleByLandlord.class)
    @TableField(exist = false)
    private Map<String, Object> isSaleByLandlordDictMap;

    @RelationConstDict(
            masterIdField = "isOnSale",
            constantDictClass = IsOnSale.class)
    @TableField(exist = false)
    private Map<String, Object> isOnSaleDictMap;

    @RelationConstDict(
            masterIdField = "isSoleDwelling",
            constantDictClass = IsSoleDwelling.class)
    @TableField(exist = false)
    private Map<String, Object> isSoleDwellingDictMap;

    @RelationGlobalDict(
            masterIdField = "houseSourceType",
            dictCode = "HouseSourceType")
    @TableField(exist = false)
    private Map<String, Object> houseSourceTypeDictMap;

    @RelationGlobalDict(
            masterIdField = "officeType",
            dictCode = "OfficeType")
    @TableField(exist = false)
    private Map<String, Object> officeTypeDictMap;

    @RelationGlobalDict(
            masterIdField = "houseType",
            dictCode = "HouseType")
    @TableField(exist = false)
    private Map<String, Object> houseTypeDictMap;

    @RelationGlobalDict(
            masterIdField = "orientation",
            dictCode = "Orientation")
    @TableField(exist = false)
    private Map<String, Object> orientationDictMap;

    @RelationGlobalDict(
            masterIdField = "decoration",
            dictCode = "Decoration")
    @TableField(exist = false)
    private Map<String, Object> decorationDictMap;

    @TableField(exist = false)
    private List<String> areaIds;

    @TableField(exist = false)
    private List<String> advisors;
}
