当前位置:网站首页>According to the use and configuration of data permissions in the open source framework
According to the use and configuration of data permissions in the open source framework
2022-07-25 22:20:00 【Steal the moon by riding the wind】
Ruoyi open source project online documentation : Introduce | RuoYi
If according to the open source project Vue Front and rear separated version :RuoYi-Vue: be based on SpringBoot,Spring Security,JWT,Vue & Element Before and after the separation of rights management system , It also provides Vue3 Version of
In use, ruoyi (RuoYi) When open source projects build their own application systems , The whole process is very simple and efficient , The system runs smoothly , Thanks to the silent efforts of developers behind the ruoyi project , Thank them again !!
In use , Functional permissions and button level permissions have been quite mature , It can be used after several direct operations . however , For data isolation , That is, the data permissions of users in different roles , Although the document also describes , There is also a ready-made example , But there is no result business function , It's a little hard to understand , Here I will directly give an example of business functions , Help friends make adjustments according to their business , Complete the use of data permissions , It can meet the needs of the owner .
First , When establishing the business function database table , Need to add user_id And dept_id, there user_id Indicates who created the record of this table ,dept_id Actually, the founder's Department id, These two fields need to be added to each business function table that requires data permission , For example, my business menu

Create script sql
DROP TABLE IF EXISTS `print_entrust`;
CREATE TABLE `print_entrust` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
`xh` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT ' Student number ',
`entrustedXh` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT '0' COMMENT ' Print terminal ID',
`printtype` int DEFAULT '0' COMMENT ' Print type ',
`copies` int DEFAULT '1' COMMENT ' Number of printed copies ',
`payable` int DEFAULT '0' COMMENT ' To cope with ( branch )',
`actualpay` int DEFAULT '0' COMMENT ' Paid in ( branch )',
`create_time` datetime DEFAULT NULL COMMENT ' Print time ',
`user_id` bigint DEFAULT NULL COMMENT ' founder ',
`dept_id` bigint DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;After adding the database table , Again web End synchronization database , And automatically generate code

After generating the code file , The structure is as follows :
Put relevant modules into your own project , There are several areas that need to be modified , as follows :
1、 stay Controller modular , When adding records , Need to give user_id And dept_id assignment
2、 stay xxxx Mapper.xml Add table alias in , Add if according to the frame sql strand

The table alias here t It will be used in the service layer
3、 stay lmpl Service layer , Add data permission annotation . Be careful : Use the above t Alias

Here we are , The data permissions of business functions are set . These are the points to pay attention to . that , What if you use it ?
Still here web End , System management -> Role management

Click More , Display data permissions

There are several options ,
1、 Only my data permission , Explain that you see your own . Generally, this kind of bottom operator ;
2、 division manager , You can only see the data of the personnel in your department ;
3、 Management , Then you can see the data of this department and below ;
The intuition of this permission can be reflected through the department structure tree .
If you feel simple and easy to use , Please give me a compliment , If you feel in doubt , You can leave a message or contact me at any time , To discuss , thank you !!
边栏推荐
- 『SignalR』.NET使用 SignalR 进行实时通信初体验
- JS timer and swiper plug-in
- What is partition and barrel division?
- H5幸运刮刮乐抽奖 免公众号+直运营
- Wechat official account application development (I)
- Why does redis choose single thread?
- IPv4地址已经完全耗尽,互联网还能正常运转,NAT是最大功臣!
- 三菱FX PLC自由口RS指令实现MODBUS通讯
- Solutions to the failure of win key in ikbc keyboard
- VIM usage record
猜你喜欢

Flex layout

How to implement an app application to limit users' time use?

在进行自动化测试,遇到验证码的问题,怎么办?

微信发卡小程序源码-自动发卡小程序源码-带流量主功能

字节跳动技术面都过了,结果还是被刷了,问HR原因竟是。。。

SQL中in的用法 DQL 查询

PySpark数据分析基础:pyspark.sql.SparkSession类方法详解及操作+代码展示

编译和反编译

JMeter websocket interface test

MySQL - subquery - column subquery (multi row subquery)
随机推荐
Why does redis choose single thread?
Virtual memory and disk
Common source code for ArcGIS development
Sofa weekly | open source person - Niu Xuewei, QA this week, contributor this week
淦,为什么 '𠮷𠮷𠮷' .length !== 3 ??
PySpark数据分析基础:pyspark.sql.SparkSession类方法详解及操作+代码展示
测试工作不受重视,你换位思考了吗?
Method of converting MAPGIS format to ArcGIS
[test development methodology] experience of test development platform PK - choice
Synchronized and volatile
QML module not found
The third day of Xiaobai programmer
What is the difference between minor GC and full GC?
3dslicer introduction and installation tutorial
internship:普通常用的工具类编写
What have I experienced to become a harder tester than development?
Having met a tester with three years' experience in Tencent, I saw the real test ceiling
什么是分区分桶?
Ts:typera code fragment indentation display exception (resolved) -2022.7.24
完啦,上班三个月,变秃了