123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?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.uuid as uuid,
- g.name as name,
- g.description as description,
- 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.name = #{name,jdbcType=VARCHAR}
- </select>
-
- <select id="selectByUuids" parameterType="String" resultType="Group">
- select
- <include refid="groupColumns"/>
- from groups g
- where g.uuid in
- <foreach item="uuid" index="index" collection="uuids" open="(" separator="," close=")">
- #{uuid,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectByUuid" parameterType="String" resultType="Group">
- SELECT
- <include refid="groupColumns"/>
- FROM groups g
- <where>
- g.uuid=#{uuid,jdbcType=VARCHAR}
- </where>
- </select>
-
- <delete id="deleteByUuid" parameterType="String">
- DELETE FROM groups
- <where>
- uuid=#{uuid,jdbcType=VARCHAR}
- </where>
- </delete>
-
- <select id="selectByUserLogin" parameterType="string" resultType="Group">
- select
- <include refid="groupColumns"/>
- from groups g
- inner join groups_users gu on gu.group_uuid = g.uuid
- inner join users u on u.uuid = gu.user_uuid
- where u.login=#{login,jdbcType=VARCHAR}
- </select>
-
- <select id="selectByNames" parameterType="map" resultType="Group">
- select
- <include refid="groupColumns"/>
- from groups g
- where
- g.name in
- <foreach item="name" index="index" collection="names" open="(" separator="," close=")">
- #{name,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <insert id="insert" parameterType="Group" useGeneratedKeys="false">
- insert into groups (
- uuid,
- name,
- description,
- created_at,
- updated_at
- ) values (
- #{uuid,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 uuid=#{uuid}
- </update>
-
- <select id="selectByQuery" parameterType="map" resultType="Group">
- select
- <include refid="groupColumns"/>
- from groups g
- <if test="query!=null">
- where 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
- <if test="query!=null">
- where upper(g.name) like #{query,jdbcType=VARCHAR} escape '/'
- </if>
- </select>
- </mapper>
|