Universal storage method capable of meeting input of different business scenes

By citing common saving related jar packages and automatically assembling SQL statements using database capabilities, the differences in financial input and saving data in various places are solved, and efficient data storage and rapid delivery are achieved.

CN119556913APending Publication Date: 2025-03-04JIANGSU FINSTONE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311118035.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-01
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

In the prior art, local finances input elements and fields saved to the database are different when entering, resulting in a specific storage method for each finance, resulting in low development efficiency, unstable procedures, and affecting product quality.

Method used

By referring to the general saving related jar package, combining the data object to be saved provided by the front-end and the physical table name set by the back-end, the database itself can obtain all fields and field properties of the physical table, and automatically assemble the SQL statement to realize the data storage.

Benefits of technology

It greatly reduces the amount of back-end code writing, improves delivery efficiency and delivery quality, and can only modify the front-end and database table interfaces when business needs change, without modifying the back-end code, achieving rapid delivery and reducing development costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure HDA0004425643140000011
    Figure HDA0004425643140000011
  • Figure HDA0004425643140000021
    Figure HDA0004425643140000021
Patent Text Reader

Abstract

The invention discloses a general storage method capable of meeting input of different business scenes, which comprises the following steps that: a general storage related jar package is quoted in a system project, the file of the quoted general storage related jar package is sfcp-compent-pub-1. 1.0-SNAPSHOT.jar, and a used class is quoted in a service class. The invention discloses a universal storage method meeting input of different business scenes. The universal storage method comprises the following steps of: 1, checking document elements; step 2, pre-rule verification is carried out; step 3; obtaining a physical table column; step 4, a compatible tenant mode; 5, processing the compatible optimistic lock; step 6, checking whether the required fields are non-empty or not; step 7, assembling sql statements; 8, executing the sql statement; step 9, post rule verification is carried out; according to the method, the writing amount of the back-end codes is greatly reduced, meanwhile, the code error probability is reduced, the delivery efficiency and the delivery quality are improved, and when the service requirements change, the back-end codes do not need to be modified, and the use of the user is not influenced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data management, and in particular to a universal storage method that meets the requirements of data entry in different business scenarios. Background Art

[0002] For the same business, local finance departments have different input elements when entering data according to their own management needs, and the corresponding fields saved in the database are also different. The conventional practice is to have one saving method for each finance department, and the program needs to be modified every time the needs change. On the one hand, it is duplication of work and greatly reduces development efficiency. On the other hand, it causes program instability and affects product quality. Therefore, it is necessary to use a general saving method that meets the requirements of different business scenarios in order to solve the technical problems raised. Summary of the invention

[0003] The purpose of the present invention is to provide a universal saving method that meets the requirements of different business scenarios. The backend does not need to create a series of files such as entity classes, Mapper interface classes and Mapper.xml configuration files, which greatly reduces the amount of backend code to be written, and also reduces the probability of coding errors, greatly improves delivery efficiency and delivery quality. When business requirements change, only the frontend and database table interface need to be modified, and the backend code does not need to be modified, so that the project does not need to be redeployed, and does not affect user use at all. The capabilities of the database and cache middleware can be fully utilized, combined with the data objects to be saved provided by the frontend and the physical table names set by the backend, etc., all fields and field attributes of the physical table are obtained through the database's own capabilities, and the SQL statements are automatically assembled using the provided program. After execution, the purpose of saving data can be achieved, and a set of saving method codes are implemented to meet the financial needs of various places, greatly improving development efficiency and product quality. Only very few codes are required to realize data verification and preservation. When business requirements change, only the table structure and the data objects to be saved passed in by the frontend need to be adjusted to realize the preservation of different data structures without modifying the backend code, thereby achieving the purpose of reducing development costs and rapid delivery, so as to solve the problems raised in the above background technology.

