package com.tourism.webadmin.back.model;

import com.baomidou.mybatisplus.annotation.*;
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 com.tourism.webadmin.back.model.constant.CompanyType;
import com.tourism.webadmin.back.model.constant.Enable;
import com.tourism.webadmin.back.model.constant.Hotspot;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Map;

/**
 * 门户菜单管理实体对象。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "tour_directory_info")
public class DirectoryInfo extends BaseModel {

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

    /**
     * 父级id。
     */
    @TableField(value = "parent_id")
    private Long parentId;

    /**
     * 菜单名称。
     */
    @TableField(value = "menu_name")
    private String menuName;

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

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

    /**
     * 菜单类型。
     */
    @TableField(value = "directory_type")
    private Integer directoryType;

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

    /**
     * 是否热点，0非热点，1热点。
     */
    @TableField(value = "is_hotspot")
    private Integer isHotspot;

    /**
     * 热门排序。
     */
    @TableField(value = "hot_order")
    private Integer hotOrder;

    /**
     * 热点图片。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "hot_picture_url")
    private String hotPictureUrl;
//
//    /**
//     * 精选目的地 1 是 2 不是。
//     */
//    @TableField(value = "is_winnow_destination")
//    private Integer isWinnowDestination;

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

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

    @RelationDict(
            masterIdField = "parentId",
            slaveModelClass = DirectoryInfo.class,
            slaveIdField = "id",
            slaveNameField = "menuName")
    @TableField(exist = false)
    private Map<String, Object> parentIdDictMap;

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

    @RelationConstDict(
            masterIdField = "directoryType",
            constantDictClass = CompanyType.class)
    @TableField(exist = false)
    private Map<String, Object> directoryTypeDictMap;

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


//    @RelationConstDict(
//            masterIdField = "isWinnowDestination",
//            constantDictClass = IsWinnowDestination.class)
//    @TableField(exist = false)
//    private Map<String, Object> isWinnowDestinationDictMap;

    /**
     * 根据directoryId的大小来获取对应级别的菜单。
     */
    @TableField(exist = false)
    private Long directoryId;
}
