<?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.srs.comprehensive.mapper.CphCardersMapper">
    
    <resultMap type="CphCarders" id="CphCardersResult">
        <result property="id"    column="id"    />
        <result property="carderName"    column="carder_name"    />
    </resultMap>

    <sql id="selectCphCardersVo">
        select id, carder_name from cph_carders
    </sql>

    <select id="selectCphCardersList" parameterType="CphCarders" resultMap="CphCardersResult">
        <include refid="selectCphCardersVo"/>
        <where>  
            <if test="carderName != null  and carderName != ''"> and carder_name like concat('%', #{carderName}, '%')</if>
        </where>
    </select>
    
    <select id="selectCphCardersById" parameterType="Long" resultMap="CphCardersResult">
        <include refid="selectCphCardersVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCphCarders" parameterType="CphCarders">
        insert into cph_carders
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="carderName != null and carderName != ''">carder_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="carderName != null and carderName != ''">#{carderName},</if>
         </trim>
    </insert>

    <update id="updateCphCarders" parameterType="CphCarders">
        update cph_carders
        <trim prefix="SET" suffixOverrides=",">
            <if test="carderName != null and carderName != ''">carder_name = #{carderName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCphCardersById" parameterType="Long">
        delete from cph_carders where id = #{id}
    </delete>

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