[0004] To achieve the above-mentioned purpose, the present invention provides the following technical solutions: a general saving method that meets the requirements of different business scenarios, including referencing a general saving related jar package in a system project, wherein the file of the referenced general saving related jar package is sfcp-component-pub-1.0-SNAPSHOT.jar, and referencing the used classes in the service class, wherein the referenced classes are importcom.finstone.sfcp.component.pub.entity.SaveEntity and importcom.finstone.sfcp.compon ent.pub.util.SaveUtils, automatically assembling the SaveUtils class through the @Autowired annotation, and using the construction method public SaveEntity as String tableName and ObjectsaveDatas to construct a saveEntity object, specifically: SaveEntity saveEntity=new SaveEntity(tableName,saveDatas), the parameter tableName is the name of the table where the data object is finally saved, and the parameter saveDatas is the data object to be saved in JSON format. The rule identifier and document identifier can be selectively configured into saveEntity to achieve the purpose of document verification and rule verification. The financial business of each region is different. It is only necessary to configure different verification methods for the rules corresponding to the rule identifier and document identifier. By calling the saveUtils.saveTable(saveEntity) method, you can enter the general save to process and store the data. The general save will return the saved result to realize the call of the general save method.

[0005] A general saving method that meets the requirements of different business scenarios, including step 1: document element verification; step 2: pre-rule verification; step 3: obtaining physical table columns; step 4: compatible with tenant mode; step 5: compatible with optimistic lock processing; step 6: verifying whether required fields are not empty; step 7: assembling SQL statements; step 8: executing SQL statements; step 9: post-rule verification;

[0006] In the above step 1, by calling the supporting document verification engine, the engine will verify the legality of the incoming JSON object according to the business document type brought in by saveEntity, and check whether each element meets the business requirements. The data in the same target table may need to be controlled by different verification rules due to different businesses, so different verification types need to be configured. The implementation personnel can configure the attributes of each element according to business needs or application requirements, including whether it is a required item, data type, whether it is a business primary key, which basic code set it belongs to, the value setting method, data verification method and the value setting formula. The value setting of the element can reduce the amount of user input. In the program, other content can be supplemented according to the content entered by the user. The value setting methods include fixed value, rule value setting, java class value setting and indefinite value. The data verification methods include fixed value verification, code verification, expression verification and no verification.

[0007] In the above step 2, by calling the supporting business rule engine, the rule engine will poll the corresponding rule verification details according to the passed-in business rule identifier to determine whether the execution of this save complies with the business logic. When the general save is executed to this step and no business rule identifier is found, no verification is performed. The business rule identifier corresponds to several rules, and each rule corresponds to a configurable SQL statement and error prompt, etc. The implementation personnel configure the fragment of the where condition in the SQL statement with dynamic parameters according to business needs. Finally, the program automatically combines into a SQL statement such as select count(*)fromtableName where#configured where condition#, and passes the data elements to be saved into the SQL to replace the dynamic parameters. After execution, it is determined whether the data violates the business rules according to the execution result and rule type;

[0008] In the above step 3, the physical table corresponding to tableName in saveEntity is queried in the database to determine whether the table exists. If the table exists, the table columns and data attributes of the table columns of the physical table are obtained. The data attributes include whether it is non-empty, whether it is a primary key field, etc.;

[0009] In the above step 4, developers can enable tenant mode by adding the configuration tenant:${fusion.tenant.enabled:false} in application.yml, and configure multiple tenant fields in the tenantCols constant of the constant class GlobalParams according to requirements. After the configuration is completed, when the general save method runs to this step, the program will poll all the fields obtained in the previous step. When a field matching the tenant field in tenantCols is found, it means that the tenant field is found. The program will automatically fill in the tenant value of the logged-in user into the tenant field. When the user queries the data, the program will automatically add the tenant condition, and finally achieve the purpose of isolating the data of each tenant. When the table does not poll the matching tenant field, it means that this table is not a business data table or this application does not need to consider the tenant mode, and the program does not process the tenant field.

[0010] In the above step 5, the optimistic lock function is enabled by configuring locker-enabled:true in application.yml, and the optimistic lock field is specified by configuring locker-column:VER_LOCK. After enabling, the value of the field corresponding to the optimistic lock is automatically set to 1 when saving data, indicating that the data version is 1. When the data is subsequently modified or logically deleted, it is automatically increased by 1 each time, without manually processing the self-increment of the optimistic lock, which increases the fault tolerance of the system.

