| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- <?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.pine.admin.modules.system.dao.SysPermissionDao">
- <!-- 可根据自己的需求,是否要使用 -->
- <resultMap type="com.pine.admin.modules.system.entity.SysPermission" id="sysPermissionMap">
- <result property="id" column="id"/>
- <result property="name" column="name"/>
- <result property="type" column="type"/>
- <result property="url" column="url"/>
- <result property="percode" column="percode"/>
- <result property="parentid" column="parentid"/>
- <result property="parentids" column="parentids"/>
- <result property="sortstring" column="sortstring"/>
- <result property="available" column="available"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- </resultMap>
- <sql id="Base_Column_List">
- id,
- name,
- type,
- url,
- percode,
- parentid,
- parentids,
- sortstring,
- available,
- create_time,
- update_time </sql>
- <!-- 根据Id查询-->
- <select id="selectByPrimaryKey" resultMap="sysPermissionMap" parameterType="java.lang.Integer">
- select
- <include refid="Base_Column_List"/>
- from sys_permission
- where id = #{id,jdbcType=INTEGER}
- </select>
- <!-- 根据Id删除-->
- <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
- delete from sys_permission
- where id = #{id,jdbcType=INTEGER}
- </delete>
- <!-- 插入数据-->
- <insert id="insertSelective" parameterType="com.pine.admin.modules.system.entity.SysPermission"
- useGeneratedKeys="true" keyProperty="id">
- insert into sys_permission
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="id !=null">id,</if>
- <if test="name !=null">name,</if>
- <if test="type !=null">type,</if>
- <if test="url !=null">url,</if>
- <if test="percode !=null">percode,</if>
- <if test="parentid !=null">parentid,</if>
- <if test="parentids !=null">parentids,</if>
- <if test="sortstring !=null">sortstring,</if>
- <if test="available !=null">available,</if>
- <if test="createTime !=null">create_time,</if>
- <if test="updateTime !=null">update_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="id !=null">#{id},</if>
- <if test="name !=null">#{name},</if>
- <if test="type !=null">#{type},</if>
- <if test="url !=null">#{url},</if>
- <if test="percode !=null">#{percode},</if>
- <if test="parentid !=null">#{parentid},</if>
- <if test="parentids !=null">#{parentids},</if>
- <if test="sortstring !=null">#{sortstring},</if>
- <if test="available !=null">#{available},</if>
- <if test="createTime !=null">#{createTime},</if>
- <if test="updateTime !=null">#{updateTime},</if>
- </trim>
- </insert>
- <!-- 更新数据-->
- <update id="updateByPrimaryKeySelective"
- parameterType="com.pine.admin.modules.system.entity.SysPermission">
- update sys_permission
- <set>
- <if test="id != null">id = #{id},</if>
- <if test="name != null">name = #{name},</if>
- <if test="type != null">type = #{type},</if>
- <if test="url != null">url = #{url},</if>
- <if test="percode != null">percode = #{percode},</if>
- <if test="parentid != null">parentid = #{parentid},</if>
- <if test="parentids != null">parentids = #{parentids},</if>
- <if test="sortstring != null">sortstring = #{sortstring},</if>
- <if test="available != null">available = #{available},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- </set>
- where id = #{id,jdbcType=INTEGER}
- </update>
- <!-- 分页查询-->
- <select id="querySysPermissionsByPage" parameterType="java.util.Map"
- resultType="com.pine.admin.modules.system.entity.SysPermission">
- select
- <include refid="Base_Column_List"/>
- from sys_permission
- <where>
- and del_flag = 'N'
- <if test="record.id != null and !"".equals(record.id)">and id = #{record.id}</if>
- <if test="record.name != null and !"".equals(record.name)">and name = #{record.name}</if>
- <if test="record.type != null and !"".equals(record.type)">and type = #{record.type}</if>
- <if test="record.url != null and !"".equals(record.url)">and url = #{record.url}</if>
- <if test="record.percode != null and !"".equals(record.percode)">and percode = #{record.percode}
- </if>
- <if test="record.parentid != null and !"".equals(record.parentid)">and parentid =
- #{record.parentid}
- </if>
- <if test="record.parentids != null and !"".equals(record.parentids)">and parentids =
- #{record.parentids}
- </if>
- <if test="record.sortstring != null and !"".equals(record.sortstring)">and sortstring =
- #{record.sortstring}
- </if>
- <if test="record.available != null and !"".equals(record.available)">and available =
- #{record.available}
- </if>
- <if test="record.createTime != null and !"".equals(record.createTime)">and create_time =
- #{record.createTime}
- </if>
- <if test="record.updateTime != null and !"".equals(record.updateTime)">and update_time =
- #{record.updateTime}
- </if>
- </where>
- order by id desc
- </select>
- <!-- 全部查询 -->
- <select id="queryAllSysPermission" parameterType="java.util.Map"
- resultType="com.pine.admin.modules.system.entity.SysPermission">
- select
- <include refid="Base_Column_List"/>
- from sys_permission
- <where>
- and del_flag = 'N'
- <if test="id != null and !"".equals(id)">and id = #{id}</if>
- <if test="name != null and !"".equals(name)">and name = #{name}</if>
- <if test="type != null and !"".equals(type)">and type = #{type}</if>
- <if test="url != null and !"".equals(url)">and url = #{url}</if>
- <if test="percode != null and !"".equals(percode)">and percode = #{percode}</if>
- <if test="parentid != null and !"".equals(parentid)">and parentid = #{parentid}</if>
- <if test="parentids != null and !"".equals(parentids)">and parentids = #{parentids}</if>
- <if test="sortstring != null and !"".equals(sortstring)">and sortstring = #{sortstring}</if>
- <if test="available != null and !"".equals(available)">and available = #{available}</if>
- <if test="createTime != null and !"".equals(createTime)">and create_time = #{createTime}</if>
- <if test="updateTime != null and !"".equals(updateTime)">and update_time = #{updateTime}</if>
- </where>
- order by id desc
- </select>
- <!-- 根据条件查询一个 -->
- <select id="querySysPermission" parameterType="java.util.Map"
- resultType="com.pine.admin.modules.system.entity.SysPermission">
- select
- <include refid="Base_Column_List"/>
- from sys_permission
- <where>
- and del_flag = 'N'
- <if test="id != null and !"".equals(id)">and id = #{id}</if>
- <if test="name != null and !"".equals(name)">and name = #{name}</if>
- <if test="type != null and !"".equals(type)">and type = #{type}</if>
- <if test="url != null and !"".equals(url)">and url = #{url}</if>
- <if test="percode != null and !"".equals(percode)">and percode = #{percode}</if>
- <if test="parentid != null and !"".equals(parentid)">and parentid = #{parentid}</if>
- <if test="parentids != null and !"".equals(parentids)">and parentids = #{parentids}</if>
- <if test="sortstring != null and !"".equals(sortstring)">and sortstring = #{sortstring}</if>
- <if test="available != null and !"".equals(available)">and available = #{available}</if>
- <if test="createTime != null and !"".equals(createTime)">and create_time = #{createTime}</if>
- <if test="updateTime != null and !"".equals(updateTime)">and update_time = #{updateTime}</if>
- </where>
- LIMIT 1
- </select>
- <!-- 根据用户id查询菜单 -->
- <select id="findMenuListByUserId" parameterType="java.lang.Integer"
- resultType="com.pine.admin.modules.system.entity.SysPermission">
- SELECT
- *
- FROM
- sys_permission
- WHERE TYPE = 'menu'
- AND id IN
- (SELECT
- sys_permission_id
- FROM
- sys_role_permission
- WHERE
- del_flag = 'N' AND
- sys_role_id IN
- (SELECT
- sys_role_id
- FROM
- sys_user_role
- WHERE sys_user_id = #{userId}))
- </select>
- <!-- 根据用户id查询URL -->
- <select id="findPermissionListByUserId" parameterType="java.lang.Integer"
- resultType="com.pine.admin.modules.system.entity.SysPermission">
- SELECT
- *
- FROM
- sys_permission
- WHERE TYPE = 'permission'
- AND id IN
- (SELECT
- sys_permission_id
- FROM
- sys_role_permission
- WHERE
- del_flag = 'N' AND
- sys_role_id IN
- (SELECT
- sys_role_id
- FROM
- sys_user_role
- WHERE sys_user_id = #{userId}))
- </select>
- <update id="delete">
- UPDATE sys_permission SET del_flag = 'Y'
- <where>
- AND id = #{id}
- </where>
- </update>
- </mapper>
|