<?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.liquidnet.client.admin.zhengzai.kylin.mapper.KylinPerformancesMapper">
    
    <resultMap type="KylinPerformances" id="KylinPerformancesResult">
        <result property="mid"    column="mid"    />
        <result property="performancesId"    column="performances_id"    />
        <result property="title"    column="title"    />
        <result property="type"    column="type"    />
        <result property="imgPoster"    column="img_poster"    />
        <result property="provinceId"    column="province_id"    />
        <result property="provinceName"    column="province_name"    />
        <result property="cityId"    column="city_id"    />
        <result property="cityName"    column="city_name"    />
        <result property="districtId"    column="district_id"    />
        <result property="districtName"    column="district_name"    />
        <result property="approvalUrl"    column="approval_url"    />
        <result property="notice"    column="notice"    />
        <result property="sponsorId"    column="sponsor_id"    />
        <result property="sponsorType"    column="sponsor_type"    />
        <result property="sponsor"    column="sponsor"    />
        <result property="contacts"    column="contacts"    />
        <result property="mobile"    column="mobile"    />
        <result property="describes"    column="describes"    />
        <result property="details"    column="details"    />
        <result property="noticeImage"    column="notice_image"    />
        <result property="timeStart"    column="time_start"    />
        <result property="timeEnd"    column="time_end"    />
        <result property="auditTime"    column="audit_time"    />
        <result property="rejectTxt"    column="reject_txt"    />
        <result property="sort"    column="sort"    />
        <result property="comment"    column="comment"    />
        <result property="createdAt"    column="created_at"    />
        <result property="updatedAt"    column="updated_at"    />
    </resultMap>

    <sql id="selectKylinPerformancesVo">
        select mid, performances_id, title, type, img_poster, province_id, province_name, city_id, city_name, district_id, district_name, approval_url, notice, sponsor_id, sponsor_type, sponsor, contacts, mobile, describes, details, notice_image, time_start, time_end, audit_time, reject_txt, sort, comment, created_at, updated_at from kylin_performances
    </sql>

    <select id="selectKylinPerformancesList" parameterType="KylinPerformances" resultMap="KylinPerformancesResult">
        <include refid="selectKylinPerformancesVo"/>
        <where>  
            <if test="performancesId != null  and performancesId != ''"> and performances_id = #{performancesId}</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="imgPoster != null  and imgPoster != ''"> and img_poster = #{imgPoster}</if>
            <if test="provinceId != null  and provinceId != ''"> and province_id = #{provinceId}</if>
            <if test="provinceName != null  and provinceName != ''"> and province_name like concat('%', #{provinceName}, '%')</if>
            <if test="cityId != null "> and city_id = #{cityId}</if>
            <if test="cityName != null  and cityName != ''"> and city_name like concat('%', #{cityName}, '%')</if>
            <if test="districtId != null "> and district_id = #{districtId}</if>
            <if test="districtName != null  and districtName != ''"> and district_name like concat('%', #{districtName}, '%')</if>
            <if test="approvalUrl != null  and approvalUrl != ''"> and approval_url = #{approvalUrl}</if>
            <if test="notice != null  and notice != ''"> and notice = #{notice}</if>
            <if test="sponsorId != null  and sponsorId != ''"> and sponsor_id = #{sponsorId}</if>
            <if test="sponsorType != null  and sponsorType != ''"> and sponsor_type = #{sponsorType}</if>
            <if test="sponsor != null  and sponsor != ''"> and sponsor = #{sponsor}</if>
            <if test="contacts != null  and contacts != ''"> and contacts = #{contacts}</if>
            <if test="mobile != null  and mobile != ''"> and mobile = #{mobile}</if>
            <if test="describes != null  and describes != ''"> and describes = #{describes}</if>
            <if test="details != null  and details != ''"> and details = #{details}</if>
            <if test="noticeImage != null  and noticeImage != ''"> and notice_image = #{noticeImage}</if>
            <if test="timeStart != null "> and time_start = #{timeStart}</if>
            <if test="timeEnd != null "> and time_end = #{timeEnd}</if>
            <if test="auditTime != null "> and audit_time = #{auditTime}</if>
            <if test="rejectTxt != null  and rejectTxt != ''"> and reject_txt = #{rejectTxt}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="comment != null  and comment != ''"> and comment = #{comment}</if>
            <if test="createdAt != null "> and created_at = #{createdAt}</if>
            <if test="updatedAt != null "> and updated_at = #{updatedAt}</if>
        </where>
    </select>
    
    <select id="selectKylinPerformancesById" parameterType="Long" resultMap="KylinPerformancesResult">
        <include refid="selectKylinPerformancesVo"/>
        where mid = #{mid}
    </select>
        
    <insert id="insertKylinPerformances" parameterType="KylinPerformances" useGeneratedKeys="true" keyProperty="mid">
        insert into kylin_performances
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="performancesId != null and performancesId != ''">performances_id,</if>
            <if test="title != null and title != ''">title,</if>
            <if test="type != null">type,</if>
            <if test="imgPoster != null and imgPoster != ''">img_poster,</if>
            <if test="provinceId != null and provinceId != ''">province_id,</if>
            <if test="provinceName != null and provinceName != ''">province_name,</if>
            <if test="cityId != null">city_id,</if>
            <if test="cityName != null and cityName != ''">city_name,</if>
            <if test="districtId != null">district_id,</if>
            <if test="districtName != null and districtName != ''">district_name,</if>
            <if test="approvalUrl != null and approvalUrl != ''">approval_url,</if>
            <if test="notice != null and notice != ''">notice,</if>
            <if test="sponsorId != null and sponsorId != ''">sponsor_id,</if>
            <if test="sponsorType != null and sponsorType != ''">sponsor_type,</if>
            <if test="sponsor != null and sponsor != ''">sponsor,</if>
            <if test="contacts != null and contacts != ''">contacts,</if>
            <if test="mobile != null and mobile != ''">mobile,</if>
            <if test="describes != null and describes != ''">describes,</if>
            <if test="details != null">details,</if>
            <if test="noticeImage != null">notice_image,</if>
            <if test="timeStart != null">time_start,</if>
            <if test="timeEnd != null">time_end,</if>
            <if test="auditTime != null">audit_time,</if>
            <if test="rejectTxt != null and rejectTxt != ''">reject_txt,</if>
            <if test="sort != null">sort,</if>
            <if test="comment != null and comment != ''">comment,</if>
            <if test="createdAt != null">created_at,</if>
            <if test="updatedAt != null">updated_at,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="performancesId != null and performancesId != ''">#{performancesId},</if>
            <if test="title != null and title != ''">#{title},</if>
            <if test="type != null">#{type},</if>
            <if test="imgPoster != null and imgPoster != ''">#{imgPoster},</if>
            <if test="provinceId != null and provinceId != ''">#{provinceId},</if>
            <if test="provinceName != null and provinceName != ''">#{provinceName},</if>
            <if test="cityId != null">#{cityId},</if>
            <if test="cityName != null and cityName != ''">#{cityName},</if>
            <if test="districtId != null">#{districtId},</if>
            <if test="districtName != null and districtName != ''">#{districtName},</if>
            <if test="approvalUrl != null and approvalUrl != ''">#{approvalUrl},</if>
            <if test="notice != null and notice != ''">#{notice},</if>
            <if test="sponsorId != null and sponsorId != ''">#{sponsorId},</if>
            <if test="sponsorType != null and sponsorType != ''">#{sponsorType},</if>
            <if test="sponsor != null and sponsor != ''">#{sponsor},</if>
            <if test="contacts != null and contacts != ''">#{contacts},</if>
            <if test="mobile != null and mobile != ''">#{mobile},</if>
            <if test="describes != null and describes != ''">#{describes},</if>
            <if test="details != null">#{details},</if>
            <if test="noticeImage != null">#{noticeImage},</if>
            <if test="timeStart != null">#{timeStart},</if>
            <if test="timeEnd != null">#{timeEnd},</if>
            <if test="auditTime != null">#{auditTime},</if>
            <if test="rejectTxt != null and rejectTxt != ''">#{rejectTxt},</if>
            <if test="sort != null">#{sort},</if>
            <if test="comment != null and comment != ''">#{comment},</if>
            <if test="createdAt != null">#{createdAt},</if>
            <if test="updatedAt != null">#{updatedAt},</if>
         </trim>
    </insert>

    <update id="updateKylinPerformances" parameterType="KylinPerformances">
        update kylin_performances
        <trim prefix="SET" suffixOverrides=",">
            <if test="performancesId != null and performancesId != ''">performances_id = #{performancesId},</if>
            <if test="title != null and title != ''">title = #{title},</if>
            <if test="type != null">type = #{type},</if>
            <if test="imgPoster != null and imgPoster != ''">img_poster = #{imgPoster},</if>
            <if test="provinceId != null and provinceId != ''">province_id = #{provinceId},</if>
            <if test="provinceName != null and provinceName != ''">province_name = #{provinceName},</if>
            <if test="cityId != null">city_id = #{cityId},</if>
            <if test="cityName != null and cityName != ''">city_name = #{cityName},</if>
            <if test="districtId != null">district_id = #{districtId},</if>
            <if test="districtName != null and districtName != ''">district_name = #{districtName},</if>
            <if test="approvalUrl != null and approvalUrl != ''">approval_url = #{approvalUrl},</if>
            <if test="notice != null and notice != ''">notice = #{notice},</if>
            <if test="sponsorId != null and sponsorId != ''">sponsor_id = #{sponsorId},</if>
            <if test="sponsorType != null and sponsorType != ''">sponsor_type = #{sponsorType},</if>
            <if test="sponsor != null and sponsor != ''">sponsor = #{sponsor},</if>
            <if test="contacts != null and contacts != ''">contacts = #{contacts},</if>
            <if test="mobile != null and mobile != ''">mobile = #{mobile},</if>
            <if test="describes != null and describes != ''">describes = #{describes},</if>
            <if test="details != null">details = #{details},</if>
            <if test="noticeImage != null">notice_image = #{noticeImage},</if>
            <if test="timeStart != null">time_start = #{timeStart},</if>
            <if test="timeEnd != null">time_end = #{timeEnd},</if>
            <if test="auditTime != null">audit_time = #{auditTime},</if>
            <if test="rejectTxt != null and rejectTxt != ''">reject_txt = #{rejectTxt},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="comment != null and comment != ''">comment = #{comment},</if>
            <if test="createdAt != null">created_at = #{createdAt},</if>
            <if test="updatedAt != null">updated_at = #{updatedAt},</if>
        </trim>
        where mid = #{mid}
    </update>

    <delete id="deleteKylinPerformancesById" parameterType="Long">
        delete from kylin_performances where mid = #{mid}
    </delete>

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

</mapper>