<?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.CphCardersStudentMapper">

    <resultMap type="CphCardersStudent" id="CphCardersStudentResult">
        <result property="id"    column="id"    />
        <result property="carderId"    column="carder_id"    />
        <result property="stuNo"    column="stu_no"    />
    </resultMap>

    <sql id="selectCphCardersStudentVo">
        select id, carder_id, stu_no from cph_carders_student
    </sql>

    <select id="selectCphCardersStudentList" parameterType="CphCardersStudent" resultMap="CphCardersStudentResult">
        <include refid="selectCphCardersStudentVo"/>
        <where>
            <if test="carderId != null "> and carder_id = #{carderId}</if>
            <if test="stuNo != null  and stuNo != ''"> and stu_no = #{stuNo}</if>
        </where>
    </select>

    <select id="selectCphCardersStudentById" parameterType="Long" resultMap="CphCardersStudentResult">
        <include refid="selectCphCardersStudentVo"/>
        where id = #{id}
    </select>

    <insert id="insertCphCardersStudent" parameterType="CphCardersStudent">
        insert into cph_carders_student
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="carderId != null">carder_id,</if>
            <if test="stuNo != null and stuNo != ''">stu_no,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="carderId != null">#{carderId},</if>
            <if test="stuNo != null and stuNo != ''">#{stuNo},</if>
        </trim>
    </insert>

    <update id="updateCphCardersStudent" parameterType="CphCardersStudent">
        update cph_carders_student
        <trim prefix="SET" suffixOverrides=",">
            <if test="carderId != null">carder_id = #{carderId},</if>
            <if test="stuNo != null and stuNo != ''">stu_no = #{stuNo},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCphCardersStudentById" parameterType="Long">
        delete from cph_carders_student where id = #{id}
    </delete>

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