blob: e2fd69ffc400c1641c68b89a2b0ca15bc6305d82 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.apache.shenyu.admin.mapper.DataPermissionMapper">
<resultMap id="BaseResultMap" type="org.apache.shenyu.admin.model.entity.DataPermissionDO">
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="date_created" jdbcType="TIMESTAMP" property="dateCreated"/>
<result column="date_updated" jdbcType="TIMESTAMP" property="dateUpdated"/>
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
<result column="data_type" jdbcType="INTEGER" property="dataType"/>
<result column="data_id" jdbcType="VARCHAR" property="dataId"/>
</resultMap>
<sql id="Base_Column_List">
id,
date_created,
date_updated,
user_id,
data_id,
data_type
</sql>
<delete id="deleteByUniqueKey">
DELETE FROM data_permission
WHERE data_id = #{dataId, jdbcType=VARCHAR}
AND user_id = #{userId,jdbcType=VARCHAR}
AND data_type = #{dataType,jdbcType=INTEGER}
</delete>
<delete id="deleteByDataIdsAndUserId" parameterType="java.util.List">
DELETE FROM data_permission
WHERE data_id
IN <foreach item="id" collection="list" open="(" separator="," close=")">
#{id,jdbcType=VARCHAR}
</foreach>
AND user_id = #{userId, jdbcType=VARCHAR}
AND data_type = #{dataType,jdbcType=VARCHAR}
</delete>
<delete id="deleteByUserId">
DELETE FROM data_permission
WHERE user_id = #{userId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByUserIdList">
DELETE FROM data_permission
WHERE user_id
IN <foreach collection="userIdList" index="index" item="userId" open="(" separator="," close=")">
#{userId,jdbcType=VARCHAR}
</foreach>
</delete>
<delete id="deleteByDataId">
DELETE FROM data_permission
WHERE data_id = #{dataId,jdbcType=VARCHAR}
</delete>
<delete id="deleteByDataIdList">
DELETE FROM data_permission
WHERE data_id
IN <foreach item="dataId" collection="dataIdList" open="(" separator="," close=")">
#{dataId,jdbcType=VARCHAR}
</foreach>
</delete>
<select id="listByUserId" resultMap="BaseResultMap">
SELECT id,
user_id,
data_type,
data_id
FROM data_permission
WHERE user_id = #{userId,jdbcType=VARCHAR}
</select>
<select id="selectDataIds" resultType="java.lang.String">
SELECT data_id
FROM data_permission
WHERE user_id = #{userId,jdbcType=VARCHAR}
AND data_type = #{dataType,jdbcType=INTEGER}
AND data_id IN
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id,jdbcType=VARCHAR}
</foreach>
</select>
<select id="findOneByUniqueKey" resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM data_permission
WHERE data_id = #{dataId,jdbcType=VARCHAR}
AND user_id = #{userId,jdbcType=VARCHAR}
AND data_type = #{dataType,jdbcType=INTEGER}
</select>
<select id="existed" resultType="java.lang.Boolean">
SELECT true
FROM data_permission
WHERE user_id = #{userId,jdbcType=VARCHAR}
LIMIT 1
</select>
<insert id="insertSelective" parameterType="org.apache.shenyu.admin.model.entity.DataPermissionDO">
INSERT INTO data_permission
<trim prefix="(" suffix=")" suffixOverrides=",">
id,
<if test="dateCreated != null">
date_created,
</if>
<if test="dateUpdated != null">
date_updated,
</if>
<if test="userId != null">
user_id,
</if>
<if test="dataId != null">
data_id,
</if>
<if test="dataType != null">
data_type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
#{id,jdbcType=VARCHAR},
<if test="dateCreated != null">
#{dateCreated,jdbcType=TIMESTAMP},
</if>
<if test="dateUpdated != null">
#{dateUpdated,jdbcType=TIMESTAMP},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="dataId != null">
#{dataId,jdbcType=VARCHAR},
</if>
<if test="dataType != null">
#{dataType,jdbcType=INTEGER},
</if>
</trim>
</insert>
<insert id="insertBatch">
INSERT INTO data_permission (id,
user_id,
data_id,
data_type)
VALUES
<foreach collection="dataPermissionList" item="dataPermission" separator=",">
(
#{dataPermission.id,jdbcType=VARCHAR},
#{dataPermission.userId,jdbcType=VARCHAR},
#{dataPermission.dataId,jdbcType=VARCHAR},
#{dataPermission.dataType,jdbcType=INTEGER}
)
</foreach>
</insert>
</mapper>