Field processing method and device for external interface
By obtaining and processing the field template of the interface, and processing the underlying interface data to generate data that meets the requirements of the external interface, it solves the problems of high external interface maintenance costs and missing fields when the underlying interface is modified, improves development efficiency and reduces maintenance costs.
Patent Information
- Application Number
- CN202210556610.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-19
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2042-05-19
AI Technical Summary
In the existing technology, when modifying the underlying interface, it is necessary to maintain the external interface at the same time, which increases the maintenance cost, and it is easy to cause fields to be omitted due to communication problems. Especially when the platform has many existing interfaces, migration development is difficult.
By obtaining the access address for calling the external interface, obtain the matching field template from the database, process the underlying interface data according to the template, and generate interface return data that meets the requirements of the external interface, including generating empty data entities, converting data structures, filling data entities, and Preprocess and package to avoid directly modifying the external interface.
Using templates to filter required fields reduces the impact on external interfaces. You only need to write the code part that calls the interface, speeding up development, reducing maintenance costs, and avoiding missing fields.
Smart Images

Figure CN114942750B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for processing fields of an external interface. Background Art
[0002] When providing external interfaces, it is necessary to reuse the same underlying data interface with the C-end and APP for cost savings and convenient unified maintenance. Data interfaces often need to add and modify fields, and these fields will be transparently transmitted to external interface users, causing processing errors by users and even system crashes. It will also cause fields that should be charged to be obtained for free, causing losses to the company. Therefore, technical means are needed to process the fields.
[0003] The current way to handle fields is to remove extra fields in the external interface. The disadvantage of this implementation is that when modifying the underlying interface, the external interface must be maintained at the same time, which increases the maintenance cost and is prone to omission of fields due to communication problems. At the same time, due to the large number of existing interfaces on the platform, migration and development are difficult. Summary of the invention
[0004] The embodiments of the present disclosure provide a method and device for processing fields of an external interface, so as to at least solve the existing technical problems that when modifying the underlying interface, the external interface must be maintained at the same time, which increases the maintenance cost and easily leads to field omissions due to communication problems. At the same time, due to the large number of existing interfaces on the platform, the migration development is difficult.
[0005] According to one aspect of an embodiment of the present disclosure, a method for processing a field of an external interface is provided, the method comprising: obtaining an access address for calling the external interface;
[0006] Acquire a field template matching the access address from a database, wherein the field template defines a plurality of interface fields and a plurality of corresponding field value formats;
[0007] Obtaining underlying interface data of the external interface; and
[0008] According to the interface fields and corresponding field value formats defined in the field template, the interface fields and corresponding field values contained in the underlying interface data are processed to obtain interface return data for the call request of the external interface.
[0009] Optionally, according to the interface fields and corresponding field value formats defined in the field template, the interface fields and corresponding field values contained in the underlying interface data are processed to obtain interface return data for the call request of the external interface, including:
[0010] Generate a corresponding empty data entity according to the interface field and the corresponding field value format defined in the field template;
[0011] According to the standard data structure consisting of the interface fields and the corresponding field value formats defined in the field template, converting the original data structure consisting of the interface fields and the corresponding field values contained in the underlying interface data into a target data structure that conforms to the standard data structure; and
[0012] The data entities in the target data structure are filled in the empty data entity one by one, and the interface return data for the call request of the external interface is obtained.
[0013] Optionally, the original data structure is converted according to the standard data structure, including at least one of the following: conversion between camel case naming and underscore naming, field name mapping, and cross-level field mapping.
[0014] Optionally, it also includes:
[0015] After obtaining the interface return data, the interface return data is packaged and then returned.
[0016] Optionally, where:
[0017] According to the corresponding packaging factory class, the interface return data is outer packaged and then returned.
[0018] Optionally, it also includes:
[0019] According to the packaging type configured in the field template, a corresponding packaging factory class is selected for the external interface.
[0020] Optionally, the method further comprises: after obtaining the underlying interface data of the external interface, preprocessing the obtained underlying interface data, wherein:
[0021] The preprocessing method of the bottom layer interface data comprises:
[0022] Obtaining a preprocessing solution for the external interface;
[0023] Generate a data preprocessing responsibility chain dedicated to the external interface according to the acquired preprocessing solution;
[0024] The underlying interface data is preprocessed through the data preprocessing responsibility chain.
[0025] Optionally, where:
[0026] The preprocessing solution of the external interface is obtained by reading the annotation matching on the preprocessing method name of the external interface.
[0027] According to another aspect of the present application, a field processing device for an external interface is also provided, the device comprising:
[0028] The module for obtaining access address is used to obtain the access address for calling the external interface;
[0029] A field template acquisition module is used to acquire a field template matching the access address from a database, wherein the field template defines a plurality of interface fields and a plurality of corresponding field value formats;
[0030] A bottom layer interface data acquisition module is used to acquire bottom layer interface data of the external interface; and
[0031] The interface return data obtaining module is used to process the interface fields and corresponding field values contained in the underlying interface data according to the interface fields and corresponding field value formats defined in the field template, and obtain the interface return data for the call request of the external interface.
[0032] According to another aspect of an embodiment of the present invention, an electronic device is provided, comprising: a processor; a memory for storing instructions executable by the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement any one of the methods described above.
[0033] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and the computer program is used to execute the method described in any of the above embodiments of the present invention.
[0034] According to another aspect of an embodiment of the present invention, a computer program is provided, including a computer-readable code. When the computer-readable code is executed on a device, a processor in the device is used to implement any one of the methods described above.
[0035] The method of the present invention can use templates to filter the fields that need to be used, avoiding the impact of adding or changing fields in the data interface on the external interface. Only the code part that calls the interface needs to be written, which speeds up the code development speed, improves efficiency, and saves maintenance costs. It solves the problem that when modifying the underlying interface, the external interface must be maintained at the same time, which increases the maintenance cost and is prone to field omissions due to communication problems. At the same time, due to the large number of existing interfaces on the platform, the migration development is difficult. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present application. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure. In the drawings:
[0037] Figure 1 A flowchart of a field processing method 100 of an external interface provided according to an exemplary embodiment of the present invention;
[0038] Figure 2 A flowchart of a method 200 for processing the interface fields and corresponding field values contained in the underlying interface data according to the interface fields and corresponding field value formats defined in the field template to obtain interface return data for the call request of the external interface according to an exemplary embodiment of the present invention;
[0039] Figure 3 A flowchart of a method 300 for preprocessing underlying interface data according to an exemplary embodiment of the present invention;
[0040] Figure 4 is a structural diagram of a field processing device 400 of an external interface provided according to an exemplary embodiment of the present invention;
[0041] Figure 5 This is a structure of an electronic device provided by an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0042] Below, the exemplary embodiments according to the present invention will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments of the present invention, and it should be understood that the present invention is not limited to the exemplary embodiments described here.
[0043] It should be noted that the relative arrangement of components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
[0044] Those skilled in the art can understand that the terms "first" and "second" in the embodiments of the present invention are only used to distinguish different steps, devices or modules, etc., and neither represent any specific technical meaning nor indicate the necessary logical order between them.
[0045] It should also be understood that, in the embodiments of the present invention, “plurality” may refer to two or more than two, and “at least one” may refer to one, two or more than two.
[0046] It should also be understood that any component, data or structure mentioned in the embodiments of the present invention can generally be understood as one or more, unless explicitly limited or otherwise indicated in the context.
[0047] In addition, the term "and / or" in the present invention is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in the present invention generally indicates that the associated objects before and after are in an "or" relationship.
[0048] It should also be understood that the description of the various embodiments of the present invention focuses on the differences between the various embodiments, and the same or similar aspects thereof can be referenced to each other, and for the sake of brevity, they will not be described one by one.
[0049] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0050] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
[0051] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.
[0052] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0053] Embodiments of the present invention can be applied to electronic devices such as terminal devices, computer systems, servers, etc., which can operate with many other general or special computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers, etc. include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network personal computers, small computer systems, large computer systems, and distributed cloud computing technology environments including any of the above systems, etc.
[0054] Electronic devices such as terminal devices, computer systems, servers, etc. can be described in the general context of computer system executable instructions (such as program modules) executed by computer systems. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.
[0055] Exemplary Methods
[0056] Figure 1 FIG. 1 is a flow chart of a field processing method 100 of an external interface provided by an exemplary embodiment of the present invention. This embodiment can be applied to electronic devices, such as Figure 1 As shown, the following steps are included:
[0057] Step 101, obtaining an access address for calling an external interface.
[0058] Specifically, an access to an external interface is received, and a unique address url of the access is obtained, so as to determine a corresponding field template from a database according to the unique address url.
[0059] Step 102: Acquire a field template matching the access address from a database, wherein the field template defines a plurality of interface fields and a plurality of corresponding field value formats.
[0060] Specifically, the field template is stored in the database in JSON format, which is more flexible and uses one field to define node attributes. Typical node attributes include: string, number, date, entity, list, nested, etc.
[0061] For the specific attributes of the node, use the [type+:+specific type] format to record them. For example, when recording the date, use the date:yyyy-MM-dd format to record it. This can meet the requirements of data output in different formats.
[0062] The specific format of the returned data is defined through the combination of node attributes.
[0063] Furthermore, a field template matching the unique address URL is obtained from the database. Considering that the system runs in a high-concurrency scenario, this solution uses a cache to store the field template to reduce database pressure. The template can be used in the interface description for parsing and display to provide customers with an accurate data structure.
[0064] If no field template matching the unique address URL is found in the database, some special interfaces need to directly return the data to the external interface.
[0065] Step 103, obtaining the underlying interface data of the external interface.
[0066] Specifically, the data source is the underlying data interface, and the underlying interface data is obtained by internal calling.
[0067] Step 104: Process the interface fields and corresponding field values contained in the underlying interface data according to the interface fields and corresponding field value formats defined in the field template to obtain interface return data for the call request of the external interface.
[0068] Specifically, by obtaining the field template stored in JSON from the database, the field template is converted from JSON to a field template map structure, the interface fields and corresponding field values contained in the underlying interface data are processed, and the interface return data for the call request of the external interface is obtained.
[0069] In order to obtain the interface return data for the call request of the external interface. Figure 2 The present invention provides a flowchart of a method for processing the interface fields and corresponding field values contained in the underlying interface data according to the interface fields and corresponding field value formats defined in the field template to obtain the interface return data for the call request of the external interface. Figure 2 As shown, according to the interface fields and corresponding field value formats defined in the field template, the interface fields and corresponding field values contained in the underlying interface data are processed to obtain interface return data for the call request for the external interface, including:
[0070] Step 201, generating a corresponding empty data entity according to the interface field and the corresponding field value format defined in the field template;
[0071] Step 202, according to the standard data structure consisting of the interface fields and the corresponding field value formats defined in the field template, converting the original data structure consisting of the interface fields and the corresponding field values contained in the underlying interface data into a target data structure that conforms to the standard data structure; and
[0072] Step 203: fill the data entities in the target data structure into the empty data entity one by one, and obtain the interface return data for the call request of the external interface.
[0073] Specifically, an empty data entity is generated according to the field template, the field template is parsed from the previous JSON format to a map structure, and the underlying data entity is converted from the original map structure to the map structure corresponding to the template.
[0074] Generate an empty data entity according to the template, and map the pre-processed underlying interface data to the empty data entity according to the layering and key values, that is, select and fill the data in the data entity according to the entity.
[0075] At this time, the field template and the original data are both map structures and correspond to each other. For example, taking the key-value pair as an example, the data entity key of the underlying data is filled into the empty data entity value of the field template one by one to obtain the interface return data for the call request of the external interface.
[0076] Preferably, the original data structure is converted according to the standard data structure, including at least one of the following: conversion between camel case naming and underscore naming, field name mapping, and cross-level field mapping.
[0077] Specifically, the conversion of the underlying interface data from the original map structure to the template corresponding map structure includes but is not limited to the following:
[0078] 1. Conversion between camel case naming and underline naming: Since the underline naming method of "xxx_xx" is commonly used in external interfaces, the camel case naming method of "xxxxx" is used for internal data interaction. Therefore, traverse the map structure, copy all camel case naming nodes, and change the key to the underline naming method of "xxx_xx".
[0079] 2. Field name mapping: Since the field names of the original data are not completely consistent with the template definition, the data needs to be mapped. Use the configuration file to configure the node key that needs to be converted. When processing the data, copy the corresponding node in the original data according to the configuration and change the key to the new node key defined in the configuration file.
[0080] 3. Field mapping between different levels: Since the original data field may be different from the level defined by the template, it may be necessary to map the data across levels. Use "." in the configuration file to separate the levels. For example, "ab=c" means that the b field under the a field of the first level needs to be mapped to the c field of the first level. The processing method adopted is to find the ab node in the original data and copy the data to the c of the first level. When processing the hierarchical field mapping, there may be a situation where the lower-level node is a list. For example, in "ab=c", b is a list type. In this case, the first element in b is copied to the c field by default.
[0081] Preferably, it also includes:
[0082] After obtaining the interface return data, the interface return data is packaged and then returned.
[0083] Preferably, the interface return data is outer packaged and then returned according to the corresponding packaging factory class.
[0084] Specifically, since the packaging methods of the data returned by each version of the interface are different, it is necessary to select different packaging factory classes according to the packaging type configured in the interface template and hand over the data to the factory for processing.
[0085] Preferably, it also includes:
[0086] According to the packaging type configured in the field template, a corresponding packaging factory class is selected for the external interface.
[0087] Preferably, the method further comprises: after obtaining the underlying interface data of the external interface, preprocessing the obtained underlying interface data, wherein:
[0088] In order to obtain the preprocessing method of the underlying interface data. Figure 3 FIG. 1 is a flow chart of a method for preprocessing underlying interface data provided by an exemplary embodiment of the present invention. Figure 3 As shown, the preprocessing method of the underlying interface data includes:
[0089] Step 301, obtaining a preprocessing solution for the external interface;
[0090] Step 302, generating a data preprocessing responsibility chain dedicated to the external interface according to the acquired preprocessing solution;
[0091] Step 303: pre-process the underlying interface data through the data pre-processing responsibility chain.
[0092] Specifically, the underlying interface data is obtained by internal call. The data is preprocessed using the chain of responsibility model. The preprocessing scheme required for each interface is configured on the method name using annotations to achieve flexible processing of each interface data.
[0093] Preferably, wherein:
[0094] The preprocessing solution of the external interface is obtained by reading the annotation matching on the preprocessing method name of the external interface.
[0095] Specifically, the annotation configuration of the method is read using the aspect method, an interface-specific data preprocessing chain is generated, and the data is handed over to the processing chain for processing.
[0096] Therefore, templates are used to filter the fields that need to be used, avoiding the impact of adding or changing fields in the data interface on the external interface. Only the code part that calls the interface needs to be written, which speeds up code development, improves efficiency, and saves maintenance costs. It solves the problem of maintaining the external interface while modifying the underlying interface, which increases maintenance costs and is prone to field omissions due to communication problems. At the same time, due to the large number of existing interfaces on the platform, migration development is difficult.
[0097] Exemplary Devices
[0098] Figure 4 FIG. 4 is a schematic diagram of a field processing device 400 for an external interface provided by an exemplary embodiment of the present invention. Figure 4 As shown, this embodiment includes:
[0099] The access address acquisition module 410 is used to acquire the access address for calling the external interface.
[0100] The field template acquisition module 420 is used to acquire a field template matching the access address from a database, wherein the field template defines a plurality of interface fields and a plurality of corresponding field value formats.
[0101] The bottom layer interface data acquisition module 430 is used to acquire the bottom layer interface data of the external interface.
[0102] The module 430 for obtaining the underlying interface data includes:
[0103] A pre-processing scheme obtaining unit, used for obtaining the pre-processing scheme of the external interface;
[0104] A data preprocessing responsibility chain generation unit is used to generate a data preprocessing responsibility chain dedicated to the external interface according to the acquired preprocessing solution;
[0105] The preprocessing bottom layer interface data unit is used to preprocess the bottom layer interface data through the data preprocessing responsibility chain.
[0106] The obtaining of the pretreatment scheme unit includes:
[0107] The preprocessing scheme acquisition subunit is used to acquire the preprocessing scheme of the external interface by reading the annotation matching on the preprocessing method name of the external interface.
[0108] The interface return data obtaining module 440 is used to process the interface fields and corresponding field values contained in the underlying interface data according to the interface fields and corresponding field value formats defined in the field template, and obtain the interface return data for the call request of the external interface.
[0109] The obtaining interface return data module 440 includes:
[0110] Generate an empty data entity unit, used to generate a corresponding empty data entity according to the interface field and the corresponding field value format defined in the field template;
[0111] a data structure conversion unit, configured to convert an original data structure consisting of interface fields and corresponding field values included in the underlying interface data into a target data structure conforming to the standard data structure according to a standard data structure consisting of interface fields and corresponding field value formats defined in the field template; and
[0112] An interface return data unit is obtained, which is used to fill the data entities in the target data structure into the empty data entity one by one, and obtain the interface return data for the call request of the external interface.
[0113] In one embodiment, the original data structure is converted according to the standard data structure, including at least one of the following: conversion between camel case naming and underscore naming, field name mapping, and cross-level field mapping.
[0114] In one embodiment, it further includes:
[0115] The packaging interface return data module is used to perform outer packaging on the interface return data after obtaining the interface return data and then return it.
[0116] Among them: the packaging interface returns the data module, including:
[0117] The packaging interface return data unit is used to perform outer packaging on the interface return data according to the corresponding packaging factory class and then return it.
[0118] Among them: the packaging interface returns the data module, and also includes:
[0119] The packaging factory class selection unit is used to select a corresponding packaging factory class for the external interface according to the packaging type configured in the field template.
[0120] An external interface field processing device 400 according to an embodiment of the present invention corresponds to an external interface field processing method 100 according to another embodiment of the present invention, and will not be described in detail herein.
[0121] Exemplary Electronic Devices
[0122] Figure 5The electronic device provided by an exemplary embodiment of the present invention may be any one or both of the first device and the second device, or a stand-alone device independent of them, and the stand-alone device may communicate with the first device and the second device to receive the collected input signals from them. Figure 5 FIG. 1 is a block diagram of an electronic device according to an embodiment of the present disclosure. Figure 5 As shown, the electronic device includes one or more processors 51 and a memory 52 .
[0123] The processor 51 may be a central processing unit (CPU) or other forms of processing units having data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device to perform desired functions.
[0124] The memory 52 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory (cache), etc. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 51 may run the program instructions to implement the method for information mining of historical change records and / or other desired functions of the software program of each embodiment of the present disclosure described above. In one example, the electronic device may also include: an input device 53 and an output device 54, which are interconnected via a bus system and / or other forms of connection mechanisms (not shown).
[0125] In addition, the input device 53 may also include, for example, a keyboard, a mouse, etc.
[0126] The output device 54 can output various information to the outside. The output device 34 can include, for example, a display, a speaker, a printer, a communication network and a remote output device connected thereto.
[0127] Of course, to simplify, Figure 5 Only some of the components related to the present disclosure in the electronic device are shown, and components such as a bus, an input / output interface, etc. are omitted. In addition, according to specific application situations, the electronic device may further include any other appropriate components.
[0128] Exemplary computer program products and computer-readable storage media
[0129] In addition to the above-mentioned methods and devices, an embodiment of the present disclosure may also be a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps of the method for performing information mining on historical change records according to various embodiments of the present disclosure described in the above "Exemplary Method" section of this specification.
[0130] The computer program product may be written in any combination of one or more programming languages to write program code for performing the operations of the disclosed embodiments, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0131] In addition, an embodiment of the present disclosure may also be a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, enables the processor to execute the steps of the method for performing information mining on historical change records according to various embodiments of the present disclosure described in the above “Exemplary Method” section of this specification.
[0132] The computer readable storage medium can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium can include, for example, but is not limited to, a system, device or device of electricity, magnetism, light, electromagnetic, infrared, or semiconductor, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0133] The basic principles of the present disclosure are described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, effects, etc. mentioned in the present disclosure are only examples and not limitations, and it cannot be considered that these advantages, strengths, effects, etc. are required by each embodiment of the present disclosure. In addition, the specific details disclosed above are only for the purpose of illustration and ease of understanding, and are not limitations. The above details do not limit the present disclosure to the necessity of adopting the above specific details to be implemented.
[0134] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0135] The block diagrams of the devices, apparatuses, equipment, and systems involved in this disclosure are only illustrative examples and are not intended to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including," "comprising," "having," and the like are open words, referring to "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or," and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.
[0136] The method and apparatus of the present disclosure may be implemented in many ways. For example, the method and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.
[0137] It should also be noted that in the apparatus, equipment and method of the present disclosure, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent schemes of the present disclosure. The above description of the disclosed aspects is provided to enable any technician in the field to make or use the present disclosure. Various modifications to these aspects are very obvious to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the aspects shown here, but to the widest scope consistent with the principles and novel features disclosed herein.
[0138] The above description has been given for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, changes, additions and sub-combinations thereof.
Claims
1. A method for processing fields of an external interface, comprising: Get the access address for calling the external interface; Acquire a field template matching the access address from a database, wherein the field template defines a plurality of interface fields and a plurality of corresponding field value formats; Obtaining underlying interface data of the external interface; and According to the interface fields and corresponding field value formats defined in the field template, the interface fields and corresponding field values contained in the underlying interface data are processed to obtain interface return data for the call request of the external interface; According to the interface fields and corresponding field value formats defined in the field template, the interface fields and corresponding field values contained in the underlying interface data are processed to obtain interface return data for the call request of the external interface, including: Generate a corresponding empty data entity according to the interface field and the corresponding field value format defined in the field template; According to the standard data structure consisting of the interface fields and the corresponding field value formats defined in the field template, converting the original data structure consisting of the interface fields and the corresponding field values contained in the underlying interface data into a target data structure that conforms to the standard data structure; and The data entities in the target data structure are filled in the empty data entity one by one, and the interface return data for the call request of the external interface is obtained.
2. The method according to claim 1, wherein: The original data structure is converted according to the standard data structure, including at least one of the following: conversion between camel case naming and underline naming, field name mapping, and cross-level field mapping.
3. The method according to claim 1, further comprising: After obtaining the interface return data, the interface return data is packaged and then returned.
4. The method according to claim 3, wherein: According to the corresponding packaging factory class, the interface return data is outer packaged and then returned.
5. The method according to claim 4, further comprising: According to the packaging type configured in the field template, a corresponding packaging factory class is selected for the external interface.
6. The method according to claim 1, further comprising: After obtaining the underlying interface data of the external interface, the obtained underlying interface data is preprocessed, wherein: The preprocessing method of the bottom layer interface data comprises: Obtaining a preprocessing solution for the external interface; Generate a data preprocessing responsibility chain dedicated to the external interface according to the acquired preprocessing solution; The underlying interface data is preprocessed through the data preprocessing responsibility chain.
7. The method according to claim 6, wherein: The preprocessing solution of the external interface is obtained by reading the annotation matching on the preprocessing method name of the external interface.
8. A field processing device for an external interface, characterized in that: include: The module for obtaining access address is used to obtain the access address for calling the external interface; A field template acquisition module is used to acquire a field template matching the access address from a database, wherein the field template defines a plurality of interface fields and a plurality of corresponding field value formats; A bottom layer interface data acquisition module is used to acquire bottom layer interface data of the external interface; and An interface return data obtaining module is used to process the interface fields and corresponding field values contained in the underlying interface data according to the interface fields and corresponding field value formats defined in the field template, and obtain interface return data for the call request of the external interface; Among them, the module for getting the data returned by the interface includes: Generate an empty data entity unit, used to generate a corresponding empty data entity according to the interface field and the corresponding field value format defined in the field template; a data structure conversion unit, configured to convert an original data structure consisting of interface fields and corresponding field values included in the underlying interface data into a target data structure conforming to the standard data structure according to a standard data structure consisting of interface fields and corresponding field value formats defined in the field template; and An interface return data unit is obtained, which is used to fill the data entities in the target data structure into the empty data entity one by one, and obtain the interface return data for the call request of the external interface.
9. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the method described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program is used to execute the method according to any one of claims 1 to 7.
11. A computer program comprising computer readable code, characterized in that When the computer readable code is executed on a device, a processor in the device executes the method for implementing any one of claims 1 to 7.
Citation Information
Patent Citations
Building and managing data-processing attributes for modeled data sources
CA2994831A1
A data processing method and apparatus
CN109271180A
Field management method and device, server and storage medium
CN109710613A
Method and device for operating Redis database
CN110109983A
Object conversion method based on XML template
CN111552839A
