CN115098530A - Data acquisition method and device - Google Patents

Data acquisition method and device Download PDF

Info

Publication number
CN115098530A
CN115098530A CN202210736382.9A CN202210736382A CN115098530A CN 115098530 A CN115098530 A CN 115098530A CN 202210736382 A CN202210736382 A CN 202210736382A CN 115098530 A CN115098530 A CN 115098530A
Authority
CN
China
Prior art keywords
query
query statement
side interface
preset protocol
server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210736382.9A
Other languages
Chinese (zh)
Inventor
王芳
马吉祥
韩立元
张玉良
高晨峰
刘�文
周越佳
韩威旺
石朕邦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jingdong Technology Holding Co Ltd
Original Assignee
Jingdong Technology Holding Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jingdong Technology Holding Co Ltd filed Critical Jingdong Technology Holding Co Ltd
Priority to CN202210736382.9A priority Critical patent/CN115098530A/en
Publication of CN115098530A publication Critical patent/CN115098530A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • G06F16/2448Query languages for particular applications; for extensibility, e.g. user defined types
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24564Applying rules; Deductive queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the disclosure discloses a data acquisition method and a data acquisition device. One embodiment of the method comprises: acquiring a query statement written based on a preset protocol, wherein the preset protocol is used for describing a server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of a target server-side interface; and calling a target server-side interface corresponding to the query statement according to a preset protocol to obtain the return data of the target server-side interface as a query result. This embodiment helps to increase the flexibility of return data queries for the server interface.

Description

