A multi-tenant-based electronic document processing method, system and storage medium
By storing data in Schema-level isolation areas in a multi-tenant model, the problem of resource waste in electronic document software is solved, and efficient utilization of system resources and improved stability are achieved.
Patent Information
- Application Number
- CN202411659154.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2044-11-20
AI Technical Summary
The service deployment of existing electronic document software leads to waste of resources and inefficient use of system resources.
A multi-tenant model is adopted, by setting up a unique tenant for each user, sharing a set of electronic document service systems and database services, and setting up Schema-level isolation areas in the system and database to achieve logical isolation of data and dynamic storage of operation data.
It saves database server resources, improves system performance and stability, reduces operation and maintenance costs, and achieves efficient use of resources.
Smart Images

Figure CN119645958B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a multi-tenant-based electronic document processing method, system and storage medium. Background Art
[0002] Electronic document software was previously deployed and managed using a method where each unit had independent service deployment, independent data storage, and independent upgrade and maintenance. While this approach provided a high level of data isolation, it also resulted in unnecessary hardware and software resource overhead and wasted resources. Therefore, finding a way to maximize resource utilization while using electronic document software became a pressing issue. Summary of the Invention
[0003] The present invention provides a multi-tenant-based electronic document processing method, system and storage medium to solve the problem that the existing service deployment using document software cannot efficiently use system resources, resulting in resource waste.
[0004] In a first aspect, the present invention provides a multi-tenant-based electronic document processing method, comprising:
[0005] Each user is assigned a unique tenant, and multiple tenants share a set of electronic document service systems and database services;
[0006] The data of each tenant is isolated from each other in the electronic document service system and the database service. That is, a unique schema-level isolation zone is set for each tenant in the electronic document service system and the database to achieve logical isolation of the data of different tenants in the electronic document service system and the database.
[0007] Establish an association between a user's data operations and the tenant corresponding to the user, so that the data operations are completed only within the Schema-level isolation area corresponding to the tenant. When performing database operations, operate the user data in the corresponding Schema-level isolation area based on the user's user information, and dynamically store the operation data in the Schema-level isolation area.
[0008] Optionally, the dynamic storage of the operation data in the Schema-level isolation area includes: storing the structured data generated by the user in the Schema-level isolation area corresponding to the tenant where the user is located in a schema-based manner, and dynamically generating a persistent directory based on the user's user information to store unstructured data in the persistent directory of the tenant corresponding to the user.
[0009] Optionally, the method further includes: storing public data as shared data in a public Schema area in the electronic document service system and the database, wherein the public data includes menus, dictionaries, and configuration information.
[0010] Optionally, the user's log and situation data are independently stored in a time-partitioned area in the Schema-level isolation area corresponding to the user.
[0011] Optionally, the method further includes: setting a top-level system administrator, where the top-level system administrator has the authority to create a new tenant and create a Schema-level isolation area corresponding to the new tenant.
[0012] Optionally, establishing an association between a user's data operation and the tenant corresponding to the user includes: retrieving tenant information of the tenant corresponding to the user who issued the data operation request based on the data operation request issued by the user through a preset tenant filter, and storing the tenant information in the data operation information of the user context through a preset thread decorator, so that in subsequent processing, the user's operation information is directly connected to the Schema-level isolation area corresponding to the user.
[0013] Optionally, the method further includes: dynamically storing the data generated by the operation data in the Schema-level isolation area corresponding to the user according to the user information of the user corresponding to the current data operation through a preset tenant filter, a preset electronic document thread decorator, and a preset persistence layer interceptor.
[0014] Optionally, dynamically storing the data generated by the operation data in the Schema-level isolation area corresponding to the user according to the user information of the user corresponding to the current data operation through a preset tenant filter, a preset electronic document thread decorator, and a preset persistence layer interceptor includes:
[0015] Retrieving tenant information of a tenant corresponding to a user who issues a data operation request based on a data operation request issued by the user through a preset tenant filter;
[0016] By presetting the thread decorator, tenant information is stored in the data operation information of the user context, so that in subsequent processing, the user's operation information is directly connected to the schema-level isolation area corresponding to the user;
[0017] The SQL statement is processed through the preset persistence layer interceptor, and the data generated by the operation data is dynamically stored in the user's corresponding Schema-level isolation area.
[0018] In a second aspect, the present invention provides a multi-tenant-based electronic document processing system for implementing any of the above methods, the system comprising: an electronic document service system and a database service;
[0019] A setting unit is configured to set a tenant uniquely corresponding to each user, set up multiple tenants to share an electronic document service system and a database service, and set up isolation of the data of each tenant in the electronic document service system and the database service. That is, by setting up a unique schema-level isolation zone for each tenant in the electronic document service system and the database, logical isolation of the data of different tenants in the electronic document service system and the database is achieved;
[0020] The processing unit is used to establish an association between a user's data operation and the tenant corresponding to the user, so that the data operation is completed only in the Schema-level isolation area corresponding to the tenant. When performing database operations, the user data in the corresponding Schema-level isolation area is operated according to the user's user information, and the operation data is dynamically stored in the Schema-level isolation area.
[0021] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-mentioned multi-tenant-based electronic document processing methods.
[0022] The beneficial effects of the present invention are as follows:
[0023] The present invention adopts a service sharing and data logic isolation mode. All tenants in this user mode share a set of services and a database, but each tenant has its own schema for storing data related to its own tenant, thereby greatly saving resource overhead. That is, the method of the present invention not only saves more database server resources, but also does not occupy a large amount of server system resources due to too many database instances when the software initializes the database connection pool resources, thereby significantly improving performance and system stability.
[0024] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiment below. The accompanying drawings are for illustration purposes only and are not to be considered as limiting the present invention. The same reference symbols are used throughout the drawings to represent the same components. In the drawings:
[0026] Figure 1 This is a schematic diagram of a data storage structure provided by an embodiment of the present invention;
[0027] Figure 2 This is a schematic diagram of the process of creating a new tenant provided by an embodiment of the present invention;
[0028] Figure 3 1 is a flow chart of a user access control method provided by an embodiment of the present invention;
[0029] Figure 4 1 is a flow chart of a user access control method provided by an embodiment of the present invention; DETAILED DESCRIPTION
[0030] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0031] To address the problem that existing service deployment using official document software cannot efficiently utilize system resources, resulting in resource waste, an embodiment of the present invention provides a multi-tenant-based electronic document processing method, including:
[0032] Step 101: Set a tenant uniquely corresponding to each user, and set up multiple tenants to share a set of electronic document service systems and a set of database services;
[0033] Among them, the electronic document processing system in the embodiment of the present invention can correspond to an organization, group or company. Taking the organization as an example, the organization may have multiple different departments. The method described in the embodiment of the present invention is to treat the department as a user and set a unique corresponding tenant for the user in the electronic document processing system. Through the setting, all tenants share an electronic document processing system, but the information between each tenant is isolated from each other, thereby improving the utilization rate of system resources while effectively ensuring the information privacy of each tenant.
[0034] Step 102: Isolate the data of each tenant in the electronic document service system and the database service. That is, set a unique schema-level isolation zone for each tenant in the electronic document service system and the database to achieve logical isolation of data of different tenants in the electronic document service system and the database.
[0035] In order to ensure the security of all users' data, the embodiment of the present invention is configured so that the data of each tenant is isolated from each other in the electronic document service system and the database service, that is, a Schema-level isolation area is set for each tenant.
[0036] Step 103: Associate the user's data operations with the tenant corresponding to the user, so that the data operations are completed only within the Schema-level isolation zone corresponding to the tenant. When performing database operations, operate the user data in the corresponding Schema-level isolation zone based on the user's user information, and dynamically store the operation data in the Schema-level isolation zone.
[0037] After setting up the Schema-level isolation zone, establish users and tenants, that is, establish an association between the user and its corresponding Schema-level isolation zone, so that the user can only operate the data in the corresponding isolation zone, and the processed data is also stored in the corresponding isolation zone.
[0038] Specifically, an embodiment of the present invention stores the structured data generated by the user in a schema-level isolation area corresponding to the tenant where the user is located, and dynamically generates a persistent directory based on the user's user information to store unstructured data in the persistent directory of the tenant corresponding to the user.
[0039] In order to further save resource usage, the embodiment of the present invention also provides a public Schema area, by storing public data as shared data in the public Schema area of the electronic document service system and the database. That is, the embodiment of the present invention stores public data such as menus, dictionaries and configuration information in the public Schema area.
[0040] By setting up a public Schema area, public data can be stored publicly, thus avoiding repeated storage of data in different Schema-level isolation areas, which can further save the consumption of system resources.
[0041] In addition, in order to facilitate searching, the present invention also independently stores the user's log and situation data in the time-partitioned area in the Schema-level isolation area corresponding to the user.
[0042] Through this standardized data storage method, on the one hand, the data can be effectively stored, and on the other hand, it can facilitate the subsequent retrieval and use of the data at any time. Therefore, this can also greatly save the consumption of system resources.
[0043] The present invention can greatly save the consumption of system resources by setting up a public Schema area, effectively storing user logs and situation data, and dynamically generating a persistent directory based on the user's user information to store unstructured data in the persistent directory of the tenant corresponding to the user, thereby greatly improving the processing efficiency of electronic documents and greatly improving the user experience.
[0044] See also Figure 1 The method described in this embodiment of the present invention is based on the concepts of service sharing and logical data isolation. By adopting schema-level isolation in the database design of the electronic document processing software, in addition to public data, independent schemas are created for tenant data. Structured data is stored in the database in separate schemas by unit; unstructured data is isolated and stored in separate directories by unit in the storage resources. Based on performance and resource considerations, public data (such as menus, dictionaries, and configuration information) is stored independently as shared data, while log and status data are stored independently and partitioned by year.
[0045] Through the above, the embodiment of the present invention is that multiple units share a set of electronic official document services and share the same hardware and software resources. This can not only ensure that the resource expenditure of the electronic official document software is not excessively wasted, but also that the operation and maintenance manpower and costs only need to maintain one set of electronic official document software. At the same time, each unit uses a unified version of electronic official documents, and can obtain the latest functions and problem fixes at the same time. In addition, the embodiment of the present invention can ensure that the data of each unit are independent of each other and do not affect each other through settings. In the case of sharing a set of electronic official document processing software, the independent storage of the data of each unit can still be guaranteed, and it is more conducive to the unit data not affecting the data of other units when migrating in and out.
[0046] During specific implementation, the method described in the embodiment of the present invention further sets a top-level system administrator, who has the authority to create a new tenant and create a Schema-level isolation zone corresponding to the new tenant.
[0047] The top system administrator is responsible for creating new tenants, revoking tenants, and adjusting various tenant permissions. For example, because Tenant A corresponds to the comprehensive management department, this tenant can view the permissions of a certain isolation area or a certain target of other tenants. Tenant B is the highest leader of the unit and has the permission to view a certain isolation area of a certain department, and so on.
[0048] In addition, when the top-level system administrator creates a new tenant, he or she also has the authority to assign an isolation area to the new tenant. That is, after the top-level system administrator creates a new tenant, he or she must also assign an isolation area to the new tenant and enable the new user to use the newly created tenant normally through settings.
[0049] Specifically, see Figure 2 In the embodiment of the present invention, in the tenant design, a top-level system administrator is set to be able to create a new tenant. At the same time, the administrator can select the organization managed under the tenant to create the tenant's isolation scope, etc., and each organization exists under only one tenant;
[0050] The electronic document processing software adds entity annotations to distinguish the tenant strategy of the entity class and whether it is a multi-tenant database table. When creating a new tenant, it creates a tenant-specific schema and a set of business tables unique to the schema.
[0051] At the same time, a file directory for distinguishing tenant identifiers is created under the persistent directory of unstructured data of the electronic document software for independent storage of unstructured data.
[0052] Furthermore, the embodiment of the present invention establishes an association between a user's data operation and the tenant corresponding to the user by retrieving the tenant information of the tenant corresponding to the user who issued the data operation request based on the data operation request issued by the user through a preset tenant filter, and stores the tenant information in the data operation information of the user context through a preset thread decorator, so that in subsequent processing, the user's operation information is directly connected to the Schema-level isolation area corresponding to the user.
[0053] Furthermore, in an embodiment of the present invention, the method further includes:
[0054] By presetting tenant filters, presetting electronic document thread decorators and presetting persistence layer interceptors, the data generated by the operation data is dynamically stored in the Schema-level isolation area corresponding to the user according to the user information of the user corresponding to the current data operation.
[0055] For specific implementation, see Figure 3 The embodiment of the present invention is based on a service sharing and data logic isolation model. Since the same database stores the business data of multiple tenants, it is necessary to ensure that each user can only access the business data of the tenant to which he belongs after logging in.
[0056] After the user logs in to the system using the single sign-on (SSO) authentication mechanism, the electronic document software adds a tenant filter to store and retrieve the corresponding tenant information based on the user when performing data operations. Before the user requests a data operation, the thread stores the tenant information in the tenant context when processing the request by using a thread decorator, ensuring that when processing concurrent requests, the user can also use a specific tenant and data source in subsequent processing.
[0057] In specific implementation, the embodiments of the present invention use a preset tenant filter, a preset electronic document thread decorator, and a preset persistence layer interceptor to dynamically store the data generated by the operation data in the Schema-level isolation area corresponding to the user according to the user information of the user corresponding to the current data operation, including:
[0058] Retrieving tenant information of a tenant corresponding to a user who issues a data operation request based on a data operation request issued by the user through a preset tenant filter;
[0059] By presetting the thread decorator, tenant information is stored in the data operation information of the user context, so that in subsequent processing, the user's operation information is directly connected to the schema-level isolation area corresponding to the user;
[0060] The SQL statement is processed through the preset persistence layer interceptor, and the data generated by the operation data is dynamically stored in the user's corresponding Schema-level isolation area.
[0061] Specifically, the embodiment of the present invention is based on a model of service sharing and data logic isolation. Because each unit has an independent database schema, when performing database operations, SQL statements for the corresponding schema need to be dynamically executed based on tenant information. Therefore, the MyBatis-Plus persistence layer framework needs to be modified and rewritten.
[0062] For specific implementation, see Figure 4 The method described in the embodiment of the present invention is to obtain the current schema from the thread context when performing data operations, and create a class to hold the information of the current schema; by rewriting the SQL interceptor of mybatis-plus, when processing SQL statements, according to the custom annotations of the entity class, determine which tables are fixed schemas and which tables are tenant schemas, and dynamically replace the table names with the tenant information in the fixed schema and the context, so as to achieve the electronic document processing software supporting multi-schema operations.
[0063] That is to say, the method described in the embodiment of the present invention modifies the background code of the electronic document processing software, adds tenant filters and thread decorators, and rewrites the SQL interceptor of the persistence layer, thereby ensuring that complex logical SQL statements and multi-mode SQL processing statements can still accurately and reliably query corresponding data based on the user's tenant information.
[0064] By comparison, it can be seen that compared with an independent database, the method described in the present invention saves a lot of resource overhead and application pressure. It not only saves more database server resources, but also does not occupy a large amount of server system resources due to too many database instances when the software initializes the database connection pool resources, which significantly improves performance and system stability.
[0065] Accordingly, an embodiment of the present invention further provides a multi-tenant-based electronic document processing system for implementing any of the above methods, the system comprising: an electronic document service system and a database service;
[0066] A setting unit is configured to set a tenant uniquely corresponding to each user, set up multiple tenants to share an electronic document service system and a database service, and set up isolation of the data of each tenant in the electronic document service system and the database service. That is, by setting up a unique schema-level isolation zone for each tenant in the electronic document service system and the database, logical isolation of the data of different tenants in the electronic document service system and the database is achieved;
[0067] Specifically, the setting unit of the embodiment of the present invention is used for the confidentiality officer to set the unit to be sent when sending an electronic document, and to set the tenant information of the selected unit. The selected unit may be a unit under the same tenant or a cross-tenant unit under different tenants. According to the set unit information, it is necessary to set the tenant information of the corresponding unit and the context information of the electronic document processing software.
[0068] The processing unit is used to establish an association between a user's data operation and the tenant corresponding to the user, so that the data operation is completed only in the Schema-level isolation area corresponding to the tenant. When performing database operations, the user data in the corresponding Schema-level isolation area is operated according to the user's user information, and the operation data is dynamically stored in the Schema-level isolation area.
[0069] That is, in the embodiment of the present invention, the electronic documents are distributed to different units and tenant associations through the processing unit, and the distribution units are classified according to the tenant information. When distributing to different units, the tenant information is set for the system context to ensure that when distributing to the current tenant unit, it will not be distributed to other units. After processing the distribution information of the current tenant, it continues to process the information of other tenants.
[0070] In other words, the embodiment of the present invention can realize service sharing and data isolation, that is, multiple units share a set of electronic document services, but the data is logically isolated. This method can solve the current problems of high electronic document software resource overhead, high operation and maintenance costs, and difficulty in version control.
[0071] In addition, embodiments of the present invention further provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements any of the above-described multi-tenant-based electronic document processing methods. The relevant contents of the storage medium and system embodiments of the present invention can be understood by referring to the relevant contents of the method embodiments of the present invention and are not discussed in detail here.
[0072] Although the preferred embodiments of the present invention have been disclosed for illustrative purposes, those skilled in the art will appreciate that various modifications, additions and substitutions are possible, and thus, the scope of the present invention should not be limited to the above embodiments.
Claims
1. A multi-tenant-based electronic document processing method, characterized in that: include: Each user is assigned a unique tenant, and multiple tenants share a set of electronic document service systems and database services; The data of each tenant is isolated from each other in the electronic document service system and the database service. That is, a unique schema-level isolation zone is set for each tenant in the electronic document service system and the database to achieve logical isolation of the data of different tenants in the electronic document service system and the database. Establish an association between a user's data operations and the tenant corresponding to the user, so that the data operations are completed only within the Schema-level isolation zone corresponding to the tenant. When performing database operations, the user data in the corresponding Schema-level isolation zone is operated based on the user's user information, and the operation data is dynamically stored in the Schema-level isolation zone. Dynamically storing the operation data in the Schema-level isolation area includes: The structured data generated by the user is stored in the Schema-level isolation area corresponding to the user's tenant, and a persistent directory is dynamically generated based on the user's user information to store unstructured data in the persistent directory of the user's tenant; New entity annotations are added to distinguish the tenant strategy of the entity class and whether it is a multi-tenant database table. In the process of creating a new tenant, a tenant corresponding model is created, and a set of business tables unique to this model is created under this model; in the persistent directory of unstructured data, a file directory is created to distinguish tenant identifiers for independent storage of unstructured data.
2. The method according to claim 1, characterized in that The method further comprises: Public data is stored as shared data in the public Schema area of the electronic document service system and the database, wherein the public data includes menus, dictionaries and configuration information.
3. The method according to claim 1, characterized in that The user's logs and situation data are stored independently in the time-partitioned area of the Schema-level isolation zone corresponding to the user.
4. The method according to claim 1, wherein The method further comprises: A top-level system administrator is set. The top-level system administrator has the permission to create a new tenant and create a Schema-level isolation zone corresponding to the new tenant.
5. The method according to any one of claims 1 to 4, characterized in that The operation of establishing a user's data association with the tenant corresponding to the user includes: By presetting the tenant filter, the tenant information of the tenant corresponding to the user who issued the data operation request is retrieved based on the data operation request issued by the user, and the tenant information is stored in the data operation information of the user context through the presetting thread decorator, so that in subsequent processing, the user's operation information is directly connected to the Schema-level isolation area corresponding to the user.
6. The method according to any one of claims 1 to 4, characterized in that The method further comprises: By presetting tenant filters, presetting electronic document thread decorators and presetting persistence layer interceptors, the data generated by the operation data is dynamically stored in the Schema-level isolation area corresponding to the user according to the user information of the user corresponding to the current data operation.
7. The method according to claim 6, characterized in that The method of dynamically storing the data generated by the operation data in the Schema-level isolation area corresponding to the user according to the user information of the user corresponding to the current data operation through the preset tenant filter, the preset electronic document thread decorator, and the preset persistence layer interceptor includes: Retrieving tenant information of a tenant corresponding to a user who issues a data operation request based on a data operation request issued by the user through a preset tenant filter; By presetting the thread decorator, tenant information is stored in the data operation information of the user context, so that in subsequent processing, the user's operation information is directly connected to the schema-level isolation area corresponding to the user; The SQL statement is processed through the preset persistence layer interceptor, and the data generated by the operation data is dynamically stored in the user's corresponding Schema-level isolation area.
8. A multi-tenant electronic document processing system for implementing the method according to any one of claims 1 to 7, characterized in that: The system includes: an electronic document service system and a database service system; A setting unit is configured to set a tenant uniquely corresponding to each user, set up multiple tenants to share an electronic document service system and a database service, and set up isolation of the data of each tenant in the electronic document service system and the database service. That is, by setting up a unique schema-level isolation zone for each tenant in the electronic document service system and the database, logical isolation of the data of different tenants in the electronic document service system and the database is achieved; A processing unit is configured to associate a user's data operations with the tenant corresponding to the user, so that the data operations are performed only within the schema-level isolation zone corresponding to the tenant. When performing database operations, the user data in the corresponding schema-level isolation zone is operated based on the user's user information, and the operation data is dynamically stored in the schema-level isolation zone. The processing unit is specifically used to store the structured data generated by the user in a schema-level isolation area corresponding to the tenant where the user is located, and dynamically generate a persistent directory based on the user's user information to store unstructured data in the persistent directory of the tenant corresponding to the user; by adding new entity annotations to distinguish the tenant strategy of the entity class and whether it is a multi-tenant database table, a tenant corresponding schema is created in the process of creating a new tenant, and a set of business tables unique to the schema is created under the schema; under the persistent directory of unstructured data, a file directory for distinguishing tenant identifiers is created for independent storage of unstructured data.
9. A computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the multi-tenant-based electronic document processing method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Multi-tenant database management and control method and system and storage medium
CN113535723A
Data routing method and device based on multiple tenants
CN118646705A