Subversion Repositories SmartDukaan

Rev

Rev 3578 | Rev 4793 | 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>
3024 mandeep.dh 48
    closeDate = #{closeDate}
49
    WHERE id = #{id}
50
  </update>
51
 
3137 mandeep.dh 52
  <select id="getUnassignedTickets" resultType="ticket">
53
    SELECT * FROM ticket
54
    WHERE assigneeId IS NULL
55
    ORDER BY openDate DESC
56
  </select>
3390 mandeep.dh 57
 
58
  <select id="getTickets" parameterType="searchFilter" resultType="ticket">
3546 mandeep.dh 59
    SELECT *
60
    FROM ticket
3390 mandeep.dh 61
    <where>
62
    <if test="ticketId != null">
3546 mandeep.dh 63
        AND id = #{ticketId}
3390 mandeep.dh 64
    </if>
65
    <if test="ticketAssigneeIds != null">
3546 mandeep.dh 66
        AND assigneeId IN 
3390 mandeep.dh 67
        <foreach collection="ticketAssigneeIds" item="ticketAssigneeId"
68
                 index="index" open="(" close=")" separator=",">
69
            #{ticketAssigneeId}
70
        </foreach>
71
    </if>
72
    <if test="customerId != null">
3546 mandeep.dh 73
        AND customerId = #{customerId}
3390 mandeep.dh 74
    </if>
75
    <if test="startTimestamp != null">
3546 mandeep.dh 76
        AND openDate &gt; #{startTimestamp}
3390 mandeep.dh 77
    </if>
78
    <if test="endTimestamp != null">
3546 mandeep.dh 79
        AND openDate &lt; #{endTimestamp}
3390 mandeep.dh 80
    </if>
81
    <if test="customerEmailId != null">
3546 mandeep.dh 82
        AND customerEmailId = #{customerEmailId}
3390 mandeep.dh 83
    </if>
84
    <if test="customerMobileNumber != null">
3546 mandeep.dh 85
        AND customerMobileNumber = #{customerMobileNumber}
3390 mandeep.dh 86
    </if>
3546 mandeep.dh 87
    <if test="ticketStatuses != null">
88
        AND status IN 
89
        <foreach collection="ticketStatuses" item="ticketStatus"
90
                 index="index" open="(" close=")" separator=",">
91
            #{ticketStatus}
92
        </foreach>
3499 mandeep.dh 93
    </if>
94
    <if test="ticketPriority != null">
95
        AND priority = #{ticketPriority}
96
    </if>
97
    <if test="ticketCategory != null">
98
        AND category = #{ticketCategory}
99
    </if>
3390 mandeep.dh 100
    </where>
4142 mandeep.dh 101
    ORDER BY openDate
3390 mandeep.dh 102
  </select>
3137 mandeep.dh 103
</mapper>