Subversion Repositories SmartDukaan

Rev

Rev 3339 | Rev 4793 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="in.shop2020.crm.persistence.AgentMapper">
  <resultMap type="agent" id="agentResult">
    <id property="id" column="id"/>
  </resultMap>

  <select id="getAgents" parameterType="searchFilter" resultType="agent">
    SELECT *
    FROM agent a
    <where>
        <if test="agentId != null">
            AND a.id = #{agentId}
        </if>
        <if test="agentEmailId != null">
            AND a.emailId = #{agentEmailId}
        </if>
    </where>
  </select>

  <select id="getRoleNamesForAgent" parameterType="String" resultType="String">
    SELECT role_name 
    FROM user_roles a
    JOIN agent b
        ON (b.id = a.agentId)
    WHERE b.emailId = #{emailId}
  </select>

  <select id="getPermissionsForRoleName" parameterType="String" resultType="String">
    SELECT permission
    FROM roles_permissions
    WHERE role_name = #{role_name}
  </select>
  
  <update id="updatePasswordForAgent" parameterType="map">
    UPDATE agent
    SET password = #{password}
    WHERE emailId = #{emailId}
  </update>

  <select id="getLastEmailProcessedTimestamp" resultType="java.util.Date">
    SELECT lastUpdatedTimestamp from emailStatus
  </select>

  <update id="updateLastEmailProcessedTimestamp" parameterType="java.util.Date">
    UPDATE emailStatus
    SET lastUpdatedTimestamp = #{timestamp} 
  </update>
</mapper>