<?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.zbf.system.mapper.TSeqMapper">

    <resultMap type="TSeq" id="TSeqResult">
            <result property="id"    column="id"    />
            <result property="k"    column="k"    />
            <result property="v"    column="v"    />
    </resultMap>

    <sql id="selectTSeqVo">
        select id, k, v from t_seq
    </sql>

    <select id="selectTSeqList" parameterType="TSeq" resultMap="TSeqResult">
        <include refid="selectTSeqVo"/>
        <where>
                        <if test="k != null  and k != ''"> and k = #{k}</if>
                        <if test="v != null "> and v = #{v}</if>
        </where>
    </select>

    <select id="selectTSeqById" parameterType="Long" resultMap="TSeqResult">
            <include refid="selectTSeqVo"/>
            where id = #{id}
    </select>

    <insert id="insertTSeq" parameterType="TSeq" useGeneratedKeys="true" keyProperty="id">
        insert into t_seq
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="k != null">k,</if>
                    <if test="v != null">v,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="k != null">#{k},</if>
                    <if test="v != null">#{v},</if>
        </trim>
    </insert>

    <update id="updateTSeq" parameterType="TSeq">
        update t_seq
        <trim prefix="SET" suffixOverrides=",">
                    <if test="k != null">k = #{k},</if>
                    <if test="v != null">v = #{v},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="enableTSeqByIds" parameterType="String">
        update t_seq set status=0 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    <update id="disabledTSeqByIds" parameterType="String">
        update t_seq set status=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>

    <delete id="deleteTSeqById" parameterType="Long">
        delete from t_seq  where id = #{id}
    </delete>

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