<?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.ics.admin.mapper.meeting.TicketMapper">
    
    <resultMap type="com.ics.admin.domain.meeting.Ticket" id="TicketResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="type"    column="type"    />
        <result property="duration"    column="duration"    />
        <result property="discount"    column="discount"    />
        <result property="address"    column="address"    />
        <result property="isVerification"    column="is_verification"    />
        <result property="isShow"    column="is_show"    />
        <result property="startTime"    column="start_time"    />
        <result property="endDate"    column="end_date"    />
        <result property="remark"    column="remark"    />
        <result property="num"    column="num"    />
        <result property="isDefault"    column="is_default"    />
        <result property="version"    column="version"    />
        <result property="deleteFlag"    column="delete_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"    />
    </resultMap>

    <sql id="selectTicketVo">
        SELECT id, title, content, type, duration, address, is_verification,discount,num, is_show, start_time, end_date, remark, is_default, version, delete_flag, create_by, create_time, update_by, update_time FROM tb_ticket
    </sql>

    <select id="selectTicketList" parameterType="Ticket" resultMap="TicketResult">
        <include refid="selectTicketVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectTicketById" parameterType="Long" resultMap="TicketResult">
        <include refid="selectTicketVo"/>
        WHERE id = #{id}
    </select>
        
    <insert id="insertTicket" parameterType="Ticket" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO tb_ticket
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null  and title != ''">title,</if>
            <if test="content != null  and content != ''">content,</if>
            <if test="type != null ">type,</if>
            <if test="duration != null  and duration != ''">duration,</if>
            <if test="discount != null  and discount != ''">discount,</if>
            <if test="address != null  and address != ''">address,</if>
            <if test="isVerification != null ">is_verification,</if>
            <if test="isShow != null ">is_show,</if>
            <if test="startTime != null ">start_time,</if>
            <if test="endDate != null ">end_date,</if>
            <if test="num != null ">num,</if>
            <if test="remark != null  and remark != ''">remark,</if>
            <if test="isDefault != null ">is_default,</if>
            <if test="version != null ">version,</if>
            <if test="deleteFlag != null ">delete_flag,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="updateBy != null  and updateBy != ''">update_by,</if>
            <if test="updateTime != null ">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null  and title != ''">#{title},</if>
            <if test="content != null  and content != ''">#{content},</if>
            <if test="type != null ">#{type},</if>
            <if test="duration != null  and duration != ''">#{duration},</if>
            <if test="discount != null  and discount != ''">#{discount},</if>
            <if test="address != null  and address != ''">#{address},</if>
            <if test="isVerification != null ">#{isVerification},</if>
            <if test="num != null ">#{num},</if>
            <if test="isShow != null ">#{isShow},</if>
            <if test="startTime != null ">#{startTime},</if>
            <if test="endDate != null ">#{endDate},</if>
            <if test="remark != null  and remark != ''">#{remark},</if>
            <if test="isDefault != null ">#{isDefault},</if>
            <if test="version != null ">#{version},</if>
            <if test="deleteFlag != null ">#{deleteFlag},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="updateBy != null  and updateBy != ''">#{updateBy},</if>
            <if test="updateTime != null ">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateTicket" parameterType="Ticket">
        UPDATE tb_ticket
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null  and title != ''">title = #{title},</if>
            <if test="content != null  and content != ''">content = #{content},</if>
            <if test="type != null ">type = #{type},</if>
            <if test="duration != null  and duration != ''">duration = #{duration},</if>
            <if test="discount != null  and discount != ''">discount = #{discount},</if>
            <if test="address != null  and address != ''">address = #{address},</if>
            <if test="num != null  and num != ''">num = #{num},</if>
            <if test="isVerification != null ">is_verification = #{isVerification},</if>
            <if test="isShow != null ">is_show = #{isShow},</if>
            <if test="startTime != null ">start_time = #{startTime},</if>
            <if test="endDate != null ">end_DATE = #{endDate},</if>
            <if test="remark != null  and remark != ''">remark = #{remark},</if>
            <if test="isDefault != null ">is_default = #{isDefault},</if>
            <if test="version != null ">version = #{version},</if>
            <if test="deleteFlag != null ">delete_flag = #{deleteFlag},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="updateBy != null  and updateBy != ''">update_by = #{updateBy},</if>
            <if test="updateTime != null ">update_time = #{updateTime},</if>
        </trim>
        WHERE id = #{id}
    </update>

    <delete id="deleteTicketById" parameterType="Long">
        DELETE FROM tb_ticket WHERE id = #{id}
    </delete>

    <delete id="deleteTicketByIds" parameterType="String">
        DELETE FROM tb_ticket where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>