| <?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.PermissionMapper"> |
| <resultMap id="BaseResultMap" type="org.apache.shenyu.admin.model.entity.PermissionDO"> |
| <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="object_id" jdbcType="VARCHAR" property="objectId"/> |
| <result column="resource_id" jdbcType="VARCHAR" property="resourceId"/> |
| </resultMap> |
| |
| <sql id="Base_Column_List"> |
| id, |
| date_created, |
| date_updated, |
| object_id, |
| resource_id |
| </sql> |
| |
| <select id="selectById" parameterType="java.lang.String" resultMap="BaseResultMap"> |
| SELECT |
| <include refid="Base_Column_List"/> |
| FROM permission |
| WHERE id = #{id,jdbcType=VARCHAR} |
| </select> |
| |
| <select id="findByObjectId" parameterType="java.lang.String" resultMap="BaseResultMap"> |
| SELECT |
| <include refid="Base_Column_List"/> |
| FROM permission |
| WHERE object_id = #{objectId,jdbcType=VARCHAR} |
| </select> |
| |
| <select id="findByObjectIds" parameterType="java.util.List" resultMap="BaseResultMap"> |
| SELECT |
| <include refid="Base_Column_List"/> |
| FROM permission |
| WHERE object_id |
| IN <foreach item="objectId" collection="list" open="(" separator="," close=")"> |
| #{objectId, jdbcType=VARCHAR} |
| </foreach> |
| </select> |
| |
| <insert id="insert" parameterType="org.apache.shenyu.admin.model.entity.PermissionDO"> |
| INSERT INTO permission |
| (id, |
| date_created, |
| date_updated, |
| object_id, |
| resource_id) |
| VALUES |
| (#{id,jdbcType=VARCHAR}, |
| #{dateCreated,jdbcType=TIMESTAMP}, |
| #{dateUpdated,jdbcType=TIMESTAMP}, |
| #{objectId,jdbcType=VARCHAR}, |
| #{resourceId,jdbcType=VARCHAR}) |
| </insert> |
| |
| <insert id="insertSelective" parameterType="org.apache.shenyu.admin.model.entity.PermissionDO"> |
| INSERT INTO permission |
| <trim prefix="(" suffix=")" suffixOverrides=","> |
| id, |
| <if test="dateCreated != null"> |
| date_created, |
| </if> |
| <if test="dateUpdated != null"> |
| date_updated, |
| </if> |
| <if test="objectId != null"> |
| object_id, |
| </if> |
| <if test="resourceId != null"> |
| resource_id, |
| </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="objectId != null"> |
| #{objectId,jdbcType=VARCHAR}, |
| </if> |
| <if test="resourceId != null"> |
| #{resourceId,jdbcType=VARCHAR}, |
| </if> |
| </trim> |
| </insert> |
| |
| <insert id="insertBatch"> |
| INSERT INTO permission |
| (id, |
| object_id, |
| resource_id) |
| VALUES |
| <foreach collection="permissionDOList" item="permissionDO" separator=","> |
| (#{permissionDO.id,jdbcType=VARCHAR}, |
| #{permissionDO.objectId,jdbcType=VARCHAR}, |
| #{permissionDO.resourceId,jdbcType=VARCHAR}) |
| </foreach> |
| </insert> |
| |
| <delete id="delete" parameterType="java.lang.String"> |
| DELETE FROM permission |
| WHERE id = #{id,jdbcType=VARCHAR} |
| </delete> |
| |
| <delete id="deleteByObjectIdAndResourceId" parameterType="org.apache.shenyu.admin.model.query.PermissionQuery"> |
| DELETE FROM permission |
| WHERE object_id = #{objectId, jdbcType=VARCHAR} |
| AND resource_id = #{resourceId, jdbcType=VARCHAR} |
| </delete> |
| |
| <delete id="deleteByResourceId" parameterType="java.util.List"> |
| DELETE FROM permission |
| WHERE resource_id IN |
| <foreach item="resourceId" collection="list" open="(" separator="," close=")"> |
| #{resourceId, jdbcType=VARCHAR} |
| </foreach> |
| </delete> |
| |
| <delete id="deleteByObjectIds" parameterType="java.util.List"> |
| DELETE FROM permission |
| WHERE object_id IN |
| <foreach item="objectId" collection="list" open="(" separator="," close=")"> |
| #{objectId, jdbcType=VARCHAR} |
| </foreach> |
| </delete> |
| </mapper> |