<mapper namespace="org.sonar.db.user.RoleMapper">
<select id="selectComponentIdsByPermissionAndUserId" parameterType="map" resultType="long">
- select ur.resource_id
- from user_roles ur
- <where>
- and ur.user_id = #{userId,jdbcType=INTEGER}
+ select
+ ur.resource_id
+ from
+ user_roles ur
+ where
+ ur.user_id = #{userId,jdbcType=INTEGER}
and ur.role = #{permission,jdbcType=VARCHAR}
- and ur.resource_id IS NOT NULL
- </where>
- UNION
- select gr.resource_id
- from group_roles gr
- inner join groups_users gu on gr.group_id=gu.group_id
- <where>
- and gr.role = #{permission,jdbcType=VARCHAR}
+ and ur.resource_id is not null
+ union
+ select
+ gr.resource_id
+ from
+ group_roles gr
+ inner join groups_users gu on
+ gr.group_id=gu.group_id
+ where
+ gr.role = #{permission,jdbcType=VARCHAR}
and gr.resource_id is not null
and gu.user_id=#{userId,jdbcType=INTEGER}
- </where>
- ORDER by resource_id
+ order by
+ resource_id
</select>
<delete id="deleteGroupRolesByGroupId" parameterType="int">
- delete from group_roles where group_id=#{id,jdbcType=INTEGER}
+ delete from
+ group_roles
+ where
+ group_id=#{id,jdbcType=INTEGER}
</delete>
</mapper>