org.sonar.db.user.UserMapper.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-db Show documentation
Show all versions of sonar-db Show documentation
Create and request SonarQube schema
<?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.UserMapper"> <sql id="userColumns"> u.id as id, u.login as login, u.name as name, u.email as email, u.active as "active", u.scm_accounts as "scmAccounts", u.salt as "salt", u.crypted_password as "cryptedPassword", u.external_identity as "externalIdentity", u.external_identity_provider as "externalIdentityProvider", u.user_local as "local", u.remember_token as "rememberToken", u.remember_token_expires_at as "rememberTokenExpiresAt", u.created_at as "createdAt", u.updated_at as "updatedAt" </sql> <select id="selectByLogin" parameterType="String" resultType="User"> SELECT <include refid="userColumns"/> FROM users u WHERE u.login=#{login} </select> <select id="selectNullableByScmAccountOrLoginOrEmail" parameterType="map" resultType="User"> SELECT <include refid="userColumns"/> FROM users u WHERE u.login=#{scmAccount} OR u.email=#{scmAccount} OR u.scm_accounts like #{likeScmAccount} </select> <select id="selectUser" parameterType="long" resultType="User"> SELECT <include refid="userColumns"/> FROM users u WHERE u.id=#{id} </select> <select id="selectUserByLogin" parameterType="string" resultType="User"> SELECT <include refid="userColumns"/> FROM users u WHERE u.login=#{id} AND u.active=${_true} </select> <select id="selectByLogins" parameterType="string" resultType="User"> SELECT <include refid="userColumns"/> FROM users u WHERE u.login in <foreach collection="list" open="(" close=")" item="login" separator=","> #{login} </foreach> </select> <select id="selectByIds" parameterType="string" resultType="User"> SELECT <include refid="userColumns"/> FROM users u WHERE u.id in <foreach collection="ids" open="(" close=")" item="id" separator=","> #{id} </foreach> </select> <select id="selectUsers" parameterType="map" resultType="User"> SELECT <include refid="userColumns"/> FROM users u <where> <if test="logins != null and logins.size() > 0"> u.login IN <foreach item="login" index="index" collection="logins" open="(" separator="," close=")"> #{login} </foreach> </if> <if test="includeDeactivated==false"> AND u.active=${_true} </if> <if test="searchText != null"> AND (u.login LIKE #{searchTextSql} ESCAPE '/' OR u.name LIKE #{searchTextSql} ESCAPE '/') </if> </where> ORDER BY u.name </select> <select id="countByEmail" parameterType="String" resultType="long"> SELECT count(1) FROM users u where lower(u.email)=#{email} AND u.active=${_true} </select> <delete id="removeUserFromGroups" parameterType="long"> DELETE FROM groups_users WHERE user_id=#{id} </delete> <delete id="deleteUserRoles" parameterType="long"> DELETE FROM user_roles WHERE user_id=#{id} </delete> <delete id="deleteUserProperties" parameterType="long"> DELETE FROM properties WHERE user_id=#{id} </delete> <delete id="deleteUnsharedUserDashboards" parameterType="long"> DELETE FROM dashboards WHERE user_id=#{id} and shared <> ${_true} </delete> <delete id="deleteUserActiveDashboards" parameterType="long"> DELETE FROM active_dashboards WHERE user_id=#{id} </delete> <delete id="deleteUnsharedUserMeasureFilters" parameterType="long"> DELETE FROM measure_filters WHERE user_id=#{id} and shared <> ${_true} </delete> <delete id="deleteUserMeasureFilterFavourites" parameterType="long"> DELETE FROM measure_filter_favourites WHERE user_id=#{id} </delete> <delete id="deleteUnsharedUserIssueFilters" parameterType="String"> DELETE FROM issue_filters WHERE user_login=#{id} and shared <> ${_true} </delete> <delete id="deleteUserIssueFilterFavourites" parameterType="String"> DELETE FROM issue_filter_favourites WHERE user_login=#{id} </delete> <update id="deactivateUser" parameterType="long"> UPDATE users SET active=${_false}, email=null, scm_accounts=null, external_identity=null, external_identity_provider=null, salt=null, crypted_password=null, remember_token=null, remember_token_expires_at=null, updated_at=#{now,jdbcType=BIGINT} WHERE id=#{id} </update> <insert id="insert" parameterType="User" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> INSERT INTO users (login, name, email, active, scm_accounts, external_identity, external_identity_provider, user_local, salt, crypted_password, remember_token, remember_token_expires_at, created_at, updated_at) VALUES (#{login,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{active,jdbcType=BOOLEAN}, #{scmAccounts,jdbcType=VARCHAR}, #{externalIdentity,jdbcType=VARCHAR}, #{externalIdentityProvider,jdbcType=VARCHAR}, #{local,jdbcType=BOOLEAN}, #{salt,jdbcType=VARCHAR}, #{cryptedPassword,jdbcType=VARCHAR}, #{rememberToken,jdbcType=VARCHAR}, #{rememberTokenExpiresAt,jdbcType=TIMESTAMP}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}) </insert> <insert id="update" parameterType="User" useGeneratedKeys="false"> UPDATE users set name=#{name,jdbcType=VARCHAR}, email=#{email,jdbcType=VARCHAR}, active=#{active,jdbcType=BOOLEAN}, scm_accounts=#{scmAccounts,jdbcType=VARCHAR}, external_identity=#{externalIdentity,jdbcType=VARCHAR}, external_identity_provider=#{externalIdentityProvider,jdbcType=VARCHAR}, user_local=#{local,jdbcType=BOOLEAN}, salt=#{salt,jdbcType=VARCHAR}, crypted_password=#{cryptedPassword,jdbcType=BIGINT}, remember_token=#{rememberToken,jdbcType=VARCHAR}, remember_token_expires_at=#{rememberTokenExpiresAt,jdbcType=TIMESTAMP}, updated_at=#{updatedAt,jdbcType=BIGINT} WHERE login = #{login} </insert> </mapper>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy