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 LIMIT #{pagination.pageSize,jdbcType=INTEGER}
45 OFFSET #{pagination.offset,jdbcType=INTEGER}
48 <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchUserMembershipDto"
51 select row_number() over(order by u.name asc) as number,
52 u.uuid as userUuid, u.name as name, qup.uuid as uuid
53 <include refid="sqlSelectByQuery"/>
56 query.number between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
57 order by query.name asc
60 <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchUserMembershipDto"
63 select rownum as rn, t.* from (
64 select u.uuid as userUuid, u.name as name, qup.uuid as uuid
65 <include refid="sqlSelectByQuery"/>
70 t.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
73 <sql id="sqlSelectByQuery">
75 LEFT JOIN qgate_user_permissions qup ON qup.user_uuid=u.uuid AND
76 qup.quality_gate_uuid=#{query.qualityGateUuid, jdbcType=VARCHAR}
79 <when test="query.getMembership() == 'IN'">
80 AND qup.uuid IS NOT NULL
82 <when test="query.getMembership() == 'OUT'">
86 <if test="query.getQuery() != null">
88 lower(u.name) like #{query.querySqlLowercase} ESCAPE '/'
89 or u.login like #{query.querySql} ESCAPE '/')
96 delete from qgate_user_permissions
97 where quality_gate_uuid = #{qualityGateUuid}
98 and user_uuid = #{userUuid}
101 <delete id="deleteByUser">
102 delete from qgate_user_permissions
103 where user_uuid = #{userUuid}
106 <delete id="deleteByQualityGate">
107 delete from qgate_user_permissions
108 where quality_gate_uuid = #{qualityGateUuid, jdbcType=VARCHAR}