1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
4 <mapper namespace="org.sonar.db.qualitygate.QualityGateUserPermissionsMapper">
8 qup.user_uuid as "userUuid",
9 qup.quality_gate_uuid as "qualityGateUuid"
12 <select id="selectByQualityGateAndUser" parameterType="String" resultType="org.sonar.db.qualitygate.QualityGateUserPermissionsDto">
14 <include refid="sqlColumns"/>
15 from qgate_user_permissions qup
17 qup.user_uuid = #{userUuid}
18 and qup.quality_gate_uuid = #{qualityGateUuid}
21 <insert id="insert" useGeneratedKeys="false" parameterType="map">
22 insert into qgate_user_permissions(
28 #{dto.uuid, jdbcType=VARCHAR},
29 #{dto.userUuid, jdbcType=VARCHAR},
30 #{dto.qualityGateUuid, jdbcType=VARCHAR},
31 #{now, jdbcType=BIGINT}
35 <select id="countByQuery" resultType="int">
37 <include refid="sqlSelectByQuery"/>
40 <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchUserMembershipDto">
41 SELECT u.uuid as userUuid, u.name as name, qup.uuid as uuid
42 <include refid="sqlSelectByQuery"/>
44 offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
47 <sql id="sqlSelectByQuery">
49 LEFT JOIN qgate_user_permissions qup ON qup.user_uuid=u.uuid AND
50 qup.quality_gate_uuid=#{query.qualityGateUuid, jdbcType=VARCHAR}
53 <when test="query.getMembership() == 'IN'">
54 AND qup.uuid IS NOT NULL
56 <when test="query.getMembership() == 'OUT'">
60 <if test="query.getQuery() != null">
62 lower(u.name) like #{query.querySqlLowercase} ESCAPE '/'
63 or u.login like #{query.querySql} ESCAPE '/')
70 delete from qgate_user_permissions
71 where quality_gate_uuid = #{qualityGateUuid}
72 and user_uuid = #{userUuid}
75 <delete id="deleteByUser">
76 delete from qgate_user_permissions
77 where user_uuid = #{userUuid}
80 <delete id="deleteByQualityGate">
81 delete from qgate_user_permissions
82 where quality_gate_uuid = #{qualityGateUuid, jdbcType=VARCHAR}