Method, device and equipment for efficiently and automatically filling dictionary data into interface and medium
By performing field annotation declarations in the interface program code and building a query database, the problem of inefficient encoding description of interface returns is solved, and more efficient data processing and performance improvement is achieved.
Patent Information
- Application Number
- CN202411699969.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-18
AI Technical Summary
The encoding description efficiency of the returned data of existing interfaces is low, especially when there is a lot of dictionary data, the front-end performance is affected, and the back-end multi-table association query is inefficient.
By scanning the fields in the target interface program code, performing field annotation declarations, and building a query database; obtaining the data object returned by the data interface, adding encoded field annotations, performing field matching, calculating field annotations, and filling data in the data object.
Improves the encoding and description efficiency of the interface return data, reduces the number of queries on the front-end and back-end, improves performance, and avoids the problem of cache size limitation.
Smart Images

Figure CN119645489A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data encoding technology, and in particular to a method, device, equipment and medium for efficiently and automatically filling in dictionary data on an interface. Background Art
[0002] In software development, the data returned by the interface usually contains some codes, and the front end needs to display the corresponding description according to the code. For example, if the interface returns the gender value of M / F, the front end needs to convert it into male / female. The existing interface data encoding method can query dictionary data through the front end calling the back end interface and cache it to the front end, but the front end page refresh will cause frequent calls to the back end interface to query dictionary data. When there is a lot of dictionary data, the amount of data that the front end needs to cache is large, which may affect the front end performance, and some browsers may have cache size restrictions; when the interface queries, the back end can also perform multi-table association queries in the database and return codes and descriptions at the same time, but at the same time, when there are many codes to be returned, there are also many associated tables, the query efficiency is low, and it takes a long time. Therefore, how to improve the coding description efficiency of the data returned by the interface has become an urgent problem to be solved. Summary of the invention
[0003] The present invention provides a method, device, equipment and medium for automatically filling dictionary data in an interface efficiently, and its main purpose is to solve the problem of poor coding description efficiency of existing interface return data.
[0004] To achieve the above object, the present invention provides a method for efficiently and automatically filling dictionary data in an interface, comprising:
[0005] Scanning fields in the target interface program code, making field annotation declarations for the fields, and building a query database according to the results of the field annotation declarations;
[0006] Obtaining the data object returned after the data interface is called, adding annotations to the encoding fields of the data object, and obtaining data field annotations;
[0007] Performing field matching on the data field annotation in the query database to obtain a field matching result;
[0008] Calculate the field annotation description corresponding to the data field annotation according to the field matching result;
[0009] Data is filled in the data object according to the field annotation description to obtain a data description corresponding to the data object.
[0010] Optionally, the declaring a field annotation for the field includes:
[0011] Searching for a field annotation declaration corresponding to the field in a pre-built field annotation type library;
[0012] The field is annotated according to the field annotation declaration.
[0013] Optionally, constructing a query database according to the result of the field annotation declaration includes:
[0014] Generate a field key-value pair of the field according to the result of the field annotation declaration;
[0015] Generate a data dictionary according to the field key-value pairs;
[0016] The data dictionary is stored in a preset database to obtain a query database.
[0017] Optionally, the adding annotations to the encoding fields of the data object to obtain data field annotations includes:
[0018] Parsing the data object according to the data format of the data object to obtain the encoding field of the data object;
[0019] The preset coding annotation is added to the coding field to obtain the data field annotation.
[0020] Optionally, performing field matching on the data field annotation in the query database to obtain a field matching result includes:
[0021] Determine a matching field according to the data field annotation;
[0022] The matching fields are searched in the query database to obtain field matching results.
[0023] Optionally, the calculating a field annotation description corresponding to the data field annotation according to the field matching result includes:
[0024] If the field matching result is a successful match, then counting the field annotation description of the data field annotation in the query database;
[0025] If the field matching result is an unsuccessful match, determining the to-be-matched field corresponding to the data field annotation;
[0026] The field to be matched is used to query the field annotation description of the data field annotation in a pre-built enumeration table.
[0027] Optionally, filling data in the data object according to the field annotation description to obtain a data description corresponding to the data object includes:
[0028] Generate a fill field according to the field annotation description;
[0029] Determine the data level at which the coded field corresponding to the field annotation description is located;
[0030] The fill field is filled into the data level to obtain the data description corresponding to the data object.
[0031] In order to solve the above problems, the present invention also provides an interface efficient automatic dictionary data filling device, the device comprising:
[0032] A query database construction module is used to scan the fields in the target interface program code, perform field annotation declaration on the fields, and construct a query database according to the results of the field annotation declaration;
[0033] A data field annotation adding module is used to obtain the data object returned after the data interface is called, add annotations to the encoding fields of the data object, and obtain data field annotations;
[0034] A field matching module, used for performing field matching on the data field annotation in the query database to obtain a field matching result;
[0035] A field annotation description module, used to calculate the field annotation description corresponding to the data field annotation according to the field matching result;
[0036] The data filling module is used to fill data in the data object according to the field annotation description to obtain the data description corresponding to the data object.
[0037] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0038] at least one processor;
[0039] and, a memory communicatively coupled to the at least one processor;
[0040] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the above-mentioned method for efficiently and automatically filling in dictionary data through an interface.
[0041] In order to solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the above-mentioned method for efficiently and automatically filling in dictionary data in an interface.
[0042] The embodiment of the present invention scans the fields in the target interface program code, declares field annotations for the fields, and builds a query database based on the results of the field annotation declaration. The fields and the results of the field annotations can be stored in the form of mapping from key to value, which can improve the efficiency of subsequent field annotation description calculations; obtain the data object returned after the data interface is called, add annotations to the coding field of the data object, and obtain data field annotations; perform field matching on the data field annotations in the query database, and directly obtain the corresponding field annotation description from the query database, effectively improving the efficiency of coding description; calculate the field annotation description corresponding to the data field annotation based on the field matching results, and quickly query the value through the key to improve the efficiency of field annotation description; obtain the coding field description value from the query database based on the field annotation description, without writing any additional query statements, which can effectively improve the efficiency of coding description. Therefore, the interface efficient automatic filling dictionary data method interaction method, device, electronic device and computer-readable storage medium proposed by the present invention can solve the problem of poor efficiency of coding description of existing interface return data. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 A schematic diagram of a flow chart of a method for efficiently and automatically filling dictionary data in an interface provided by an embodiment of the present invention;
[0044] Figure 2 A schematic diagram of a process for constructing a query database according to the results of a field annotation declaration provided in one embodiment of the present invention;
[0045] Figure 3 A schematic diagram of a process for filling data in a data object provided by an embodiment of the present invention;
[0046] Figure 4 A functional module diagram of a device for efficiently and automatically filling dictionary data with an interface provided by an embodiment of the present invention;
[0047] Figure 5 is a schematic diagram of a structure of a computer device in one embodiment of the present invention;
[0048] Figure 6 It is another structural schematic diagram of a computer device in one embodiment of the present invention.
[0049] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0051] The embodiment of the present application provides a method for efficiently and automatically filling in dictionary data with an interface. The execution subject of the method for efficiently and automatically filling in dictionary data with an interface includes but is not limited to at least one of the electronic devices such as a server, a terminal, etc. that can be configured to execute the method provided by the embodiment of the present application. In other words, the method for efficiently and automatically filling in dictionary data with an interface can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms.
[0052] Reference Figure 1 FIG. 1 is a flow chart of a method for efficiently and automatically filling dictionary data with an interface according to an embodiment of the present invention. In this embodiment, the method for efficiently and automatically filling dictionary data with an interface includes:
[0053] S1. Scan the fields in the target interface program code, perform field annotation declaration on the fields, and build a query database according to the results of the field annotation declaration.
[0054] In an embodiment of the present invention, the target interface program code may be those fields defined in the response object of the target interface that are used to describe the interface response status and data. For example, these fields may be HTTP status codes, error messages, data entities, etc., wherein the target interface may be an API (application programming interface) interface, and the fields in the target interface program code may be scanned by traversing all the codes in the target interface program code.
[0055] Furthermore, the field annotation declaration actually declares the table where the query encoding is located, the encoding field in the table and the encoding description field in the field annotation, wherein the field annotation is to use specific tags (called annotations or attributes) next to the field to provide additional information or instructions, and the field annotation can be read and interpreted by the compiler, runtime environment or other tools to change the behavior of the field in the code or provide metadata.
[0056] In the embodiment of the present invention, the step of declaring a field annotation on the field includes:
[0057] Searching for a field annotation declaration corresponding to the field in a pre-built field annotation type library;
[0058] The field is annotated according to the field annotation declaration.
[0059] In an embodiment of the present invention, a field annotation declaration is a declaration in a field annotation of a table where the query code is located, a code field and a code description field in the table, wherein the statistical table name is the name of a table used to store statistical data in a database or data warehouse, and may contain various statistical information; the code field is a field in a data table, and usually contains a code or key used to uniquely identify a record; the code description field is associated with the code field, but provides a more detailed description or explanation, and the code description field usually contains more information, which can further understand the meaning of the code field. Specifically, the field annotation declaration corresponding to each field can be determined by performing field matching in the field annotation declaration library.
[0060] Furthermore, the field annotation declaration library may contain annotation declarations contained in pre-built different fields. For example, the table name of the city code table (city_info), the city code field (city_no) and the city Chinese name field (city_name) may be added to the city field, thereby obtaining a field annotation declaration library.
[0061] In an embodiment of the present invention, the query database is to splice the results of the fields and field annotation declarations into dictionary data, for example, the statistical table name, coding field and coding description field of each field are spliced into dictionary data to construct a query database for subsequent field matching.
[0062] In the embodiment of the present invention, refer to Figure 2 As shown, the query database is constructed according to the result of the field annotation declaration, including:
[0063] S21, generating a field key-value pair of the field according to the result of the field annotation declaration;
[0064] S22, generating a data dictionary according to the field key-value pairs;
[0065] S23, storing the data dictionary in a preset database to obtain a query database.
[0066] In an embodiment of the present invention, a field key-value pair stores fields and the results of field annotation declarations in the form of key-value pairs, each of which contains a key and a value, wherein the field can be the key and the result of the field annotation declaration can be the value. For example, a field key-value pair is constructed by using the statistical table name in the result of the field and the field annotation declaration. Therefore, a field key-value pair is generated for each field according to the result of the field annotation declaration, wherein the field key-value pair for each field is not limited to one.
[0067] Furthermore, the field key-value pair is a data structure in the data dictionary, and a pre-built data dictionary template can be used to generate a data dictionary, wherein the data dictionary template includes all field names, data types, and field key-value pairs, etc. The field key-value pairs are filled into the preset data dictionary template to generate a data dictionary.
[0068] In an embodiment of the present invention, the preset database may be Redis (Remote Dictionary Server), and the data dictionary is stored in a high-performance redis, that is, the dictionary data in the data dictionary is cached in the high-performance redis. Furthermore, the query database may be updated by periodically querying the results of the field annotation declaration.
[0069] In the embodiment of the present invention, by querying the database, the fields and the results of the field annotations are stored in the form of a mapping from keys to values, and the corresponding values can be quickly retrieved through the keys to improve the efficiency of subsequent field annotation description calculations.
[0070] S2. Obtain the data object returned after the data interface is called, add annotations to the encoding field of the data object, and obtain data field annotations.
[0071] In the embodiment of the present invention, the data object is a data structure returned by the target interface after a function or method calls the target interface. It may be a dictionary, a hash table, an object or other types of data structures, depending on the programming language and context used.
[0072] The encoding field is a field in the API (application programming interface) response that is used to specify the data encoding format. The encoding field can tell the recipient how the data is encoded so as to correctly decode and parse the data object.
[0073] In the embodiment of the present invention, the step of adding annotations to the encoding fields of the data object to obtain data field annotations includes:
[0074] Parsing the data object according to the data format of the data object to obtain the encoding field of the data object;
[0075] The preset coding annotation is added to the coding field to obtain the data field annotation.
[0076] In an embodiment of the present invention, the encoding field in the interface return object generally refers to the field specified in JSON, XML or other data formats, which are used to describe the encoding information of the data object itself. The encoding field is different in different contexts. For example, for data objects in JSON format, some APIs may provide a field at the top level of the JSON object to indicate the encoding information. Therefore, the encoding field can be identified by checking the top-level field, or the encoding method of the data object can be described in the API document; for data objects in the interface of XML format, the encoding field can be identified by finding the XML declaration or parsing the XML element. Therefore, the encoding field in the data object can be parsed according to the data format.
[0077] In an embodiment of the present invention, the preset coding annotation is the table where the coding field to be queried is located, the coding field and the coding description field in the table. Therefore, the field that needs to be coded description can be determined through the preset coding annotation to improve the efficiency of subsequent coding description. For example, if the returned data object contains a city field, an annotation can be added to the city field to declare the table name (city_info) of the city code table that needs to be queried, the city code field (city_no) and the city Chinese name field (city_name).
[0078] S3. Perform field matching on the data field annotation in the query database to obtain a field matching result.
[0079] In the embodiment of the present invention, field matching is to match the data field annotation with the field annotation in the query database to obtain the field matching result corresponding to each data field annotation.
[0080] In the embodiment of the present invention, performing field matching on the data field annotation in the query database to obtain a field matching result includes:
[0081] Determine a matching field according to the data field annotation;
[0082] The matching fields are searched in the query database to obtain field matching results.
[0083] In an embodiment of the present invention, the matching field is a coded field with field annotations added to the data object. For example, when adding annotations to the coded field, the gender and city fields are annotated. Then, the gender and city fields are traversed and retrieved in the query database to obtain the field matching results corresponding to the data field annotations.
[0084] In the embodiment of the present invention, by performing field matching, the corresponding field annotation description can be directly obtained from the query database according to the result of the field matching, without paying attention to how to cache or query dictionary data, which can effectively improve the efficiency of the encoding description.
[0085] S4. Calculate the field annotation description corresponding to the data field annotation according to the field matching result.
[0086] In an embodiment of the present invention, the field annotation description further describes the data field annotation. For example, the description of the gender field is M-male, F-female, that is, gender:M-male, F-female. Through the field annotation description, the interface return data can be converted into male / female on the front end, so that the encoding in the interface return data can be displayed with the corresponding description.
[0087] Furthermore, the field matching result is the result of field matching of the data field annotation in the query database. There may be fields that cannot be matched in the query database, so the field annotation description corresponding to each data field annotation is determined through the field matching result.
[0088] In the embodiment of the present invention, the step of calculating the field annotation description corresponding to the data field annotation according to the field matching result includes:
[0089] If the field matching result is a successful match, then counting the field annotation description of the data field annotation in the query database;
[0090] If the field matching result is an unsuccessful match, determining the to-be-matched field corresponding to the data field annotation;
[0091] The field to be matched is used to query the field annotation description of the data field annotation in a pre-built enumeration table.
[0092] In the embodiment of the present invention, if the field matching result is a successful match, all field values are traversed in the query database, and then the corresponding field annotation declaration is queried from the query database at one time as the field annotation description. For example, if the gender and city fields are successfully matched in the query database, all gender and city field values are traversed to obtain the coded field to be queried, that is, gender: M, F; city: 01, 02, and then the corresponding field annotation description is queried from the query database at one time, that is, gender: M-male, F-female; city: 01-Beijing, 02-Shanghai, which can be specifically expressed as:
[0093]
[0094] "gender":"F",
[0095] "city":"02"
[0096] } ]
[0098] Furthermore, if the field matching result is an unsuccessful match, it means that the query database does not include the encoding field corresponding to the data field annotation, but uses an enumeration class. Therefore, an annotation can be provided in advance to declare the enumeration class, encoding field and description field, and cached in a Map without regular updates. When the interface returns the data object, it traverses the fields to be matched in the Map. The description corresponding to the field to be matched can be queried from the Map to obtain the corresponding field annotation description. Among them, Map is a data structure that stores key-value pairs. Through Map, you can quickly query values by key, thereby improving the efficiency of field annotation description.
[0099] S5. Fill data in the data object according to the field annotation description to obtain a data description corresponding to the data object.
[0100] In the embodiment of the present invention, data filling is to fill a description field at the same level of the field where the annotation is added to the data object, so as to further describe the coding field in the data object.
[0101] In the embodiment of the present invention, refer to Figure 3 As shown, the data object is filled with data according to the field annotation description to obtain the data description corresponding to the data object, including:
[0102] S31, generating a fill field according to the field annotation description;
[0103] S32, determining the data level at which the coded field corresponding to the field annotation description is located;
[0104] S33. Fill the fill field into the data level to obtain the data description corresponding to the data object.
[0105] In an embodiment of the present invention, a fill field for field annotation description is generated using a preset description field. For example, if the preset description field is xxxDesc, the fill field corresponding to the field annotation description of the city field city can be cityDesc: "Beijing", and the field annotation description is then filled into the data object.
[0106] Specifically, the data hierarchy refers to the level or layer of the coding field in the data object, which can indicate the data nesting depth. According to the data hierarchy, the fill-in field is filled in at the same level as the coding field, and then the coding field is explained and described.
[0107] For example, after data is filled [
[0109] {
[0110]
[0111] In an embodiment of the present invention, data encoding can be further described in detail through data filling. At the same time, by querying the database, there is no need to cache the encoding and its description, and the encoding field description value can be directly obtained from the query database without writing any additional query statements, which can effectively improve the efficiency of the encoding description.
[0112] like Figure 4 FIG. 1 is a functional module diagram of a device for efficiently and automatically filling dictionary data with an interface provided by an embodiment of the present invention.
[0113] The interface efficient automatic dictionary data filling device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the interface efficient automatic dictionary data filling device 100 can include a query database construction module 101, a data field annotation adding module 102, a field matching module 103, a field annotation description module 104 and a data filling module 105. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0114] In this embodiment, the functions of each module / unit are as follows:
[0115] The query database construction module 101 is used to scan the fields in the target interface program code, perform field annotation declaration on the fields, and construct a query database according to the results of the field annotation declaration;
[0116] The data field annotation adding module 102 is used to obtain the data object returned after the data interface is called, add annotations to the encoding fields of the data object, and obtain data field annotations;
[0117] The field matching module 103 is used to perform field matching on the data field annotation in the query database to obtain a field matching result;
[0118] The field annotation description module 104 is used to calculate the field annotation description corresponding to the data field annotation according to the field matching result;
[0119] The data filling module 105 is used to fill data in the data object according to the field annotation description to obtain the data description corresponding to the data object.
[0120] In detail, each module described in the device 100 for efficiently and automatically filling dictionary data with an interface in the embodiment of the present invention is used in the same manner as described above. Figures 1 to 3 The technical means described in the method for efficiently automatically filling dictionary data with the interface are the same and can produce the same technical effects, so they will not be repeated here.
[0121] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it realizes the functions or steps on the server side of a method for efficiently and automatically filling in dictionary data with an interface.
[0122] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, the functions or steps on the client side of a method for efficiently automatically filling in dictionary data with an interface are realized.
[0123] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0124] Scanning fields in the target interface program code, making field annotation declarations for the fields, and building a query database according to the results of the field annotation declarations;
[0125] Obtaining the data object returned after the data interface is called, adding annotations to the encoding fields of the data object, and obtaining data field annotations;
[0126] Performing field matching on the data field annotation in the query database to obtain a field matching result;
[0127] Calculate the field annotation description corresponding to the data field annotation according to the field matching result;
[0128] Data is filled in the data object according to the field annotation description to obtain a data description corresponding to the data object.
[0129] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0130] Scanning fields in the target interface program code, making field annotation declarations for the fields, and building a query database according to the results of the field annotation declarations;
[0131] Obtaining the data object returned after the data interface is called, adding annotations to the encoding fields of the data object, and obtaining data field annotations;
[0132] Performing field matching on the data field annotation in the query database to obtain a field matching result;
[0133] Calculate the field annotation description corresponding to the data field annotation according to the field matching result;
[0134] Data is filled in the data object according to the field annotation description to obtain a data description corresponding to the data object.
[0135] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0136] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0137] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0138] If software tools or components not owned by the patent applicant appear in the embodiments of the present application, they are merely used to illustrate that a wide range of software tools or components can be selected during the actual implementation of the technical solution disclosed in the present application, and do not mean that the patent applicant actually used these example software tools or components; the above-mentioned embodiments 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 aforementioned embodiments, ordinary technicians in this field should understand that they can still modify the technical solutions recorded in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for efficiently and automatically filling dictionary data in an interface, characterized in that: The method comprises: Scanning fields in the target interface program code, making field annotation declarations for the fields, and building a query database according to the results of the field annotation declarations; Obtaining the data object returned after the data interface is called, adding annotations to the encoding fields of the data object, and obtaining data field annotations; Performing field matching on the data field annotation in the query database to obtain a field matching result; Calculate the field annotation description corresponding to the data field annotation according to the field matching result; Data is filled in the data object according to the field annotation description to obtain a data description corresponding to the data object.
2. The method for efficiently and automatically filling dictionary data in an interface as claimed in claim 1, characterized in that: The field annotation declaration for the field includes: Searching for a field annotation declaration corresponding to the field in a pre-built field annotation type library; The field is annotated according to the field annotation declaration.
3. The method for efficiently and automatically filling dictionary data in an interface as claimed in claim 1, characterized in that: The step of constructing a query database according to the result of the field annotation declaration includes: Generate a field key-value pair of the field according to the result of the field annotation declaration; Generate a data dictionary according to the field key-value pairs; The data dictionary is stored in a preset database to obtain a query database.
4. The method for efficiently and automatically filling dictionary data in an interface as claimed in claim 1, characterized in that: The step of adding annotations to the encoding fields of the data object to obtain data field annotations includes: Parsing the data object according to the data format of the data object to obtain the encoding field of the data object; The preset coding annotation is added to the coding field to obtain the data field annotation.
5. The method for efficiently and automatically filling dictionary data in an interface as claimed in claim 1, characterized in that: The performing field matching on the data field annotation in the query database to obtain the field matching result includes: Determine a matching field according to the data field annotation; The matching fields are searched in the query database to obtain field matching results.
6. The method for efficiently and automatically filling dictionary data in an interface as claimed in claim 1, characterized in that: The calculating, according to the field matching result, the field annotation description corresponding to the data field annotation includes: If the field matching result is a successful match, then counting the field annotation description of the data field annotation in the query database; If the field matching result is an unsuccessful match, determining the to-be-matched field corresponding to the data field annotation; The field to be matched is used to query the field annotation description of the data field annotation in a pre-built enumeration table.
7. The method for efficiently and automatically filling dictionary data in an interface as claimed in claim 1, characterized in that: Filling data in the data object according to the field annotation description to obtain a data description corresponding to the data object includes: Generate a fill field according to the field annotation description; Determine the data level at which the coded field corresponding to the field annotation description is located; The fill field is filled into the data level to obtain the data description corresponding to the data object.
8. An interface efficient and automatic dictionary data filling device, characterized in that: The device comprises: A query database construction module is used to scan the fields in the target interface program code, perform field annotation declaration on the fields, and construct a query database according to the results of the field annotation declaration; A data field annotation adding module is used to obtain the data object returned after the data interface is called, add annotations to the encoding fields of the data object, and obtain data field annotations; A field matching module, used for performing field matching on the data field annotation in the query database to obtain a field matching result; A field annotation description module, used to calculate the field annotation description corresponding to the data field annotation according to the field matching result; The data filling module is used to fill data in the data object according to the field annotation description to obtain the data description corresponding to the data object.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively coupled to the at least one processor; The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the method for efficiently and automatically filling in dictionary data in an interface as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for efficiently and automatically filling in dictionary data on an interface as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Interface calling method and device, electronic equipment and storage medium
CN114942855A
Dynamic generation method of interface document and terminal
CN117785276A
Method for annotating data, related apparatus and computer program product
US20220129423A1