org.sonar.db.user.GroupMapper.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-db-dao Show documentation
Show all versions of sonar-db-dao Show documentation
Open source platform for continuous inspection of code quality
The newest version!
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd"> <mapper namespace="org.sonar.db.user.GroupMapper"> <sql id="groupColumns"> g.id as id, g.name as name, g.description as description, g.organization_uuid as organizationUuid, g.created_at as "createdAt", g.updated_at as "updatedAt" </sql> <select id="selectByName" parameterType="map" resultType="Group"> select <include refid="groupColumns"/> from groups g where g.organization_uuid = #{organizationUuid,jdbcType=VARCHAR} and g.name = #{name,jdbcType=VARCHAR} </select> <select id="selectByIds" parameterType="int" resultType="Group"> select <include refid="groupColumns"/> from groups g where g.id in <foreach item="id" index="index" collection="ids" open="(" separator="," close=")"> #{id,jdbcType=BIGINT} </foreach> </select> <select id="selectById" parameterType="int" resultType="Group"> SELECT <include refid="groupColumns"/> FROM groups g <where> g.id=#{id,jdbcType=BIGINT} </where> </select> <delete id="deleteById" parameterType="int"> DELETE FROM groups <where> id=#{id,jdbcType=BIGINT} </where> </delete> <delete id="deleteByOrganization" parameterType="String"> delete from groups where organization_uuid=#{organizationUuid,jdbcType=VARCHAR} </delete> <select id="selectByUserLogin" parameterType="string" resultType="Group"> select <include refid="groupColumns"/> from groups g inner join groups_users gu on gu.group_id = g.id inner join users u on u.id = gu.user_id where u.login=#{login,jdbcType=VARCHAR} </select> <select id="selectByNames" parameterType="map" resultType="Group"> select <include refid="groupColumns"/> from groups g where g.organization_uuid = #{organizationUuid,jdbcType=VARCHAR} and g.name in <foreach item="name" index="index" collection="names" open="(" separator="," close=")"> #{name,jdbcType=VARCHAR} </foreach> </select> <insert id="insert" parameterType="Group" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> insert into groups ( organization_uuid, name, description, created_at, updated_at ) values ( #{organizationUuid,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP} ) </insert> <update id="update" parameterType="Group"> UPDATE groups SET name=#{name,jdbcType=VARCHAR}, description=#{description,jdbcType=VARCHAR}, updated_at=#{updatedAt,jdbcType=TIMESTAMP} WHERE id=#{id} </update> <select id="selectByQuery" parameterType="map" resultType="Group"> select <include refid="groupColumns"/> from groups g where organization_uuid = #{organizationUuid,jdbcType=VARCHAR} <if test="query!=null"> and upper(g.name) like #{query,jdbcType=VARCHAR} escape '/' </if> order by upper(g.name) </select> <select id="countByQuery" parameterType="map" resultType="int"> select count(1) from groups g where organization_uuid = #{organizationUuid,jdbcType=VARCHAR} <if test="query!=null"> and upper(g.name) like #{query,jdbcType=VARCHAR} escape '/' </if> </select> <select id="countGroupByOrganizationAndId" parameterType="map" resultType="int"> select count(1) from groups g where g.organization_uuid = #{organizationUuid,jdbcType=VARCHAR} and g.id = #{groupId,jdbcType=INTEGER} </select> <select id="selectByOrganizationUuid" parameterType="map" resultType="Group"> select <include refid="groupColumns"/> from groups g where g.organization_uuid = #{organizationUuid,jdbcType=VARCHAR} order by upper(g.name) </select> </mapper>