<?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.ruoyi.system.mapper.LabelInfoMapper">
    
    <resultMap type="LabelInfo" id="LabelInfoResult">
        <result property="id"    column="id"    />
        <result property="labelName"    column="label_name"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="creator"    column="creator"    />
        <result property="modify"    column="modify"    />
    </resultMap>

    <sql id="selectLabelInfoVo">
        select id, label_name, create_time, update_time, creator, modify from label_info
    </sql>

    <select id="selectLabelInfoList" parameterType="LabelInfo" resultMap="LabelInfoResult">
        <include refid="selectLabelInfoVo"/>
        <where>  
            <if test="labelName != null  and labelName != ''"> and label_name like concat('%', #{labelName}, '%')</if>
            <if test="creator != null  and creator != ''"> and creator = #{creator}</if>
            <if test="modify != null  and modify != ''"> and modify = #{modify}</if>
        </where>
    </select>
    
    <select id="selectLabelInfoById" parameterType="Long" resultMap="LabelInfoResult">
        <include refid="selectLabelInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertLabelInfo" parameterType="LabelInfo">
        insert into label_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="labelName != null">label_name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="creator != null">creator,</if>
            <if test="modify != null">modify,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="labelName != null">#{labelName},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="creator != null">#{creator},</if>
            <if test="modify != null">#{modify},</if>
         </trim>
    </insert>

    <update id="updateLabelInfo" parameterType="LabelInfo">
        update label_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="labelName != null">label_name = #{labelName},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="modify != null">modify = #{modify},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLabelInfoById" parameterType="Long">
        delete from label_info where id = #{id}
    </delete>

    <delete id="deleteLabelInfoByIds" parameterType="String">
        delete from label_info where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>