package com.tourism.webadmin.back.model;

import com.baomidou.mybatisplus.annotation.*;
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.Map;

/**
 * 聊天群聊类型管理实体对象。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "tour_im_group_type")
public class TourImGroupType extends BaseModel {

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

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

    /**
     * 类型名称。
     */
    @TableField(value = "type_name")
    private String typeName;

    /**
     * 类型图标。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "type_icon")
    private String typeIcon;

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

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

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

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

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

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