<?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.diagnostic.mapper.DiaEligibilityMapper">

    <resultMap type="DiaEligibility" id="DiaEligibilityResult">
        <result property="eliId"    column="eliId"    />
        <result property="relId"    column="relId"    />
        <result property="stuYearName"    column="stu_year_name"    />
        <result property="status"    column="status"    />
        <result property="name" column="name"  />
    </resultMap>

    <sql id="selectDiaEligibilityVo">
        select  eliId,relId,stu_year_name,`status` from dia_eligibility;
    </sql>

    <select id="selectDiaEligibilityList" parameterType="DiaEligibility" resultMap="DiaEligibilityResult">
        <include refid="selectDiaEligibilityVo"/>
        <where>
            <if test="relId != null "> and a.relId = #{relId}</if>
            <if test="name != null and a.name!='' "> and name = #{name}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>

    <select id="selectDiaEligibilityByEliId" parameterType="Long" resultMap="DiaEligibilityResult">
        <include refid="selectDiaEligibilityVo"/>
        where eliId = #{eliId}
    </select>

    <insert id="insertDiaEligibility" parameterType="DiaEligibility">
        insert into dia_eligibility
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="eliId != null">eliId,</if>
            <if test="relId != null">relId,</if>
            <if test="stuYearName != null">stu_year_name,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="eliId != null">#{eliId},</if>
            <if test="relId != null">#{relId},</if>
            <if test="stuYearName != null">#{stuYearName},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateDiaEligibility" parameterType="DiaEligibility">
        update dia_eligibility
        <trim prefix="SET" suffixOverrides=",">
            <if test="relId != null">relId = #{relId},</if>
            <if test="stuYearName != null">stu_year_name = #{stuYearName},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where eliId = #{eliId}
    </update>

    <delete id="deleteDiaEligibilityByEliId" parameterType="Long">
        delete from dia_eligibility where eliId = #{eliId}
    </delete>

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