<?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.cloud.user.dao.SysRoleDao">
|
|
<select id="count" resultType="int">
|
select count(*) from sys_role t WHERE t.delFlag = '0'
|
<if test="name != null and name != ''">
|
and t.name like concat('%', #{name}, '%')
|
</if>
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
</select>
|
|
<select id="findData" resultType="com.cloud.model.sys.SysRole" parameterType="map">
|
select * from sys_role t
|
WHERE t.delFlag = '0'
|
<if test="name != null and name != ''">
|
and t.name like concat('%', #{name}, '%')
|
</if>
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
<if test="start != null and length != null">
|
limit ${start},${length}
|
</if>
|
</select>
|
|
<!--验证角色名称-->
|
<select id="findByName" parameterType="map" resultType="com.cloud.model.sys.SysRole">
|
select * from sys_role t
|
WHERE t.delFlag = '0'
|
and t.name = #{name}
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
</select>
|
|
<select id="findByIdParams" resultType="com.cloud.model.sys.SysRole">
|
select * from sys_role t where delFlag = '0' and t.id = #{id}
|
<if test="orgId != null">
|
and orgId = #{orgId}
|
</if>
|
</select>
|
|
<update id="delete" >
|
UPDATE sys_role SET
|
delFlag = '1' WHERE id = #{id}
|
<if test="orgId != null">
|
and orgId = #{orgId}
|
</if>
|
</update>
|
|
<!--角色下拉列表查询-->
|
<select id="findRoleList" parameterType="map" resultType="map">
|
select id,name from sys_role where delFlag = '0'
|
<if test="orgId != null and orgId != ''">
|
and orgId = #{orgId}
|
</if>
|
</select>
|
|
<!--角色修改-->
|
<update id="updateByPrimaryKeySelective" parameterType="com.cloud.model.sys.SysRole">
|
update sys_role
|
<set>
|
<if test="orgId != null">
|
orgId = #{orgId,jdbcType=INTEGER},
|
</if>
|
<if test="name != null">
|
name = #{name,jdbcType=VARCHAR},
|
</if>
|
<if test="code != null">
|
code = #{code,jdbcType=VARCHAR},
|
</if>
|
<if test="roleType != null">
|
roleType = #{roleType,jdbcType=VARCHAR},
|
</if>
|
<if test="dataScope != null">
|
dataScope = #{dataScope,jdbcType=VARCHAR},
|
</if>
|
<if test="isSys != null">
|
isSys = #{isSys,jdbcType=INTEGER},
|
</if>
|
<if test="enabled != null">
|
enabled = #{enabled,jdbcType=VARCHAR},
|
</if>
|
<if test="delFlag != null">
|
delFlag = #{delFlag,jdbcType=INTEGER},
|
</if>
|
<if test="createTime != null">
|
createTime = #{createTime,jdbcType=TIMESTAMP},
|
</if>
|
<if test="updateTime != null">
|
updateTime = #{updateTime,jdbcType=TIMESTAMP},
|
</if>
|
</set>
|
where id = #{id,jdbcType=INTEGER}
|
</update>
|
|
<!--更新前删除角色相关的权限-->
|
<delete id="deleteRoleMenus" parameterType="map">
|
DELETE FROM sys_role_menu WHERE roleId = #{id} and orgId = #{orgId}
|
</delete>
|
|
<!--更新角色权限-->
|
<insert id="saveRoleMenus" parameterType="map">
|
INSERT sys_role_menu values(#{id},#{menuId},#{orgId})
|
</insert>
|
|
</mapper>
|