[0011] In the above step 6, the table column of the physical table in the database can be defined as non-empty. When the non-empty field has no corresponding value, the program will report an error, and the user will be given an unfriendly and unprofessional prompt. This step can be verified in advance before operating the database, and accurately prompt the user of the unfilled information items, which reduces the database overhead and makes the prompt more friendly;

[0012] In the above step 7, the SQL statement is a language recognizable by the database, and the syntax structure for saving the SQL statement is insert into table_name(column1,column2,column3,...)values(value1,value2,value3,...), where table_name is the target table, column is the table field, and values ​​is the value corresponding to each field. To dynamically generate such an SQL statement, the program concatenates all fields of the target physical table into a column code segment in a polling manner, and at the same time finds the corresponding value of the field from the object to be saved, and concatenates the value code segment in the same order, and finally forms an SQL statement that can be executed in the database;

[0013] In the above step eight, when the sql statement needs to be executed in the java program, a Java API for executing SQL statements is required. JDBC is Java DataBase Connectivity, java database connection, a Java API for executing SQL statements, which can provide unified access to multiple relational databases and consists of a group of classes and interfaces written in Java. The bottom layer of this system uses JdbcTemplate technology to implement database operations. Executing the sql statement just assembled can save the data into the target table. Template is a template. JDBCTemplate is a set of class libraries provided by Spring for accessing the database. Spring encapsulates the template for JDBC.

[0014] Among them, the difference between the above step nine and the pre-verification is that the time verification is done after the execution of the insert statement is completed and before the transaction is committed. The purpose is to avoid the submission of other data during the period between the execution of the SQL statement and the submission of the transaction. The post-verification will verify the scenario of how much balance is left in a bank card after a user withdraws money. Once the balance is found to be less than 0, the user's withdrawal operation is blocked. At this time, although the statement is executed, it is not committed, and a rollback operation can be performed. The execution method is the same as the pre-verification.

[0015] Preferably, the business document type in step one is passed in from the front end together with the object to be saved. The document verification engine will poll and verify each element to be saved passed in from the front end to verify whether it meets the configured attribute requirements. The verification content includes whether the required items are complete, whether the data type filled in by the user is consistent with the configuration, whether the selected data set code belongs to the configured data set, whether the data verification meets the configuration requirements, etc. If the requirements are not met, the subsequent steps will no longer be processed, which can meet different business requirements and reduce the overhead of the program and database. The specific reason for not meeting the requirements will be prompted to the user, guiding the user to enter the correct data, and the program will automatically calculate the value of the content that needs to be set according to the setting method.

[0016] Preferably, the rule types in step 2 are inclusion rules and exclusion rules. The inclusion rule means that the execution result is passed if it is greater than 1, and the execution result is failed if it is equal to 0; the exclusion rule means that the execution result is failed if it is greater than 1, and passed if it is equal to 0. If the elements in the business object to be saved violate the business rules, the subsequent steps will no longer be processed, and the reason for the violation of the rules will be prompted to the user, so that the user can enter data that complies with the business rules.

[0017] Preferably, the first acquisition in step three will be stored in the cache to reduce the database overhead when querying the table information next time. When the database table structure changes due to business changes, only the cache needs to be cleared without re-encoding to obtain the latest table column information.

[0018] Preferably, the tenant model in step 4 is applicable to scenarios where multiple different regions need to use the same system and database, but the data needs to be isolated from each other. The system is deployed at the municipal level, and users in various districts and counties in the city use this system as tenants, and each other's data is not allowed to be shared, viewed, or operated.

[0019] Preferably, the optimistic lock in step 5 is to maintain an optimistic attitude towards data conflicts, and the data being operated will not be locked when the data is being operated, and only when the data is submitted will a mechanism be used to verify whether there is a conflict in the data.

[0020] Preferably, the document elements in step six are configured with mandatory items for the business, and the non-empty items in the database can be regarded as absolutely non-empty at the physical level. The non-empty check in this step adds the last line of defense on the basis of the document element check, and increases the fault tolerance mechanism.

[0021] Compared with the prior art, the present invention has the following beneficial effects:

[0022] The present invention does not need to create a series of files such as entity classes, Mapper interface classes and Mapper.xml configuration files at the back end, thereby greatly reducing the amount of back end code to be written, and also reducing the probability of coding errors, thereby greatly improving delivery efficiency and delivery quality. When business requirements change, only the front end and database table interface need to be modified, and the back end code does not need to be modified, so that the project does not need to be redeployed, and user use is not affected at all. The present invention can fully utilize the capabilities of the database and cache middleware, and in combination with the data objects to be saved provided by the front end and the physical table names set by the back end, etc., obtain all fields and field attributes of the physical table through the database's own capabilities, and automatically assemble SQL statements using the provided program. After execution, the purpose of saving data can be achieved, and a set of saving method codes can be implemented to meet the financial needs of various places, thereby greatly improving development efficiency and product quality. Only very few codes are required to implement data verification and preservation. When business requirements change, only the table structure and the data objects to be saved passed in by the front end need to be adjusted to implement the preservation of different data structures without modifying the back end code, thereby reducing development costs and achieving the purpose of rapid delivery. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 It is a schematic diagram of the general saving and calling steps of the present invention;

[0024] Figure 2 It is a schematic diagram of the general storage internal implementation process of the present invention. DETAILED DESCRIPTION

[0025] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0026] In the description of the present invention, it should be noted that the terms "upper", "lower", "inner", "outer", "front end", "rear end", "two ends", "one end", "the other end" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.

[0027] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "provided with", "connected", etc. should be understood in a broad sense. For example, "connected" can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0028] See also Figure 1-2 , an embodiment provided by the present invention:

[0029] Example 1

[0030] A general saving method that meets the requirements of different business scenarios includes referencing the general saving related jar package in the system project. The file of the referenced general saving related jar package is sfcp-component-pub-1.0-SNAPSHOT.jar, and referencing the used class in the service class. The referenced class is importcom.finstone.sfcp.component.pub.entity.SaveEntity and import com.finstone.sfcp.component.pub.util.SaveUtils. The SaveUtils class is automatically assembled through the @Autowired annotation. The construction method public SaveEntity is String tableName and Object saveDatas to construct a saveEntity object, specifically: SaveEntity saveEntity = new SaveEntity, new SaveEntity is tableName, saveDatas atas, the parameter tableName is the name of the table where the data object is finally saved, the parameter saveDatas is the data object to be saved, in JSON format, and the rule identifier and document identifier can be selectively configured into saveEntity to achieve the purpose of document verification and rule verification. The fiscal business of each region is different, and it is only necessary to configure different verification methods for the rules corresponding to the rule identifier and document identifier. By calling the saveUtils.saveTable(saveEntity) method, you can enter the general save, process and store the data, and the general save will return the saved result to realize the call of the general save method.

[0031] A general saving method that meets the requirements of different business scenarios, including step 1: document element verification; step 2: pre-rule verification; step 3: obtaining physical table columns; step 4: compatible with tenant mode; step 5: compatible with optimistic lock processing; step 6: verifying whether required fields are not empty; step 7: assembling SQL statements; step 8: executing SQL statements; step 9: post-rule verification;

[0032] In the above step 1, by calling the supporting document verification engine, the engine will verify the legality of the incoming JSON object according to the business document type brought in by saveEntity, and check whether each element meets the business requirements. The data in the same target table may need to be controlled by different verification rules due to different businesses, so different verification types need to be configured. The implementation personnel can configure the attributes of each element according to business needs or application requirements, including whether it is a required item, data type, whether it is a business primary key, which basic code set it belongs to, the value setting method, data verification method and the value setting formula. The value setting of the element can reduce the amount of user input. In the program, other content can be supplemented according to the content entered by the user. The value setting methods include fixed value, rule value setting, java class value setting and indefinite value. The data verification methods include fixed value verification, code verification, expression verification and no verification.

[0033] In the above step 2, by calling the supporting business rule engine, the rule engine will poll the corresponding rule verification details according to the passed-in business rule identifier to determine whether the execution of this save complies with the business logic. When the general save is executed to this step and no business rule identifier is found, no verification is performed. The business rule identifier corresponds to several rules, and each rule corresponds to a configurable SQL statement and error prompt, etc. The implementation personnel configure the fragment of the where condition in the SQL statement with dynamic parameters according to business needs. Finally, the program automatically combines into a SQL statement such as select count(*)fromtableName where#configured where condition#, and passes the data elements to be saved into the SQL to replace the dynamic parameters. After execution, it is determined whether the data violates the business rules according to the execution result and rule type;

[0034] In the above step 3, the physical table corresponding to tableName in saveEntity is queried in the database to determine whether the table exists. If the table exists, the table columns and data attributes of the table columns of the physical table are obtained. The data attributes include whether it is non-empty, whether it is a primary key field, etc.;

[0035] In the above step 4, developers can enable tenant mode by adding the configuration tenant:${fusion.tenant.enabled:false} in application.yml, and configure multiple tenant fields in the tenantCols constant of the constant class GlobalParams according to requirements. After the configuration is completed, when the general save method runs to this step, the program will poll all the fields obtained in the previous step. When a field matching the tenant field in tenantCols is found, it means that the tenant field is found. The program will automatically fill in the tenant value of the logged-in user into the tenant field. When the user queries the data, the program will automatically add the tenant condition, and finally achieve the purpose of isolating the data of each tenant. When the table does not poll the matching tenant field, it means that this table is not a business data table or this application does not need to consider the tenant mode, and the program does not process the tenant field.

[0036] In the above step 5, the optimistic lock function is enabled by configuring locker-enabled:true in application.yml, and the optimistic lock field is specified by configuring locker-column:VER_LOCK. After enabling, the value of the field corresponding to the optimistic lock is automatically set to 1 when saving data, indicating that the data version is 1. When the data is subsequently modified or logically deleted, it is automatically increased by 1 each time, without manually processing the self-increment of the optimistic lock, which increases the fault tolerance of the system.

[0037] In the above step 6, the table column of the physical table in the database can be defined as non-empty. When the non-empty field has no corresponding value, the program will report an error, and the user will be given an unfriendly and unprofessional prompt. This step can be verified in advance before operating the database, and accurately prompt the user of the unfilled information items, which reduces the database overhead and makes the prompt more friendly;

[0038] In the above step 7, the SQL statement is a language recognizable by the database, and the syntax structure for saving the SQL statement is insert into table_name(column1,column2,column3,...)values(value1,value2,value3,...), where table_name is the target table, column is the table field, and values ​​is the value corresponding to each field. To dynamically generate such an SQL statement, the program concatenates all fields of the target physical table into a column code segment in a polling manner, and at the same time finds the corresponding value of the field from the object to be saved, and concatenates the value code segment in the same order, and finally forms an SQL statement that can be executed in the database;

[0039] In the above step eight, when the sql statement needs to be executed in the java program, a Java API for executing SQL statements is required. JDBC is Java DataBase Connectivity, java database connection, a Java API for executing SQL statements, which can provide unified access to multiple relational databases and consists of a group of classes and interfaces written in Java. The bottom layer of this system uses JdbcTemplate technology to implement database operations. Executing the sql statement just assembled can save the data into the target table. Template is a template. JDBCTemplate is a set of class libraries provided by Spring for accessing the database. Spring encapsulates the template for JDBC.

[0040] Among them, the difference between the above step nine and the pre-verification is that the time verification is done after the execution of the insert statement is completed and before the transaction is committed. The purpose is to avoid the submission of other data during the period between the execution of the SQL statement and the submission of the transaction. The post-verification will verify the scenario of how much balance is left in a bank card after a user withdraws money. Once the balance is found to be less than 0, the user's withdrawal operation is blocked. At this time, although the statement is executed, it is not committed, and a rollback operation can be performed. The execution method is the same as the pre-verification.

