Subversion Repositories SmartDukaan

Rev

Rev 4142 | Rev 5168 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3024 mandeep.dh 1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
3
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
4
 
5
<mapper namespace="in.shop2020.crm.persistence.TicketMapper">
6
  <resultMap type="ticket" id="ticketResult">
7
    <id property="id" column="id"/>
8
  </resultMap>
9
 
10
  <insert id="insertTicket" parameterType="ticket" useGeneratedKeys="true" keyProperty="id">
11
    INSERT INTO ticket
3106 mandeep.dh 12
      (customerId, openDate, closeDate, creatorId, description, assigneeId, status,
3390 mandeep.dh 13
       priority, category, productName, airwayBillNo, orderId, customerEmailId,
14
       customerMobileNumber, customerName)
3024 mandeep.dh 15
    VALUES
3106 mandeep.dh 16
      (#{customerId}, NOW(),  #{closeDate},  #{creatorId}, #{description}, #{assigneeId}, #{status},
3390 mandeep.dh 17
       #{priority}, #{category}, #{productName}, #{airwayBillNo}, #{orderId}, #{customerEmailId},
18
       #{customerMobileNumber}, #{customerName})
3024 mandeep.dh 19
  </insert>
4793 amar.kumar 20
 
21
  <update id="unassignAgentTickets" parameterType="int">
22
  	UPDATE ticket
23
  	SET assigneeId = NULL
24
  	WHERE	assigneeId = #{assigneeId} 
25
  		AND status != 2
26
 
27
  </update>
28
 
3024 mandeep.dh 29
  <update id="updateTicket" parameterType="ticket">
30
    UPDATE ticket
31
    SET
3106 mandeep.dh 32
    <if test="assigneeId != null">
33
      assigneeId = #{assigneeId},
3024 mandeep.dh 34
    </if>
3106 mandeep.dh 35
    <if test="status != null">
36
      status = #{status},
37
    </if>
38
    <if test="priority != null">
39
      priority = #{priority},
40
    </if>
41
    <if test="category != null">
42
      category = #{category},
43
    </if>
44
    <if test="description != null">
45
      description = #{description},
46
    </if>
3390 mandeep.dh 47
    <if test="customerEmailId != null">
48
      customerEmailId = #{customerEmailId},
49
    </if>
50
    <if test="customerName != null">
51
      customerName = #{customerName},
52
    </if>
53
    <if test="customerMobileNumber != null">
54
      customerMobileNumber = #{customerMobileNumber},
55
    </if>
3024 mandeep.dh 56
    closeDate = #{closeDate}
57
    WHERE id = #{id}
58
  </update>
59
 
3137 mandeep.dh 60
  <select id="getUnassignedTickets" resultType="ticket">
61
    SELECT * FROM ticket
62
    WHERE assigneeId IS NULL
63
    ORDER BY openDate DESC
64
  </select>
3390 mandeep.dh 65
 
66
  <select id="getTickets" parameterType="searchFilter" resultType="ticket">
3546 mandeep.dh 67
    SELECT *
68
    FROM ticket
3390 mandeep.dh 69
    <where>
70
    <if test="ticketId != null">
3546 mandeep.dh 71
        AND id = #{ticketId}
3390 mandeep.dh 72
    </if>
73
    <if test="ticketAssigneeIds != null">
3546 mandeep.dh 74
        AND assigneeId IN 
3390 mandeep.dh 75
        <foreach collection="ticketAssigneeIds" item="ticketAssigneeId"
76
                 index="index" open="(" close=")" separator=",">
77
            #{ticketAssigneeId}
78
        </foreach>
79
    </if>
80
    <if test="customerId != null">
3546 mandeep.dh 81
        AND customerId = #{customerId}
3390 mandeep.dh 82
    </if>
83
    <if test="startTimestamp != null">
3546 mandeep.dh 84
        AND openDate &gt; #{startTimestamp}
3390 mandeep.dh 85
    </if>
86
    <if test="endTimestamp != null">
3546 mandeep.dh 87
        AND openDate &lt; #{endTimestamp}
3390 mandeep.dh 88
    </if>
89
    <if test="customerEmailId != null">
3546 mandeep.dh 90
        AND customerEmailId = #{customerEmailId}
3390 mandeep.dh 91
    </if>
92
    <if test="customerMobileNumber != null">
3546 mandeep.dh 93
        AND customerMobileNumber = #{customerMobileNumber}
3390 mandeep.dh 94
    </if>
3546 mandeep.dh 95
    <if test="ticketStatuses != null">
96
        AND status IN 
97
        <foreach collection="ticketStatuses" item="ticketStatus"
98
                 index="index" open="(" close=")" separator=",">
99
            #{ticketStatus}
100
        </foreach>
3499 mandeep.dh 101
    </if>
102
    <if test="ticketPriority != null">
103
        AND priority = #{ticketPriority}
104
    </if>
105
    <if test="ticketCategory != null">
106
        AND category = #{ticketCategory}
107
    </if>
3390 mandeep.dh 108
    </where>
4142 mandeep.dh 109
    ORDER BY openDate
3390 mandeep.dh 110
  </select>
3137 mandeep.dh 111
</mapper>