<?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.yifu.cloud.plus.v1.business.mapper.system.TBusLableMapper">
    <resultMap id="tBusLableMap" type="com.yifu.cloud.plus.v1.business.entity.system.TBusLable">
        <id property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="remark" column="remark"/>
        <result property="status" column="status"/>
        <result property="createUserId" column="create_user_id"/>
        <result property="createUserName" column="create_user_name"/>
        <result property="createTime" column="create_time"/>
        <result property="deleteFlag" column="delete_flag"/>
    </resultMap>
    <sql id="Base_Column_List">
             a.id,
                  a.name,
                  a.remark,
                  a.status,
                  a.create_user_id,
                  a.create_user_name,
                  a.create_time,
                  a.delete_flag
         </sql>
    <sql id="tBusLable_where">
        <if test="tBusLable != null">
            <if test="tBusLable.id != null">
                AND a.id = #{tBusLable.id}
            </if>
            <if test="tBusLable.name != null and tBusLable.name.trim() != ''">
                AND a.name like concat('%', #{tBusLable.name},'%')
            </if>
            <if test="tBusLable.remark != null and tBusLable.remark.trim() != ''">
                AND a.remark = #{tBusLable.remark}
            </if>
            <if test="tBusLable.status != null">
                AND a.status = #{tBusLable.status}
            </if>
            <if test="tBusLable.createUserId != null and tBusLable.createUserId.trim() != ''">
                AND a.create_user_id = #{tBusLable.createUserId}
            </if>
            <if test="tBusLable.createUserName != null and tBusLable.createUserName.trim() != ''">
                AND a.create_user_name = #{tBusLable.createUserName}
            </if>
            <if test="tBusLable.createTime != null">
                AND a.create_time = #{tBusLable.createTime}
            </if>
            <if test="tBusLable.deleteFlag != null">
                AND a.delete_flag = #{tBusLable.deleteFlag}
            </if>
        </if>
    </sql>
    <!--tBusLable简单分页查询-->
    <select id="getTBusLablePage" resultMap="tBusLableMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_bus_lable a
        <where>
            a.delete_flag = 0
            <include refid="tBusLable_where"/>
        </where>
        ORDER BY a.create_time desc
    </select>

    <!--list-->
    <select id="getTBusLableList" resultMap="tBusLableMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_bus_lable a
        <where>
            a.delete_flag = 0
            <include refid="tBusLable_where"/>
        </where>
        ORDER BY a.create_time desc
    </select>

    <!--判重-->
    <select id="getLableByName" resultMap="tBusLableMap">
        SELECT
        a.id
        FROM t_bus_lable a
        where
        a.delete_flag = 0
        <if test="id != null">
            and a.id != #{id}
        </if>
        AND a.name = #{name}
    </select>

</mapper>
