<?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.system.mapper.IllegalParkingMapper">
    
    <resultMap type="IllegalParking" id="IllegalParkingResult">
        <result property="illegalParkingId"    column="illegal_parking_id"    />
        <result property="plateNumber"    column="plate_number"    />
        <result property="portalId"    column="portal_id"    />
        <result property="visitPortal"    column="visit_portal"    />
        <result property="mobileNumber"    column="mobile_number"    />
        <result property="visitName"    column="visit_name"    />
        <result property="illegalPhoto"    column="illegal_photo"    />
        <result property="isBlack"    column="is_black"    />
        <result property="carType"    column="car_type"    />
        <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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectIllegalParkingVo">
        select illegal_parking_id, plate_number, car_type,portal_id, visit_portal, mobile_number, visit_name, illegal_photo, is_black, create_by, create_time, update_by, update_time, remark from illegal_parking
    </sql>

    <select id="selectIllegalParkingList" parameterType="IllegalParking" resultMap="IllegalParkingResult">
        <include refid="selectIllegalParkingVo"/>
        <where>  
            <if test="plateNumber != null  and plateNumber != ''"> and plate_number = #{plateNumber}</if>
            <if test="portalId != null "> and portal_id = #{portalId}</if>
            <if test="visitPortal != null  and visitPortal != ''"> and visit_portal = #{visitPortal}</if>
            <if test="mobileNumber != null  and mobileNumber != ''"> and mobile_number = #{mobileNumber}</if>
            <if test="visitName != null  and visitName != ''"> and visit_name like concat('%', #{visitName}, '%')</if>
            <if test="illegalPhoto != null  and illegalPhoto != ''"> and illegal_photo = #{illegalPhoto}</if>
            <if test="isBlack != null  and isBlack != ''"> and is_black = #{isBlack}</if>
            <if test="carType != null  and carType != ''"> and car_type = #{carType}</if>
        </where>
    </select>
    
    <select id="selectIllegalParkingByIllegalParkingId" parameterType="Long" resultMap="IllegalParkingResult">
        <include refid="selectIllegalParkingVo"/>
        where illegal_parking_id = #{illegalParkingId}
    </select>

    <insert id="insertIllegalParking" parameterType="IllegalParking" useGeneratedKeys="true" keyProperty="illegalParkingId">
        insert into illegal_parking
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="plateNumber != null and plateNumber != ''">plate_number,</if>
            <if test="portalId != null">portal_id,</if>
            <if test="visitPortal != null and visitPortal != ''">visit_portal,</if>
            <if test="mobileNumber != null and mobileNumber != ''">mobile_number,</if>
            <if test="visitName != null">visit_name,</if>
            <if test="illegalPhoto != null">illegal_photo,</if>
            <if test="isBlack != null">is_black,</if>
            <if test="carType != null">car_type,</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="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="plateNumber != null and plateNumber != ''">#{plateNumber},</if>
            <if test="portalId != null">#{portalId},</if>
            <if test="visitPortal != null and visitPortal != ''">#{visitPortal},</if>
            <if test="mobileNumber != null and mobileNumber != ''">#{mobileNumber},</if>
            <if test="visitName != null">#{visitName},</if>
            <if test="illegalPhoto != null">#{illegalPhoto},</if>
            <if test="isBlack != null">#{isBlack},</if>
            <if test="carType != null">#{carType},</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="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateIllegalParking" parameterType="IllegalParking">
        update illegal_parking
        <trim prefix="SET" suffixOverrides=",">
            <if test="plateNumber != null and plateNumber != ''">plate_number = #{plateNumber},</if>
            <if test="portalId != null">portal_id = #{portalId},</if>
            <if test="visitPortal != null and visitPortal != ''">visit_portal = #{visitPortal},</if>
            <if test="mobileNumber != null and mobileNumber != ''">mobile_number = #{mobileNumber},</if>
            <if test="visitName != null">visit_name = #{visitName},</if>
            <if test="illegalPhoto != null">illegal_photo = #{illegalPhoto},</if>
            <if test="isBlack != null">is_black = #{isBlack},</if>
            <if test="carType != null">car_type = #{carType},</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="remark != null">remark = #{remark},</if>
        </trim>
        where illegal_parking_id = #{illegalParkingId}
    </update>

    <delete id="deleteIllegalParkingByIllegalParkingId" parameterType="Long">
        delete from illegal_parking where illegal_parking_id = #{illegalParkingId}
    </delete>

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