<?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.younike.system.mapper.SysTreatyMapper">

    <resultMap id="SysTreatyResult" type="com.younike.system.domain.SysTreaty">

        <result column="id" property="id"/>

        <result column="memo" property="memo"/>

        <result column="content" property="content"/>

    </resultMap>

    <sql id="selectSysTreatyVo">select id, memo, content from sys_treaty </sql>

    <select id="selectSysTreatyList" resultMap="SysTreatyResult" parameterType="com.younike.system.domain.SysTreaty">

        <include refid="selectSysTreatyVo"/>

        <where>

            <if test="memo != null and memo != ''">and memo = #{memo}</if>

            <if test="content != null and content != ''">and content = #{content}</if>

        </where>

    </select>

    <select id="selectSysTreatyById" resultMap="SysTreatyResult" parameterType="Long">

        <include refid="selectSysTreatyVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysTreaty" parameterType="com.younike.system.domain.SysTreaty" keyProperty="id" useGeneratedKeys="true">
        insert into sys_treaty

        <trim suffixOverrides="," suffix=")" prefix="(">

            <if test="memo != null">memo,</if>

            <if test="content != null">content,</if>

        </trim>


        <trim suffixOverrides="," suffix=")" prefix="values (">

            <if test="memo != null">#{memo},</if>

            <if test="content != null">#{content},</if>

        </trim>

    </insert>

    <update id="updateSysTreaty" parameterType="com.younike.system.domain.SysTreaty">
        update sys_treaty

        <trim suffixOverrides="," prefix="SET">

            <if test="memo != null">memo = #{memo},</if>

            <if test="content != null">content = #{content},</if>

        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysTreatyById" parameterType="Long">delete from sys_treaty where id = #{id} </delete>

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

    </delete>


</mapper>
