当前位置:网站首页>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 !!
边栏推荐
- 科大讯飞智能办公本Air电纸书阅读器,让我的工作生活更加健康
- C language: random generated number + selective sorting
- 如何将一个域名解析到多个IP地址?
- Xiaobai programmer the next day
- Method of converting MAPGIS format to ArcGIS
- 关于接口测试你想知道的都在这儿了
- Playwright tutorial (I) suitable for Xiaobai
- How many bytes does Boolean occupy?
- Redis memory elimination mechanism?
- 3. Editors (vim)
猜你喜欢

Use of hyperlinks

Xiaobai programmer's first day

Application of breakthrough thinking in testing work

编译和反编译

Basic principle of torque motor control

Xiaobai programmer the next day

jenkins+SVN配置

kubernetes之VictoriaMetrics单节点

Smart S7-200 PLC channel free mapping function block (do_map)

Selenium basic use and use selenium to capture the recruitment information of a website (continuously updating)
随机推荐
测试工作不受重视,你换位思考了吗?
Some summary about function
聚名十年,说出你的故事,百万豪礼等你拿
什么是分区分桶?
访问者模式(visitor)模式
arcgis开发常用源码
Compile and decompile
手机端微信发朋友圈功能测试点总结
Minor GC 和 Full GC 有什么不同呢?
SQL基本语句 DQL select与提取 DML插入删除
Output Yang Hui triangle with two-dimensional array
编译和反编译
What have I experienced to become a harder tester than development?
SMART S7-200 PLC通道自由映射功能块(DO_Map)
How to resolve a domain name to multiple IP addresses?
Whether the five distribution methods will produce internal fragments and external fragments
如何将一个域名解析到多个IP地址?
JS timer and swiper plug-in
PySpark数据分析基础:pyspark.sql.SparkSession类方法详解及操作+代码展示
Why is the integer type 128 to byte -128