package com.tourism.webadmin.back.model;

import com.baomidou.mybatisplus.annotation.*;
import com.tourism.webadmin.back.model.constant.Hotspot;
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_tourism_project")
public class TourismProject extends BaseModel {

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

    /**
     * 项目标题。
     */
    @TableField(value = "project_title")
    private String projectTitle;

    /**
     * 项目简述。
     */
    @TableField(value = "remarks")
    private String remarks;

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

    /**
     * 标签。
     */
    @TableField(value = "project_label")
    private String projectLabel;

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

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

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

    /**
     * 出发地。
     */
    @TableField(value = "start_place")
    private String startPlace;

    /**
     * 目的地。
     */
    @TableField(value = "end_place")
    private String endPlace;

    /**
     * 总天数。
     */
    @TableField(value = "count_times")
    private String countTimes;

    /**
     * 项目价格。
     */
    @TableField(value = "price")
    private String price;

    /**
     * 项目展示图片。
     */
    @UploadFlagColumn(storeType = UploadStoreTypeEnum.LOCAL_SYSTEM)
    @TableField(value = "tourism_url")
    private String tourismUrl;

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

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

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

    @RelationOneToOne(
            masterIdField = "id",
            slaveModelClass = TourismFile.class,
            slaveIdField = "associationTableId")
    @TableField(exist = false)
    private TourismFile tourismFile;

    @RelationOneToOne(
            masterIdField = "id",
            slaveModelClass = TourismContent.class,
            slaveIdField = "associationId")
    @TableField(exist = false)
    private TourismContent tourismContent;

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

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

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