2023-12-13 16:53:53 +08:00
|
|
|
<?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.bunny.mapper.SysRoleMapper">
|
|
|
|
|
|
|
|
<!-- 映射查询到的字段 -->
|
2023-12-14 00:14:42 +08:00
|
|
|
<resultMap id="sysRoleMap" type="cn.bunny.common.spzx.model.entity.system.SysRole" autoMapping="true"/>
|
2023-12-13 16:53:53 +08:00
|
|
|
|
|
|
|
<!-- 用于select查询公用抽取的列 -->
|
|
|
|
<sql id="columns">
|
|
|
|
id,role_name,role_code,description,create_time,update_time,is_deleted
|
|
|
|
</sql>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 角色添加的方法 -->
|
|
|
|
<insert id="saveSysRole">
|
|
|
|
insert into sys_role (id,
|
|
|
|
role_name,
|
|
|
|
role_code,
|
|
|
|
description)
|
|
|
|
values (#{id},
|
|
|
|
#{roleName},
|
|
|
|
#{roleCode},
|
|
|
|
#{description})
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
<!-- 修改角色 -->
|
|
|
|
<update id="updateSysRole">
|
|
|
|
update sys_role set
|
|
|
|
<if test="roleName != null and roleName != ''">
|
|
|
|
role_name = #{roleName},
|
|
|
|
</if>
|
|
|
|
<if test="roleCode != null and roleCode != ''">
|
|
|
|
role_code = #{roleCode},
|
|
|
|
</if>
|
|
|
|
<if test="description != null and description != ''">
|
|
|
|
description = #{description},
|
|
|
|
</if>
|
|
|
|
update_time = now()
|
|
|
|
where
|
|
|
|
id = #{id}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 删除角色 -->
|
|
|
|
<update id="deleteSysRole">
|
|
|
|
update sys_role
|
|
|
|
set is_deleted=1
|
|
|
|
where id = #{roleId}
|
|
|
|
</update>
|
|
|
|
|
|
|
|
<!-- 彻底删除角色 -->
|
|
|
|
<delete id="deleteSysRoleByRoleId">
|
|
|
|
delete
|
|
|
|
from sys_role
|
|
|
|
where id = #{roleId}
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
<!-- 角色列表方法 -->
|
|
|
|
<select id="findByPage" resultMap="sysRoleMap">
|
|
|
|
select
|
|
|
|
<include refid="columns"/>
|
|
|
|
from sys_role
|
|
|
|
<where>
|
|
|
|
<if test="roleName != null and roleName != ''">
|
|
|
|
and role_name like CONCAT('%',#{roleName},'%')
|
|
|
|
</if>
|
|
|
|
and is_deleted=0
|
|
|
|
</where>
|
|
|
|
order by id desc
|
|
|
|
</select>
|
|
|
|
</mapper>
|