<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nantian.cloud.query.mapper.jljc.MultiDimensionTableRelationshipMapper">

    <resultMap id="BaseResultMap" type="com.nantian.cloud.query.entity.jljc.MultiDimensionTableRelationship">
        <id column="id" property="id" />
        <result column="table_name" property="tableName" />
        <result column="link_table_name" property="linkTableName" />
        <result column="link_flied" property="linkFlied" />
        <result column="dict_belong" property="dictBelong" />
        <result column="table_belong" property="tableBelong"/>
        <result column="filed_belong" property="filedBelong"/>
        <result column="update_time" property="updateTime"/>
        <result column="del_flag" property="delFlag"/>
        <result column="create_time" property="createTime"/>
    </resultMap>
    <sql id="tableName">
        multi_dimension_table_relationship
    </sql>

    <sql id="baseColumn">
        id,table_name,link_table_name,link_flied,table_belong,filed_belong,create_time,update_time,del_flag
    </sql>

    <select id="getPageScope" resultType="com.nantian.cloud.query.entity.jljc.MultiDimensionTableRelationship">
        select <include refid="baseColumn"></include>
        from multi_dimension_table_relationship
        <trim prefix="where" prefixOverrides="and">
            <if test="query.tableName != null and query.tableName != ''">
                and table_name like concat("%",#{query.tableName},"%")
            </if>
            <if test="query.linkTableName != null and query.linkTableName != ''">
                and link_table_name =  #{query.linkTableName}
            </if>
            <if test="query.linkFlied != null and query.linkFlied != ''">
                and link_flied =  #{query.linkFlied}
            </if>
        </trim>
        order by update_time desc
    </select>

</mapper>