[0041] Furthermore, the business document type in step one is passed in from the front end together with the object to be saved. The document verification engine will poll and verify each element to be saved passed in from the front end to verify whether it meets the configured attribute requirements. The verification content includes whether the required items are complete, whether the data type filled in by the user is consistent with the configuration, whether the selected data set code belongs to the configured data set, whether the data verification meets the configuration requirements, etc. If the requirements are not met, the subsequent steps will no longer be processed, which can meet different business requirements and reduce the overhead of the program and database. The specific reason for not meeting the requirements will be prompted to the user to guide the user to enter the correct data. The program will automatically calculate the value of the content that needs to be set according to the setting method.

[0042] Furthermore, there are two types of rules in step 2: inclusion rules and exclusion rules. Inclusion rules mean that if the execution result is greater than 1, it will pass, and if the execution result is equal to 0, it will fail; exclusion rules mean that if the execution result is greater than 1, it will fail, and if it is equal to 0, it will pass. If the elements in the business object to be saved violate the business rules, the subsequent steps will no longer be processed, and the reason for the violation of the rules will be prompted to the user, so that the user can enter data that complies with the business rules.

[0043] After the first acquisition in step 3, it will be stored in the cache to reduce the database overhead when querying the table information next time. When the database table structure changes due to business changes, you only need to clear the cache to obtain the latest table column information without re-encoding.

[0044] The tenant model in step 4 is applicable to scenarios where multiple different regions need to use the same system and database, but the data needs to be isolated from each other. The system is deployed at the municipal level, and users in various districts and counties in the city use this system as tenants, and each other's data is not allowed to be shared, viewed, or operated.

[0045] The optimistic lock in step 5 is to maintain an optimistic attitude towards data conflicts. The data will not be locked when it is operated. Only when the data is submitted will a mechanism be used to verify whether there is a conflict in the data.

[0046] The document elements in step 6 are configured with mandatory items for the business. The non-empty items in the database can be regarded as absolutely non-empty at the physical level. The non-empty check in this step adds the last line of defense on the basis of the document element check and increases the fault tolerance mechanism.

[0047] Example 2

[0048] By not needing to create a series of files such as entity classes, Mapper interface classes, and Mapper.xml configuration files on the back end, the amount of back end code to be written is greatly reduced, and the probability of coding errors is also reduced, which greatly improves delivery efficiency and delivery quality. When business requirements change, only the front end and database table interfaces need to be modified, and the back end code does not need to be modified, so that the project does not need to be redeployed, and user use is not affected at all. It can make full use of the capabilities of the database and cache middleware, combine the data objects to be saved provided by the front end, and the physical table names set by the back end, etc., obtain all fields and field attributes of the physical table through the database's own capabilities, and use the provided program to automatically assemble SQL statements. After execution, the purpose of saving data can be achieved, and a set of saving method codes are implemented to meet the financial needs of various places, greatly improving development efficiency and product quality. Only very little code is needed to realize data verification and preservation. When business requirements change, only the table structure and the data objects to be saved passed in by the front end need to be adjusted to achieve the preservation of different data structures without modifying the back end code, thereby reducing development costs and achieving the purpose of rapid delivery.

[0049] The matters not described in detail in the present invention are all known technologies to those skilled in the art.

[0050] Finally, it should be noted that the above specific implementation methods are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified and replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.

Claims

1. A general saving method that meets the requirements of different business scenarios, characterized by: Including referencing the general save-related jar package in the system project, the file of the referenced general save-related jar package is sf cp-component-pub-1.0-SNAPSHOT.jar, and referencing the used classes in the service class, the referenced classes are import com.finstone.sfcp.component.pub.entity.Save Entity and import com.finstone.sfcp.component.pub.util.SaveUtils, automatically assembling the SaveUtils class through the @Autowired annotation, using the construction method public SaveEntity as String tableName and Object saveDatas, to construct a saveEntity object, specifically: SaveEntity saveEntity=new SaveEntity(tableName,saveDatas tas), the parameter tableName is the name of the table where the data object is finally saved, the parameter saveDatas is the data object to be saved, in JSON format, and the rule identifier and document identifier can be selectively configured into saveEntity to achieve the purpose of document verification and rule verification. The financial business of each region is different, and it is only necessary to configure different verification methods for the rules corresponding to the rule identifier and document identifier. By calling the saveUtils.saveTable(saveEntity) method, you can enter the general save to process and store the data. The general save will return the saved result to realize the call of the general save method.

