Subversion Repositories SmartDukaan

Rev

Rev 14910 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?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="in.shop2020.crm.persistence.ActivityMapper">
  <resultMap type="activity" id="activityResult">
    <id property="id" column="id"/>
  </resultMap>

  <insert id="insertActivity" parameterType="activity" useGeneratedKeys="true" keyProperty="id">
    INSERT INTO activity
      (customerId, ticketAssigneeId, description, ticketId, creatorId, type, creationTimestamp,
       ticketPriority, ticketStatus, ticketCategory, ticketDescription, userEmailId, customerMobileNumber,
       isRead, customerEmailId, customerName, attachments)
    VALUES
      (#{customerId}, #{ticketAssigneeId}, #{description}, #{ticketId}, #{creatorId}, #{type}, NOW(),
       #{ticketPriority}, #{ticketStatus}, #{ticketCategory}, #{ticketDescription}, #{userEmailId},
       #{customerMobileNumber}, #{isRead}, #{customerEmailId}, #{customerName}, #{attachments})
  </insert>
  
  <select id="getActivities" parameterType="searchFilter" resultType="activity">
    SELECT *
    FROM activity
    <where>
    <if test="ticketId != null">
        AND ticketId = #{ticketId}
    </if>
    <if test="activityId != null">
        AND id = #{activityId}
    </if>
    <if test="activityCreatorIds != null">
        AND creatorId IN 
        <foreach collection="activityCreatorIds" item="activityCreatorId"
                 index="index" open="(" close=")" separator=",">
            #{activityCreatorId}
        </foreach>
    </if>
    <if test="customerId != null">
        AND customerId = #{customerId}
    </if>
    <if test="startTimestamp != null">
        AND creationTimestamp &gt; #{startTimestamp}
    </if>
    <if test="endTimestamp != null">
        AND creationTimestamp &lt; #{endTimestamp}
    </if>
    <if test="customerEmailId != null">
        AND customerEmailId = #{customerEmailId}
    </if>
    <if test="customerMobileNumber != null">
        AND customerMobileNumber = #{customerMobileNumber}
    </if>
    <if test="isActivityRead != null">
        AND isRead = #{isActivityRead}
    </if>
    <if test="activityType != null">
        AND type = #{activityType}
    </if>
    <if test="ticketCategory != null">
        AND ticketCategory = #{ticketCategory}
    </if>
    <if test="ticketAssigneeIds != null">
        AND ticketAssigneeId IN 
        <foreach collection="ticketAssigneeIds" item="ticketAssigneeId"
                 index="index" open="(" close=")" separator=",">
            #{ticketAssigneeId}
        </foreach>
    </if>
    <if test="notShowPmTickets != null and notShowPmTickets == true">
        AND ticketCategory not IN 
        <foreach collection="ticketCategoryList" item="tkCategory" 
                         index="index" open="(" close=")" separator=",">
                #{tkCategory}
        </foreach>
    </if>
    <if test="notShowPmTickets != null and notShowPmTickets == false">
        AND ticketCategory IN 
        <foreach collection="ticketCategoryList" item="tkCategory" 
                         index="index" open="(" close=")" separator=",">
                #{tkCategory}
        </foreach>
    </if>
    </where>
    ORDER BY creationTimestamp DESC
  </select>

  <update id="markAsRead" parameterType="long">
    UPDATE activity
    SET isRead = 1
    WHERE id = #{activityId}
  </update>
</mapper>