Home > Back-end >  System management functions of how to plan the business class
System management functions of how to plan the business class

Time:10-26

Background: general software needs to be a core module, system management, including user management, role management, function menu, the user configuration corresponding roles, role corresponding function configuration menu,
The users table: user_id, user_name
Role table: role_id, role_name
User roles associated table: user_id, role_id
Menu table: menu_id, menu_name menu_addr
Character menu associated list: role_id, menu_id
The data structure, software functions are implemented this is easy, but the related service class, and how to define the invocation of the relationship between each other?

Consider the following scenario:
1 when the user login, to query the function of a user menu, the related information in the session menu
Class, this process needs to the user information service function menu service class, user role service class, the role of corresponding function menu service class, how to define the function of each service class, and organize the service classes finish "to query the function of a user menu" this function?
Thinking: the user query service class by - "call user role service class query user corresponding character ID (there may be multiple roles) - & gt; Call character menu service class query ID - & gt; Call menu service class query to specific information - "the query to the menu in the session (of course, to be organized into a tree structure of objects can be)
Question: whether it should be in order to establish the service class association form alone, such as user roles associated table, also want to build a UserRoleService class? Whether can also go to query the user role in UserSerivce associative table sys_user_role? Of course both practices to achieve specific functions, just don't know the specific design principles, will affect future modifications,

CodePudding user response:

User roles associated table must be set up an independent service, this is for reducing the permission check with
UserSerivce is used for configuration, configuration, of course, and the role of service
Certainly not in a service

CodePudding user response:

You say a specific service class, in fact, the open API library for use by the User, this class is to function, so you just a class as a function of these containers, such as the service class that contains API1, API2, API3, don't need each table has a service class, the class can be divided according to the business, such as your example involving multiple tables, but business is dealing with the User, so building a User_Service class, the class can contain more than one object, and the User class is the User an object

CodePudding user response:

reference 1st floor KeepSayingNo response:
user roles associated table must be set up an independent service, this is for reducing the permission check with
UserSerivce is used for configuration, configuration, of course, and the role of service
Certainly not in a service inside

Service class planning:
UserService focus on the basic information of the user to add and delete, RoleService is used for Angle to add and delete the information management, MenuService focused on the menu to add and delete,
PermissionService - focused on authorization, access query function, support of user roles, user menu function (and set user roles and role Settings menu related functions)
The PermissionService will invoke the UserService RoleService MenuService to query information, at the same time will directly call UserRoleMapper (persistence layer use mybatis), RoleMapper needed data,
  • Related