Subversion Repositories SmartDukaan

Rev

Rev 3499 | Rev 3578 | 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>
3390 mandeep.dh 20
 
3024 mandeep.dh 21
  <update id="updateTicket" parameterType="ticket">
22
    UPDATE ticket
23
    SET
3106 mandeep.dh 24
    <if test="assigneeId != null">
25
      assigneeId = #{assigneeId},
3024 mandeep.dh 26
    </if>
3106 mandeep.dh 27
    <if test="status != null">
28
      status = #{status},
29
    </if>
30
    <if test="priority != null">
31
      priority = #{priority},
32
    </if>
33
    <if test="category != null">
34
      category = #{category},
35
    </if>
36
    <if test="description != null">
37
      description = #{description},
38
    </if>
3390 mandeep.dh 39
    <if test="customerEmailId != null">
40
      customerEmailId = #{customerEmailId},
41
    </if>
42
    <if test="customerName != null">
43
      customerName = #{customerName},
44
    </if>
45
    <if test="customerMobileNumber != null">
46
      customerMobileNumber = #{customerMobileNumber},
47
    </if>
3499 mandeep.dh 48
    <if test="status != null">
49
      status = #{status},
50
    </if>
51
    <if test="priority != null">
52
      priority = #{priority},
53
    </if>
54
    <if test="category != null">
55
      category = #{category},
56
    </if>
3024 mandeep.dh 57
    closeDate = #{closeDate}
58
    WHERE id = #{id}
59
  </update>
60
 
3137 mandeep.dh 61
  <select id="getUnassignedTickets" resultType="ticket">
62
    SELECT * FROM ticket
63
    WHERE assigneeId IS NULL
3546 mandeep.dh 64
    AND category != 'COD_VERIFICATION'
3137 mandeep.dh 65
    ORDER BY openDate DESC
66
  </select>
3390 mandeep.dh 67
 
68
  <select id="getTickets" parameterType="searchFilter" resultType="ticket">
3546 mandeep.dh 69
    SELECT *
70
    FROM ticket
3390 mandeep.dh 71
    <where>
72
    <if test="ticketId != null">
3546 mandeep.dh 73
        AND id = #{ticketId}
3390 mandeep.dh 74
    </if>
75
    <if test="ticketAssigneeIds != null">
3546 mandeep.dh 76
        AND assigneeId IN 
3390 mandeep.dh 77
        <foreach collection="ticketAssigneeIds" item="ticketAssigneeId"
78
                 index="index" open="(" close=")" separator=",">
79
            #{ticketAssigneeId}
80
        </foreach>
81
    </if>
82
    <if test="customerId != null">
3546 mandeep.dh 83
        AND customerId = #{customerId}
3390 mandeep.dh 84
    </if>
85
    <if test="startTimestamp != null">
3546 mandeep.dh 86
        AND openDate &gt; #{startTimestamp}
3390 mandeep.dh 87
    </if>
88
    <if test="endTimestamp != null">
3546 mandeep.dh 89
        AND openDate &lt; #{endTimestamp}
3390 mandeep.dh 90
    </if>
91
    <if test="customerEmailId != null">
3546 mandeep.dh 92
        AND customerEmailId = #{customerEmailId}
3390 mandeep.dh 93
    </if>
94
    <if test="customerMobileNumber != null">
3546 mandeep.dh 95
        AND customerMobileNumber = #{customerMobileNumber}
3390 mandeep.dh 96
    </if>
3546 mandeep.dh 97
    <if test="ticketStatuses != null">
98
        AND status IN 
99
        <foreach collection="ticketStatuses" item="ticketStatus"
100
                 index="index" open="(" close=")" separator=",">
101
            #{ticketStatus}
102
        </foreach>
3499 mandeep.dh 103
    </if>
104
    <if test="ticketPriority != null">
105
        AND priority = #{ticketPriority}
106
    </if>
107
    <if test="ticketCategory != null">
108
        AND category = #{ticketCategory}
109
    </if>
3390 mandeep.dh 110
    </where>
3546 mandeep.dh 111
    ORDER BY openDate DESC
3390 mandeep.dh 112
  </select>
3137 mandeep.dh 113
</mapper>