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 withUserSerivce 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 objectCodePudding user response: