<?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.ruoyi.voluntary.mapper.PdDirectionManualMapper">
    
    <resultMap type="PdDirectionManual" id="PdDirectionManualResult">
        <result property="direction"    column="direction"    />
        <result property="count"    column="count"    />
        <result property="row"    column="row"    />
        <result property="invalidRemark"    column="invalidRemark"    />
        <result property="hasDirection"    column="hasDirection"    />
        <result property="schoolLocation"    column="schoolLocation"    />
        <result property="memo1"    column="memo1"    />
        <result property="memo2"    column="memo2"    />
        <result property="specialType"    column="specialType"    />
    </resultMap>

    <sql id="selectPdDirectionManualVo">
        select direction, count, `row`, invalidRemark, hasDirection, schoolLocation, memo1, memo2, specialType from pd_direction_manual
    </sql>

    <select id="selectPdDirectionManualList" parameterType="PdDirectionManual" resultMap="PdDirectionManualResult">
        <include refid="selectPdDirectionManualVo"/>
        <where>  
            <if test="count != null "> and count = #{count}</if>
            <if test="row != null "> and row = #{row}</if>
            <if test="invalidRemark != null  and invalidRemark != ''"> and invalidRemark = #{invalidRemark}</if>
            <if test="hasDirection != null  and hasDirection != ''"> and hasDirection = #{hasDirection}</if>
            <if test="schoolLocation != null  and schoolLocation != ''"> and schoolLocation = #{schoolLocation}</if>
            <if test="memo1 != null  and memo1 != ''"> and memo1 = #{memo1}</if>
            <if test="memo2 != null  and memo2 != ''"> and memo2 = #{memo2}</if>
            <if test="specialType != null  and specialType != ''"> and specialType = #{specialType}</if>
        </where>
    </select>
    
    <select id="selectPdDirectionManualByDirection" parameterType="String" resultMap="PdDirectionManualResult">
        <include refid="selectPdDirectionManualVo"/>
        where direction = #{direction}
    </select>
        
    <insert id="insertPdDirectionManual" parameterType="PdDirectionManual">
        insert into pd_direction_manual
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="direction != null">direction,</if>
            <if test="count != null">count,</if>
            <if test="row != null">row,</if>
            <if test="invalidRemark != null">invalidRemark,</if>
            <if test="hasDirection != null">hasDirection,</if>
            <if test="schoolLocation != null">schoolLocation,</if>
            <if test="memo1 != null">memo1,</if>
            <if test="memo2 != null">memo2,</if>
            <if test="specialType != null">specialType,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="direction != null">#{direction},</if>
            <if test="count != null">#{count},</if>
            <if test="row != null">#{row},</if>
            <if test="invalidRemark != null">#{invalidRemark},</if>
            <if test="hasDirection != null">#{hasDirection},</if>
            <if test="schoolLocation != null">#{schoolLocation},</if>
            <if test="memo1 != null">#{memo1},</if>
            <if test="memo2 != null">#{memo2},</if>
            <if test="specialType != null">#{specialType},</if>
         </trim>
    </insert>

    <insert id="batchInsert" parameterType="PdDirectionManual">
        replace into pd_direction_manual(direction, count, row, invalidRemark, hasDirection, schoolLocation, memo1, memo2, specialType) VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.direction}, #{item.count}, #{item.row}, #{item.invalidRemark}, #{item.hasDirection}, #{item.schoolLocation}, #{item.memo1}, #{item.memo2}, #{item.specialType})
        </foreach>
    </insert>

    <update id="truncateTable">
        truncate table pd_direction_manual
    </update>

    <update id="updatePdDirectionManual" parameterType="PdDirectionManual">
        update pd_direction_manual
        <trim prefix="SET" suffixOverrides=",">
            <if test="count != null">count = #{count},</if>
            <if test="row != null">count = #{row},</if>
            <if test="invalidRemark != null">invalidRemark = #{invalidRemark},</if>
            <if test="hasDirection != null">hasDirection = #{hasDirection},</if>
            <if test="schoolLocation != null">schoolLocation = #{schoolLocation},</if>
            <if test="memo1 != null">memo1 = #{memo1},</if>
            <if test="memo2 != null">memo2 = #{memo2},</if>
            <if test="specialType != null">specialType = #{specialType},</if>
        </trim>
        where direction = #{direction}
    </update>

    <delete id="deletePdDirectionManualByDirection" parameterType="String">
        delete from pd_direction_manual where direction = #{direction}
    </delete>

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