<?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="beilv.venue.mapper.BeilvVenueMapper">
    
    <resultMap type="BeilvVenue" id="BeilvVenueResult">
        <result property="id"    column="id"    />
        <result property="cover"    column="cover"    />
        <result property="address"    column="address"    />
        <result property="phoneNumber"    column="phone_number"    />
        <result property="businessHours"    column="business_hours"    />
        <result property="venueIntroduction"    column="venue_introduction"    />
        <result property="venueService"    column="venue_service"    />
        <result property="thresholdValue"    column="threshold_value"    />
        <result property="venueName"    column="venue_name"    />
    </resultMap>

    <sql id="selectBeilvVenueVo">
        select id, cover, address, phone_number, business_hours, venue_introduction, venue_service, threshold_value,venue_name from beilv_venue
    </sql>

    <select id="selectBeilvVenueList" parameterType="BeilvVenue" resultMap="BeilvVenueResult">
        <include refid="selectBeilvVenueVo"/>
        <where>
            <if test="venueName != null  and venueName != ''"> and venue_name like concat('%', #{venueName}, '%')</if>
            <if test="cover != null  and cover != ''"> and cover = #{cover}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="phoneNumber != null  and phoneNumber != ''"> and phone_number = #{phoneNumber}</if>
            <if test="businessHours != null "> and business_hours = #{businessHours}</if>
            <if test="venueIntroduction != null  and venueIntroduction != ''"> and venue_introduction = #{venueIntroduction}</if>
            <if test="venueService != null  and venueService != ''"> and venue_service = #{venueService}</if>
            <if test="thresholdValue != null  and thresholdValue != ''"> and threshold_value = #{thresholdValue}</if>
        </where>
    </select>
    
    <select id="selectBeilvVenueById" parameterType="Long" resultMap="BeilvVenueResult">
        <include refid="selectBeilvVenueVo"/>
        where id = #{id}
    </select>

    <insert id="insertBeilvVenue" parameterType="BeilvVenue">
        insert into beilv_venue
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="cover != null">cover,</if>
            <if test="address != null">address,</if>
            <if test="phoneNumber != null">phone_number,</if>
            <if test="businessHours != null">business_hours,</if>
            <if test="venueIntroduction != null">venue_introduction,</if>
            <if test="venueService != null">venue_service,</if>
            <if test="thresholdValue != null">threshold_value,</if>
            <if test="venueName != null">venue_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="cover != null">#{cover},</if>
            <if test="address != null">#{address},</if>
            <if test="phoneNumber != null">#{phoneNumber},</if>
            <if test="businessHours != null">#{businessHours},</if>
            <if test="venueIntroduction != null">#{venueIntroduction},</if>
            <if test="venueService != null">#{venueService},</if>
            <if test="thresholdValue != null">#{thresholdValue},</if>
            <if test="venueName != null">#{venueName},</if>
         </trim>
    </insert>

    <update id="updateBeilvVenue" parameterType="BeilvVenue">
        update beilv_venue
        <trim prefix="SET" suffixOverrides=",">
            <if test="cover != null">cover = #{cover},</if>
            <if test="address != null">address = #{address},</if>
            <if test="phoneNumber != null">phone_number = #{phoneNumber},</if>
            <if test="businessHours != null">business_hours = #{businessHours},</if>
            <if test="venueIntroduction != null">venue_introduction = #{venueIntroduction},</if>
            <if test="venueService != null">venue_service = #{venueService},</if>
            <if test="thresholdValue != null">threshold_value = #{thresholdValue},</if>
            <if test="venueName != null">venue_name = #{venueName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBeilvVenueById" parameterType="Long">
        delete from beilv_venue where id = #{id}
    </delete>

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

</mapper>