2. A general saving method that meets the requirements of different business scenarios includes step 1, document element verification; step 2, pre-rule verification; step 3, obtaining physical table columns; step 4, compatible tenant mode; step 5, compatible optimistic lock processing; step 6, verifying whether the required fields are not empty; step 7, assembling SQL statements; step 8, executing SQL statements; step 9, post-rule verification; the characteristics are: In the above step 1, by calling the supporting document verification engine, the engine will verify the legality of the incoming JSON object according to the business document type brought in by saveEntity, and check whether each element meets the business requirements. The data in the same target table may need to be controlled by different verification rules due to different businesses, so different verification types need to be configured. The implementation personnel can configure the attributes of each element according to business needs or application requirements, including whether it is a required item, data type, whether it is a business primary key, which basic code set it belongs to, the value setting method, data verification method and the value setting formula. The value setting of the element can reduce the amount of user input. In the program, other content can be supplemented according to the content entered by the user. The value setting methods include fixed value, rule value setting, java class value setting and indefinite value. The data verification methods include fixed value verification, code verification, expression verification and no verification. In the above step 2, by calling the supporting business rule engine, the rule engine will poll the corresponding rule verification details according to the passed-in business rule identifier to determine whether the execution of this save complies with the business logic. When the general save is executed to this step and no business rule identifier is found, no verification is performed. The business rule identifier corresponds to several rules, and each rule corresponds to a configurable SQL statement and error prompt, etc. The implementation personnel configure the fragment of the where condition in the SQL statement with dynamic parameters according to business needs. Finally, the program automatically combines into a SQL statement such as select count(*)from tableNamewhere#configured where condition#, and passes the data elements to be saved into the SQL to replace the dynamic parameters. After execution, it is determined whether the data violates the business rules according to the execution result and rule type; In the above step 3, the physical table corresponding to tableName in saveEntity is queried in the database to determine whether the table exists. If the table exists, the table columns and data attributes of the table columns of the physical table are obtained. The data attributes include whether it is non-empty, whether it is a primary key field, etc.; In the above step 4, developers can enable tenant mode by adding the configuration tenant:${fusion.tenant.enabled:false} in application.yml, and configure multiple tenant fields in the tenantCols constant of the constant class GlobalParams according to needs. After the configuration is completed, when the general save method runs to this step, the program will poll all the fields obtained in the previous step. When a field matching the tenant field in tenan tCols is found, it means that the tenant field is found. The program will automatically fill in the tenant value of the logged-in user into the tenant field. When the user queries the data, the program will automatically add the tenant condition, and finally achieve the purpose of isolating the data of each tenant. When the table does not poll the matching tenant field, it means that this table is not a business data table or this application does not need to consider the tenant mode, and the program does not process the tenant field. In the above step 5, the optimistic lock function is enabled by configuring locker-enabled:true in application.yml, and the optimistic lock field is specified by configuring locker-column:VER_LOCK. After enabling, the value of the field corresponding to the optimistic lock is automatically set to 1 when saving data, indicating that the data version is 1. When the data is subsequently modified or logically deleted, it is automatically increased by 1 each time, without the need to manually process the self-increment of the optimistic lock, thereby increasing the fault tolerance of the system. In the above step six, the table columns of the physical table in the database can be defined as non-empty. When the non-empty field has no corresponding value, the program will report an error and provide unfriendly and unprofessional prompts to the user. This step can verify in advance before operating the database and accurately prompt the user of the unfilled information items, reducing the database overhead while making the prompt more friendly. In the above step seven, the SQL statement is a language recognizable by the database, and the grammatical structure for saving the SQL statement is insert into table_name(column1,column2,column3,...)values(value1,value2,value3,...), where table_name is the target table, column is the table field, and values ​​is the value corresponding to each field. To dynamically generate such an SQL statement, the program concatenates all fields of the target physical table into a column code segment in a polling manner, and at the same time finds the corresponding value of the field from the object to be saved, and concatenates the value code segment in the same order, finally forming a SQL statement that can be executed in the database. In the above step eight, when the SQL statement needs to be executed in the Java program, a Java API for executing SQL statements is required. JDBC is Java DataBase Connectivity, java database connection, a Java API for executing SQL statements, which can provide unified access to multiple relational databases and consists of a group of classes and interfaces written in Java. The underlying system uses JdbcTemplate technology to implement database operations. Executing the SQL statement just assembled can save the data into the target table. Template is a template. JDBCTemplate is a set of class libraries for accessing databases provided by Spring, and Spring encapsulates the template for JDBC. Among them, the difference between the above step nine and the pre-verification is that the time verification is done after the execution of the insert statement is completed and before the transaction is committed. The purpose is to avoid the submission of other data during the period between the execution of the SQL statement and the submission of the transaction. The post-verification will verify the scenario of how much balance is left in a bank card after a user withdraws money. Once the balance is found to be less than 0, the user's withdrawal operation is blocked. At this time, although the statement is executed, it is not committed, and a rollback operation can be performed. The execution method is the same as the pre-verification.

