76 lines
2.0 KiB
XML
76 lines
2.0 KiB
XML
|
|
<?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.bonus.imgTool.system.dao.RoleDao">
|
||
|
|
|
||
|
|
<sql id="where">
|
||
|
|
<where>
|
||
|
|
t.del_flag = 0
|
||
|
|
<if test="name != null and name != ''">
|
||
|
|
and t.role_name like concat('%', #{name}, '%')
|
||
|
|
</if>
|
||
|
|
</where>
|
||
|
|
</sql>
|
||
|
|
<update id="delete">
|
||
|
|
update sys_role
|
||
|
|
set del_flag = 1
|
||
|
|
where role_id = #{id}
|
||
|
|
</update>
|
||
|
|
<update id="updateEnableState">
|
||
|
|
update sys_role
|
||
|
|
set state = #{state}
|
||
|
|
where role_id = #{id}
|
||
|
|
</update>
|
||
|
|
|
||
|
|
|
||
|
|
<select id="list" resultType="com.bonus.imgTool.model.Role">
|
||
|
|
select t.role_id as id,
|
||
|
|
t.role_name as name,
|
||
|
|
t.role_code as roleCode,
|
||
|
|
t.remarks,
|
||
|
|
so.org_name as orgName,
|
||
|
|
t.state,
|
||
|
|
t.create_time AS createTime
|
||
|
|
from sys_role t
|
||
|
|
LEFT JOIN sys_org so on so.org_id=t.org_id and so.del_flag='0'
|
||
|
|
<include refid="where" />
|
||
|
|
</select>
|
||
|
|
<select id="getRole" resultType="com.bonus.imgTool.model.Role">
|
||
|
|
select t.role_id as id,
|
||
|
|
t.role_name as name,
|
||
|
|
t.role_code as roleCode,
|
||
|
|
t.remarks
|
||
|
|
from sys_role t
|
||
|
|
where t.role_name = #{name} and t.del_flag = 0
|
||
|
|
</select>
|
||
|
|
<select id="getById" resultType="com.bonus.imgTool.model.Role">
|
||
|
|
select t.role_id as id,
|
||
|
|
t.role_name as name,
|
||
|
|
t.role_code as roleCode,
|
||
|
|
t.remarks,
|
||
|
|
t.org_id as orgId,
|
||
|
|
t.state
|
||
|
|
from sys_role t where t.role_id = #{id}
|
||
|
|
</select>
|
||
|
|
<!--获取用户使用该角色数量-->
|
||
|
|
<select id="getUserNumByRole" resultType="java.lang.Integer">
|
||
|
|
SELECT COUNT(*) FROM sys_user WHERE del_flag = 0 AND role_id = #{id}
|
||
|
|
</select>
|
||
|
|
<select id="getRoleCode" resultType="com.bonus.imgTool.model.Role">
|
||
|
|
select t.role_id as id,
|
||
|
|
t.role_name as name,
|
||
|
|
t.role_code as roleCode,
|
||
|
|
t.remarks
|
||
|
|
from sys_role t
|
||
|
|
where t.role_code = #{roleCode} and t.del_flag = 0
|
||
|
|
</select>
|
||
|
|
|
||
|
|
<insert id="saveRolePermission">
|
||
|
|
insert into sys_role_menu(role_id, menu_id) values
|
||
|
|
<foreach collection="permissionIds" item="permissionId"
|
||
|
|
separator=",">
|
||
|
|
(#{roleId}, #{permissionId})
|
||
|
|
</foreach>
|
||
|
|
</insert>
|
||
|
|
|
||
|
|
</mapper>
|