Subversion Repositories SmartDukaan

Rev

Rev 3546 | Rev 4142 | 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
64
    ORDER BY openDate DESC
65
  </select>
3390 mandeep.dh 66
 
67
  <select id="getTickets" parameterType="searchFilter" resultType="ticket">
3546 mandeep.dh 68
    SELECT *
69
    FROM ticket
3390 mandeep.dh 70
    <where>
71
    <if test="ticketId != null">
3546 mandeep.dh 72
        AND id = #{ticketId}
3390 mandeep.dh 73
    </if>
74
    <if test="ticketAssigneeIds != null">
3546 mandeep.dh 75
        AND assigneeId IN 
3390 mandeep.dh 76
        <foreach collection="ticketAssigneeIds" item="ticketAssigneeId"
77
                 index="index" open="(" close=")" separator=",">
78
            #{ticketAssigneeId}
79
        </foreach>
80
    </if>
81
    <if test="customerId != null">
3546 mandeep.dh 82
        AND customerId = #{customerId}
3390 mandeep.dh 83
    </if>
84
    <if test="startTimestamp != null">
3546 mandeep.dh 85
        AND openDate &gt; #{startTimestamp}
3390 mandeep.dh 86
    </if>
87
    <if test="endTimestamp != null">
3546 mandeep.dh 88
        AND openDate &lt; #{endTimestamp}
3390 mandeep.dh 89
    </if>
90
    <if test="customerEmailId != null">
3546 mandeep.dh 91
        AND customerEmailId = #{customerEmailId}
3390 mandeep.dh 92
    </if>
93
    <if test="customerMobileNumber != null">
3546 mandeep.dh 94
        AND customerMobileNumber = #{customerMobileNumber}
3390 mandeep.dh 95
    </if>
3546 mandeep.dh 96
    <if test="ticketStatuses != null">
97
        AND status IN 
98
        <foreach collection="ticketStatuses" item="ticketStatus"
99
                 index="index" open="(" close=")" separator=",">
100
            #{ticketStatus}
101
        </foreach>
3499 mandeep.dh 102
    </if>
103
    <if test="ticketPriority != null">
104
        AND priority = #{ticketPriority}
105
    </if>
106
    <if test="ticketCategory != null">
107
        AND category = #{ticketCategory}
108
    </if>
3390 mandeep.dh 109
    </where>
3546 mandeep.dh 110
    ORDER BY openDate DESC
3390 mandeep.dh 111
  </select>
3137 mandeep.dh 112
</mapper>