<?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.qianhe.zqcz.pwxx.mapper.ZqczPwxxMapper">
    <!--  返回实体  -->
    <resultMap id="ZqczPwxxResult" type="com.qianhe.zqcz.pwxx.domain.ZqczPwxxVo">
        <result property="pwid" column="PWID"/>
        <result property="pwmc" column="PWMC"/>
        <result property="jcrwid" column="JCRWID"/>
        <result property="remark" column="REMARK"/>
    </resultMap>
    <!--  通用查询  -->
    <sql id="selectCommon">
        SELECT PWID, PWMC, JCRWID, REMARK from zqcz_pwxx
    </sql>
    <!--  条件查询  -->
    <select id="list" parameterType="com.qianhe.zqcz.pwxx.domain.ZqczPwxxQuery" resultMap="ZqczPwxxResult">
        <include refid="selectCommon"></include>
        <where>
            <if test="pwmc != null  and pwmc !='' ">AND PWMC like concat('%', #{pwmc}, '%')</if>
            <if test="jcrwid != null ">AND JCRWID = #{jcrwid}</if>
        </where>
        ORDER BY UPDATE_TIME DESC
    </select>
    <!--  查询详情  -->
    <select id="info" parameterType="long" resultMap="ZqczPwxxResult">
        <include refid="selectCommon"></include> WHERE PWID = #{pwid}
    </select>
    <!--  新增  -->
    <insert id="add" parameterType="com.qianhe.zqcz.pwxx.domain.ZqczPwxx">
        INSERT INTO zqcz_pwxx
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="pwmc != null and pwmc != ''">PWMC,</if>
            <if test="jcrwid != null ">JCRWID,</if>
            <if test="createBy != null  and createBy != ''">CREATE_BY,</if>
            <if test="createTime != null ">CREATE_TIME,</if>
            <if test="updateBy != null  and updateBy != ''">UPDATE_BY,</if>
            <if test="remark != null  and remark != ''">REMARK,</if>
            <if test="yl1 != null  and yl1 != ''">YL1,</if>
            <if test="yl2 != null  and yl2 != ''">YL2,</if>
            <if test="yl3 != null  and yl3 != ''">YL3,</if>
            <if test="yl4 != null  and yl4 != ''">YL4,</if>
            <if test="yl5 != null  and yl5 != ''">YL5,</if>
            UPDATE_TIME
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="pwmc != null and pwmc != ''">#{pwmc},</if>
            <if test="jcrwid != null">#{jcrwid},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="remark != null and remark != ''">#{remark},</if>
            <if test="yl1 != null">#{yl1},</if>
            <if test="yl2 != null">#{yl2},</if>
            <if test="yl3 != null">#{yl3},</if>
            <if test="yl4 != null">#{yl4},</if>
            <if test="yl5 != null">#{yl5},</if>
            now()
        </trim>
    </insert>
    <!-- 评委信息表批量插入 -->
    <insert id="batchAdd" parameterType="java.util.List">
        <choose>
            <when test="pwxxList != null and pwxxList.size() > 0 and !pwxxList.isEmpty()">
                INSERT INTO zqcz_pwxx
                <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="pwxxList[0].pwid != null">PWID,</if>
                    <if test="pwxxList[0].pwmc != null and pwxxList[0].pwmc != ''">PWMC,</if>
                    <if test="pwxxList[0].jcrwid != null">JCRWID,</if>
                    <if test="pwxxList[0].createBy != null and pwxxList[0].createBy != ''">CREATE_BY,</if>
                    <if test="pwxxList[0].createTime != null">CREATE_TIME,</if>
                    <if test="pwxxList[0].updateBy != null and pwxxList[0].updateBy != ''">UPDATE_BY,</if>
                    <if test="pwxxList[0].remark != null and pwxxList[0].remark != ''">REMARK,</if>
                    <if test="pwxxList[0].yl1 != null and pwxxList[0].yl1 != ''">YL1,</if>
                    <if test="pwxxList[0].yl2 != null and pwxxList[0].yl2 != ''">YL2,</if>
                    <if test="pwxxList[0].yl3 != null and pwxxList[0].yl3 != ''">YL3,</if>
                    <if test="pwxxList[0].yl4 != null and pwxxList[0].yl4 != ''">YL4,</if>
                    <if test="pwxxList[0].yl5 != null and pwxxList[0].yl5 != ''">YL5,</if>
                    UPDATE_TIME
                </trim>
                VALUES
                <foreach collection="pwxxList" item="item" index="index" separator=",">
                    <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test="item.pwid != null">#{item.pwid},</if>
                        <if test="item.pwmc != null and item.pwmc != ''">#{item.pwmc},</if>
                        <if test="item.jcrwid != null">#{item.jcrwid},</if>
                        <if test="item.createBy != null and item.createBy != ''">#{item.createBy},</if>
                        <if test="item.createTime != null">#{item.createTime},</if>
                        <if test="item.updateBy != null and item.updateBy != ''">#{item.updateBy},</if>
                        <if test="item.remark != null and item.remark != ''">#{item.remark},</if>
                        <if test="item.yl1 != null and item.yl1 != ''">#{item.yl1},</if>
                        <if test="item.yl2 != null and item.yl2 != ''">#{item.yl2},</if>
                        <if test="item.yl3 != null and item.yl3 != ''">#{item.yl3},</if>
                        <if test="item.yl4 != null and item.yl4 != ''">#{item.yl4},</if>
                        <if test="item.yl5 != null and item.yl5 != ''">#{item.yl5},</if>
                        now()
                    </trim>
                </foreach>
            </when>
            <otherwise>
                SELECT 0 FROM DUAL
            </otherwise>
        </choose>
    </insert>
    <!--  修改  -->
    <update id="edit" parameterType="com.qianhe.zqcz.pwxx.domain.ZqczPwxx">
        UPDATE zqcz_pwxx
        <trim prefix="SET" suffixOverrides=",">
            <if test="pwmc != null and pwmc != ''">PWMC = #{pwmc},</if>
            <if test="jcrwid != null">JCRWID = #{jcrwid},</if>
            <if test="createBy != null">CREATE_BY = #{createBy},</if>
            <if test="createTime != null">CREATE_TIME = #{createTime},</if>
            <if test="updateBy != null">UPDATE_BY = #{updateBy},</if>
            <if test="remark != null">REMARK = #{remark},</if>
            <if test="yl1 != null">YL1 = #{yl1},</if>
            <if test="yl2 != null">YL2 = #{yl2},</if>
            <if test="yl3 != null">YL3 = #{yl3},</if>
            <if test="yl4 != null">YL4 = #{yl4},</if>
            <if test="yl5 != null">YL5 = #{yl5},</if>
            UPDATE_TIME = now()
        </trim>
        WHERE PWID = #{pwid}
    </update>
    <!--  删除  -->
    <delete id="delete" parameterType="long">
        DELETE FROM zqcz_pwxx WHERE PWID IN
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <!--  删除  -->
    <delete id="deleteByJcrwid" parameterType="long">
        DELETE FROM zqcz_pwxx WHERE JCRWID = #{jcrwid}
    </delete>
</mapper>