You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SessionTokenMapper.xml 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
  3. <mapper namespace="org.sonar.db.user.SessionTokenMapper">
  4. <sql id="columns">
  5. st.uuid as uuid,
  6. st.user_uuid as "userUuid",
  7. st.expiration_date as "expirationDate",
  8. st.created_at as "createdAt",
  9. st.updated_at as "updatedAt"
  10. </sql>
  11. <select id="selectByUuid" parameterType="String" resultType="org.sonar.db.user.SessionTokenDto">
  12. select
  13. <include refid="columns"/>
  14. from session_tokens st
  15. where st.uuid=#{uuid, jdbcType=VARCHAR}
  16. </select>
  17. <insert id="insert" parameterType="Map" useGeneratedKeys="false">
  18. insert into session_tokens
  19. (
  20. uuid,
  21. user_uuid,
  22. expiration_date,
  23. created_at,
  24. updated_at
  25. )
  26. values (
  27. #{dto.uuid, jdbcType=VARCHAR},
  28. #{dto.userUuid, jdbcType=VARCHAR},
  29. #{dto.expirationDate, jdbcType=BIGINT},
  30. #{dto.createdAt, jdbcType=BIGINT},
  31. #{dto.updatedAt, jdbcType=BIGINT}
  32. )
  33. </insert>
  34. <update id="update" parameterType="Map">
  35. update session_tokens set
  36. expiration_date = #{dto.expirationDate, jdbcType=BIGINT},
  37. updated_at = #{dto.updatedAt, jdbcType=BIGINT}
  38. where
  39. uuid = #{dto.uuid, jdbcType=VARCHAR}
  40. </update>
  41. <delete id="deleteByUuid" parameterType="String">
  42. delete from session_tokens where uuid = #{uuid, jdbcType=VARCHAR}
  43. </delete>
  44. <delete id="deleteByUserUuid" parameterType="String">
  45. delete from session_tokens where user_uuid = #{userUuid, jdbcType=VARCHAR}
  46. </delete>
  47. <delete id="deleteExpired" parameterType="Long" >
  48. delete from session_tokens where expiration_date &lt; #{now, jdbcType=BIGINT}
  49. </delete>
  50. </mapper>