package com.yice.webadmin.app.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yice.common.core.annotation.RelationDict;
import com.yice.common.core.base.mapper.BaseModelMapper;
import com.yice.common.core.base.model.BaseModel;
import com.yice.common.core.util.MyCommonUtil;
import com.yice.webadmin.app.vo.KnowledgeManageVo;
import com.yice.webadmin.upms.model.SysUser;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.Map;

/**
 * KnowledgeManage实体对象。
 *
 * @author linking
 * @date 2023-04-13
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName(value = "lmp_knowledge_manage")
public class KnowledgeManage extends BaseModel {

    /**
     * 知识库ID。
     */
    @TableId(value = "knowledge_id")
    private Long knowledgeId;

    /**
     * 知识库名称。
     */
    private String knowledgeName;

    /**
     * 知识库编码。
     */
    private String knowledgeCode;

    /**
     * 知识库描述。
     */
    private String knowledgeDescribe;

    /**
     * 知识格式。
     */
    private String knowledgeFormat;

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

    /**
     * 创建人名称字典。
     */
    @RelationDict(
            masterIdField = "createUserId",
            slaveModelClass = SysUser.class,
            slaveIdField = "userId",
            slaveNameField = "showName")
    @TableField(exist = false)
    private Map<String, Object> createUserIdDictMap;

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

    @Mapper
    public interface KnowledgeManageModelMapper extends BaseModelMapper<KnowledgeManageVo, KnowledgeManage> {
    }

    public static final KnowledgeManageModelMapper INSTANCE = Mappers.getMapper(KnowledgeManageModelMapper.class);
}
