Subversion Repositories SmartDukaan

Rev

Rev 3390 | Rev 5168 | 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.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
12
      ( name, emailId, password, managerId, is_active)
13
    VALUES
14
      (#{name}, #{emailId},  #{password}, #{managerId}, #{is_active})
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>
35
 
36
  <select id="getRoleNamesForAgent" parameterType="String" resultType="String">
37
    SELECT role_name 
38
    FROM user_roles a
39
    JOIN agent b
40
        ON (b.id = a.agentId)
41
    WHERE b.emailId = #{emailId}
42
  </select>
43
 
44
  <select id="getPermissionsForRoleName" parameterType="String" resultType="String">
45
    SELECT permission
46
    FROM roles_permissions
47
    WHERE role_name = #{role_name}
48
  </select>
49
 
50
  <update id="updatePasswordForAgent" parameterType="map">
51
    UPDATE agent
52
    SET password = #{password}
53
    WHERE emailId = #{emailId}
54
  </update>
3390 mandeep.dh 55
 
3339 mandeep.dh 56
  <select id="getLastEmailProcessedTimestamp" resultType="java.util.Date">
57
    SELECT lastUpdatedTimestamp from emailStatus
58
  </select>
59
 
60
  <update id="updateLastEmailProcessedTimestamp" parameterType="java.util.Date">
61
    UPDATE emailStatus
62
    SET lastUpdatedTimestamp = #{timestamp} 
63
  </update>
4793 amar.kumar 64
 
65
  <update id="changeAgentStatus" parameterType="map">
66
  	UPDATE agent
67
  	SET is_active = #{status}
68
  	WHERE emailId = #{emailId}
69
  </update>
70
 
71
 
3024 mandeep.dh 72
</mapper>