package com.tourism.webadmin.back.model;

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

/**
 * 签证信息管理实体对象。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "tour_visa")
public class TourVisa extends BaseModel {

    /**
     * 签证id。
     */
    @TableId(value = "id")
    private Long id;

    /**
     * 图片地址。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "img")
    private String img;

    /**
     * 名称。
     */
    @TableField(value = "visa_title")
    private String visaTitle;

    /**
     * 类型id。
     */
    @TableField(value = "visa_type_id")
    private Long visaTypeId;

    /**
     * 国家编码。
     */
    @TableField(value = "country_code_id")
    private String countryCodeId;

    /**
     * 使馆名称。
     */
    @TableField(value = "embassy_name")
    private String embassyName;

    /**
     * 使馆地址。
     */
    @TableField(value = "embassy_address")
    private String embassyAddress;

    /**
     * 是否面签 0 是 1否。
     */
    @TableField(value = "interview_flag")
    private Integer interviewFlag;

    /**
     * 有效期（日）。
     */
    @TableField(value = "validity")
    private Integer validity;

    /**
     * 停留天数。
     */
    @TableField(value = "idle_days")
    private Integer idleDays;

    /**
     * 预计办理天数。
     */
    @TableField(value = "processing_days")
    private Integer processingDays;

    /**
     * 预计价格。
     */
    @TableField(value = "floor_price")
    private Integer floorPrice;

    /**
     * 受理范围。
     */
    @TableField(value = "acceptance_range")
    private String acceptanceRange;

    /**
     * 入境次数。
     */
    @TableField(value = "entries_num")
    private Integer entriesNum;

    /**
     * 预定须知。
     */
    @TableField(value = "data_text")
    private String dataText;

    /**
     * 出签地编码。
     */
    @TableField(value = "issue_visa_code")
    private Long issueVisaCode;

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

    /**
     * 负责顾问。
     */
    @TableField(value = "counselor_id")
    private Long counselorId;

    /**
     * 热门数据。
     */
    @TableField(value = "hot_value")
    private Integer hotValue;

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

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

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

    @RelationDict(
            masterIdField = "id",
            slaveModelClass = TourVisaCounselor.class,
            slaveIdField = "id",
            slaveNameField = "counselorName")
    @TableField(exist = false)
    private Map<String, Object> idDictMap;

    @RelationDict(
            masterIdField = "visaTypeId",
            slaveModelClass = TourVisaType.class,
            slaveIdField = "id",
            slaveNameField = "title")
    @TableField(exist = false)
    private Map<String, Object> visaTypeIdDictMap;

    @RelationDict(
            masterIdField = "countryCodeId",
            slaveModelClass = TourCountryCode.class,
            slaveIdField = "countryCode",
            slaveNameField = "country")
    @TableField(exist = false)
    private Map<String, Object> countryCodeIdDictMap;

    @RelationDict(
            masterIdField = "issueVisaCode",
            slaveModelClass = ChinaArea.class,
            slaveIdField = "code",
            slaveNameField = "name")
    @TableField(exist = false)
    private Map<String, Object> issueVisaCodeDictMap;

    @RelationDict(
            masterIdField = "counselorId",
            slaveModelClass = TourVisaCounselor.class,
            slaveIdField = "id",
            slaveNameField = "counselorName")
    @TableField(exist = false)
    private Map<String, Object> counselorIdDictMap;

    @RelationConstDict(
            masterIdField = "interviewFlag",
            constantDictClass = InterviewFlag.class)
    @TableField(exist = false)
    private Map<String, Object> interviewFlagDictMap;

    @RelationConstDict(
            masterIdField = "hotValue",
            constantDictClass = Hotspot.class)
    @TableField(exist = false)
    private Map<String, Object> hotValueDictMap;
}
