Subversion Repositories SmartDukaan

Rev

Rev 5286 | 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.AgentMapper">
6
  <resultMap type="agent" id="agentResult">
7
    <id property="id" column="id"/>
8
  </resultMap>
3088 mandeep.dh 9
 
4793 amar.kumar 10
	<insert id="insertAgent" parameterType="agent" useGeneratedKeys="true" keyProperty="id">
11
    INSERT INTO agent
16244 manish.sha 12
      ( name, emailId, password, managerId, is_active, is_pmCrmUser, is_allAssignable)
4793 amar.kumar 13
    VALUES
16244 manish.sha 14
      (#{name}, #{emailId},  #{password}, #{managerId}, #{is_active}, #{is_pmCrmUser}, #{is_allAssignable})
4793 amar.kumar 15
  </insert>
16
 
17
	<insert id="insertAgentRole" parameterType="map">
18
	INSERT INTO user_roles
19
		(agentId, role_name)
20
	VALUES 
21
		(#{id}, #{agentRole})
22
	</insert>
23
 
3390 mandeep.dh 24
  <select id="getAgents" parameterType="searchFilter" resultType="agent">
25
    SELECT *
26
    FROM agent a
4793 amar.kumar 27
    WHERE is_active = 1
3390 mandeep.dh 28
        <if test="agentId != null">
29
            AND a.id = #{agentId}
30
        </if>
31
        <if test="agentEmailId != null">
32
            AND a.emailId = #{agentEmailId}
33
        </if>
3088 mandeep.dh 34
  </select>
5286 amar.kumar 35
 
36
  <select id="getInactiveAgents" parameterType="searchFilter" resultType="agent">
37
    SELECT *
38
    FROM agent a
39
    WHERE is_active = 0
40
        <if test="agentId != null">
41
            AND a.id = #{agentId}
42
        </if>
43
        <if test="agentEmailId != null">
44
            AND a.emailId = #{agentEmailId}
45
        </if>
46
  </select>  
3088 mandeep.dh 47
 
48
  <select id="getRoleNamesForAgent" parameterType="String" resultType="String">
49
    SELECT role_name 
50
    FROM user_roles a
51
    JOIN agent b
52
        ON (b.id = a.agentId)
53
    WHERE b.emailId = #{emailId}
54
  </select>
55
 
56
  <select id="getPermissionsForRoleName" parameterType="String" resultType="String">
57
    SELECT permission
58
    FROM roles_permissions
59
    WHERE role_name = #{role_name}
60
  </select>
61
 
62
  <update id="updatePasswordForAgent" parameterType="map">
63
    UPDATE agent
64
    SET password = #{password}
65
    WHERE emailId = #{emailId}
66
  </update>
3390 mandeep.dh 67
 
3339 mandeep.dh 68
  <select id="getLastEmailProcessedTimestamp" resultType="java.util.Date">
69
    SELECT lastUpdatedTimestamp from emailStatus
70
  </select>
71
 
72
  <update id="updateLastEmailProcessedTimestamp" parameterType="java.util.Date">
73
    UPDATE emailStatus
74
    SET lastUpdatedTimestamp = #{timestamp} 
75
  </update>
4793 amar.kumar 76
 
77
  <update id="changeAgentStatus" parameterType="map">
78
  	UPDATE agent
79
  	SET is_active = #{status}
80
  	WHERE emailId = #{emailId}
81
  </update>
5168 amar.kumar 82
 
83
  <update id="removeAgentRoles" parameterType="long">
84
  	DELETE FROM user_roles
85
  	WHERE agentId = #{id}
86
  </update>  
4793 amar.kumar 87
 
88
 
3024 mandeep.dh 89
</mapper>