<?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="cn.com.basic.role.entity.SysRoleFunctionitem">
|
|
<resultMap id="BaseResultMap" type="cn.com.basic.role.entity.SysRoleFunctionitem" >
|
<id column="id" property="id" jdbcType="VARCHAR" />
|
<result column="role_id" property="roleId" jdbcType="VARCHAR" />
|
<result column="function_item_id" property="functionItemId" jdbcType="VARCHAR" />
|
<result column="is_valid" property="isValid" jdbcType="TINYINT" />
|
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
|
<result column="update_user_id" property="updateUserId" jdbcType="VARCHAR" />
|
</resultMap>
|
|
<resultMap id="SysFunctionItemTree" type="cn.com.basic.role.entity.SysRoleFunctionItemTree">
|
<result column="function_item_id" property="functionItemId" jdbcType="VARCHAR" />
|
<result column="role_id" property="roleId" jdbcType="VARCHAR" />
|
<result column="name" property="name" jdbcType="VARCHAR" />
|
<result column="pid" property="pid" jdbcType="VARCHAR" />
|
<result column="src_url" property="srcUrl" jdbcType="VARCHAR" />
|
<result column="target_url" property="targetUrl" jdbcType="VARCHAR" />
|
<result column="url_param" property="urlParam" jdbcType="VARCHAR" />
|
<result column="order_num" property="orderNum" jdbcType="BIGINT" />
|
<result column="privilege" property="privilege" jdbcType="BIGINT" />
|
</resultMap>
|
<sql id="Base_Column_List" >
|
id, role_id, function_item_id, is_valid, update_time, update_user_id
|
</sql>
|
|
<sql id="Base_Where_Clause">
|
<where>
|
<trim prefixOverrides="and">
|
<if test="id != null"> and ID = #{id}</if>
|
<if test="roleId != null" >
|
and role_id = #{roleId,jdbcType=VARCHAR}
|
</if>
|
<if test="functionItemId != null" >
|
and function_item_id = #{functionItemId,jdbcType=VARCHAR}
|
</if>
|
<if test="isValid != null" >
|
and is_valid = #{isValid,jdbcType=TINYINT}
|
</if>
|
<if test="updateTime != null" >
|
and update_time = #{updateTime,jdbcType=TIMESTAMP}
|
</if>
|
<if test="updateUserId != null" >
|
and update_user_id = #{updateUserId,jdbcType=VARCHAR}
|
</if>
|
</trim>
|
</where>
|
<if test="sorting != null">order by ${sorting}</if>
|
<if test="offset != null and limit != null">
|
limit #{offset}, #{limit}
|
</if>
|
</sql>
|
|
<!-- 查询总数 -->
|
<select id="selectCount" resultType="java.lang.Long" parameterType="java.util.Map">
|
select count(ID)
|
from re_sys_role_functionitem
|
<include refid="Base_Where_Clause" />
|
</select>
|
|
<!-- 查询 -->
|
<select id="select" resultMap="BaseResultMap" parameterType="java.util.Map">
|
select
|
<include refid="Base_Column_List" />
|
from re_sys_role_functionitem
|
<include refid="Base_Where_Clause" />
|
</select>
|
<!-- 根据ID删除-->
|
<delete id="deleteById" parameterType="java.lang.String">
|
delete from
|
re_sys_role_functionitem
|
where ID = #{id}
|
</delete>
|
|
<delete id="delete" parameterType="java.util.Map">
|
update re_sys_role_functionitem
|
set is_valid=0
|
<include refid="Base_Where_Clause" />
|
</delete>
|
|
<!-- 根据ID查询 -->
|
<select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.String">
|
select
|
<include refid="Base_Column_List" />
|
from re_sys_role_functionitem
|
where ID = #{id}
|
</select>
|
<!-- 添加 -->
|
<insert id="insert" parameterType="cn.com.basic.role.entity.SysRoleFunctionitem">
|
insert into re_sys_role_functionitem (id, role_id, function_item_id,
|
privilege, is_valid, update_time,
|
update_user_id)
|
values (#{id,jdbcType=VARCHAR}, #{roleId,jdbcType=VARCHAR}, #{functionItemId,jdbcType=VARCHAR},
|
#{privilege,jdbcType=BIGINT}, #{isValid,jdbcType=TINYINT}, #{updateTime,jdbcType=TIMESTAMP},
|
#{updateUserId,jdbcType=VARCHAR})
|
</insert>
|
|
<!-- 通过ID更新 -->
|
<update id="updateByIdSelective" parameterType="cn.com.basic.role.entity.SysRoleFunctionitem">
|
update re_sys_role_functionitem
|
<set >
|
<if test="roleId != null" >
|
role_id = #{roleId,jdbcType=VARCHAR},
|
</if>
|
<if test="functionItemId != null" >
|
function_item_id = #{functionItemId,jdbcType=VARCHAR},
|
</if>
|
<if test="privilege != null" >
|
privilege = #{privilege,jdbcType=BIGINT},
|
</if>
|
<if test="isValid != null" >
|
is_valid = #{isValid,jdbcType=TINYINT},
|
</if>
|
<if test="updateTime != null" >
|
update_time = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateUserId != null" >
|
update_user_id = #{updateUserId,jdbcType=VARCHAR},
|
</if>
|
</set>
|
where id = #{id,jdbcType=VARCHAR}
|
</update>
|
|
<!-- 根据IDs删除 -->
|
<delete id="deleteByIds">
|
delete from
|
re_sys_role_functionitem
|
where
|
<foreach collection="array" item="id" open="id in (" close=")" separator=",">
|
'${id}'
|
</foreach>
|
</delete>
|
|
<!-- 查询当前角色的功能树列表 -->
|
<select id="getSysFunctionItemTreeByRoleId" resultMap="SysFunctionItemTree" parameterType="java.lang.String">
|
select *
|
from v_sys_role_function_item_tree
|
where role_id = #{roleId}
|
order by order_num
|
</select>
|
</mapper>
|