3. The universal storage method for recording data in different business scenarios according to claim 1 is characterized in that: The business document type in step one is passed in from the front end together with the object to be saved. The document verification engine will poll and verify each element to be saved passed in from the front end to verify whether it meets the configured attribute requirements. The verification content includes whether the required items are complete, whether the data type filled in by the user is consistent with the configuration, whether the selected data set code belongs to the configured data set, whether the data verification meets the configuration requirements, etc. If the requirements are not met, the subsequent steps will no longer be processed, which can meet different business requirements and reduce the overhead of the program and database. The specific reason for not meeting the requirements will be prompted to the user, guiding the user to enter the correct data, and the program will automatically calculate the value of the content that needs to be set according to the setting method.

4. The universal storage method for recording data in different business scenarios according to claim 1 is characterized in that: There are two types of rules in step 2: inclusion rules and exclusion rules. Inclusion rules mean that if the execution result is greater than 1, it will pass, and if the execution result is equal to 0, it will fail; exclusion rules mean that if the execution result is greater than 1, it will fail, and if it is equal to 0, it will pass. If the elements in the business object to be saved violate the business rules, the subsequent steps will no longer be processed, and the reason for the violation of the rules will be prompted to the user, so that the user can enter data that complies with the business rules.

5. The universal storage method for recording data in different business scenarios according to claim 1 is characterized in that: After the first acquisition in step three, the information will be stored in the cache to reduce the overhead on the database when querying the table information next time. When the database table structure changes due to business changes, the latest table column information can be obtained by clearing the cache without re-encoding.

6. The universal storage method for recording data in different business scenarios according to claim 1 is characterized in that: The tenant mode in step 4 is applicable to scenarios where multiple different regions need to use the same system and database, but the data needs to be isolated from each other. The system is deployed at the city level, and users in various districts and counties in the city use this system as tenants, and each other's data is not allowed to be shared, viewed, or operated.

7. The universal storage method for recording data in different business scenarios according to claim 1 is characterized in that: The optimistic lock in step 5 is to maintain an optimistic attitude towards data conflicts. The data will not be locked when the data is operated. Only when the data is submitted will a mechanism be used to verify whether there is a conflict in the data.

8. The universal storage method for recording data in different business scenarios according to claim 1 is characterized in that: The document elements in step six are configured with mandatory items for the business. The non-empty items in the database can be regarded as absolutely non-empty at the physical level. The non-empty check in this step adds the last line of defense on the basis of the document element check and increases the fault tolerance mechanism.