Data acquisition method and device
Technical Field
The embodiment of the disclosure relates to the technical field of computers, in particular to a data acquisition method and device.
Background
An API (Application Programming Interface) is some predefined Interface (e.g. function, etc.) or convention for linking different components in some software systems, and is used to provide a set of routines that an Application and a developer can access based on software or hardware without accessing source code.
When designing the API, the service end may consider requirements of different devices or different service fields, and provide different API interfaces For different devices or different service fields, For example, by using some bff (backups For fronts) architectures. The format of the return data of the server API is usually designed in advance according to the presentation form of the corresponding page. For example, a JSON (JavaScript Object Notation) format is customized in advance according to the presentation form of the page.
When data of a plurality of server side APIs are assembled, the server side is generally required to firstly inquire the return data of each API, then the return data of each API are assembled according to a specified format and the like according to requirements, and then the return data are output to the front end through the API to be analyzed, rendered and the like to complete page display. But since different pages may have different page styles, it is often necessary to assemble the return data for multiple APIs. Alternatively, data of similar requirements may be combined into one interface output, but then for each front end some data may be sent down that is not needed.
Disclosure of Invention
The embodiment of the disclosure provides a data acquisition method and device.
In a first aspect, an embodiment of the present disclosure provides a data acquisition method, including: acquiring a query statement written based on a preset protocol, wherein the preset protocol is used for describing a server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of a target server-side interface; and calling a target server-side interface corresponding to the query statement according to a preset protocol to obtain the return data of the target server-side interface as a query result.
In a second aspect, an embodiment of the present disclosure provides a page display method, where the method includes: receiving target operation of a user for a page; determining a query statement corresponding to a target operation, wherein the query statement is compiled based on a preset protocol, the preset protocol is used for describing a server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of the target server-side interface; obtaining a query result corresponding to the query statement, wherein the query result is obtained by using the method described in the first aspect; and updating the page according to the query result.
In a third aspect, an embodiment of the present disclosure provides a data acquisition apparatus, including: the query statement acquisition unit is configured to acquire a query statement written based on a preset protocol, wherein the preset protocol is used for describing the server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of a target server-side interface; and the interface calling unit is configured to call the target server-side interface corresponding to the query statement according to a preset protocol to obtain the return data of the target server-side interface as a query result.
In a fourth aspect, an embodiment of the present disclosure provides a page display apparatus, including: a receiving unit configured to receive a target operation of a user for a page; the determining unit is configured to determine a query statement corresponding to the target operation, wherein the query statement is compiled based on a preset protocol, the preset protocol is used for describing the server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of the target server-side interface; a query result obtaining unit configured to obtain a query result corresponding to the query statement, where the query result is obtained by using the method described in the first aspect; and the page updating unit is configured to update the page according to the query result.
In a fifth aspect, an embodiment of the present disclosure provides an electronic device, including: one or more processors; storage means for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the method as described in any implementation of the first aspect.
In a fourth aspect, embodiments of the present disclosure provide a computer-readable medium on which a computer program is stored, which computer program, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
According to the data acquisition method and device provided by the embodiment of the disclosure, the protocol for describing the server interface and the query rule for the server interface is preset, the corresponding query statement can be compiled according to actual requirements based on the preset protocol, and the required server interface is called through the preset protocol to acquire the required returned data, so that the method for acquiring the returned data of the server segment interface based on the preset protocol is realized.
Drawings
Other features, objects and advantages of the disclosure will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which one embodiment of the present disclosure may be applied;
FIG. 2 is a flow diagram of one embodiment of a data acquisition method according to the present disclosure;
3a-3b are schematic diagrams of developing a preset protocol using a visual configuration management tool;
3c-3d are schematic diagrams of compiling query statements and obtaining corresponding query results using a visual configuration management tool;
FIG. 4 is a flow diagram of one embodiment of a page presentation method according to the present disclosure;
FIG. 5 is a schematic block diagram of one embodiment of a data acquisition device according to the present disclosure;
FIG. 6 is a schematic structural diagram of one embodiment of a page presentation apparatus according to the present disclosure;
FIG. 7 is a schematic structural diagram of an electronic device suitable for use in implementing embodiments of the present disclosure.
Detailed Description
The present disclosure is described in further detail below with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that, in the present disclosure, the embodiments and features of the embodiments may be combined with each other without conflict. The present disclosure will be described in detail below with reference to the accompanying drawings in conjunction with embodiments.
Fig. 1 illustrates an exemplary architecture 100 to which embodiments of the data acquisition method or data acquisition apparatus of the present disclosure may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The terminal devices 101, 102, 103 interact with a server 105 via a network 104 to receive or send messages or the like. Various client applications or tools, etc., such as browser-type applications, search-type applications, instant messaging tools, development-type applications or tools, etc., may be installed on the terminal devices 101, 102, 103.
The terminal apparatuses 101, 102, and 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices including, but not limited to, smart phones, tablet computers, e-book readers, laptop portable computers, desktop computers, and the like. When the terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. It may be implemented as multiple pieces of software or software modules (e.g., multiple pieces of software or software modules to provide distributed services) or as a single piece of software or software module. And is not particularly limited herein.
The server 105 may be a server that provides various services, such as a backend server that provides support for client applications and the like installed on the terminal apparatuses 101, 102, 103. The server 105 may be hardware or software. When the server 105 is hardware, it may be implemented as a distributed server cluster composed of a plurality of servers, or may be implemented as a single server. When the server 105 is software, it may be implemented as multiple pieces of software or software modules (e.g., multiple pieces of software or software modules used to provide distributed services), or as a single piece of software or software module. And is not particularly limited herein.
It should be noted that the data acquisition method provided by the embodiment of the present disclosure is generally executed by the server 105, and accordingly, the data acquisition device is generally disposed in the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a data acquisition method according to the present disclosure is shown. The data acquisition method comprises the following steps:
step 201, obtaining a query statement written based on a preset protocol.
In this embodiment, a protocol may refer to a set of conventions or rules that each participant needs to follow according to actual requirements. A preset protocol may be used to describe the server interface and corresponding query rules. The service-side interface may refer to an interface that the service side has. An interface may refer to an application program interface, API, or the like. A query rule may refer to a rule that needs to be followed to query the return data of the server interface.
The specific description information of the server interface and the specific content of the query rule can be flexibly set according to the actual application requirements. For example, the description information of the server interface may include, but is not limited to, the name, in-party, out-party, return body, address, etc. of the interface. Specific contents of the query rule may include, but are not limited to, supported query types, syntax structures and arguments of the query statement, and the like. Specifically, the preset protocol may be written by a technician in advance according to actual application requirements. The service-side interfaces described in the preset protocol may include all interfaces of the service side, or may only include some interfaces of the service side, and may be specifically set according to actual requirements.
Specifically, the preset protocol may be developed in advance by using various existing protocol development methods. For example, a preset protocol may be developed based on Schema.
The query statement may be used to obtain return data for the target server-side interface. The target server interface may refer to a server interface to be queried by the query statement. The query statement may be written according to a preset protocol. Specifically, the query statement may be written according to a server interface and a query rule of a desired query in a preset protocol.
The execution subject of the data acquisition method (e.g., server 105 shown in fig. 1, etc.) may acquire the query statement from a local or other electronic device, etc., in various ways. For example, a query statement input by a user with an execution body may be received.
Step 202, according to a preset protocol, calling a target server-side interface corresponding to the query statement to obtain the return data of the target server-side interface as a query result.
In this embodiment, the target server interface of the query indicated by the query statement may be parsed according to a preset protocol, and then the target server interface may be called by using various existing interface calling methods to obtain the return data of the target server interface, so that the obtained return data of the target server interface may be used as the query result corresponding to the query statement.
The existing query mode of data of the server-side interface can only query the data corresponding to the server-side interface according to a data assembly mode pre-designed in a code, for a user, if the user has a customized query requirement, for example, the user expects the return data of a plurality of server-side interfaces to be spliced and returned according to a specified sequence, or the return data of the specified server-side interface is added with some keywords, and the like, when the current code design cannot meet the requirement, the code is generally required to be modified. According to the scheme, the information of each server-side interface is recorded in the preset protocol, meanwhile, the query rule is set in the preset protocol according to the actual query requirement, a user can compile the query statement according to the preset protocol, then the preset protocol can be utilized, the server-side interface corresponding to the query statement is called to obtain the required return data, therefore, the corresponding query rule can be customized according to the actual requirement of the user, various query requirements of the user can be met conveniently, and the application code does not need to be modified.
In some optional implementations of this embodiment, the query statement may also be used to indicate a data format of the query result. The data format is used for describing rules of recording, storing or displaying the query result. The data format of the query result may be specifically set according to the actual application requirements. By way of example, the data format may refer to the exchange format of the query results, in which case the data format includes, but is not limited to: JSON, XML (Extensible Markup Language), YAML (YAML Ain't Markup Language).
It should be noted that, because the query statement is written according to the preset protocol, the data format of the query result indicated by the query statement is also defined in the preset protocol.
At this time, after the target server-side interface is called to obtain the corresponding return data, the return data can be adjusted according to the data format indicated by the query statement, so that the adjusted return data conforms to the data format, and the adjusted return data is used as the query result corresponding to the query statement.
The data format can be further specified by the user, so that the user can customize the required data format, the required data can be obtained, the data returned in the specified format can be obtained, the user can conveniently use or operate the data, and the customization requirement of the user query is further met.
In some optional implementations of this embodiment, the return data of the server interface may be formed by at least one Key-Value pair (Key-Value) concatenation. For example, the return data of the server interface may be in JSON format. At this time, the data format of the query result may be used to describe the splicing order between the key value pairs.
In some optional implementations of this embodiment, the number of target server interfaces of the query required by the query statement is at least two. At this time, the data format of the query result may be used to describe the splicing sequence between the return data corresponding to each server interface.
Different data assembling and splicing requirements may be met in different scenes, and through providing the setting of the splicing sequence between the key value pairs and the splicing sequence between the returned data of the server interfaces, the key value pairs in the query result can be assembled and spliced according to the actual requirements of the user, so that the flexibility of the user in setting the format of the query result is further improved, and the requirements of different users are met.
For example, some return data of the server interfaces "a" and "B" need to be spliced in sequence, and the return data of the server interfaces "B" and "a" need to be spliced in sequence, so that for different requirements, corresponding data formats can be customized to meet different requirements.
In some optional implementations of the present embodiment, the preset protocol may be developed by using a visualization configuration management tool. The visualization configuration management tool may be an application installed in the electronic device, and may be specifically developed in advance by a technician.
The visualization configuration management tool may also be used to manage protocols and query statements. The management of the protocol and query statement includes, but is not limited to, new creation, modification, query, deletion, and the like.
For example, a plurality of preset protocols may be constructed on demand using a visualization configuration management tool. For each preset protocol, a plurality of query statements can be written based on the preset protocol and by using a visual configuration management tool, the established preset protocol can be modified or deleted, and the written query statements can be modified or deleted.
As an example, the number of the preset protocols may be at least two, and each preset protocol may correspond to different types of server interfaces respectively. The types of the server interfaces can be divided according to actual application requirements. For example, the server interfaces may be divided by traffic type. At this time, for each type of service-side interface, a preset protocol corresponding to the service-side interface may be developed, that is, each preset protocol is only used for describing the corresponding service-side interface. The mode can also realize the isolation between the different types of service end interfaces, and is convenient for the management and maintenance of the different types of service end interfaces.
The management of the related users on the protocols or the query sentences and the like can be facilitated through the visual configuration management tool, and the low-level technical complexity is shielded, so that the users can complete the related configuration and management only by performing simple operation in the visual page, the technical requirements and the learning cost of the related users are reduced, and the operation of the related users is facilitated.
In some optional implementations of this embodiment, the preset protocol may include a defined parameter object and a query object. Among other things, the parameter object may be used to describe a Key (Key) included in the return data of the server interface. The query object may be used to describe the format of the query statement. The format of the query statement may include an entry and an exit, and the entry and the exit belong to keywords of the parameter object description.
At this time, the preset protocol is also used for describing the corresponding relationship between the calling address of the server interface and the defined parameter object and query object. That is, the preset protocol records the server interface corresponding to the parameter object and also records the server interface corresponding to the query object.
The calling address of the server interface may refer to an execution location of a method for implementing class implementation of the server interface. For example, the calling address can be represented by a class name corresponding to the server interface and a name of a method implemented by the class.
In this implementation manner, the call address of the target server interface corresponding to the query statement may be determined according to a preset protocol, and then the determined call address is used to call the corresponding target server interface to obtain the return data as the query result.
The description of the corresponding server interface is realized by defining various query objects and parameter objects in the protocol, and the calling addresses of the server interfaces corresponding to the query objects and the parameter objects are set simultaneously, so that the corresponding server interfaces are called based on the query statements to obtain the query result. It should be noted that the implementation manner is only an example of a content setting manner of an optional preset protocol, and different technicians may develop the preset protocol in different manners according to different needs or scenarios.
It should be noted that the preset protocol may be one protocol, or may be composed of multiple protocols according to requirements. For example, the preset protocol may include a first protocol and a second protocol, wherein the first protocol may include a defined parameter object and a query object, and the second protocol may describe a correspondence between a call address of the server-side interface and the defined parameter object and the query object.
By way of example, reference may be made to fig. 3a-3b, which illustrate schematic diagrams of developing a pre-set protocol using a visualization configuration management tool. As shown in fig. 3a, the developer may fill in the title and content of the protocol in a page provided by the visualization configuration management tool. A header may be used to indicate the protocol development.
For example, the protocol content may be as follows:
Figure BDA0003698552080000081
Figure BDA0003698552080000091
the objects "Query", "Book", and "Author" are defined in the above protocol content example. The content of the object "Query" includes a Query rule, specifically, a Query statement "cookbyid" with "id" as an entry, and the object "Book" is returned. The contents of the object "Book" include keywords "id", "name", "pageCount", "author", and the types of the respective keywords. The contents of the object "Author" include the keywords "id", "firstName", "lastName", and the types of the respective keywords. The keywords included in each object may be keywords corresponding to the server interface.
As shown in fig. 3b, the developer may configure, in a page provided by the visualization configuration management tool, a call address of a server interface corresponding to an object in the protocol content filled in fig. 3 a. Meanwhile, various related information can be configured according to requirements, including but not limited to numbers, protocol identifications, objects, object contents, classes of interfaces, methods, creation time, creators, modification time, modifiers, operations and the like.
For example, one row in FIG. 3b is recorded as "17, 9, Book, author, XX. XX, getAuthordataFelcher, Y-M-D-H-MS, test, null, 'View'. Then, indicating the record in line 17, the class in which the server interface actually corresponding to the keyword "author" in the object "Book" in the protocol identified as line 9 is located is "xx.xx", the method implemented by this class is "getauuthordatafelcher", the record is created by "test" at the time point of "Y-M-D-H-MS", and the record is not modified by anyone, and the user can also view detailed information or modify the record by clicking "view" in the operation bar, and so on.
With continued reference to FIGS. 3c-3d, schematic diagrams of composing a query statement and retrieving corresponding query results using a visual configuration management tool are shown. As shown in fig. 3c, a user with a query requirement may fill in the identification of the protocol used, the title of the query, and the query sentence using the page provided by the visual configuration management tool.
For example, based on the protocol content example above, the query statement may be:
Figure BDA0003698552080000101
in the above example of the query statement, the values (Value) corresponding to the keywords "id", "firstName" and "lastName" included in the "bookmark id" query keyword "id", "name" and "author" are respectively arranged in order.
As shown in fig. 3d, after the user inputs the query statement, the user may call the corresponding server interface according to the query protocol to obtain the values corresponding to the keywords respectively, arrange the values in order as the query result, and display the query result in the page of the visual configuration management tool.
For example, the query result may be "'id': 'book-3'; the 'name': 'XX'; 'author': { 'id': 'author-3'; 'firstName': 'YY'; 'lastName': 'ZZ' }. At this time, the values corresponding to the keywords obtained by the query are "book-3", "XX", "author-3", "YY", and "ZZ", respectively.
In some optional implementation manners of this embodiment, a target server interface corresponding to the query statement may be called according to a preset protocol through the following steps, and return data of the target server interface is obtained as a query result:
and step one, performing lexical analysis on the query statement according to a preset protocol to generate a corresponding abstract syntax tree.
In this step, the query statement may be lexically analyzed according to a preset protocol by using various existing abstract syntax tree generating methods to generate a corresponding Abstract Syntax Tree (AST). For example, lexical analysis may be performed on the query sentence based on a preset protocol to obtain tokens, and then the tokens are further identified according to the grammar of the language and the like to generate the abstract syntax tree.
And step two, performing syntax analysis on the abstract syntax tree to generate a corresponding byte code file.
In this step, various existing bytecode file conversion methods can be adopted to perform syntax analysis on the abstract syntax tree to generate corresponding bytecode files. For example, a syntax checking process may be performed on a node in the abstract syntax tree, and a dynamically called bytecode file, such as an asm (assembly language) file, may be generated for the method of the runtime class.
And step three, based on the byte code file, calling a target server-side interface corresponding to the query statement by using a reflection technology to obtain return data of the target server-side interface as a query result.
In this step, after the bytecode file is obtained, a target server interface corresponding to the query statement may be called by using a reflection technique. For example, after the bytecode file is obtained, the bytecode file is loaded by using methods such as classloader.
And analyzing the query statement by using a preset protocol to generate a corresponding abstract syntax tree, then generating a corresponding byte code file based on the abstract syntax tree, and dynamically calling a corresponding server interface by using the byte code file, thereby obtaining a query result. It should be noted that the above implementation is only an example of invoking a corresponding server interface, and a technician may use different methods to complete invoking the server interface according to needs or actual scenarios. For example, a technician may write a corresponding script engine to complete the call to the desired server interface based on the preset protocol and query statements.
In some application scenarios, research and development personnel or product business personnel with query requirements can conveniently write query statements to query required data based on a visual configuration management tool, so that the personnel can conveniently perform operations such as testing, research or sampling based on the required data.
In some scenarios, a protocol may be used to present the server interface to the front end, so that a user may customize a query statement and a required data format, etc. at the front end according to the protocol, and obtain required data as needed, and the back end may analyze the query statement based on a preset protocol and dynamically invoke the corresponding server interface to obtain a required query result.
The data acquisition method provided by the above embodiment of the present disclosure generally sets a protocol describing a server interface and a query rule, and writes a query statement using the preset protocol to call a corresponding server interface to acquire a query result, so that various customized query requirements of a user can be met through flexibility of protocol setting without modifying an application code. In addition, the existing server interface design mode is combined, the existing server interface design can be simplified, processing such as redundancy for various business logics is not needed, the workload of a BFF layer on acquisition, assembly and the like of return data of the server interface can be reduced, the complexity of the BFF logic design can be reduced, meanwhile, the requirement of a user on customized query can be met, unnecessary data issuing of the server can be avoided, and data flow is saved.
With further reference to FIG. 4, a flow 400 of one embodiment of a page presentation method is shown. The process 400 of the page display method includes the following steps:
step 401, receiving a target operation of a user for a page.
In this embodiment, the page may be any application page. The user's operation on the page may be various user operations (e.g., clicking, sliding, etc.). The target operation of the user for the page may refer to a user operation that meets a preset condition, where the preset condition may be set according to an actual application scenario. For example, the preset condition may be that the type of the user operation is a specified type. For another example, the preset condition may be that the operation belongs to a user operation specified in advance.
Step 402, determining a query statement corresponding to the target operation.
In this embodiment, the query statement may be written based on a preset protocol. The preset protocol may be used to describe the server interface and the corresponding query rule, and the query statement may be used to obtain the return data of the target server interface. Specifically, various methods can be adopted to determine the query statement corresponding to the target operation
For example, the correspondence between the target operation and the query statement may be set in advance. At this time, the query statement corresponding to the target operation may be queried according to the preset corresponding relationship. For another example, the corresponding query statement may be generated in real time by using a preset protocol according to the return data of the server interface acquired by the target operation instruction.
As an example, the page may provide different presentation manners based on different data, and at this time, the user may select a desired presentation manner according to a requirement, so that the corresponding query statement may be determined by the data required by the presentation manner selected by the user.
And step 403, obtaining a query result corresponding to the query statement.
In this embodiment, the data obtaining method described in the embodiment of fig. 2 may be used to obtain a query result corresponding to the query statement.
And step 404, updating the page according to the query result.
In this embodiment, after the query result is obtained, the page may be further updated according to the query result, and the specific updating method may be flexibly set according to the actual application requirement. For example, the query results are presented in a specified manner at specified locations of the page.
The execution process not specifically described in this embodiment may refer to the related description in the corresponding embodiment of fig. 2, and is not repeated herein.
It should be noted that the execution main bodies of the page display method provided in this embodiment and the data acquisition method described in the embodiment corresponding to fig. 2 may be the same or different.
According to the method provided by the embodiment of the disclosure, when the target operation of the user on the page is received, the corresponding query statement written based on the preset protocol is determined, the preset protocol is utilized to call the query statement to obtain the corresponding query result, and then the page is updated based on the query result, so that the page can conveniently expand various functions according to actual requirements, and the user experience is facilitated to be improved.
With further reference to fig. 5, as an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a data acquisition apparatus, which corresponds to the method embodiment shown in fig. 2, and which can be specifically applied to various electronic devices.
As shown in fig. 5, the data acquisition apparatus 500 provided in the present embodiment includes a query statement acquisition unit 501 and an interface call unit 502. The query statement acquiring unit 501 is configured to acquire a query statement written based on a preset protocol, where the preset protocol is used to describe a server interface and a corresponding query rule, and the query statement is used to acquire return data of a target server interface; the interface calling unit 502 is configured to call a target server interface corresponding to the query statement according to a preset protocol, and obtain return data of the target server interface as a query result.
In the present embodiment, in the data acquisition apparatus 500: the specific processing of the query statement obtaining unit 501 and the interface calling unit 502 and the technical effects thereof can refer to the related descriptions of step 201 and step 202 in the corresponding embodiment of fig. 2, which are not described herein again.
In some optional implementations of this embodiment, the query statement is further used to indicate a data format of the query result; and the interface call unit 502 is further configured to: calling a target server-side interface corresponding to the query statement according to a preset protocol to obtain return data of the target server-side interface; and adjusting the obtained return data according to the data format indicated by the query statement, and taking the return data with the adjusted format as a query result.
In some optional implementations of this embodiment, the return data of the server interface is formed by splicing at least one key value pair; and the data format is used for describing the splicing sequence among the key value pairs.
In some optional implementations of this embodiment, the number of target server interfaces is at least two.
In some optional implementations of the present embodiment, the interface invoking unit 502 is further configured to: performing lexical analysis on the query statement according to a preset protocol to generate a corresponding abstract syntax tree; carrying out syntactic analysis on the abstract syntactic tree to generate a corresponding byte code file; based on the byte code file, the target server-side interface corresponding to the query statement is called by utilizing a reflection technology, and return data of the target server-side interface is obtained and used as a query result.
In some optional implementations of this embodiment, the preset protocol is developed by using a visualization configuration management tool, where the visualization configuration management tool is used for managing the protocol and the query statement.
In some optional implementation manners of this embodiment, the number of the preset protocols is at least two, and each preset protocol corresponds to a different type of server interface.
In some optional implementation manners of this embodiment, the preset protocol includes a defined parameter object and a query object, where the parameter object is used to describe a keyword, where the keyword belongs to a keyword corresponding to return data of the server-side interface, and the query object is used to describe a format of a query statement, where the format of the query statement includes an entry argument and an exit argument, and the entry argument and the exit argument belong to the parameter object; the preset protocol is also used for describing the corresponding relation between the calling address of the server-side interface and the defined parameter object and query object; and the interface call unit 502 is further configured to: and according to a preset protocol, determining a calling address of a target server interface corresponding to the query statement, calling the target server interface corresponding to the query statement by using the determined calling address, and obtaining return data of the target server interface as a query result.
The apparatus provided by the above embodiment of the present disclosure obtains, by a query statement obtaining unit, a query statement written based on a preset protocol, where the preset protocol is used to describe a server interface and a corresponding query rule, and the query statement is used to obtain return data of a target server interface; the interface calling unit calls the target server-side interface corresponding to the query statement according to the preset protocol to obtain the return data of the target server-side interface as a query result, and can meet various customized query requirements of a user through the flexibility of protocol setting without modifying application codes
With further reference to fig. 6, as an implementation of the methods shown in the above-mentioned figures, the present disclosure provides an embodiment of a page display apparatus, where the embodiment of the apparatus corresponds to the embodiment of the method shown in fig. 4, and the apparatus may be specifically applied to various electronic devices.
As shown in fig. 6, the page presenting apparatus 600 provided in this embodiment includes a receiving unit 601, a determining unit 602, a query result obtaining unit 603, and a page updating unit 604. Wherein, the receiving unit 601 is configured to receive a target operation of a user for a page; the determining unit 602 is configured to determine a query statement corresponding to the target operation, where the query statement is written based on a preset protocol, the preset protocol is used to describe the server interface and a corresponding query rule, and the query statement is used to obtain return data of the target server interface; the query result obtaining unit 603 is configured to obtain a query result corresponding to the query statement, where the query result is obtained by using the method described in the embodiment of fig. 2; the page updating unit 604 is configured to update the page according to the query result.
In the present embodiment, in the page displaying apparatus 600: the specific processing and the technical effects thereof of the receiving unit 601, the determining unit 602, the query result obtaining unit 603, and the page updating unit 604 can refer to the related descriptions of step 401 and step 404 in the corresponding embodiment of fig. 4, which are not described herein again.
The device provided by the above embodiment of the present disclosure receives, by a receiving unit, a target operation of a user for a page; the determining unit determines a query statement corresponding to the target operation, wherein the query statement is compiled based on a preset protocol, the preset protocol is used for describing the server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of the target server-side interface; a query result acquisition unit acquires a query result corresponding to the query statement; the page updating unit updates the page according to the query result, so that the page can expand various functions according to actual requirements, and the user experience is improved.
Referring now to fig. 7, shown is a schematic diagram of an electronic device (e.g., terminal device in fig. 1) 700 suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. The terminal device shown in fig. 7 is only an example, and should not bring any limitation to the functions and the use range of the embodiments of the present disclosure.
As shown in fig. 7, electronic device 700 may include a processing means (e.g., central processing unit, graphics processor, etc.) 701 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)702 or a program loaded from a storage means 708 into a Random Access Memory (RAM) 703. In the RAM703, various programs and data necessary for the operation of the electronic apparatus 700 are also stored. The processing device 701, the ROM 702, and the RAM703 are connected to each other by a bus 704. An input/output (I/O) interface 705 is also connected to bus 704.
Generally, the following devices may be connected to the I/O interface 705: input devices 706 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 707 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 708 including, for example, magnetic tape, hard disk, etc.; and a communication device 709. The communication means 709 may allow the electronic device 700 to communicate wirelessly or by wire with other devices to exchange data. While fig. 7 illustrates an electronic device 700 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided. Each block shown in fig. 7 may represent one device or may represent multiple devices as desired.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such embodiments, the computer program may be downloaded and installed from a network via the communication means 709, or may be installed from the storage means 708, or may be installed from the ROM 702. The computer program, when executed by the processing device 701, performs the above-described functions defined in the methods of embodiments of the present disclosure.
It should be noted that the computer readable medium described in the embodiments of the present disclosure may be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In embodiments of the present disclosure, however, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may be separate and not incorporated into the electronic device. The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: acquiring a query statement written based on a preset protocol, wherein the preset protocol is used for describing a server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of a target server-side interface; and calling a target server-side interface corresponding to the query statement according to a preset protocol to obtain the return data of the target server-side interface as a query result.
Computer program code for carrying out operations for embodiments of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a query statement acquisition unit and an interface calling unit. For example, the interface calling unit may also be described as a unit that "calls a target server interface corresponding to the query statement according to a preset protocol, and obtains return data of the target server interface as a query result".
The foregoing description is only exemplary of the preferred embodiments of the disclosure and is illustrative of the principles of the technology employed. It will be appreciated by those skilled in the art that the scope of the invention in the embodiments of the present disclosure is not limited to the specific combination of the above-mentioned features, but also encompasses other embodiments in which any combination of the above-mentioned features or their equivalents is made without departing from the inventive concept as defined above. For example, the above features and (but not limited to) technical features with similar functions disclosed in the embodiments of the present disclosure are mutually replaced to form the technical solution.

