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 lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.Map;

/**
 * 投诉内容管理实体对象。
 *
 * @author 吃饭睡觉
 * @date 2024-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "tour_im_complaint")
public class TourImComplait extends BaseModel {

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

    /**
     * 举报类型id。
     */
    @TableField(value = "type_id")
    private Long typeId;

    /**
     * 类型为其他违规的理由。
     */
    @TableField(value = "else_type_reason")
    private String elseTypeReason;

    /**
     * 举报对象 1用户 2群组。
     */
    @TableField(value = "object_type")
    private Integer objectType;

    /**
     * 举报描述。
     */
    @TableField(value = "description")
    private String description;

    /**
     * 举报图片 最多三张。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.HUAWEI_OBS_SYSTEM)
    @TableField(value = "image")
    private String image;

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

    /**
     * 用户id。
     */
    @TableField(value = "user_id")
    private Long userId;

    /**
     * 群组id。
     */
    @TableField(value = "group_id")
    private Long groupId;

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

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

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

    @RelationDict(
            masterIdField = "userId",
            slaveModelClass = TourUser.class,
            slaveIdField = "userId",
            slaveNameField = "mobile")
    @TableField(exist = false)
    private Map<String, Object> userIdDictMap;

    @RelationDict(
            masterIdField = "groupId",
            slaveModelClass = TourImGroup.class,
            slaveIdField = "id",
            slaveNameField = "groupName")
    @TableField(exist = false)
    private Map<String, Object> groupIdDictMap;

    @RelationGlobalDict(
            masterIdField = "objectType",
            dictCode = "ComplaintObjectType")
    @TableField(exist = false)
    private Map<String, Object> objectTypeDictMap;
}
