当前位置:网站首页>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 !!
边栏推荐
- Xiaobai programmer's fourth day
- On the difference between break and continue statements
- 什么是类加载?类加载的过程?
- Three ways to allocate disk space
- Randomly generate 10 (range 1~100) integers, save them to the array, and print the array in reverse order. And find the average value, the maximum value and the subscript of the maximum value, and fin
- Which is reliable between qiniu business school and WeiMiao business school? Is it safe to open an account recommended by the teacher?
- Interpretation of the source code of all logging systems in XXL job (line by line source code interpretation)
- What is the difference between minor GC and full GC?
- MapGIS格式转ArcGIS方法
- 4day
猜你喜欢

Randomly generate 10 (range 1~100) integers, save them to the array, and print the array in reverse order. And find the average value, the maximum value and the subscript of the maximum value, and fin
![[go basics 02] the first procedure](/img/af/f32762a828f384bf6aa063ebf959aa.png)
[go basics 02] the first procedure

On the difference between break and continue statements

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

Nuclear power plants strive to maintain safety in the heat wave sweeping Europe

Application of breakthrough thinking in testing work

TFrecord写入与读取

Three ways to allocate disk space

数据质量:数据治理的核心

Playwright tutorial (II) suitable for Xiaobai
随机推荐
How to call the size of two numbers with a function--- Xiao Tang
Wechat official account application development (I)
D3.js 学习
Flex layout
Wkid in ArcGIS
Call of addition, subtraction, multiplication and division of integer type only
C language: random generated number + selective sorting
3day
After 2 years of functional testing, I feel like I can't do anything. Where should I go in 2022?
Div drag effect
Tfrecord write and read
The third day of Xiaobai programmer
Playwright tutorial (I) suitable for Xiaobai
Randomly generate 10 (range 1~100) integers, save them to the array, and print the array in reverse order. And find the average value, the maximum value and the subscript of the maximum value, and fin
Xiaobai programmer's fourth day
在进行自动化测试,遇到验证码的问题,怎么办?
Xiaobai programmer the next day
Redis memory elimination mechanism?
JSP novice
Arcgis10.2 configuring postgresql9.2 standard tutorial