Claims (13)

1. A method of data acquisition, comprising:
acquiring a query statement written based on a preset protocol, wherein the preset protocol is used for describing a server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of a target server-side interface;
and calling a target server-side interface corresponding to the query statement according to the preset protocol to obtain the return data of the target server-side interface as a query result.
2. The method of claim 1, wherein the query statement is further used to indicate a data format of a query result; and
the step of calling a target server-side interface corresponding to the query statement according to the preset protocol to obtain return data of the target server-side interface as a query result includes:
calling a target server-side interface corresponding to the query statement according to the preset protocol to obtain return data of the target server-side interface;
and adjusting the obtained return data according to the data format indicated by the query statement, and obtaining the return data with the adjusted format as a query result.
3. The method of claim 2, wherein the return data of the server interface is formed by at least one key-value pair concatenation; and
the data format is used for describing the splicing sequence among the key value pairs.
4. The method of claim 3, wherein the number of target server interfaces is at least two.
5. The method according to one of claims 1 to 4, wherein the invoking, according to the preset protocol, a target server interface corresponding to the query statement to obtain return data of the target server interface as a query result includes:
performing lexical analysis on the query statement according to the preset protocol to generate a corresponding abstract syntax tree;
carrying out syntactic analysis on the abstract syntactic tree to generate a corresponding byte code file;
and calling a target server-side interface corresponding to the query statement by using a reflection technology based on the byte code file to obtain return data of the target server-side interface as a query result.
6. The method of any one of claims 1 to 4, wherein the preset protocol is developed using a visual configuration management tool for managing protocols and query statements.
7. The method of claim 6, wherein the number of the preset protocols is at least two, and each preset protocol corresponds to a different type of service interface.
8. The method of claim 6, wherein the preset protocol comprises a defined parameter object and a query object, wherein the parameter object is used for describing a keyword, the keyword belongs to the keyword corresponding to the return data of the server interface, the query object is used for describing a format of the query statement, the format of the query statement comprises an entry parameter and an exit parameter, and the entry parameter and the exit parameter belong to the parameter object; and
the preset protocol is also used for describing the corresponding relation between the calling address of the server-side interface and the defined parameter object and query object; and
the step of calling a target server-side interface corresponding to the query statement according to the preset protocol to obtain return data of the target server-side interface as a query result includes:
and determining a calling address of a target server-side interface corresponding to the query statement according to the preset protocol, calling the target server-side interface corresponding to the query statement by using the determined calling address, and obtaining return data of the target server-side interface as a query result.
9. A page display method comprises the following steps:
receiving target operation of a user for a page;
determining a query statement corresponding to the target operation, wherein the query statement is compiled based on a preset protocol, the preset protocol is used for describing a server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of the target server-side interface;
obtaining a query result corresponding to the query statement, wherein the query result is obtained by using the method according to one of claims 1 to 8;
and updating the page according to the query result.
10. A data acquisition apparatus, wherein the apparatus comprises:
the query statement acquisition unit is configured to acquire a query statement written based on a preset protocol, wherein the preset protocol is used for describing a server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of a target server-side interface;
and the interface calling unit is configured to call a target server-side interface corresponding to the query statement according to the preset protocol to obtain the return data of the target server-side interface as a query result.
11. A page display apparatus, wherein the apparatus comprises:
a receiving unit configured to receive a target operation of a user for a page;
the determining unit is configured to determine a query statement corresponding to the target operation, wherein the query statement is written based on a preset protocol, the preset protocol is used for describing a server-side interface and a corresponding query rule, and the query statement is used for acquiring return data of the target server-side interface;
a query result obtaining unit configured to obtain a query result corresponding to the query statement, wherein the query result is obtained by using the method according to one of claims 1 to 8;
and the page updating unit is configured to update the page according to the query result.
12. An electronic device, comprising:
one or more processors;
a storage device having one or more programs stored thereon;
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-9.
13. A computer-readable medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-9.
CN202210736382.9A 2022-06-16 2022-06-16 Data acquisition method and device Pending CN115098530A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210736382.9A CN115098530A (en) 2022-06-16 2022-06-16 Data acquisition method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210736382.9A CN115098530A (en) 2022-06-16 2022-06-16 Data acquisition method and device

