package com.tourism.webadmin.back.model;

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

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

    /**
     * 主键。
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

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

    /**
     * 顾问类型 0.顾问 1.房东。
     */
    @TableField(value = "type")
    private Integer type;

    /**
     * 姓名。
     */
    @TableField(value = "name")
    private String name;

    /**
     * 行业经验年限。
     */
    @TableField(value = "experience_age")
    private Integer experienceAge;

    /**
     * 成功交房数量。
     */
    @TableField(value = "successful_delivery_count")
    private Integer successfulDeliveryCount;

    /**
     * 是否金牌顾问 0不是 1是。
     */
    @TableField(value = "is_gold_advisor")
    private Integer isGoldAdvisor;

    /**
     * 头像url。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "avatar_url")
    private String avatarUrl;

    /**
     * 备案编号。
     */
    @TableField(value = "record_number")
    private String recordNumber;

    /**
     * 公司名称。
     */
    @TableField(value = "company_name")
    private String companyName;

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

    /**
     * 是否启用，0禁用，1启用。
     */
    @TableField(value = "enable")
    private Integer enable;

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

    /**
     * 手机号。
     */
    @TableField(value = "mobile")
    private String mobile;

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

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

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

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

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

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

    /**
     * id 的多对多关联表数据对象。
     */
    @TableField(exist = false)
    private TourHouseAdvisorRelation tourHouseAdvisorRelation;

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

    @RelationConstDict(
            masterIdField = "isGoldAdvisor",
            constantDictClass = IsGoldAdvisor.class)
    @TableField(exist = false)
    private Map<String, Object> isGoldAdvisorDictMap;

    @RelationConstDict(
            masterIdField = "enable",
            constantDictClass = Enable.class)
    @TableField(exist = false)
    private Map<String, Object> enableDictMap;

    @RelationGlobalDict(
            masterIdField = "type",
            dictCode = "AdvisorType")
    @TableField(exist = false)
    private Map<String, Object> typeDictMap;
}
