当前位置:网站首页>Ruoyi Ruoyi framework @DataScope annotation use and some problems encountered
Ruoyi Ruoyi framework @DataScope annotation use and some problems encountered
2022-08-03 15:44:00 【Flying page】
1️⃣、项目使用场景:
Login users according to different roles,View different list data
2️⃣、思路
因为使用的是ruoyi若依框架,So the first thought is to [email protected]注解,Used to control data permissions
3️⃣、具体使用方法
使用起来很简单:
1、Add this annotation to the method of your implementing class @DataScope(deptAlias = “d”)
@Override
@DataScope(deptAlias = "d")
public List<BackupQueueManage> selectBackupQueueManageList(BackupQueueManage backupQueueManage) {
List<BackupQueueManage> backupQueueManages = backupQueueManageMapper.selectBackupQueueManageList(backupQueueManage);
for (BackupQueueManage manage : backupQueueManages) {
String linkScriptId = manage.getLinkScriptId();
if(StringUtils.isBlank(linkScriptId)){
linkScriptId = configService.selectConfigByKey(DB2_BACKUP_SCRIPT);
}
......
}
return backupQueueManages;
}
2、在mybatis的xml文件中加上 ${params.dataScope}
<sql id="selectBackupQueueManageVo">
select queue_id, queue_name from backup_queue_manage d
</sql>
<
select id="selectBackupQueueManageList" parameterType="BackupQueueManage" resultMap="BackupQueueManageResult">
<include refid="selectBackupQueueManageVo"/>
<where>
<if test="queueName != null and queueName != ''"> and queue_name like concat('%', #{queueName}, '%')</if>
<if test="scheduleType != null and scheduleType != ''"> and schedule_type = #{scheduleType}</if>
<if test="executorTime != null and executorTime != ''"> and executor_time = #{executorTime}</if>
<if test="dbIds != null and dbIds != ''"> and db_ids = #{dbIds}</if>
<if test="jobId != null "> and job_id = #{jobId}</if>
<if test="isOpen != null and isOpen != ''"> and is_open = #{isOpen}</if>
<if test="dbType != null and dbType != ''"> and db_type = #{dbType}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</where>
</select>
4️⃣、遇到的问题
问题1、我们访问页面的时候,发现如下报错信息
Error querying database. Cause: java.sql.SQLSyntaxErrorException: Unknown column 'd.dept_id' in 'IN/ALL/ANY subquery'
The error may exist in URL [jar:file:/opt/hidata/hidbm-vue/paas.jar!/BOOT-INF/classes!/mapper/BackupQueueManageMapper.xml] ###
The error may involve com.hidata.devops.selfops.mapper.BackupQueueManageMapper.selectBackupQueueManageList-Inline ### The error occurred while setting parameters
SQL: SELECT count(0) FROM backup_queue_manage WHERE (d.dept_id IN (SELECT dept_id FROM sys_dept WHERE dept_id = 100 OR find_in_set(NULL, ancestors)))
### Cause: java.sql.SQLSyntaxErrorException: Unknown column 'd.dept_id' in 'IN/ALL/ANY subquery' ; bad SQL grammar [];
nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'd.dept_id' in 'IN/ALL/ANY subquery'
原因是因为:Not added to our tabledept_id字段
问题2、报错信息如下:
Error querying database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN
( SELECT dept_id FROM sys_dept WHERE dept_id = 101 or find_in_set( 101 , ance' at line 4 The error may exist in URL
[jar:file:/opt/hidata/hidbm-vue/paas.jar!/BOOT-INF/classes!/mapper/BackupQueueManageMapper.xml] The error may involve
com.hidata.devops.selfops.mapper.BackupQueueManageMapper.selectBackupQueueManageList-Inline The error occurred while
setting parameters SQL: select count(0) from ( select queue_id, queue_name, schedule_type, executor_time, db_ids, job_id, create_time, is_open,link_script_id
,db_type, create_by, update_time, update_by from backup_queue_manage WHERE (.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = 101 or find_in_set( 101 , ancestors ) )) ) tmp_count Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IN ( SELECT dept_id FROM sys_dept WHERE dept_id = 101 or find_in_set( 101 , ance' at line 4 ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for
the right syntax to use near 'IN ( SELECT dept_id FROM sys_dept WHERE dept_id = 101 or find_in_set( 101 , ance' at line 4
通过报错信息,We found this sentence WHERE (.dept_id ,说明sqlNo aliases in the statement,只要加上即可:select queue_id, queue_name from backup_queue_manage d
边栏推荐
- 王守创:多组学整合分析揭示植物代谢多样性的分子机制(8月2号晚)
- 问题3:你提交的缺陷开发认为这不是BUG,怎么办?
- leetcode: 899. Ordered Queue [Thinking Question]
- 在 360 度绩效评估中应该问的 20 个问题
- 兔起鹘落全端涵盖,Go lang1.18入门精炼教程,由白丁入鸿儒,全平台(Sublime 4)Go lang开发环境搭建EP00
- 土耳其国防部:联合协调中心将对首艘乌克兰粮船进行安全检查
- 问题7:功能测试花瓶用例
- How to play deep paging with hundreds of millions of data?Compatible with MySQL + ES + MongoDB
- Fortinet产品导入AWS AMI操作文档
- 2021年12月电子学会图形化二级编程题解析含答案:绘制多边形
猜你喜欢
随机推荐
1、实例开启无锁表结构变更以后,在任务编排中通过“单实例SQL”节点进行的结构变更,是优先采用无锁表
Three key expectations for the crypto market in August Price moves north?Still expected to be in turmoil
一个在浏览器中看到的透视Cell实现
问题9:为什么有边界值的测试?
6000 字+,帮你搞懂互联网架构演变历程!
一通骚操作,我把SQL执行效率提高了10000000倍!
上亿数据怎么玩深度分页?兼容MySQL + ES + MongoDB
DC-DC 2C(40W/30W) JD6606SX2退功率应用
新版本MaxCompute 的SQL支持 UDF 分区裁剪的逻辑是怎样的?
问题1:批量测试(正式测试)之前应该怎么做?
请问大家,MySQL全量怎么样可以提高性能呢?我这里瓶颈是在Source上,在不增加并行度的情况下,
测试基础整合-测试分类、软件质量模型、测试流程、测试用例、测试点划分方法、缺陷、例子
Internship Road: Documenting Confusion in My First Internship Project
【周报】2022年7月31日
开源一夏 | 阿里云物联网平台之极速体验
MATLAB gcf figure save image with black background/transparent background
MySQL性能优化的'4工具+10技巧'
2021年12月电子学会图形化四级编程题解析含答案:新冠疫苗接种系统
生物统计师与临床医生协同研究使用的低代码洞察平台丨数据科学 x 临床医学
AWS中国区SDN Connector