Data permission design)

Source: Internet
Author: User

Preliminary Research on Data permission Design

Http://gocom.primeton.com/modules/newbb/forumtopic24265_13900_25.htm

 

Overview

 

In many projects, data permissions are involved. Data permissions indicate that the system has operation permissions even if the roles are the same, however, business operations are restricted by business attributes such as risks, quotas, and sales regions.

 

For example, a salesperson can view his/her own sales list, and a sales manager can view the sales list of the salesperson within his/her jurisdiction, the senior sales manager can view the sales list of the sales managers under his/her jurisdiction. Further, he can only view the list with more than 10 million yuan, but not the list with less than 10 million Yuan. If the salesperson sells products, but because of the different product attributes, if the sales region in the product attribute is in the "suhang region", the sales personnel in the Beijing region cannot sell the products. For example, if the product property has a high risk attribute, the level of the sales personnel is also required to be high, then the low-level sales personnel cannot sell the product. Further, with the development of time or situation, the risks of this product are not that high, and low-level sales personnel can also sell it. Or the low-level sales personnel of this product can sell the product for less than 100 RMB, the sales volume of senior personnel is million.

 

Architecture Analysis and Design

 

At the beginning of the design, the location of the Data permission was determined. Similar to the operation permission, the Operation permission is generally placed on the Controller layer of MVC, and is used as a plug-in to control whether the operation permission exists. Data permissions can also be designed in this way, but data permissions are more entangled with business logic. Therefore, data permissions can be used as plug-ins at the business layer (model ), A more elegant design is to use the template mode as a filter in the default business implementation base class. As shown in, bizclass actually represents the complex design of the business layer. During the analysis and design process, my experience is to understand the requirements as much as possible, and to present the requirements as directly as possible, instead of defining the design pattern at the beginning of the design, the design pattern is taken into consideration after figuring out the requirement and providing a complete design idea. Of course, you must first define the position of the software architecture at the beginning of the design.

 

In terms of requirements, the data permissions of the operator should be granted to the operator, including the query details and data operation rules. From this point, we can analyze that to obtain data permissions, there are two parameters: userid,

 

Bizname.

 

In fact, the design path for any business needs is similar. It is "processing of incoming materials", with raw materials and target finished products, and then processing raw materials into target finished products. Of course, many factors should be taken into account. The object-oriented design idea is very important. We should not consider the number of tables at the beginning of the design, the associations between tables, and what is one-to-many, multiple-to-many join tables. First, consider the business needs, how these business functions are transformed into some use cases, and how these use cases are converted into several business classes, these classes have the attributes or methods to implement these business functions. Tables are only the data storage of some entity classes and cannot be expressed as business logic. It is also difficult to reflect the ideas of designers.

 

 

 

 

 

 

Organization and (position vs role)

 

In system design, the Operation permission and data permission are often confused and controlled by the role permission. In fact, this is a misunderstanding, because the operation permission is to solve the problem of whether the problem can be solved, data permissions solve the problem of increasing data permissions. The role has no level concept, that is, there is no Level-level concept.

 

Therefore, the concept of "Post" is calculated. Positions are classified, and the relationship between superiors and subordinates is reported. The region attribute is also designed here, which is based on certain requirements, this design is based on the management of some companies divided into matrix management, both Departments, according to the product line is divided into business group management.

 

As shown in, an organizational unit is divided into upper and lower levels. The organizational unit contains several positions. The user belongs to a certain position due to his/her job responsibilities. This adds an intermediate layer of positions to the relationship between organizations and people in the original design. That is to say, an organizational unit only contains the positions that need to be set in its business, these positions are enriched by personnel. In other words, no idle persons are in the organizational unit!

 

An important concept in a position is resource management. To simplify the design, a position is only set to process a single business, the bizes attribute indicates that the job involves several resources.

 

 

 

 

Business resources and data permission rules

 

The main function of this group of classes is to prepare raw materials and map data rules to jobs. There is no entity class involved, and data is required to support these classes, it is not too late to consider data storage. For example, bizdatruler requires an entity class, which may be the data of multiple related tables.

 

Class resource contains data permission rules for multiple products. In productinfo, datarulers indicates (Key = positiongrades value = bizrers). In bizdataruler attributes, positiongrades includes: 3, 4, 5, and 6, separated by commas (,), indicating that a rule applies to positions of certain levels. The hashmap attribute of productrulers is <string productattr, string scope>, where the range of numbers in scope is "[()] "indicates," ["indicates greater than or equal to," ("indicates greater than,") "indicates less than,"] "indicates less than or equal to, for example," [300,550) "indicates greater than or equal to 300, less than 500. For a hash column, use "{}". For example, "{30, 50, 70}" indicates that data permissions are granted only for attributes equal to 30, 40, and 50, for example, "{Shanghai, Suzhou, hangzhou} is valid only in Shanghai, Suzhou, and Hangzhou. This is similar to the format text processing method, which simplifies text parsing.

 

 

 

 

 

 

Appendix: Data permission module design class diagram:

 

 

 

 

 

 

My hard work lies in my passion for my career. Together with Chinese software, I have matured and moved to the world.

 

Contact Author: lijj_72@hotmail.com =================================================== ========================= http://www.uml.org.cn/zjjs/200807144.asp

General user permission system design

Author: Li mengyu Source: Network

 

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.