| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.prac.simple.mapper.PermissionMapper">
- <resultMap id="BaseResultMap" type="Permission">
- <id column="id" jdbcType="VARCHAR" property="id" />
- <result column="pid" jdbcType="VARCHAR" property="pid" />
- <result column="title" jdbcType="VARCHAR" property="title" />
- <result column="type" jdbcType="CHAR" property="type" />
- <result column="url" jdbcType="VARCHAR" property="url" />
- <result column="description" jdbcType="VARCHAR"
- property="description" />
- <result column="orders" jdbcType="INTEGER" property="orders" />
- </resultMap>
- <sql id="Base_Column_List">
- id, pid, title, type, url, description, orders
- </sql>
- <select id="selectByPrimaryKey" parameterType="java.lang.String"
- resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from permission
- where id = #{id,jdbcType=VARCHAR}
- </select>
- <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
- delete from permission
- where id = #{id,jdbcType=VARCHAR}
- </delete>
- <insert id="insert" parameterType="Permission">
- insert into permission (id, pid, title,
- type, url, description,
- orders)
- values (#{id,jdbcType=VARCHAR}, #{pid,jdbcType=VARCHAR},
- #{title,jdbcType=VARCHAR},
- #{type,jdbcType=CHAR}, #{url,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
- #{orders,jdbcType=INTEGER})
- </insert>
- <insert id="insertSelective" parameterType="Permission">
- insert into permission
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id != null">
- id,
- </if>
- <if test="pid != null">
- pid,
- </if>
- <if test="title != null">
- title,
- </if>
- <if test="type != null">
- type,
- </if>
- <if test="url != null">
- url,
- </if>
- <if test="description != null">
- description,
- </if>
- <if test="orders != null">
- orders,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id != null">
- #{id,jdbcType=VARCHAR},
- </if>
- <if test="pid != null">
- #{pid,jdbcType=VARCHAR},
- </if>
- <if test="title != null">
- #{title,jdbcType=VARCHAR},
- </if>
- <if test="type != null">
- #{type,jdbcType=CHAR},
- </if>
- <if test="url != null">
- #{url,jdbcType=VARCHAR},
- </if>
- <if test="description != null">
- #{description,jdbcType=VARCHAR},
- </if>
- <if test="orders != null">
- #{orders,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <update id="updateByPrimaryKeySelective"
- parameterType="Permission">
- update permission
- <set>
- <if test="pid != null">
- pid = #{pid,jdbcType=VARCHAR},
- </if>
- <if test="title != null">
- title = #{title,jdbcType=VARCHAR},
- </if>
- <if test="type != null">
- type = #{type,jdbcType=CHAR},
- </if>
- <if test="url != null">
- url = #{url,jdbcType=VARCHAR},
- </if>
- <if test="description != null">
- description = #{description,jdbcType=VARCHAR},
- </if>
- <if test="orders != null">
- orders = #{orders,jdbcType=INTEGER},
- </if>
- </set>
- where id = #{id,jdbcType=VARCHAR}
- </update>
- <update id="updateByPrimaryKey" parameterType="Permission">
- update permission
- set pid = #{pid,jdbcType=VARCHAR},
- title = #{title,jdbcType=VARCHAR},
- type = #{type,jdbcType=CHAR},
- url = #{url,jdbcType=VARCHAR},
- description = #{description,jdbcType=VARCHAR},
- orders = #{orders,jdbcType=INTEGER}
- where id = #{id,jdbcType=VARCHAR}
- </update>
- <select id="selectPermission" resultMap="BaseResultMap" parameterType="PermissionReq">
- select
- <include refid="Base_Column_List" />
- from permission
- <where>
- <if test="pid != null and pid != ''">
- pid = #{pid}
- </if>
- </where>
- order by pid,orders
- </select>
- <select id="selectAllMenu" resultMap="BaseResultMap" >
- select
- <include refid="Base_Column_List" />
- from permission
- where type <![CDATA[<>]]> '03'
- </select>
- <select id="selectRolePermissions" resultType="RolePermission">
- select p.url, r.id roleId
- from role_permission rp
- inner join permission p on rp.permission_id = p.id
- inner join role r on rp.role_id=r.id
- </select>
- <select id="selectPermissionByUserId"
- parameterType="java.lang.String" resultMap="BaseResultMap">
- select distinct p.*
- from permission p
- inner join role_permission rp on rp.permission_id = p.id
- inner join user_role ur on ur.role_id=rp.role_id
- where ur.user_id=#{userId}
- </select>
- <select id="selectPermissionByRoleId"
- parameterType="java.lang.String" resultMap="BaseResultMap">
- select p.*
- from permission p
- inner join role_permission rp on rp.permission_id = p.id
- where rp.role_id=#{roleId}
- </select>
- <select id="selectPermissionByUrl"
- parameterType="java.lang.String" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from permission
- where url=#{url} limit 1
- </select>
- <select id="selectPermissionByTitle"
- parameterType="java.lang.String" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from permission
- where title=#{title} limit 1
- </select>
- <select id="selectExistPermissionByUrl"
- parameterType="java.lang.String" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from permission
- where url=#{url} and id <![CDATA[<>]]>
- #{id} limit 1
- </select>
- <select id="selectChildrenPermission"
- parameterType="java.lang.String" resultMap="BaseResultMap">
- select
- <include refid="Base_Column_List" />
- from permission
- where pid=#{id}
- </select>
- <select id="selectAllPermissionUrl" parameterType="java.lang.String" resultType="java.lang.String" >
- select url from permission where url is not null and url <![CDATA[<>]]> ''
- </select>
- <delete id="batchDeletePermission" parameterType="list">
- delete from permission where id userId
- <foreach collection="list" item="id" open="(" close=")"
- separator=",">
- #{id,jdbcType=INTEGER}
- </foreach>
- </delete>
- </mapper>
|