package com.tourism.webadmin.back.model;

import com.baomidou.mybatisplus.annotation.*;
import com.tourism.webadmin.back.model.constant.BannerType;
import com.tourism.webadmin.back.model.constant.Enable;
import com.tourism.webadmin.back.model.constant.IsFirst;
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;

/**
 * banner管理实体对象。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "tour_banner_info")
public class BannerInfo extends BaseModel {

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

    /**
     * banner名称。
     */
    @TableField(value = "banner_name")
    private String bannerName;

    /**
     * 所属分类。
     */
    @TableField(value = "belong_tab")
    private Long belongTab;

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

    /**
     * 是否主banner。
     */
    @TableField(value = "main_banner")
    private Integer mainBanner;

    /**
     * 图片URL。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "img_url")
    private String imgUrl;

    /**
     * 跳转链接。
     */
    @TableField(value = "banner_url")
    private String bannerUrl;

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

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

    /**
     * type 类型。
     */
    @TableField(value = "type")
    private Integer type;

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

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

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

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

    @RelationConstDict(
            masterIdField = "type",
            constantDictClass = BannerType.class)
    @TableField(exist = false)
    private Map<String, Object> bannerTypeDictMap;

    @RelationConstDict(
            masterIdField = "mainBanner",
            constantDictClass = IsFirst.class)
    @TableField(exist = false)
    private Map<String, Object> mainBannerDictMap;
}