Publications (1)

Publication Number Publication Date
CN115098530A true CN115098530A (en) 2022-09-23

Family

ID=83295474

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210736382.9A Pending CN115098530A (en) 2022-06-16 2022-06-16 Data acquisition method and device

Country Status (1)

Country Link
CN (1) CN115098530A (en)

Similar Documents

Publication Publication Date Title
US11656859B2 (en) Data model API for live applications in a cloud collaboration platform
US20130054812A1 (en) System and method for dynamically assembling an application on a client device
US11550599B2 (en) Method and apparatus for running applet
CN110780874B (en) Method and device for generating information
CN111158795A (en) Report generation method, device, medium and electronic equipment
CN112684968A (en) Page display method and device, electronic equipment and computer readable medium
CN112631590B (en) Component library generation method, device, electronic equipment and computer readable medium
CN111125064A (en) Method and device for generating database mode definition statement
CN113448562A (en) Automatic logic code generation method and device and electronic equipment
WO2022184077A1 (en) Document editing method and apparatus, and terminal and non-transitory storage medium
CN113778897B (en) Automatic test method, device and equipment for interface and storage medium
CN113419740A (en) Program data stream analysis method and device, electronic device and readable storage medium
CN108694172B (en) Information output method and device
CN112631563A (en) System development method and device based on framework, computer equipment and storage medium
CN111752644A (en) Interface simulation method, device, equipment and storage medium
CN109358943B (en) Page configuration method and device, electronic equipment and storage medium
CN111767498A (en) Method and device for realizing file information sharing
CN112181408A (en) Method and device for displaying view list on front page of application program
CN115408009A (en) Code file generation method, device, equipment and storage medium
CN111539200B (en) Method, device, medium and electronic equipment for generating rich text
CN115098530A (en) Data acquisition method and device
JP2024508412A (en) Generating natural language interfaces from graphical user interfaces
CN111400623B (en) Method and device for searching information
CN113760969A (en) Data query method and device based on elastic search
CN114553688B (en) Cloud computing deployment method, device, equipment and computer readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination