Service-oriented user group management implementation method
By defining the key database table structure and implementing user group management methods, the problem of inconvenience in large-scale user group management is solved, and the lightweight and fast user group management functions are realized, which are suitable for Internet business scenarios.
Patent Information
- Application Number
- CN202411866876.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-15
AI Technical Summary
The prior art has inconvenience in the face of large-scale user group management, and the user group construction method based on user portraits has failed to effectively solve the problems of user group management and application.
A business-oriented user group management implementation method is proposed. By defining the key database table structure, including business table, user group table, user group and user relationship table, user group policy table, etc., the creation of user groups, policy addition, user association and business-corresponding user groups are realized.
It realizes a lightweight and fast user group management function, which can be quickly applied in Internet business scenarios, meeting the needs of querying all users of the service and determining whether the user belongs to a certain business.
Smart Images

Figure CN119829577A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a method for implementing user group management for a business. Background Art
[0002] User groups refer to user groups divided according to user characteristics or business needs. User groups are often needed in business usage scenarios of the Internet. For example, if you want to push marketing information to a specific user group, or limit a specific user group to use or not use certain functions and applications of the system, the implementation of these business scenarios requires user group management. Currently, common user group implementation technologies include those based on dynamic permission management, which are flexible and accurate, but inconvenient when managing large-scale users; and those based on user portraits to build user groups, which focus on user feature extraction and user portrait implementation, and do not propose good methods for user group management and application.
[0003] Currently, there is no relevant solution on the market. Summary of the invention
[0004] In view of the above technical problems in the related art, the present invention proposes a service-oriented user group management implementation method, which can overcome the above deficiencies in the prior art.
[0005] To achieve the above technical objectives, the technical solution of the present invention is implemented as follows:
[0006] A method for implementing user group management for a service, comprising the following steps:
[0007] S1: Define the key database table structure, including the business table business, the business and user group relationship table business_group, the user group table group, the user group and user relationship table group_user, and the user group policy table group_rule;
[0008] The business table business includes: id--unique ID, name--business name, description--business description;
[0009] The business and user group relationship table business_group includes: id--unique ID, business_id--business unique ID, type--relationship type, relationship type--user group unique ID; when the type value is 1, it indicates the inclusion type, which means including all users in the user group; when the type value is 2, it indicates the exclusion type, which means excluding all users in the user group;
[0010] The user group table group includes: id--unique ID, name--user group name, description--user group description;
[0011] The user group and user relationship table group_user includes: id--unique ID, group_id--user group unique ID, user_id--user unique ID;
[0012] The user group strategy table group_rule includes: id--unique ID, group_id--user group unique ID, table_name--table name, user_column_name--the field name corresponding to the user unique ID in the table and the default value is user_id, condition--SQL query condition;
[0013] S2: User group management implementation, including the following sub-steps:
[0014] S2.1: Create a user group and use the user group table group to store the user group - when creating the user group, insert a record into the user group table group;
[0015] S2.2: Add policies for user groups, use the user group policy table group_rule to store user group policy data, and one group corresponds to one or more group_rule data;
[0016] In group_rule: the table_name field indicates the table name for querying users, which stores the corresponding user group table or business table; the user_column_name field indicates the field name corresponding to the user ID in the table. The field name is id for the user group table and user_id for the business table; the condition field indicates the SQL query condition for filtering users from the table_name table;
[0017] S2.3: Add a default policy data for the newly created user group: the table_name field value is 'group_user', the user_column_name field value is 'user_id', and the condition field value is 'group_id = current user group ID';
[0018] S2.4: directly add several users to the user group, and use the user group and user relationship table group_user to store the direct relationship between the user group and the user - that is, insert the corresponding data into the table when adding users to the user group;
[0019] S3: Implement the management of the user groups corresponding to the business, including the following sub-steps:
[0020] S3.1 Create business data: When a new business scenario requires a user group, add a piece of business data to the business table;
[0021] S3.2 Add user groups to services: Use the business and user group relationship table business_group to store the user group relationship corresponding to the service; a service can correspond to one or more user groups; the relationship between services and user groups is divided into two categories, inclusive type --- type value is 1 and exclusive type --- type value is 2. The inclusive type indicates that the users in the user group are included, and the exclusive type indicates that the users in the user group are excluded;
[0022] S4: Query several user group policy records from the user group policy table group_rule, and match them with corresponding users respectively, so as to obtain all user IDs corresponding to all the user group policy records;
[0023] S5: querying users corresponding to policy data containing multiple user groups and users corresponding to policy data excluding multiple user groups, and generating a SQL statement for querying users;
[0024] S6: Select a certain service, query the implementation steps of all users of the service, and obtain the query statements of all users of the service;
[0025] S7: Determine whether a certain user belongs to a certain service.
[0026] Preferably, the S4 specifically includes the following sub-steps:
[0027] S4.1: merge the policy data with the same table_name value and user_column_name value into one policy data;
[0028] S4.2: Merge the policy data with the same table_name value and user_column_name value into one policy data. The condition values are enclosed in brackets and concatenated with the or keyword.
[0029] S4.3: All SQL statements in S4.2 are concatenated using the union operator to obtain a new query statement, the query result of which is all user IDs corresponding to all the user group policy records.
[0030] Preferably, the S5 specifically includes the following sub-steps:
[0031] S5.1: Set the SQL query statement used in S4 to obtain the users corresponding to the policy data of multiple user groups to include_sql;
[0032] S5.2: Set the SQL query statement used in S4 to obtain the users corresponding to the exclusion policy data of multiple user groups to exclude_sql;
[0033] S5.3: Combine the SQL query statements obtained in S5.1 and S5.2 to finally generate the SQL statement for querying the user.
[0034] Preferably, the S6 specifically includes the following sub-steps:
[0035] S6.1: Query all user groups and user group policies corresponding to the service;
[0036] S6.2: Divide the policy data into two groups according to the user group type, one group is the inclusion type policy and the other group is the exclusion type policy;
[0037] S6.3: Based on the result of S6.2, refer to S5 to obtain the query statements of all users of the service.
[0038] Preferably, the step S7 includes the following sub-steps:
[0039] S7.1: Obtain all user query statements of the business in S6 and define them as business_sql;
[0040] S7.2: A query statement to determine whether a certain user is in the service. If the query result is greater than 0, it means that the user belongs to the service; otherwise, the user does not belong to the service.
[0041] Beneficial effects of the present disclosure: The present disclosure proposes a user query method based on policies and SQL statements through the management of three core objects, namely, business, user group, and user group policy, and the relationship data between them. This method can realize the management function of the business corresponding to the user group in a lightweight and fast manner, and meet the needs of querying all users corresponding to the business and determining whether a user belongs to a certain business.
[0042] This disclosure implements the management of object data and relationships by defining three core objects: business, user group, and user group strategy, and proposes a query method for corresponding users. On this basis, it implements the query of all users corresponding to the business and determines whether a user belongs to a certain business demand, which has the following effects:
[0043] (A). The implementation method is relatively lightweight and fast, and can be easily applied in various Internet business scenarios.
[0044] (B) The same user group can be reused in different business scenarios, which facilitates the maintenance and management of user groups and the selection of specific user groups for business scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0046] Figure 1 It is the relationship among the business, user group and user group strategy in the business-oriented user group management implementation method described in this disclosure. DETAILED DESCRIPTION
[0047] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0048] like Figure 1 As shown, in order to facilitate understanding of the above technical solution of the present invention, the above technical solution of the present invention is described in detail below through specific usage. Specific implementation method:
[0050] Step 1: Define the key database table structure as follows:
[0051] (1) Business table (business):
[0052] Field Name describe type Is it necessary id Unique ID varchar(64) yes name Business Name varchar(64) yes description Description of the business. varchar(128) yes
[0053] (2) Business and user group relationship table (business_group):
[0054]
[0055] (3) User group table (group):
[0056]
[0057] (4) User group and user relationship table (group_user):
[0058] Field Name describe type Is it necessary id Unique ID long yes group_id User group unique ID long yes user_id User unique ID varchar(64) yes
[0059] (5) User group policy table (group_rule):
[0060]
[0061] Step 2: User group management is implemented as follows:
[0062] (1) Create a user group: Use the group table to store user group data. When creating a user group, insert a record into the group table.
[0063] (2) Add policies for user groups: Use the group_rule table to store user group policy data. One group can correspond to multiple group_rule data. The table_name field in the group_rule table indicates the name of the table for querying users, which can be a user table or a business table; the user_column_name field indicates the field name corresponding to the user ID in the table. Generally, the field name in the user table is id, and the field name in the business table is user_id; the condition field indicates the SQL query condition for filtering users from the table_name table. An example is shown below:
[0064] Add the following policy field values for the user group (id is 1):
[0065]
[0066] Among them, sys_user is the system user table, id is the user's unique ID, sex is the gender field, and city is the user's city field; sys_vip_user is the paid membership table, pay_status is the payment status, and expired_date is the membership expiration date.
[0067] (3) A default policy data is added for the newly created user group: the table_name field value is 'group_user', the user_column_name field value is 'user_id', and the condition field value is 'group_id = current user group ID'.
[0068] (4) Directly add some users to the user group: Use the group_user table to store the direct relationship between the user group and the user, and insert the corresponding data into the table when adding users to the user group.
[0069] Step 3: The management of the business corresponding user group is implemented as follows:
[0070] (1) Create business data: When a new business scenario requires a user group, add a piece of business data to the business table.
[0071] (2) Add user groups to a business: Use the business_group table to store the user group relationship corresponding to the business. One business can correspond to multiple user groups. The relationship between a business and a user group is divided into two categories: inclusion type (type value is 1) and exclusion type (type value is 2). The former indicates that the users are included in the user group, and the latter indicates that the users are excluded from the user group.
[0072] Step 4: The implementation steps for querying the corresponding users of multiple user group policy (group_rule) data are as follows:
[0073] (1) The policy data with the same table_name value and user_column_name value are merged into one policy data. The condition values are enclosed in parentheses and concatenated with the or keyword, for example, (condition1) or (condition2) or (condition3), to form the condition value of the new data.
[0074] (2) After the policy merging process, the policy data generates an SQL query statement: select${user_column_name}as user_id from${table_name}where${condition}, where ${user_column_name}, ${table_name}, and ${conditon} correspond to the user_column_name value, table_name value, and condition value of the policy data, respectively.
[0075] (3) Use the union operator to concatenate all SQL statements in (2) to obtain a new query statement. The query result of this statement is all the user IDs corresponding to these user group strategies. For example:
[0076] select${user_column_name1}as user_id from${table_name1}where${condition1}union select${user_column_name2}as user_id from
[0077] ${table_name2}where${condition2}. If other user information is needed, you can perform a joint table query with the user table based on this.
[0078] Step 5: The implementation steps for querying the users corresponding to the policy data of multiple user groups and the users corresponding to the policy data of multiple user groups are as follows:
[0079] (1) According to step 4, the SQL query statement containing the corresponding users of multiple user group policy data is set as include_sql.
[0080] (2) The SQL query statement corresponding to the user of the exclusion policy data of multiple user groups obtained in step 4 is set as exclude_sql.
[0081] (3) The final SQL statement to query the user is: select user_id from(${include_sql})as awhere user_id not in(${exclude_sql}). ${include_sql} and ${exclude_sql} are include_sql and exclude_sql in (1) and (2) respectively.
[0082] Step 6: The implementation steps for querying all users of a certain business are as follows:
[0083] (1). Query all user groups and user group policies corresponding to the business. Query statement: select * from business_group as b inner join group as g on b.group_id = g.id inner join group_rule as r on g.id = r.group_id where b.business_id = ${business_id}. ${business_id} is the unique ID of the current business.
[0084] (3) According to the user group type, the policy data is divided into two groups, one group is the inclusion type policy and the other group is the exclusion type policy.
[0085] (3) Based on the result of (2), use the method in step 5 to obtain the query statements for all users of the service.
[0086] Step 7: The implementation steps for determining whether a user belongs to a certain service are as follows:
[0087] (1) According to step 6, all user query statements for the business are obtained and defined as business_sql.
[0088] (2) Query statement to determine whether a certain user is in the business: select * from (${business_sql}) as a where user_id = ${user_id}. ${business_sql} is the business_sql in (1), and ${user_id} is the unique ID of the current user. If the query result is greater than 0, it means that the user belongs to the business, otherwise it does not belong to the business.
[0089] In summary, through the above unique technical solution, the present disclosure implements the management of object data and relationships by defining three core objects: business, user group, and user group strategy, and proposes a query method for corresponding users. On this basis, the query of all users corresponding to the business and the determination of whether a user belongs to a certain business demand are implemented, which has the following effects: (A). The implementation method is relatively lightweight and fast, and is convenient for application in various Internet business scenarios. (B). The same user group can be reused in different business scenarios, which is convenient for the maintenance and management of user groups, as well as the selection of specific user groups for business scenarios.
[0090] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for implementing business-oriented user group management, characterized in that: The following steps are involved: S1: Define the key database table structure, including the business table business, the business and user group relationship table business_group, the user group table group, the user group and user relationship table group_user, and the user group policy table group_rule; The business table business includes: id--unique ID, name--business name, description--business description; The business and user group relationship table business_group includes: id--unique ID, business_id--business unique ID, type--relationship type, relationship type--user group unique ID; when the type value is 1, it indicates the inclusion type, which means including all users in the user group; when the type value is 2, it indicates the exclusion type, which means excluding all users in the user group; The user group table group includes: id--unique ID, name--user group name, description--user group description; The user group and user relationship table group_user includes: id--unique ID, group_id--user group unique ID, user_id--user unique ID; The user group strategy table group_rule includes: id--unique ID, group_id--user group unique ID, table_name--table name, user_column_name--the field name corresponding to the user unique ID in the table and the default value is user_id, condition--SQL query condition; S2: User group management implementation, including the following sub-steps: S2.1: Create a user group and use the user group table group to store the user group - when creating the user group, insert a record into the user group table group; S2.2: Add policies for user groups, use the user group policy table group_rule to store user group policy data, and one group corresponds to one or more group_rule data; In group_rule: the table_name field indicates the table name for querying users, which stores the corresponding user group table or business table; the user_column_name field indicates the field name corresponding to the user ID in the table. The field name is id for the user group table and user_id for the business table; the condition field indicates the SQL query condition for filtering users from the table_name table; S2.3: Add a default policy data for the newly created user group: the table_name field value is 'group_user', the user_column_nam field value is 'user_id', and the condition field value is 'group_id=current user group ID'; S2.4: directly add several users to the user group, and use the user group and user relationship table group_user to store the direct relationship between the user group and the user - that is, insert the corresponding data into the table when adding users to the user group; S3: Implement the management of the user groups corresponding to the business, including the following sub-steps: S3.1 Create business data: When a new business scenario requires a user group, add a piece of business data to the business table; S3.2 Add user groups for services: Use the business and user group relationship table business_group to store the user group relationship corresponding to the service; one service corresponds to one or more user groups; the relationship between services and user groups is divided into two categories, inclusive type --- type value is 1 and exclusive type --- type value is 2. The inclusive type indicates that the users in the user group are included, and the exclusive type indicates that the users in the user group are excluded; S4: Query several user group policy records from the user group policy table group_rule, and match them with corresponding users respectively, so as to obtain all user IDs corresponding to all the user group policy records; S5: querying users corresponding to policy data containing multiple user groups and users corresponding to policy data excluding multiple user groups, and generating a SQL statement for querying users; S6: Select a certain service, query the implementation steps of all users of the service, and obtain the query statements of all users of the service; S7: Determine whether a certain user belongs to a certain service.
2. The method for implementing user group management according to claim 1, characterized in that: The S4 specifically includes the following sub-steps: S4.1: merge the policy data with the same table_name value and user_column_name value into one policy data; S4.2: Merge the policy data with the same table_name value and user_column_name value into one policy data. The condition values are enclosed in brackets and concatenated with the or keyword. S4.3: All SQL statements in S4.2 are concatenated using the union operator to obtain a new query statement, the query result of which is all user IDs corresponding to all the user group policy records.
3. The method for implementing user group management according to claim 1, characterized in that: The S5 specifically includes the following sub-steps: S5.1: Set the SQL query statement used in S4 to obtain the users corresponding to the policy data of multiple user groups to include_sql; S5.2: Set the SQL query statement used in S4 to obtain the users corresponding to the exclusion policy data of multiple user groups to exclude_sql; S5.3: Combine the SQL query statements obtained in S5.1 and S5.2 to finally generate the SQL statement for querying the user.
4. The method for implementing user group management according to claim 1, characterized in that: The S6 specifically includes the following sub-steps: S6.1: Query all user groups and user group policies corresponding to the service; S6.2: Divide the policy data into two groups according to the user group type, one group is the inclusion type policy and the other group is the exclusion type policy; S6.3: Based on the result of S6.2, refer to S5 to obtain the query statements of all users of the service.
5. The method for implementing user group management according to claim 1, characterized in that: The S7 includes the following sub-steps: S7.1: Obtain all user query statements of the business in S6 and define them as business_sql; S7.2: A query statement to determine whether a certain user is in the service. If the query result is greater than 0, it means that the user belongs to the service; otherwise, the user does not belong to the service.