package com.keyware.shandan.bianmu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.keyware.shandan.bianmu.entity.LabelEntity;
import org.apache.ibatis.annotations.*;

import java.io.Serializable;
import java.util.List;

/**
 * @author GuoXin
 * @date 2023-01-11
 */
@Mapper
public interface LabelEntityMapper extends BaseMapper<LabelEntity> {

    @Override
    @Results(id="all_result_map", value = {
            @Result(id = true, column = "ID", property = "id"),
            @Result(column = "ENTITY_ID", property = "entityId"),
            @Result(column = "ENTITY_TYPE", property = "entityType"),
            @Result(column = "LABEL_ID", property = "labelId"),
            @Result(column = "FIELD_TITLE", property = "fieldTitle"),
            @Result(column = "LABEL", property = "label"),
            @Result(column = "LABEL_ID", property = "data", one = @One(select = "com.keyware.shandan.bianmu.mapper.DataLabelsMapper.selectById"))
    })
    @Select("SELECT * FROM B_DATA_LABEL_ENTITY WHERE ID = #{id}")
    LabelEntity selectById(Serializable id);

    @ResultMap(value = {"all_result_map"})
    @Select("SELECT * FROM B_DATA_LABEL_ENTITY WHERE ENTITY_ID = #{entityId}")
    List<LabelEntity> selectByEntityId(String entityId);

}
