Data processing method and device, electronic equipment and computer readable storage medium
By automatically creating data tables and interfaces through target code generation, the problem of developers manually creating data tables and interfaces is solved, reducing software development cycle and cost, and improving production efficiency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING PACTERA JINXIN TECH LTD
- Filing Date
- 2022-09-29
- Publication Date
- 2026-04-24
AI Technical Summary
In existing technologies, developers need to manually create data tables and interfaces, resulting in long software development cycles and high costs.
By obtaining the target table name and table fields, the template code is modified to generate the target code, automatically creating the target data table and interface, reducing manual operations.
It enables the automated creation of target databases and interfaces, reducing development time and costs and improving production efficiency.
Smart Images

Figure CN115544988B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and more specifically, to a data processing method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] With changing usage scenarios, increasing demands, and frequent requirement changes, it's often necessary to develop corresponding software. Software-related data is typically stored in database tables, requiring the creation of software-related tables or the execution of CRUD operations on these tables. Currently, developers usually need to create interfaces that match the data tables, allowing them to perform operations on the tables. However, since there's a one-to-one correspondence between data tables and interfaces, existing technologies often rely on developers manually creating these interfaces based on specific usage scenarios and requirements. This is not only time-consuming and labor-intensive but also impacts the software development cycle and cost. Summary of the Invention
[0003] This application provides a data processing method, apparatus, electronic device, computer-readable storage medium, and computer program product, which can solve the problem of developers manually creating data tables and interfaces according to specific use cases and needs. The technical solution is as follows:
[0004] According to one aspect of the embodiments of this application, a data processing method is provided, the method comprising:
[0005] Obtain the target table name, target table fields, first template code, and second template code. The first template code is used to create an empty data table. The table name of the empty data table is the template table name, and the table fields are template table fields. The second template code is used to create a template interface. The template interface is used to edit the field values corresponding to the template table fields of the empty data table.
[0006] Modify the first template code according to the target table name and the target table fields to obtain the first target code, which is used to create the target data table;
[0007] The first target code is invoked to create the target data table;
[0008] Modify the second template code according to the target table name and the target table fields to obtain the second target code. The second target code is used to create a target interface, which is used to edit the field values corresponding to the target table fields of the target data table.
[0009] The target interface is created by calling the second target code.
[0010] As an optional data processing method, after calling the second target code to create the target interface, the method further includes:
[0011] In response to an editing operation on the target table field, the value of the field to be edited is determined;
[0012] Call the target interface to edit the target data table using the field values, and obtain the edited target data table.
[0013] As an alternative data processing method, the process before obtaining the first template code also includes:
[0014] Establish the first correspondence between the table names of each data table and the first reference template code;
[0015] The step of obtaining the first template code includes: obtaining the first reference target code corresponding to the target table name according to the first correspondence, and using it as the first template code.
[0016] As an alternative data processing method, a second template code is obtained, which previously included:
[0017] Establish a second correspondence between each of the first and second reference template codes;
[0018] The step of obtaining the second template code includes: obtaining the second reference target code corresponding to the first reference target code according to the second correspondence, and using it as the second template code.
[0019] As an optional data processing method, the first template code includes a first code segment, a second code segment, and a third code segment. The first code segment is used to create multiple tables of the empty data table. The second code segment is used to fill the template table name into the corresponding first table among the multiple tables. The third code segment is used to fill the template table fields into the corresponding second table among the multiple tables. The second code segment includes a first placeholder corresponding to the template table name, and the third code segment includes a second placeholder corresponding to the template table fields.
[0020] Modify the first template code according to the target table name and the target table fields, including:
[0021] Replace the first placeholder with the third placeholder corresponding to the target table name;
[0022] Replace the second placeholder with the fourth placeholder corresponding to the target table field.
[0023] As an optional data processing method, the second template code includes a fourth code segment and a fifth code segment. The fourth code segment is used to call the empty data table, and the fifth code segment is used to create the template interface. Both the fourth and fifth code segments include a fifth placeholder corresponding to the template table name, and the fifth code segment also includes a sixth placeholder corresponding to the template table field.
[0024] Modify the second template code according to the target table name and the target table fields, including:
[0025] Replace the fifth placeholder with the seventh placeholder corresponding to the target table name;
[0026] Replace the sixth placeholder with the eighth placeholder corresponding to the target table field.
[0027] As an optional data processing method, the target table name and target table fields are obtained, followed by:
[0028] If the target database is determined to be created based on the target table name, then a third template code is obtained. The third template code is used to create an empty database, which is used to store the empty data table.
[0029] Modify the third template code according to the target table name to obtain the third target code, which is used to create the target database;
[0030] The third target code is invoked to create the target database, which is used to store the target data table.
[0031] According to another aspect of the embodiments of this application, a data processing apparatus is provided, the apparatus comprising:
[0032] The module is used to obtain the target table name, target table fields, first template code, and second template code to be processed.
[0033] The first generation module is used to modify the first template code according to the target table name and the target table fields to obtain the first target code;
[0034] The second generation module is used to modify the second template code according to the target table name and the target table fields to obtain the second target code;
[0035] A module is created to create a target database based on the first target code and a target interface based on the second target code.
[0036] According to another aspect of the present application, an electronic device is provided, which includes a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the data processing method described above.
[0037] According to another aspect of the embodiments of this application, a computer-readable storage medium is provided, wherein when the computer program is executed by a processor, it implements the steps of the data processing method described above.
[0038] According to one aspect of the embodiments of this application, a computer program product is provided, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.
[0039] The beneficial effects of the technical solution provided in this application are as follows: This invention provides a data processing method, apparatus, electronic device, and computer-readable storage medium. By obtaining the target table name and target table fields, the first template code and the second template code are modified to obtain the first target code that can create the target data table and the second target code that can create the target interface, thereby creating the target interface that can edit the target data table. The above method can automatically create the target database and the corresponding target interface, eliminating the need for developers to manually create the corresponding target interface based on the target table name and target table fields of different target data tables. This not only saves time and effort but also reduces the software development cycle and cost, and improves production efficiency. Attached Figure Description
[0040] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0041] Figure 1 A flowchart illustrating the data processing method provided in an embodiment of this application;
[0042] Figure 2 This is a schematic diagram of the structure of an empty data table provided in an embodiment of this application;
[0043] Figure 3 This is a schematic diagram of the edited empty data table structure provided in an embodiment of this application;
[0044] Figure 4 This is a schematic diagram of the structure of the target data table provided in the embodiments of this application;
[0045] Figure 5 This is a schematic diagram of the structure of the edited target data table provided in an embodiment of this application;
[0046] Figure 6This application provides schematic diagrams illustrating the structure of data tables with different table structures in its embodiments.
[0047] Figure 7 This is a schematic diagram of the structure of the data processing apparatus provided in the embodiments of this application;
[0048] Figure 8 This is a schematic diagram of the structure of an electronic device that implements the data processing method according to an embodiment of this application. Detailed Implementation
[0049] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0050] Those skilled in the art will understand that, unless otherwise stated, the singular forms “a,” “an,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, element, and / or component, but do not exclude implementation as other features, information, data, step, operation, element, component, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the one element can be directly connected or coupled to the other element, or it can mean that the one element and the other element establish a connection relationship through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.”
[0051] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0052] The data processing methods, apparatus, electronic devices, computer-readable storage media, and computer program products provided in this application are intended to solve the above-mentioned technical problems of the prior art.
[0053] The technical solutions of this application and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.
[0054] This application provides a data processing method, executed by a terminal, such as a computer, etc. Figure 1 As shown, it includes:
[0055] S100. Obtain the target table name, target table fields, first template code, and second template code. The first template code is used to create an empty data table. The empty data table name is the template table name, and the table fields are the template table fields. The second template code is used to create a template interface. The template interface is used to edit the field values corresponding to the template table fields of the empty data table.
[0056] An empty data table refers to a data table that only contains a table name and table fields. Please refer to [link / reference]. Figure 2 As shown, Figure 2 This is a schematic diagram of the structure of an empty data table in an embodiment of this application. AAA is the template table name, and BB and CC are template table fields. Please refer to... Figure 3 As shown, Figure 3 This is a schematic diagram of the structure of the edited empty data table in an embodiment of this application. The field values corresponding to BB include bb1 and bb2, and the field values corresponding to CC include cc1 and cc2. Filling bb1, cc1, bb2, and cc3 into the empty data table named AAA is a way of editing the field values corresponding to the fields of the template table.
[0057] For example, the target table name and target table fields can be obtained using JSON.
[0058] S101. Modify the first template code according to the target table name and target table fields to obtain the first target code. The first target code is used to create the target data table. The table name of the target data table is the target table name, and the table fields are the target table fields.
[0059] In S101, the target data table refers to a data table that only contains the target table name and target table fields. Please refer to [link / reference needed]. Figure 4 As shown, Figure 4 This is a schematic diagram of the structure of the target data table in an embodiment of this application. The target table is named Customer Record, and the target table fields include name and age.
[0060] S102, Call the first target code to create the target data table.
[0061] That is, after determining the first target code, the executing entity calls the first target code and creates the target database based on the first target code.
[0062] For example, the first target code can be in the Node.js language.
[0063] S103. Modify the second template code according to the target table name and target table fields to obtain the second target code. The second target code is used to create the target interface, which is used to edit the field values corresponding to the target table fields of the target data table.
[0064] Please refer to the following: Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of the target data table after editing in an embodiment of this application. The field values corresponding to the name include Zhang San and Li Si, and the field values corresponding to the age include 18 and 20. Filling Zhang San, Li Si, 18, and 20 into an empty data table named Customer Record is a way of editing the field values corresponding to the fields of the target table.
[0065] For example, the second target code can be in the Node.js language.
[0066] S104. Call the second target code to create the target interface.
[0067] That is, after determining the second target code, the execution entity calls the second target code and creates the target interface based on the second target code.
[0068] Understandably, by obtaining the target table name and target table fields, the first template code and the second template code are modified to obtain the first target code that can create the target data table and the second target code that can create the target interface, respectively. This allows the creation of the target interface that can edit the target data table. The above method can automatically create the target database and the corresponding target interface, eliminating the need for developers to manually create the corresponding target interface based on the target table name and target table fields of different target data tables. This not only saves time and effort but also reduces the software development cycle and cost, and improves productivity.
[0069] Optionally, before obtaining the target table name and target table fields to be processed, it also includes verifying whether the current operator has logged in or registered. If the current operator has logged in or registered, the interface for inputting the data model is opened to the current operator. The data model includes the target table name and target table fields.
[0070] Understandably, verifying whether the current operator is logged in or registered is necessary to save the data model edited by the current operator and to facilitate later use of the target interface.
[0071] For example, the current operator writes a data model in JSON format in the portal website's editor. The data model includes a name (i.e., the target table name), the name of at least one field (i.e., the target table field), the data type (i.e., the data type corresponding to the specific field value of the target table field), and default values, etc.
[0072] Based on the above embodiments, as an optional embodiment, after calling the second target code to create the target interface, the following is further included:
[0073] In response to an editing operation on a target table field, determine the value of the field to be edited;
[0074] Call the target interface to edit the target data table using field values and obtain the edited target data table.
[0075] Understandably, after creating the target data table using the first target code, the target data table at this point only contains the target table name and target table fields, but no field values, such as... Figure 4 As shown. Considering that users often need to use field values when developing software to establish the calling relationship between various field values and the software, after creating the target interface, the user sends the required field values to the execution entity. For example, the execution entity determines that the field values to be edited include Zhang San, 18, Li Si, and 20, and edits the target data table through the target interface to obtain the edited target data table, as shown. Figure 5 As shown.
[0076] Based on the above embodiments, as an optional embodiment, the method further includes the following steps before obtaining the first template code:
[0077] Establish the first correspondence between the table names of each data table and the first reference template code;
[0078] Obtaining the first template code includes: obtaining the first reference target code corresponding to the target table name based on the first correspondence, and using it as the first template code.
[0079] It is understandable that, such as Figure 6 As shown, Figure 6 The document provides structural diagrams of two different table structures. Figure (a) shows a table named AA1 with fields D1, D2, D3, and D4, while Figure (b) shows a table named AA2 with fields E1 and E2. The table structures and column numbers for the different table names differ, thus requiring different first reference template codes to create the tables. Therefore, by obtaining the corresponding first reference target code through the target table name, the template table structure and column numbers for the empty table created by the first template code are made consistent with the target database. This simplifies the complexity of creating the target data table for the executing entity and improves response efficiency.
[0080] Based on the above embodiments, as an optional embodiment, a second template code is obtained, which further includes:
[0081] Establish a second correspondence between each first reference template code and the second reference template code;
[0082] Obtaining the second template code includes: obtaining the second reference target code corresponding to the first reference target code according to the second correspondence, and using it as the second template code.
[0083] Understandably, since multiple first reference template codes are set up, and the table structures and column numbers of table fields differ for data tables with different names, the second reference template codes that enable the creation of the interface to edit the corresponding data tables will vary. Therefore, by obtaining the corresponding second reference target code through the first reference target code, the template interface created by the second template code can edit the field values of empty data tables, thereby simplifying the complexity of the execution body in creating the target interface and improving response efficiency.
[0084] Based on the above embodiments, as an optional embodiment, the first template code includes a first code segment, a second code segment, and a third code segment. The first code segment is used to create multiple tables of an empty data table. The second code segment is used to fill the template table name into the corresponding first table among the multiple tables. The third code segment is used to fill the template table fields into the corresponding second table among the multiple tables. The second code segment includes a first placeholder corresponding to the template table name, and the third code segment includes a second placeholder corresponding to the template table fields.
[0085] Modify the first template code based on the target table name and target table fields, including:
[0086] Replace the first placeholder with the third placeholder corresponding to the target table name;
[0087] Replace the second placeholder with the fourth placeholder that corresponds to the target table field.
[0088] Understandably, the first template code implements how to create an empty data table through the first, second, and third code segments. Since the empty data table and the target data table have the same table structure, it is only necessary to replace the corresponding first and second placeholders with the third and fourth placeholders, respectively. This allows the replaced second code segment to fill the target table name into the corresponding first table, and the replaced third code segment to fill the target table fields into the corresponding second table, thus enabling the obtained first target code to create the target data table.
[0089] For example, such as Figure 4 As shown, the target data table is named "Customer Records," and its fields include name and age. The corresponding empty data table is shown below. Figure 2As shown, the template table for the empty data table is named AAA. The template table fields include BB and CC. By replacing the first placeholder representing AAA with the third placeholder representing customer records, replacing the second placeholder representing BB with the fourth placeholder representing name, and replacing the second placeholder representing CC with the fourth placeholder representing age, the first target code can create the target data table.
[0090] Based on the above embodiments, as an optional embodiment, the second template code includes a fourth code segment and a fifth code segment. The fourth code segment is used to call an empty data table, and the fifth code segment is used to create a template interface. Both the fourth and fifth code segments include a fifth placeholder corresponding to the template table name. The fifth code segment also includes a sixth placeholder corresponding to the template table field.
[0091] Modify the second template code based on the target table name and target table fields, including:
[0092] Replace the fifth placeholder with the seventh placeholder corresponding to the target table name;
[0093] Replace the sixth placeholder with the eighth placeholder corresponding to the target table field.
[0094] Understandably, the second template code implements how to create the template interface through the fourth and fifth code segments. Since the fourth code segment is used to call an empty data table, simply replacing the fifth placeholder in the third code segment with the seventh placeholder will enable the modified fourth code segment to call the target data table. Since the fifth code segment is used to create the template interface, simply replacing the corresponding third and fourth placeholders in the fifth code segment with the seventh and eighth placeholders will enable the modified fifth code segment to create the target interface, thus obtaining the second target code.
[0095] For example, such as Figure 4 As shown, the target data table is named "Customer Records," and its fields include name and age. The corresponding empty data table is shown below. Figure 2 As shown, the template table for the empty data table is named AAA. The template table fields include BB and CC. By replacing the fifth placeholder representing AAA with the seventh placeholder representing customer records, replacing the sixth placeholder representing BB with the seventh placeholder representing name, and replacing the sixth placeholder representing CC with the seventh placeholder representing age, the second target code can be used to create the target interface. The target interface can edit the target data table using the field values.
[0096] Based on the above embodiments, as an optional embodiment, after obtaining the target table name and target table fields to be processed, the following steps are also included:
[0097] If the target database is determined based on the target table name, then the third template code is obtained. The third template code is used to create an empty database, which is used to store empty data tables.
[0098] Modify the third template code according to the target table name to obtain the third target code, which is used to create the target database.
[0099] The third-party target code is invoked to create the target database, which is used to store the target data tables.
[0100] Considering that users need to create multiple target data tables during software development, and that these target data tables are directly or indirectly related to each other, the target data tables in the same development environment need to be stored in the same database to ensure orderly storage and convenient retrieval.
[0101] For example, when the development environment is a product, the required target table names include customer records, product information, and revenue; when the development environment is a hospital, the required target table names include doctors, departments, business data, and drug statistics. When the user's currently created target table name is "Customer," and the executing entity does not have a database corresponding to a product-based development environment, it is determined that a target database corresponding to the product needs to be created. Therefore, the third template code is modified to obtain the third target code, and then the target database for the product-based development environment is created, so that the target data table named "Customer" can be stored in the target database.
[0102] When a user creates a target table named "Product Information," since a database corresponding to "Product" already exists in the development environment, there's no need to create a new database. The target data table named "Product Information" can be stored in the target database corresponding to "Product" in the development environment. However, when a user creates a target table named "Doctor," and the executing entity does not have a database corresponding to "Hospital" in the development environment, it is necessary to create a target database corresponding to "Hospital" so that the target data table named "Doctor" can be stored in the target database corresponding to "Hospital."
[0103] For example, the target database is in MongoDB format.
[0104] Based on the above embodiments, as an optional embodiment, after calling the second target code to create the target interface, it further includes:
[0105] Obtain the authorization code and establish the calling relationship between the authorization code and the target interface;
[0106] Editing the target data table using field values includes:
[0107] In response to the instruction to call the target interface, obtain the permission code included in the instruction;
[0108] If the permission code and the authorization code match, the target data table can be edited using the field values.
[0109] For example, if the authorization code is 1111, it means that the user who issued the command to call the target interface has the permission to call the target interface; if the permission code is 1112, it means that the user who issued the command to call the target interface does not have the permission to call the target interface, thereby improving the security of editing the target database.
[0110] Furthermore, considering that the target interfaces include add, modify, delete, and query interfaces, multiple permission codes can be set accordingly to meet different user needs. Some users can only call the query interface (i.e., have read-only permissions), some can only call the add interface (i.e., have write-only permissions), and some can call at least the add and query interfaces (i.e., have read and write permissions). Specifically, after logging into the portal website, users can confirm which permissions they have authorized (e.g., read-only, write-only, or read and write permissions) using the authorization button on the interface. The server generates a corresponding authorization code based on the user's selected permissions and establishes a correspondence between the authorization code and the user's login / registration information to ensure that different users have different permissions for the target interfaces after logging in.
[0111] Based on the above embodiments, as an optional embodiment, after calling the second target code to create the target interface, the method further includes: deploying the second target code to the server.
[0112] Specifically, after users write their data model on the portal website and obtain the first and second target codes, a deployment button will be displayed on the portal's current interface. Clicking the deployment button causes the terminal to select an available port on the server and establish a mapping between the port and the target interface. This uploads the first and second target codes to the server using Next.js + PM2, deploying the target interface on the server. When developers need to use the target interface, they enter the code to call it in the portal's editor. The terminal then connects to the port corresponding to the deployed target interface on the server, allowing developers to call the corresponding target interface on the server through the terminal.
[0113] Based on the above embodiments, as an optional embodiment, after calling the second target code to create the target interface, it further includes:
[0114] Obtain test data and the expected test results corresponding to the test data. The test data consists of the field values corresponding to the fields in the target table, and the expected test results are the field values corresponding to the fields in the target table.
[0115] The target interface is called based on the test data to obtain the response result. The response result is the edited target data table, and the field value corresponding to the target table field of the target data table is the test data.
[0116] If the expected test result matches the response result, then the target interface call is considered to be normal.
[0117] The target interfaces include an add interface, a modify interface, a delete interface, and a query interface. The add interface is used to populate field values in one or more tables of the target data table. The modify interface is used to modify field values in one or more tables of the target data table. The delete interface is used to delete field values in one or more tables of the target data table. The query interface is used to display field values in one or more tables of the target data table.
[0118] For example, the target table is named "Customer Records," and its fields include name and age. After the user clicks the "Deploy" button on the portal website to deploy the target interface on the server, the terminal will display a "Test" button on the current interface. The user clicks the "Test" button to test the target interface. If the user needs to test adding an interface, they enter the test data "Zhang San" and "18 years old" in the data input box on the interface. The user hopes to make the target data table contain the field values "Zhang San" and "18 years old" (i.e., the expected test result) by adding the interface. The terminal calls the add interface to get the response result and displays it to the user so that they can check whether "Zhang San" and "18 years old" exist in the edited target data table (i.e., the response result). If they exist, it means that the response result is consistent with the expected test result, and the add interface function is normal. If the user needs to test modifying the interface, they enter the test data "Li Si" in the input box on the interface. The user wants to modify the interface to make the field value of the table containing Zhang San in the target data table equal to Li Si (i.e., the expected test result). The terminal calls the modification interface, receives the response, and displays it to the user to check if the field value of the table containing Zhang San in the target data table is indeed Li Si (i.e., the response result). If it is, it means the response result is consistent with the expected test result, and the modification interface function is normal. If the user needs to test the modification interface, they enter the test data "18 years old" in the input box of the interface. The user wants to use the deletion interface to make the field value of the table containing "18 years old" in the target data table empty (i.e., the expected test result). The terminal calls the deletion interface, receives the response, and displays it to the user to check if the field value of the grid containing "18 years old" in the target data table is empty (i.e., the response result). If it is, it means the response result is consistent with the expected test result, and the deletion interface function is normal.
[0119] Based on the above embodiments, as an optional embodiment, after calling the second target code to create the target interface, the method further includes: transferring the first target code, the second target code, and the target data table to the target server. The target server refers to the user-owned server that created the current target data table.
[0120] Considering that the execution entity needs to store target data tables for multiple users simultaneously, which incurs a significant load and could easily impact server performance, users can upload their required first and second target code to the target server. By running the first and second target code on the target server, target data tables and target interfaces can be created, thus completing the transfer of the first and second target code and the target data tables. This ensures the smoothness of software development using the target data tables.
[0121] Specifically, after testing the target interface, the user can directly click the export button on the interface and enter the address of the target server in the data export input box. The terminal can then import the target data table and target interface stored on the server to the target server to complete the transfer of the first target code, the second target code, and the target data table.
[0122] This application provides a data processing apparatus, such as... Figure 7 As shown, the data processing device includes: an acquisition module 601, a first generation module 602, a second generation module 603, and a creation module 604. The acquisition module 601 is used to acquire the target table name, target table fields, a first template code, and a second template code to be processed. The first generation module 602 is used to modify the first template code according to the target table name and target table fields to obtain a first target code. The second generation module 603 is used to modify the second template code according to the target table name and target table fields to obtain a second target code. The creation module 604 is used to create a target database according to the first target code and a target interface according to the second target code.
[0123] In this embodiment, the target table name and target table fields are obtained by the obtaining module 601, the first generation module 602 modifies the first template code to obtain the first target code that can create the target data table, the second generation module 603 modifies the second template code to obtain the second target code that can create the target interface, and the creation module 604 creates the target data table and the target interface. The above data processing device can automatically create the target database and the corresponding target interface, eliminating the need for developers to manually create the corresponding target interface based on the target table name and target table fields of different target data tables. This not only saves time and effort but also reduces the software development cycle and cost, and improves production efficiency.
[0124] Based on the above embodiments, as an optional embodiment, the data processing apparatus further includes:
[0125] The receiving module is used to determine the value of the field to be edited in response to the editing operation on the target table field;
[0126] The calling module is used to call the target interface to edit the target data table using field values and obtain the edited target data table.
[0127] Based on the above embodiments, as an optional embodiment, the data processing device further includes a first processing module, used to establish a first correspondence between the table names of each data table and the first reference template code.
[0128] The obtaining module includes a first submodule, which is used to obtain the first reference target code corresponding to the target table name according to the first correspondence, and use it as the first template code.
[0129] Based on the above embodiments, as an optional embodiment, the data processing device further includes a second processing module, used to establish a second correspondence between each first reference template code and the second reference template code;
[0130] The obtaining module includes a second sub-module, which is used to obtain the second reference target code corresponding to the first reference target code according to the second correspondence relationship, and use it as the second template code.
[0131] Based on the above embodiments, as an optional embodiment, the first template code includes a first code segment, a second code segment, and a third code segment. The first code segment is used to create multiple tables of an empty data table. The second code segment is used to fill the template table name into the corresponding first table among the multiple tables. The third code segment is used to fill the template table fields into the corresponding second table among the multiple tables. The second code segment includes a first placeholder corresponding to the template table name, and the third code segment includes a second placeholder corresponding to the template table fields.
[0132] The first generation module includes a first modification submodule, which is used to modify the first template code based on the target table name and target table fields.
[0133] The first modification submodule includes:
[0134] The first modification unit is used to replace the first placeholder with the third placeholder corresponding to the target table name;
[0135] The second modification unit is used to replace the second placeholder with the fourth placeholder corresponding to the target table field.
[0136] Based on the above embodiments, as an optional embodiment, the second template code includes a fourth code segment and a fifth code segment. The fourth code segment is used to call an empty data table, and the fifth code segment is used to create a template interface. Both the fourth and fifth code segments include a fifth placeholder corresponding to the template table name, and the fifth code segment also includes a sixth placeholder corresponding to the template table field.
[0137] The second generation module includes a second modification submodule, which is used to modify the second template code based on the target table name and target table fields.
[0138] The second modified submodule includes:
[0139] The third modification unit is used to replace the fifth placeholder with the seventh placeholder corresponding to the target table name;
[0140] The fourth modification unit is used to replace the sixth placeholder with the eighth placeholder corresponding to the target table field.
[0141] Based on the above embodiments, as an optional embodiment, the data processing apparatus further includes:
[0142] The acquisition module is used to determine the target database to be created based on the target table name and obtain the third template code. The third template code is used to create an empty database, which is used to store empty data tables.
[0143] The third generation module is used to modify the third template code according to the target table name to obtain the third target code, which is used to create the target database.
[0144] The deployment module is used to call third-party target code to create a target database, which is used to store target data tables.
[0145] Based on the above embodiments, as an optional embodiment, the data processing device further includes an authorization module for obtaining an authorization code and establishing a calling relationship between the authorization code and the target interface.
[0146] The calling module also includes a preprocessing submodule, which is used to respond to the instruction to call the target interface and obtain the permission code included in the instruction. If the permission code and the authorization code are consistent, the target data table is edited using the field value.
[0147] Based on the above embodiments, as an optional embodiment, the data processing device further includes a testing module, which includes:
[0148] The Get submodule is used to obtain test data and the expected test results corresponding to the test data. The test data is the field value corresponding to the field of the target table, and the expected test result is the field value corresponding to the field of the target table that exists in the target data table.
[0149] The calling submodule is used to call the target interface based on the test data to get the response result. The response result is the edited target data table, and the field value corresponding to the target table field of the target data table is the test data.
[0150] The judgment submodule is used to determine whether the expected test results match the response results and confirm that the target interface call is normal.
[0151] The apparatus in this application embodiment can execute the method provided in this application embodiment, and the implementation principle is similar. The actions performed by each module in the apparatus of each embodiment of this application correspond to the steps in the method of each embodiment of this application. For detailed functional descriptions of each module of the apparatus, please refer to the descriptions in the corresponding methods shown above, which will not be repeated here.
[0152] This application provides an electronic device including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of a data processing method. Compared with related technologies, this method can achieve the following: by obtaining the target table name and target table fields, modifying the first template code and the second template code to obtain the first target code that can create the target data table and the second target code that can create the target interface, thereby creating the target interface that can edit the target data table. This method can automatically create the target database and the corresponding target interface, eliminating the need for developers to manually create the corresponding target interface based on the target table name and target table fields of different target data tables. This not only saves time and effort but also reduces the software development cycle and cost, and improves production efficiency.
[0153] In one alternative embodiment, an electronic device is provided, such as Figure 8 As shown, Figure 8 The illustrated electronic device 4000 includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of this application.
[0154] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0155] Bus 4002 may include a pathway for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 4002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 8 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0156] The memory 4003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.
[0157] The memory 4003 stores computer programs that execute embodiments of this application, and its execution is controlled by the processor 4001. The processor 4001 executes the computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.
[0158] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the steps and corresponding content of the aforementioned method embodiments.
[0159] This application also provides a computer program product, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.
[0160] The terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text.
[0161] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.
[0162] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of the embodiments of this application.
Claims
1. A data processing method, characterized in that, Applied to a terminal, the method includes: Obtain the target table name, target table fields, first template code, and second template code. The first template code is used to create an empty data table. The table name of the empty data table is the template table name, and the table fields are template table fields. The second template code is used to create a template interface. The template interface is used to edit the field values corresponding to the template table fields of the empty data table. Modify the first template code according to the target table name and the target table fields to obtain the first target code, which is used to create the target data table; The first target code is invoked to create the target data table; Modify the second template code according to the target table name and the target table fields to obtain the second target code. The second target code is used to create a target interface, which is used to edit the field values corresponding to the target table fields of the target data table. The second target code is invoked to create the target interface. An idle port on the server is selected, and a correspondence between the port and the target interface is established. The first target code and the second target code are uploaded to the server so that the target interface deployed on the server can be invoked by entering the code to invoke the target interface in the editor.
2. The data processing method according to claim 1, characterized in that, After the second target code is invoked to create the target interface, the process also includes: In response to an editing operation on the target table field, the value of the field to be edited is determined; Call the target interface to edit the target data table using the field values, and obtain the edited target data table.
3. The data processing method according to any one of claims 1 or 2, characterized in that, Before obtaining the first template code, the following is also included: Establish the first correspondence between the table names of each data table and the first reference template code; The step of obtaining the first template code includes: obtaining the first reference target code corresponding to the target table name according to the first correspondence, and using it as the first template code.
4. The data processing method according to claim 3, characterized in that, The second template code was obtained, which previously included: Establish a second correspondence between each of the first and second reference template codes; The step of obtaining the second template code includes: obtaining the second reference target code corresponding to the first reference target code according to the second correspondence, and using it as the second template code.
5. The data processing method according to claim 1, characterized in that, The first template code includes a first code segment, a second code segment, and a third code segment. The first code segment is used to create multiple tables of the empty data table. The second code segment is used to fill the template table name into the corresponding first table among the multiple tables. The third code segment is used to fill the template table fields into the corresponding second table among the multiple tables. The second code segment includes a first placeholder corresponding to the template table name, and the third code segment includes a second placeholder corresponding to the template table fields. Modify the first template code according to the target table name and the target table fields, including: Replace the first placeholder with the third placeholder corresponding to the target table name; Replace the second placeholder with the fourth placeholder corresponding to the target table field.
6. The data processing method according to claim 5, characterized in that, The second template code includes a fourth code segment and a fifth code segment. The fourth code segment is used to call the empty data table, and the fifth code segment is used to create the template interface. Both the fourth code segment and the fifth code segment include a fifth placeholder corresponding to the template table name. The fifth code segment also includes a sixth placeholder corresponding to the template table field. Modify the second template code according to the target table name and the target table fields, including: Replace the fifth placeholder with the seventh placeholder corresponding to the target table name; Replace the sixth placeholder with the eighth placeholder corresponding to the target table field.
7. The data processing method according to claim 1 or 2, characterized in that, After obtaining the target table name and target table fields to be processed, the following steps are also included: If the target database is determined to be created based on the target table name, then a third template code is obtained. The third template code is used to create an empty database, which is used to store the empty data table. Modify the third template code according to the target table name to obtain the third target code, which is used to create the target database; The third target code is invoked to create the target database, which is used to store the target data table.
8. A data processing apparatus, characterized in that, Applied to a terminal, the device includes: The module is used to obtain the target table name, target table fields, first template code, and second template code to be processed. The first generation module is used to modify the first template code according to the target table name and the target table fields to obtain the first target code; The second generation module is used to modify the second template code according to the target table name and the target table fields to obtain the second target code; A creation module is used to create a target database based on the first target code and a target interface based on the second target code. It selects an idle port on the server, establishes a correspondence between the port and the target interface, and uploads the first target code and the second target code to the server so that the target interface deployed on the server can be invoked by entering the code to invoke the target interface in the editor.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the data processing method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the data processing method according to any one of claims 1-7.
Citation Information
Patent Citations
An openEHR template-based data interface dynamic generation method
CN106991276A
Service generation method and device
CN111414350A
Interface generation method and device, computer equipment and readable storage medium
CN111752565A