<?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.project.zcustom.mapper.access.PlatAccessMapper">
    
    <resultMap type="PlatAccess" id="PlatAccessResult">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="appOrg"    column="app_org"    />
        <result property="carLicenseNum"    column="car_license_num"    />
        <result property="guardCardNum"    column="guard_card_num"    />
        <result property="blackListsNum"    column="black_lists_num"    />
        <result property="beforeCarNum"    column="before_car_num"    />
        <result property="twoDaysCarNum"    column="two_days_car_num"    />
        <result property="threeDaysCarNum"    column="three_days_car_num"    />
        <result property="fourDaysCarNum"    column="four_days_car_num"    />
        <result property="fiveDaysCarNum"    column="five_days_car_num"    />
        <result property="sixDaysCarNum"    column="six_days_car_num"    />
        <result property="sevenDaysCarNum"    column="seven_days_car_num"    />
    </resultMap>

    <sql id="selectPlatAccessVo">
        select id, del_flag, create_by, create_time, update_by, update_time, app_org, car_license_num, guard_card_num, black_lists_num, before_car_num, two_days_car_num, three_days_car_num, four_days_car_num, five_days_car_num, six_days_car_num, seven_days_car_num from large_plat_access
    </sql>

    <select id="selectPlatAccessList" parameterType="PlatAccess" resultMap="PlatAccessResult">
        <include refid="selectPlatAccessVo"/>
        <where>  
            <if test="appOrg != null  and appOrg != ''"> and app_org = #{appOrg}</if>
            <if test="carLicenseNum != null "> and car_license_num = #{carLicenseNum}</if>
            <if test="guardCardNum != null "> and guard_card_num = #{guardCardNum}</if>
            <if test="blackListsNum != null "> and black_lists_num = #{blackListsNum}</if>
            <if test="beforeCarNum != null "> and before_car_num = #{beforeCarNum}</if>
            <if test="twoDaysCarNum != null "> and two_days_car_num = #{twoDaysCarNum}</if>
            <if test="threeDaysCarNum != null "> and three_days_car_num = #{threeDaysCarNum}</if>
            <if test="fourDaysCarNum != null "> and four_days_car_num = #{fourDaysCarNum}</if>
            <if test="fiveDaysCarNum != null "> and five_days_car_num = #{fiveDaysCarNum}</if>
            <if test="sixDaysCarNum != null "> and six_days_car_num = #{sixDaysCarNum}</if>
            <if test="sevenDaysCarNum != null "> and seven_days_car_num = #{sevenDaysCarNum}</if>
        </where>
    </select>
    
    <select id="selectPlatAccessById" parameterType="Long" resultMap="PlatAccessResult">
        <include refid="selectPlatAccessVo"/>
        where id = #{id}
    </select>

    <insert id="insertPlatAccess" parameterType="PlatAccess" useGeneratedKeys="true" keyProperty="id">
        insert into large_plat_access
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="appOrg != null">app_org,</if>
            <if test="carLicenseNum != null">car_license_num,</if>
            <if test="guardCardNum != null">guard_card_num,</if>
            <if test="blackListsNum != null">black_lists_num,</if>
            <if test="beforeCarNum != null">before_car_num,</if>
            <if test="twoDaysCarNum != null">two_days_car_num,</if>
            <if test="threeDaysCarNum != null">three_days_car_num,</if>
            <if test="fourDaysCarNum != null">four_days_car_num,</if>
            <if test="fiveDaysCarNum != null">five_days_car_num,</if>
            <if test="sixDaysCarNum != null">six_days_car_num,</if>
            <if test="sevenDaysCarNum != null">seven_days_car_num,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="appOrg != null">#{appOrg},</if>
            <if test="carLicenseNum != null">#{carLicenseNum},</if>
            <if test="guardCardNum != null">#{guardCardNum},</if>
            <if test="blackListsNum != null">#{blackListsNum},</if>
            <if test="beforeCarNum != null">#{beforeCarNum},</if>
            <if test="twoDaysCarNum != null">#{twoDaysCarNum},</if>
            <if test="threeDaysCarNum != null">#{threeDaysCarNum},</if>
            <if test="fourDaysCarNum != null">#{fourDaysCarNum},</if>
            <if test="fiveDaysCarNum != null">#{fiveDaysCarNum},</if>
            <if test="sixDaysCarNum != null">#{sixDaysCarNum},</if>
            <if test="sevenDaysCarNum != null">#{sevenDaysCarNum},</if>
         </trim>
    </insert>

    <update id="updatePlatAccess" parameterType="PlatAccess">
        update large_plat_access
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null">del_flag = #{delFlag},</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="updateTime != null">update_time = #{updateTime},</if>
            <if test="appOrg != null">app_org = #{appOrg},</if>
            <if test="carLicenseNum != null">car_license_num = #{carLicenseNum},</if>
            <if test="guardCardNum != null">guard_card_num = #{guardCardNum},</if>
            <if test="blackListsNum != null">black_lists_num = #{blackListsNum},</if>
            <if test="beforeCarNum != null">before_car_num = #{beforeCarNum},</if>
            <if test="twoDaysCarNum != null">two_days_car_num = #{twoDaysCarNum},</if>
            <if test="threeDaysCarNum != null">three_days_car_num = #{threeDaysCarNum},</if>
            <if test="fourDaysCarNum != null">four_days_car_num = #{fourDaysCarNum},</if>
            <if test="fiveDaysCarNum != null">five_days_car_num = #{fiveDaysCarNum},</if>
            <if test="sixDaysCarNum != null">six_days_car_num = #{sixDaysCarNum},</if>
            <if test="sevenDaysCarNum != null">seven_days_car_num = #{sevenDaysCarNum},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePlatAccessById" parameterType="Long">
        delete from large_plat_access where id = #{id}
    </delete>

    <delete id="deletePlatAccessByIds" parameterType="String">
        delete from large_plat_access where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="reallyDeleteByWrapper">
        DELETE FROM large_plat_access ${ew.customSqlSegment}
    </delete>
</mapper>