Subversion Repositories SmartDukaan

Rev

Rev 3390 | Rev 3711 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3390 Rev 3546
Line 3... Line 3...
3
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
4
 
4
 
5
<mapper namespace="in.shop2020.crm.persistence.ActivityMapper">
5
<mapper namespace="in.shop2020.crm.persistence.ActivityMapper">
6
  <resultMap type="activity" id="activityResult">
6
  <resultMap type="activity" id="activityResult">
7
    <id property="id" column="id"/>
7
    <id property="id" column="id"/>
8
    <association property="creator" column="creatorId" javaType="agent">
-
 
9
        <id property="id" column="creator_id"/>
-
 
10
        <result property="name" column="creator_name"/>
-
 
11
        <result property="emailId" column="creator_emailId"/>
-
 
12
        <result property="password" column="creator_password"/>
-
 
13
        <result property="managerId" column="creator_managerId"/>
-
 
14
    </association>
-
 
15
    <association property="ticketAssignee" column="ticketAssigneeId" javaType="agent">
-
 
16
        <id property="id" column="ticketAssignee_id"/>
-
 
17
        <result property="name" column="ticketAssignee_name"/>
-
 
18
        <result property="emailId" column="ticketAssignee_emailId"/>
-
 
19
        <result property="password" column="ticketAssignee_password"/>
-
 
20
        <result property="managerId" column="ticketAssignee_managerId"/>
-
 
21
    </association>
-
 
22
  </resultMap>
8
  </resultMap>
23
 
9
 
24
  <insert id="insertActivity" parameterType="activity" useGeneratedKeys="true" keyProperty="id">
10
  <insert id="insertActivity" parameterType="activity" useGeneratedKeys="true" keyProperty="id">
25
    INSERT INTO activity
11
    INSERT INTO activity
26
      (customerId, ticketAssigneeId, description, ticketId, creatorId, type, creationTimestamp,
12
      (customerId, ticketAssigneeId, description, ticketId, creatorId, type, creationTimestamp,
Line 31... Line 17...
31
       #{ticketPriority}, #{ticketStatus}, #{ticketCategory}, #{ticketDescription}, #{userEmailId},
17
       #{ticketPriority}, #{ticketStatus}, #{ticketCategory}, #{ticketDescription}, #{userEmailId},
32
       #{customerMobileNumber}, #{isRead}, #{customerEmailId}, #{customerName})
18
       #{customerMobileNumber}, #{isRead}, #{customerEmailId}, #{customerName})
33
  </insert>
19
  </insert>
34
  
20
  
35
  <select id="getActivities" parameterType="searchFilter" resultType="activity">
21
  <select id="getActivities" parameterType="searchFilter" resultType="activity">
36
    SELECT a.*,
22
    SELECT *
37
    c.id AS creator_id,
-
 
38
    c.name AS creator_name,
-
 
39
    c.emailId AS creator_emailId,
-
 
40
    c.password AS creator_password,
-
 
41
    c.managerId AS creator_managerId,
-
 
42
    t.id AS ticketAssignee_id,
-
 
43
    t.name AS ticketAssignee_name,
-
 
44
    t.emailId AS ticketAssignee_emailId,
-
 
45
    t.password AS ticketAssignee_password,
-
 
46
    t.managerId AS ticketAssignee_managerId
-
 
47
    FROM activity a
23
    FROM activity
48
    LEFT JOIN agent c
-
 
49
        ON (c.id = a.creatorId)
-
 
50
    LEFT JOIN agent t
-
 
51
        ON (t.id = a.ticketAssigneeId)
-
 
52
    <where>
24
    <where>
53
    <if test="ticketId != null">
25
    <if test="ticketId != null">
54
        AND a.ticketId = #{ticketId}
26
        AND ticketId = #{ticketId}
55
    </if>
27
    </if>
56
    <if test="activityId != null">
28
    <if test="activityId != null">
57
        AND a.id = #{activityId}
29
        AND id = #{activityId}
58
    </if>
30
    </if>
59
    <if test="activityCreatorIds != null">
31
    <if test="activityCreatorIds != null">
60
        AND a.creatorId IN 
32
        AND creatorId IN 
61
        <foreach collection="activityCreatorIds" item="activityCreatorId"
33
        <foreach collection="activityCreatorIds" item="activityCreatorId"
62
                 index="index" open="(" close=")" separator=",">
34
                 index="index" open="(" close=")" separator=",">
63
            #{activityCreatorId}
35
            #{activityCreatorId}
64
        </foreach>
36
        </foreach>
65
    </if>
37
    </if>
66
    <if test="customerId != null">
38
    <if test="customerId != null">
67
        AND a.customerId = #{customerId}
39
        AND customerId = #{customerId}
68
    </if>
40
    </if>
69
    <if test="startTimestamp != null">
41
    <if test="startTimestamp != null">
70
        AND a.creationTimestamp &gt; #{startTimestamp}
42
        AND creationTimestamp &gt; #{startTimestamp}
71
    </if>
43
    </if>
72
    <if test="endTimestamp != null">
44
    <if test="endTimestamp != null">
73
        AND a.creationTimestamp &lt; #{endTimestamp}
45
        AND creationTimestamp &lt; #{endTimestamp}
74
    </if>
46
    </if>
75
    <if test="customerEmailId != null">
47
    <if test="customerEmailId != null">
76
        AND a.customerEmailId = #{customerEmailId}
48
        AND customerEmailId = #{customerEmailId}
77
    </if>
49
    </if>
78
    <if test="customerMobileNumber != null">
50
    <if test="customerMobileNumber != null">
79
        AND a.customerMobileNumber = #{customerMobileNumber}
51
        AND customerMobileNumber = #{customerMobileNumber}
80
    </if>
52
    </if>
81
    <if test="isActivityRead != null">
53
    <if test="isActivityRead != null">
82
        AND a.isRead = #{isActivityRead}
54
        AND isRead = #{isActivityRead}
-
 
55
    </if>
-
 
56
    <if test="activityType != null">
-
 
57
        AND type = #{activityType}
83
    </if>
58
    </if>
84
    </where>
59
    </where>
85
    ORDER BY a.creationTimestamp DESC
60
    ORDER BY creationTimestamp DESC
86
  </select>
61
  </select>
87
 
62
 
88
  <update id="markAsRead" parameterType="long">
63
  <update id="markAsRead" parameterType="long">
89
    UPDATE activity
64
    UPDATE activity
90
    SET isRead = 1
65
    SET isRead = 1