Device Resource Management System-role management
- User, role, and permission relationship
Permission:
A: Instrument and Equipment Management
B: equipment calibration and repair
C: Device purchase plan
D:
E:
.
.
.
Roles and permissions:
System Administrator:
A; B; C; D; E; F; G; h; I; j; K;
Senior Administrator:
A; B; C; D; E; I; j; K;
Business users:
A; B; F; G; h; I;
Conclusion:
1. The relationship between users and roles is many-to-many.
2. Relationship between permissions and Roles
3. roles play a crucial role in the relationship between the three
User table:
User ID, user name, username, Unit
402881e43 Liu Bei liubei 2 (Shanghai)
1 Guan Yu guanyu 1 (Beijing)
2 Zhang Fei Zhangfei 1 (Beijing)
User-role Association table:
Primary Key ID user ID role ID remarks
1 402881e43 1
2 1 2
3 1 1
Role table:
Role ID role name
1. System Administrator
2. Senior Administrator
3. Business users
4 normal users
Role and permission Association table:
Role ID permission code (SET) Remarks
1 abcdefghijk
2 abcdeijk
3 abfghi
Permission table:
Permission code permission name parent node permission code parent node permission name
A Equipment Management drvie Technical Facilities Maintenance Management
B equipment calibration and repair drvie Technical Facilities Maintenance and Management
C equipment purchase plan drvie technical facility maintenance management
D. Document Drawing Management Image Technical Document Drawing Management
Stored in the function. xml file,
Create two Association tables (user-role Association Table and role-Permission Association Table)
Operation:
1. query the data dictionary using the "role type" to obtain the role list on the page.
2. Read all the permission information in the function. xml file and display it on the page. (Read using dom4j)
Some code:
String parentcode = "";
List <xmlobject> List = request. getattribute ("xmllist ");
For (INT I = 0; I <list. size; I ++ ){
Xmlobject = list. Get (I );
If (parentcode. Equal (xmlobject. getparentcode ())){
System. Out. println (xmlobject. getname ());
}
// Each traversal goes through the first else
Else {
Parentcode = xmlobject. getparentcode ();
System. Out. println (xmlobject. getparentname ());
System. Out. println (xmlobject. getname ());
}
}
Operation:
Permission assignment:
1. Obtain the roleid parameter from the page, use the roleid to query the role permission Association table, and obtain the permissions of the current role.
2. Read the function. xml configuration file and obtain all system permissions.
3. Matching: The current role has the following permissions:
If yes, select the check box on the page.
If not, the check box on the page is not selected.
Use the flag field control: if the flag is 1, the check box of the page is selected; if the flag is 0, the check box of the page is not selected.
User allocation:
1. Obtain the roleid parameter from the page, use the roleid to query the User Role Association table, and obtain the users of the current role.
2. Obtain all in-service employees from the user table
3. Matching: users under the current role match with all active users:
If yes, select the check box on the page.
If not, the check box on the page is not selected.
Use the roleflag field control: If roleflag is set to 1, it indicates that the check box on the page is selected. If roleflag is set to 0, it indicates that the check box on the page is not selected (whether an SQL statement can be used to complete the preceding 1, 2, 3 operations)
Operation:
1. Obtain the roleid from the page, the selected permission name = selectoper, and the selected user name = selectuser.
2. Save the role and permission Association Table
1) query the role permission Association Table through roleid,
If a record exists, perform the update () operation.
If no record exists, perform the SAVE () operation.
3. Save the associated tables of roles and users
1) Use roleid to organize conditions and delete all records matching the roleid in the User Role Association Table
2) Add new users and current roles to the user role Association table.