package com.tourism.webadmin.back.model;

import com.baomidou.mybatisplus.annotation.*;
import com.tourism.webadmin.back.model.constant.RentState;
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.List;
import java.util.Map;

/**
 * 租赁房屋信息实体对象。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "tour_house_rent_info")
public class TourHouseRentInfo extends BaseModel {

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

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

    /**
     * 顾问id。
     */
    @TableField(value = "advisor_id")
    private Long advisorId;

    /**
     * 租赁方式 0整租 1合租 2个人房源 3短租。
     */
    @TableField(value = "rent_type")
    private Integer rentType;

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

    /**
     * 租金。
     */
    @TableField(value = "rent_price")
    private BigDecimal rentPrice;

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

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

    /**
     * 租金类型(0无租金;1押一付一;2押一付二;3押一付三....)。
     */
    @TableField(value = "rent_kind")
    private Integer rentKind;

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

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

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

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

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

    /**
     * 货币单位。
     */
    @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;

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

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

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

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

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

    /**
     * 备注。
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 排序顺序。
     */
    @TableField(value = "show_order")
    private Integer showOrder;

    /**
     * 租房状态(0:未租出;1:已租出)。
     */
    @TableField(value = "rent_state")
    private Integer rentState;

    /**
     * 楼层类型(1:低楼层;2:中楼层;3:高楼层)。
     */
    @TableField(value = "floor_type")
    private Integer floorType;

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

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

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

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

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

    /**
     * 是否热推房源。
     */
    @TableField(value = "is_hot_push")
    private Integer isHotPush;

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

    @RelationOneToOne(
            masterIdField = "id",
            slaveModelClass = TourHouseEquipment.class,
            slaveIdField = "houseId")
    @TableField(exist = false)
    private TourHouseEquipment tourHouseEquipment;

    @RelationOneToOne(
            masterIdField = "advisorId",
            slaveModelClass = TourHouseAdvisorInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TourHouseAdvisorInfo tourHouseAdvisorInfo;

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

    @RelationDict(
            masterIdField = "advisorId",
            equalOneToOneRelationField = "tourHouseAdvisorInfo",
            slaveModelClass = TourHouseAdvisorInfo.class,
            slaveIdField = "id",
            slaveNameField = "name")
    @TableField(exist = false)
    private Map<String, Object> advisorIdDictMap;

    @RelationConstDict(
            masterIdField = "rentState",
            constantDictClass = RentState.class)
    @TableField(exist = false)
    private Map<String, Object> rentStateDictMap;

    @RelationGlobalDict(
            masterIdField = "rentType",
            dictCode = "HouseRentType")
    @TableField(exist = false)
    private Map<String, Object> rentTypeDictMap;

    @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 = "rentKind",
            dictCode = "RentKind")
    @TableField(exist = false)
    private Map<String, Object> rentKindDictMap;

    @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;

    @RelationGlobalDict(
            masterIdField = "floorType",
            dictCode = "HouseFloorType")
    @TableField(exist = false)
    private Map<String, Object> floorTypeDictMap;

    @RelationConstDict(
            masterIdField = "isHotPush",
            constantDictClass = com.tourism.webadmin.back.model.constant.IsTrue.class)
    @TableField(exist = false)
    private Map<String, Object> isHotPushDictMap;
}
