Device Resource Management System-role management

Source: Internet
Author: User

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

  • Database Design

  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)

  • Role Management Homepage

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 ());

}

}

  • Role Query

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)

  • New Role

  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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.