Springside Development Combat (iv): Get through the data persistence layer of the Ren du two veins

Source: Internet
Author: User

Here, you will create a simplified user Management module that demonstrates how to leverage the functionality of the data persistence layer provided by Springside, including how to configure Many-to-many mappings and many-to-many mappings through hibernate annotation.

As you all know, the most popular user management model now is RBAC, the role-based access control model, in which you can divide multiple levels, such as user-role-resources, user-role-rights-resources, user-role-Role groups-permissions-resources, User-Role-Role groups-permissions-operations-resources and so on, it is quite difficult to create a sophisticated and complex user management module. In the Web2.0 era, there is a very important development idea, that is first let the program run, and then gradually add complex functions. Therefore, only a simplified user Management module is created here.

The so-called simplification, it has the following several characteristics:

1. In the authentication mode, select based on user name and password authentication, users need to provide user name, password and nickname, user name and nickname are required not to repeat, user name can not contain Chinese, and can not be modified, nickname can be Chinese, can also be modified. The password uses MD5 encryption.

2. Does not contain the user's true information, such as name, age, sex, occupation, address, postcode, and so on, because if you include these fields, you also need to include additional fields to allow users to decide whether to expose the information, so, to remove these things, you can simplify the development process, so that the site can run as quickly as possible.

3. Contact only requires the user to provide its e-mail and QQ number.

4. If the user's password is lost, it can be recovered by the password question, and the new password will be sent to the user's email address.

5. Omit the user's personalization settings, such as personalized signature, custom avatar, etc.

6. To be able to record the user's registration time and last logon time.

7. To have a perfect integration and ranking mechanism.

8. The user deletes the time does not do physical deletion, only is marked as this user is not available.

8. A simplified role and authority management mechanism, the simplification here is mainly as follows: Each user can only belong to one role, that is, the many-to-many relationship, not the traditional many-to-many relationship; The role does not need to be grouped; there is no specialized resource abstraction layer; a single field in the Role table indicates the permissions that the role has. Permissions are represented by numbers, separated by commas, such as "1,2", "1,3,15", and so on.

9. Users can create groups and join groups, in order to simplify, the founder of the group is the administrator, and can not be changed, users to join the group needs administrator approval, a user can add as many groups, that is, many-to-many relationship.

As can be seen from the above description, a simplified user management system requires a minimum of three tables, that is, users,roles and groups tables, where users and roles are many-to-many mappings, between users and groups, for many-to-many mappings, And the user needs administrator approval when joining group, need a middle table users_groups. Here is the statement that creates the data table in MySQL.

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.