【Ruoyi学习】用户数据权限管理

目录

一、代码生成

二、修改​​​​​​​​​​​​​​

设置注解  @DataDevice

 xml 使用AOP 类添加的SQL 语句

三、页面展示

超级管理员admin 

 普通用户ry

普通用户xnb

一、代码生成

运用若依代码生成工具生成设备信息表,超级管理员admin 看到的设备数据

 代码生成步骤详情请参考此文章

二、修改​​​​​​​​​​​​​​​​​​​​​

设置注解  @DataDevice

通过注解会触发数据权限判断

    @DataDevice(deptAlias = "d",userAlias = "u")
    @Override
    public List<MyDevice> selectMyDeviceList(MyDevice myDevice)
    {
        return myDeviceMapper.selectMyDeviceList(myDevice);
    }

 xml 使用AOP 类添加的SQL 语句

    <select id="selectMyDeviceList" parameterType="MyDevice" resultMap="MyDeviceResult">
        select u.id,u.device_name,u.device,u.temperature
        from my_device u left join sys_dept d on u.device = d.dept_id
        <where>
            1=1
            <if test="deviceName != null  and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
            <if test="device != null "> and device = #{device}</if>
            <if test="temperature != null  and temperature != ''"> and temperature = #{temperature}</if>
        </where>
        ${params.dataScope}
    </select>

三、页面展示

超级管理员admin 

 普通用户ry

普通用户xnb

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值