aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db/src/main/resources/org/sonar/db/user
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-db/src/main/resources/org/sonar/db/user')
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/user/UserTokenMapper.xml42
1 files changed, 42 insertions, 0 deletions
diff --git a/sonar-db/src/main/resources/org/sonar/db/user/UserTokenMapper.xml b/sonar-db/src/main/resources/org/sonar/db/user/UserTokenMapper.xml
new file mode 100644
index 00000000000..b1bcf5d0709
--- /dev/null
+++ b/sonar-db/src/main/resources/org/sonar/db/user/UserTokenMapper.xml
@@ -0,0 +1,42 @@
+<?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="org.sonar.db.user.UserTokenMapper">
+
+ <sql id="userTokensColumns">
+ t.login as "login",
+ t.name as "name",
+ t.token_hash as "tokenHash",
+ t.created_at as "createdAt"
+ </sql>
+
+ <insert id="insert" parameterType="UserToken" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
+ INSERT INTO user_tokens (login, name, token_hash, created_at)
+ VALUES (#{login,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{tokenHash,jdbcType=VARCHAR}, #{createdAt,jdbcType=BIGINT})
+ </insert>
+
+ <select id="selectByTokenHash" parameterType="String" resultType="UserToken">
+ SELECT
+ <include refid="userTokensColumns"/>
+ FROM user_tokens t
+ WHERE t.token_hash=#{tokenHash}
+ </select>
+
+ <select id="selectByLoginAndName" parameterType="map" resultType="UserToken">
+ SELECT
+ <include refid="userTokensColumns"/>
+ FROM user_tokens t
+ WHERE t.login=#{login} and t.name=#{name}
+ </select>
+
+ <select id="selectByLogin" parameterType="map" resultType="UserToken">
+ SELECT
+ <include refid="userTokensColumns"/>
+ FROM user_tokens t
+ WHERE t.login=#{login}
+ </select>
+
+ <delete id="deleteByLogin">
+ DELETE FROM user_tokens WHERE login=#{login}
+ </delete>
+</mapper>