CN114036178A - Service interface generation method, device, computer and readable storage medium - Google Patents

Service interface generation method, device, computer and readable storage medium Download PDF

Info

Publication number
CN114036178A
CN114036178A CN202111307687.XA CN202111307687A CN114036178A CN 114036178 A CN114036178 A CN 114036178A CN 202111307687 A CN202111307687 A CN 202111307687A CN 114036178 A CN114036178 A CN 114036178A
Authority
CN
China
Prior art keywords
service interface
data table
parameters
parameter
input
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
CN202111307687.XA
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.)
Shenzhen Skyworth Smart Technology Co ltd
Original Assignee
Shenzhen Skyworth Smart Technology 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 Shenzhen Skyworth Smart Technology Co ltd filed Critical Shenzhen Skyworth Smart Technology Co ltd
Priority to CN202111307687.XA priority Critical patent/CN114036178A/en
Publication of CN114036178A publication Critical patent/CN114036178A/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
    • 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented

Landscapes

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

Abstract

The invention discloses a service interface generation method, which comprises the following steps: when a service interface generation instruction is received, acquiring a data table according to the service interface generation instruction, and converting the data table into an output parameter and an input parameter of a service interface according to a first preset rule; determining a query condition corresponding to the input parameter according to the input parameter; generating a dynamic structured query statement according to the input parameters, the output parameters and the query condition; and establishing a mapping relation between the service interface information and the dynamic structured query statement according to the service interface information corresponding to the data table so as to generate a service interface. The invention also discloses a device, a computer and a readable storage medium. By applying the service interface generation method to the computer, the repeatability and unnecessary development work can be reduced, developers and personnel without development foundation can conveniently release the service interface, and therefore the rapid application of big data is realized.

Description

Service interface generation method, device, computer and readable storage medium
Technical Field
The present invention relates to the field of computers, and in particular, to a method and an apparatus for generating a service interface, a computer, and a readable storage medium.
Background
The big data platform can perform ETL (Extract-Transform-Load) on structured, semi-structured and unstructured data, convert the data into data meeting the platform standard and store the data in a data warehouse. The significance of data acquisition is to integrate a large amount of scattered data and prepare for services such as data analysis and the like. Some of the standardized data may have been calculated or summarized before being collected and only need to be sunk to a large data platform because of some reason that access to these source data is limited or not arbitrarily accessible. Other raw data needs to be analyzed and mined and returned to the large data platform for storage and management. The series of complex operations of the big data platform are finally applied to big data, namely big data retrieval, big data visualization, big data application, big data security and the like, and are particularly important for the construction of a data warehouse in order to enable the big data to be efficiently applied.
For different data warehouse construction schemes, SQL (Structured Query Language) syntax has differences, and is generally developed by using an ORM (Object Relational Mapping) framework at present, so that multiple SQL statements need to be maintained; the number of database tables of the data warehouse is large, the number of the tables is increased continuously along with the increase of services, and then a traditional ORM service development mode is used, so that dynamic construction of a mapper file, a table entity and an mvc framework layer is difficult to achieve, developers can get into low-efficiency work for developing service interfaces, and the work can be endless forever.
Disclosure of Invention
The invention provides a service interface generation method, a service interface generation device, a computer and a readable storage medium, and aims to solve the technical problem of low working efficiency when a traditional ORM (object relational mapping) business development mode is used for developing a service interface.
In order to achieve the above object, the present invention provides a service interface generation method, including the following steps:
when a service interface generation instruction is received, acquiring a data table according to the service interface generation instruction, and converting the data table into an output parameter and an input parameter of a service interface according to a first preset rule;
determining a query condition corresponding to the input parameter according to the input parameter;
generating a dynamic structured query statement according to the input parameters, the output parameters and the query condition;
and establishing a mapping relation between the service interface information and the dynamic structured query statement according to the service interface information corresponding to the data table so as to generate a service interface.
Optionally, the step of generating a dynamic structured query statement according to the input parameter, the output parameter and the query condition includes:
packaging the input parameters, the output parameters and the query conditions into object numbered musical notation data; and acquiring a preset structured query statement template, and inputting the object numbered musical notation data and the object numbered musical notation data into the structured query statement template to generate a dynamic structured query statement.
Optionally, the step of converting the data table into an output parameter of the service interface according to a first preset rule includes:
determining whether to automatically generate service interface information corresponding to the data table according to a first preset rule;
if yes, acquiring the service interface information;
if not, receiving input service interface information;
and converting the data table into an output parameter of a service interface according to the service interface information.
Optionally, the step of converting the data table into an output parameter of the service interface according to the service interface information includes:
reading all fields in the data table according to the service interface information, traversing all the fields, determining output parameters corresponding to the traversed fields, taking field names corresponding to the traversed fields as names corresponding to the output parameters, and taking field types corresponding to the traversed fields as types corresponding to the output parameters.
Optionally, the step of converting the data table into an input parameter of a service interface according to a first preset rule includes:
reading different fields in the data table with the preset number according to a first preset rule, traversing the different fields, determining input parameters corresponding to the traversed fields, taking field names corresponding to the traversed fields as names corresponding to the input parameters, and taking field types corresponding to the traversed fields as types corresponding to the input parameters.
Optionally, the step of determining the query condition corresponding to the input parameter according to the input parameter includes:
when a plurality of input parameters exist, configuring a combination relation among the input parameters, configuring a logic relation between the input parameters and parameter values corresponding to the input parameters, and taking a set of the combination relation and the logic relation as a query condition.
Optionally, after the step of converting the data table into the output parameter of the service interface according to the first preset rule, the method further includes:
acquiring a quantity value of the output parameter, and judging whether the quantity value is greater than a preset value;
if the quantity value is larger than a preset value, acquiring a ratio of the quantity value to the preset value, and determining an integer value corresponding to the ratio, wherein the integer value is larger than the ratio;
and paging the output parameters according to the integral value.
In addition, to achieve the above object, the present invention provides a service interface generation apparatus, including:
the data conversion module is used for acquiring a data table according to a service interface generation instruction when the service interface generation instruction is received, and converting the data table into an output parameter and an input parameter of a service interface according to a first preset rule;
the statement generation module is used for determining a query condition corresponding to the input parameter according to the input parameter; generating a dynamic structured query statement according to the input parameters, the output parameters and the query condition;
and the mapping storage module is used for establishing a mapping relation between the service interface information and the dynamic structured query statement according to the service interface information corresponding to the data table so as to generate a service interface.
In addition, to achieve the above object, the present invention further provides a computer including a memory, a processor, and a service interface generation program stored on the memory and executable on the processor, wherein: the service interface generation program, when executed by the processor, implements the steps of the service interface generation method as described above.
In addition, to achieve the above object, the present invention further provides a readable storage medium having stored thereon a service interface generation program, which when executed by a processor, implements the steps of the service interface generation method as described above.
According to the service interface generation method, when a service interface generation instruction is received, a data table is obtained according to the service interface generation instruction, and the data table is converted into the output parameter and the input parameter of the service interface according to a first preset rule, so that a computer automatically converts the data table into the output parameter and the input parameter, the work of manually exporting related parameters by developers is omitted, and the time of the developers is saved; determining query conditions corresponding to the input parameters according to the input parameters, and generating a dynamic structured query statement according to the input parameters, the output parameters and the query conditions, so that a complex workflow that developers need to manually configure different query conditions and structured query statements for different data tables is omitted, and repeated configuration work of the developers is greatly reduced; and finally, establishing a mapping relation between the service interface information and the dynamic structured query statement according to the service interface information corresponding to the data table to generate a service interface, so that the service interface can be conveniently verified or called. The invention avoids the problem of low working efficiency caused by using the traditional ORM business development mode to develop the service interface, and improves the application efficiency of big data.
Drawings
FIG. 1 is a schematic diagram of a terminal structure of a hardware operating environment of a computer according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a first embodiment of a method for generating a service interface according to the present invention;
FIG. 3 is a schematic diagram of a service interface generation apparatus according to the present invention;
fig. 4 is an exemplary diagram relating to a first embodiment of a service interface generation method of the present invention;
fig. 5 is a diagram illustrating a fourth embodiment of a service interface generation method according to the present invention.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, fig. 1 is a schematic terminal structure diagram of a hardware operating environment of a computer according to an embodiment of the present invention.
As shown in fig. 1, the computer terminal may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, a communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may comprise a Display (Display), an input unit such as a control panel, and the optional user interface 1003 may also comprise a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., a WLAN interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001. The memory 1005, which is a kind of computer storage medium, may include therein a service interface generation program.
Optionally, the computer terminal may further include a microphone, a speaker, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a wireless module, and the like.
Those skilled in the art will appreciate that the computer terminal architecture shown in fig. 1 is not intended to be limiting of computer terminals and may include more or less components than those shown, or some of the components may be combined, or a different arrangement of components.
As shown in fig. 2, fig. 2 is a schematic flow chart of a first embodiment of a service interface generation method of the present invention, and in this embodiment, the method includes:
step S10, when a service interface generating instruction is received, a data table is obtained according to the service interface generating instruction, and the data table is converted into output parameters and input parameters of a service interface according to a first preset rule;
the data sheet is a grid virtual sheet for temporarily storing data, the computer can search the data sheet in the database through the service interface generating program, generally, developers select the data sheet, after inputting a service interface generating instruction, the computer can automatically acquire the data sheet selected by the developers, and the data sheet is converted into output parameters and input parameters of the service interface according to a certain rule.
Specifically, the step of converting the data table into the output parameter of the service interface according to the first preset rule includes:
step a, determining whether to automatically generate service interface information corresponding to the data table according to a first preset rule;
if yes, executing step b to obtain the service interface information;
if not, executing step c, and receiving the input service interface information;
and d, converting the data table into the output parameters of the service interface according to the service interface information.
Whether the computer successfully and automatically generates the service interface information corresponding to the data table is judged, wherein the service interface information may be a URI (Uniform Resource Identifier) of the service interface and an ID (Identity document) of the service interface, where the URI corresponds to a name of the data table, for example, the name of the data table is admin, the URI of the service interface may be/api/admin, and the ID of the service interface may be a simple numerical value, for example, 1, 2, 3, or another form such as a character string, and may be preset according to actual needs.
If the computer has successfully and automatically generated the service interface information, the service interface information can be directly acquired, the data table is read according to the URI (Uniform resource identifier) related to the data table in the service interface information, and all fields in the data table are converted into output parameters. If the computer fails to automatically generate the service interface information, prompt information of failure of generating the service interface can be output, developers input the service interface information, and all fields in the data table are converted into output parameters according to the service interface information input by the developers. Through the steps, the service interface information can be ensured not to be omitted, and further, the time for a developer to carry out manual inspection is saved.
In one embodiment, step d comprises:
and e, reading all fields in the data table according to the service interface information, traversing all the fields, determining output parameters corresponding to the traversed fields, taking field names corresponding to the traversed fields as names corresponding to the output parameters, and taking field types corresponding to the traversed fields as types corresponding to the output parameters.
All types of fields in the data table selected by the developer are converted into output parameters of the service interface, for example, referring to table 1 below, table 1 is a data table,
user id name age gender class
1 Xiaoming liquor 17 male 2
2 Xiao Hong 18 female 2
3 Small light 20 male 3
4 Xiaofang (a Chinese character of 'Xiaofang') 20 female 3
5 Xiaoming liquor 19 male 4
TABLE 1
In this table, all types of fields have: the system comprises a user id field, an age field, a generator field and a class, wherein the field types corresponding to the user id field, the age field and the class field are fields of numerical value types, more specifically, a point is an integer numerical value type, and the point can be expressed as int in a database. For a field with a character string type corresponding to the name field and the generator field, generally expressed as char or varchar in a database, converting the field into an output parameter of the service interface, that is, the output parameter of the service interface is: the user id, the name, the age, the genre and the class are set, the parameter types of all the output parameters are set implicitly, the parameter types of all the parameters are consistent with the field types of all the fields, namely the user id parameter, the age parameter and the class parameter are parameters of numerical value types, and the name parameter and the genre parameter are parameters of character string types. Through the steps, the required output parameters can be extracted only by traversing all the fields in the data table through the computer, the work of manually extracting the output parameters is omitted, and the efficiency of development work is improved.
Specifically, the step of converting the data table into the input parameters of the service interface according to the first preset rule includes:
and f, reading different fields in the data table with a preset number according to a first preset rule, traversing the different fields, determining input parameters corresponding to the traversed fields, taking field names corresponding to the traversed fields as names corresponding to the input parameters, and taking field types corresponding to the traversed fields as types corresponding to the input parameters.
For the input parameters of the service interface, the input parameters may also be referred to as query parameters, i.e., the parameters are used by SQL statements to query data in a database or a data table. The input parameters are generally selected as input parameters in a default condition, i.e. the field names of all fields are converted into input parameter names, and the field types of all fields are converted into parameter types of input parameters, i.e. the input parameters are consistent with the output parameters in the default condition. The default of the input parameter may not be selected, for example, the first 3 fields of the data table are set to be converted into the input parameter or any several fields are set to be converted into the input parameter, so that the service interface, when being invoked, can only input the parameter value corresponding to the input parameter to query the relevant data in the data table, if the input parameter value is not the parameter value corresponding to the input parameter, such as the parameter value corresponding to the output parameter of the non-input parameter, the relevant data in the data table cannot be queried, for example, the output parameter is user id, name, age, generer, class, and the set input parameter is user id, name, age, and if the parameter value male corresponding to generer is input when the service interface is invoked, or the parameter value 2 corresponding to class, the state 404 is returned (this information represents that the server cannot normally provide information when the client browses a web page, or the server cannot respond and does not know the reason), alternatively, there are no choices of generator and class at the time of service interface call. In addition, the input parameter may also be set to a fixed value, for example, age >18, so that when the user calls the service interface, no matter what input parameter is used for querying, only data of age >18 can be queried, for example, a data table or a database has a plurality of "Xiaoming" of the same name, the user inputs a parameter value corresponding to a name, and only relevant data of Xiaoming with an age greater than 18 can be returned, referring to table 1, the returned data may be user id: 5 name: small image: 19 under the power: male class: 4.
the setting of the input parameters and the setting of the fixed values of the input parameters can be arbitrarily set according to actual needs. Through the steps, the input parameters required by the developers can be extracted only by traversing the fields selected by the developers in the data table through the computer, so that the work of manually extracting the input parameters is greatly reduced, and the efficiency of development work is improved.
Step S20, determining the query condition corresponding to the input parameter according to the input parameter;
when a single input parameter exists, the query condition is the input parameter itself, for example, the input parameter is a name field, and the service interface can only return data related to the name field by inputting a parameter value corresponding to the name field, such as xiaoming, when the service interface calls, but if a parameter value corresponding to another field, such as 3 corresponding to a class field, is input, the service interface returns 404 a status code, that is, the server cannot normally provide information, or the server cannot respond and does not know the reason.
When a plurality of input parameters exist, the combination relationship between the input parameters needs to be configured, wherein the combination relationship is the "and", "or" relationship between the input parameters, the computer selects the "and" combination relationship by default through the service interface generation program, if a developer has special needs, the computer can also set the "or" combination relationship or the "and" or "combination relationship, after the setting, the computer selects the" or "combination relationship or the" and "or" combination relationship, for the "and", "or" combination relationship, for example, referring to table 1, if the default "and" combination relationship is existed, the user can input: class2, then the relevant parameters with user id 1 can be returned; if the combined relation of 'OR' is selected, when the user calls the service interface, the user inputs: small red, age20, then the relevant data with user id 2, 3, 4 can be returned; if the combined relation of 'AND' and 'OR' is selected, when the user calls the service interface, the user inputs: decimal and (age17 or age19), then the relevant data with user ids 1 and 5 is returned.
Specifically, step S20 includes:
step g, when a plurality of input parameters exist, configuring a combination relation among the input parameters, configuring a logic relation between the input parameters and parameter values corresponding to the input parameters, and taking a set of the combination relation and the logic relation as a query condition.
If a plurality of input parameters are set, while the combined relationship of "and" or "between the input parameters is configured, the logical relationship between the input parameters and the parameter values corresponding to the input parameters, that is, the logical relationship is greater than, less than, equal to, contained, or not contained, may also be configured, and the combined relationship between the input parameters and the logical relationship between the input parameters and the corresponding parameter values may be combined together to jointly form a query condition, for example, the query condition may be name? and (age >: for such complex input, a query option may be provided for a user through an interface called by a service interface, so that the user may conveniently call data and know which data may be called. Through the steps, the repeated work that a developer needs to manually configure the query conditions for each different data table can be omitted, and the development time of the developer is saved.
Step S30, generating a dynamic structured query statement according to the input parameters, the output parameters and the query conditions;
the input parameters, the output parameters and the query conditions are encapsulated into object numbered musical notation data, namely data in a json format, and then the object numbered musical notation data is combined with a pre-compiled SQL statement basic template to generate dynamic structured query statements, namely dynamic SQL statements, so that different SQL statements can be automatically generated according to different data tables, namely, a program is generated through a service interface of a computer, the work that developers need to compile corresponding SQL statements according to different data tables in person can be omitted, manpower resources are greatly saved, and the efficiency of big data application is improved.
Step S40, according to the service interface information corresponding to the data table, establishing a mapping relationship between the service interface information and the dynamic structured query statement to generate a service interface.
The service interface information comprises URI, the name of the service interface and other information of service development, establishes a mapping relation between the service interface information and the generated dynamic structured query statement, and stores the mapping relation.
In addition, this embodiment can be implemented in a service interface visualization manner, referring to fig. 4, after a developer selects a service interface generation option, the developer clicks to create a service interface, at this time, the developer can click to edit an SQL template option to write a structured query statement template, and if the structured query statement template already exists or the structured query statement template is written, the developer can click to visually edit an option, at this time, the computer can automatically generate a URI, an interface name, and other development information of the service interface according to the table name of the data table, and then read the table field by the computer, set all the fields of the data table as output parameters of the service interface, query parameters, that is, the input parameters and the table field are the same name, and set a matching manner, that is, query conditions according to the type of the table field, and set the structured query statement template and the matching manner, And assembling the output parameters and the query parameters, storing the assembled parameters as a new dynamic SQL template, and finally storing the mapping relation between the service interface ID and the new dynamic SQL template to generate a complete service interface.
If the computer does not automatically generate URI and other development information of the service interface according to the table name of the data table, the information is prompted to a developer, the developer can set the information of the interface name, URI and the like of the service interface by himself, after the developer sets the information of the service interface, the computer starts to read all table fields of the data table, selects interface output parameters from the data table and can provide options of paging or not, if the developer selects paging, the developer can set by himself or the computer pages the interface output parameters according to default rules, the maximum value and paging parameter name of each page can be set no matter the rule is set by himself or the rule is set by himself, the next flow comes to add the interface input parameters, even if the developer does not select paging, the flow is entered, after the interface input parameters are added, the combination relation between the input parameters and the table fields and the combination relation between the input parameters can be set, the two combination relations can be summarized as query conditions, and finally, the output parameters, the input parameters, the query conditions and the structured query statement template are also assembled and stored as a new SQL template, and then the mapping relation between the service interface ID and the new SQL template is stored, and the generation work of the service interface is completed. Through the visualization mode of the service interface, developers can clearly see the generation process of the service interface, the service interface is conveniently developed, the efficiency of development work is greatly improved, and the frequent development work problem caused by the fact that the service interface cannot be visualized can be reduced.
According to the service interface generation method, when a service interface generation instruction is received, a data table is obtained according to the service interface generation instruction, and the data table is converted into the output parameter and the input parameter of the service interface according to a first preset rule, so that a computer automatically converts the data table into the output parameter and the input parameter, the work of manually exporting related parameters by developers is omitted, and the time of the developers is saved; determining query conditions corresponding to the input parameters according to the input parameters, and generating a dynamic structured query statement according to the input parameters, the output parameters and the query conditions, so that a complex workflow that developers need to manually configure different query conditions and structured query statements for different data tables is omitted, and repeated configuration work of the developers is greatly reduced; and finally, establishing a mapping relation between the service interface information and the dynamic structured query statement according to the service interface information corresponding to the data table to generate a service interface, so that the service interface can be conveniently verified or called. The invention avoids the problem of low working efficiency caused by using the traditional ORM business development mode to develop the service interface, and improves the application efficiency of big data.
Further, a second embodiment of the service interface generation method of the present invention is proposed based on the first embodiment of the service interface generation method of the present invention, and in this embodiment, the step S30 includes:
step h, packaging the input parameters, the output parameters and the query conditions into object numbered musical notation data; and acquiring a preset structured query statement template, and inputting the object numbered musical notation data and the object numbered musical notation data into the structured query statement template to generate a dynamic structured query statement.
After the converted input parameters, output parameters and query conditions are obtained, the input parameters, the output parameters and the query conditions are packaged into object numbered musical notation data, namely json format data, and meanwhile, a pre-edited basic template of the structured query statement is obtained, the basic template is suitable for various data tables, and the basic template and the object numbered musical notation data are combined together to generate the dynamic structured query statement. The basic template can be edited and modified by developers, but the edited basic template is a universal template for various data tables under the general condition, has high stability and does not need to be changed. The object numbered musical notation data is stored and represented in a text format that is completely independent of the programming language. The compact and clear hierarchy makes object profile data an ideal data exchange language. The network transmission method is easy to read and write by people, is easy to analyze and generate by machines, and effectively improves the network transmission efficiency. Therefore, the dynamic structured query statement generated by combining the stable basic template and the concise and easy-to-read object numbered notation data can not only save the time of writing SQL statement by developers, but also improve the analysis efficiency of the back end and the query efficiency when the service interface is called.
Further, a third embodiment of the service interface generating method according to the present invention is proposed based on the first embodiment of the service interface generating method according to the present invention, and in this embodiment, after the step of converting the data table into the output parameter of the service interface according to the first preset rule, the method further includes:
step i, acquiring a quantity value of the output parameter, and judging whether the quantity value is greater than a preset value;
if the quantity value is larger than a preset value, executing step j, obtaining a ratio of the quantity value to the preset value, and determining an integer value corresponding to the ratio, wherein the integer value is larger than the ratio;
and k, paging the output parameters according to the integral value.
The present embodiment is suitable for the case where the data amount in the data table is large, like the data table 1 in the first embodiment, because the number of the fields contained in the data table is small, and is only 5, but in fact, the fields contained in the data table composed of a large number of data tables or the data table composed of a large number of data tables are very large, and if the case is not processed, the efficiency of the application of the large data is also low, so the present embodiment provides a scheme for paging the fields in the data table, and similarly, the scheme can also be applied to various databases.
The computer obtains all the input parameters in the selected data table, counts the number value of the input parameters, that is, the number value of the field in the selected data table, and determines whether the number value is greater than a preset number value, for example, the preset value may be set to 20, if the number value of the output parameters is greater than the preset number value, all the output parameters need to be paged, and specifically, the ratio of the number value of the output parameters to the preset value is obtained through calculation. For example, if the preset value is 20, the quantity value of the input parameter is 60, and the ratio of the quantity value of the output parameter to the preset value is 3, the output parameter is divided into 3 pages, and each page contains 20 output parameters. If the quantity value of the output parameter in the above example is changed to 50, the ratio of the quantity value of the output parameter to the preset value obtained by calculation is 2.5, at this time, the ratio needs to be rounded, and the taken integer is greater than the ratio, so that 3 is taken, the output parameter is divided into 3 pages, each page of the first two pages contains 20 output parameters, and the third page contains 10 output parameters.
Further, a fourth embodiment of the service interface generation method according to the present invention is proposed based on the first embodiment of the service interface generation method according to the present invention, and in this embodiment, after step S40, the method further includes:
step m, receiving a service interface verification request, and analyzing a request parameter corresponding to the verification request by a service interceptor of the service interface, wherein the request parameter comprises a parameter to be inquired;
n, obtaining a hash value of the request parameter according to the request parameter, and judging whether the hash value is a weighted hash value;
step o, if the hash value is a weighted hash value, reading the cache data corresponding to the hash value, and judging whether the cache data is read or not;
step p, if the cache data is not read, inquiring source information corresponding to the request parameters according to the request parameters, wherein the source information comprises a preset structured inquiry statement template and a data source, and judging whether the preset structured inquiry statement template is inquired or not;
step q, if a preset structured query statement template is queried, inputting a preset structured query statement and the parameter to be queried into a template analyzer of a service interface to obtain a structured query statement corresponding to the parameter to be queried;
step r, calling the data source through a structured query statement parser of a service interface to obtain a result set corresponding to the request parameter;
and step s, inputting the result set into the cache data and outputting the result set.
In this embodiment, after step n, the method further includes: and if the hash value is an unauthorized hash value, intercepting the verification request, and outputting a first abnormal state prompt to finish the verification request. After the step o, further comprising: and if the cache data is read, outputting a result set corresponding to the request parameters. After the step p, the method further comprises the following steps: and if the structured query statement template is not queried, outputting a second abnormal state prompt to end the verification request. After the step r, the method further comprises the following steps: and if the result set is not obtained, outputting a third abnormal state prompt to end the verification request.
For facilitating understanding of the above step flow, referring to fig. 5, as shown in fig. 5, firstly, a developer initiates a check request to a service interface, the service interface intercepts the check request, analyzes a URI and an input parameter in the check request, calculates a hashId (hash value) according to the URI and the input parameter, performs interface logic such as authentication and current limiting on the hashId, ends the entire check flow if the intercepted check request fails, starts reading a cache if the intercepted check request passes, returns a result if the cache hits, passes the check, and ends the check flow. If the cache is not hit, the SQL template (the preset structured query statement template) is queried according to the URI, if the SQL template is not found through query, the state is returned to 404, the verification process is ended, after the SQL template is queried, the template is locked to execute template analysis, the template and input parameters are transmitted to the template analyzer, the template analyzer receives the query parameters (the input parameters) and the SQL template, dynamic SQL statements are output, namely, the SQL statement of the parameters to be queried (the input parameters) defined by the template is returned after the template analyzer analyzes correctly, and if the SQL statement cannot be analyzed normally, the verification process is ended. And after the template parser correctly parses, the SQL parser calls a data source through driving to obtain a result set, if the result set is not obtained, the verification process is ended, if the result set is obtained, the result set is written into a cache, a result is returned, the verification is passed, and the verification process is ended.
After the service interface is generated, the service interface can be comprehensively checked through the technical scheme in the embodiment, so that various problems of the service interface can be timely and efficiently found, the work of developers for manually checking abnormal conditions of the service interface is reduced, human resources are saved, and the efficiency of big data application is improved.
In addition, referring to fig. 3, the present invention further provides a service interface generation apparatus, including:
the data conversion module A10 is used for acquiring a data table according to a service interface generation instruction when the service interface generation instruction is received, and converting the data table into an output parameter and an input parameter of a service interface according to a first preset rule;
a statement generating module a20, configured to determine, according to the input parameter, a query condition corresponding to the input parameter; generating a dynamic structured query statement according to the input parameters, the output parameters and the query condition;
and the mapping storage module a30 is configured to establish a mapping relationship between the service interface information and the dynamic structured query statement according to the service interface information corresponding to the data table, so as to generate a service interface.
Optionally, the statement generation module a20 is further configured to:
packaging the input parameters, the output parameters and the query conditions into object numbered musical notation data; and acquiring a preset structured query statement template, and inputting the object numbered musical notation data and the object numbered musical notation data into the structured query statement template to generate a dynamic structured query statement.
Optionally, the data conversion module a10 is further configured to:
determining whether to automatically generate service interface information corresponding to the data table according to a first preset rule;
if yes, acquiring the service interface information;
if not, receiving input service interface information;
and converting the data table into an output parameter of a service interface according to the service interface information.
Optionally, the data conversion module a10 is further configured to:
reading all fields in the data table according to the service interface information, traversing all the fields, determining output parameters corresponding to all the traversed fields, taking field names corresponding to all the traversed fields as names corresponding to the output parameters, and taking field types corresponding to all the traversed fields as types corresponding to the output parameters.
Optionally, the data conversion module a10 is further configured to:
reading different fields in the data table with the preset number according to a first preset rule, traversing the different fields, determining input parameters corresponding to the traversed different fields, taking field names corresponding to the traversed different fields as names corresponding to the input parameters, and taking field types corresponding to the traversed different fields as types corresponding to the input parameters.
Optionally, the statement generation module a20 is further configured to:
when a plurality of input parameters exist, configuring a combination relation among the input parameters, configuring a logic relation between the input parameters and parameter values corresponding to the input parameters, and taking a set of the combination relation and the logic relation as a query condition.
Optionally, the data conversion module a10 is further configured to:
acquiring a quantity value of the output parameter, and judging whether the quantity value is greater than a preset value;
if the quantity value is larger than a preset value, acquiring a ratio of the quantity value to the preset value, and determining an integer value corresponding to the ratio, wherein the integer value is larger than the ratio;
and paging the output parameters according to the integral value.
In addition, the present invention further provides a computer, which includes a memory, a processor, and a service interface generation program stored in the memory and executable on the processor, and the processor implements the steps of the service interface generation method according to the above embodiment when executing the service interface generation program.
The specific computer implementation of the present invention is substantially the same as the embodiments of the service interface generation method described above, and is not described herein again.
Furthermore, the present invention also provides a readable storage medium, where the readable storage medium may be a computer readable storage medium, characterized in that the readable storage medium includes a service interface generating program, and the service interface generating program, when executed by a processor, implements the steps of the service interface generating method according to the above embodiment.
The specific implementation of the readable storage medium of the present invention is substantially the same as that of each embodiment of the service interface generation method described above, and is not described herein again.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a computer, a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
In the present invention, the terms "first", "second", "third", "fourth" and "fifth" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance, and those skilled in the art can understand the specific meanings of the above terms in the present invention according to specific situations.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Although the embodiment of the present invention has been shown and described, the scope of the present invention is not limited thereto, it should be understood that the above embodiment is illustrative and not to be construed as limiting the present invention, and that those skilled in the art can make changes, modifications and substitutions to the above embodiment within the scope of the present invention, and that these changes, modifications and substitutions should be covered by the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A service interface generation method is characterized by comprising the following steps:
when a service interface generation instruction is received, acquiring a data table according to the service interface generation instruction, and converting the data table into an output parameter and an input parameter of a service interface according to a first preset rule;
determining a query condition corresponding to the input parameter according to the input parameter;
generating a dynamic structured query statement according to the input parameters, the output parameters and the query condition;
and establishing a mapping relation between the service interface information and the dynamic structured query statement according to the service interface information corresponding to the data table so as to generate a service interface.
2. The service interface generation method of claim 1, wherein the step of generating a dynamic structured query statement from the input parameters, the output parameters, and the query conditions comprises:
packaging the input parameters, the output parameters and the query conditions into object numbered musical notation data; and acquiring a preset structured query statement template, and inputting the object numbered musical notation data and the object numbered musical notation data into the structured query statement template to generate a dynamic structured query statement.
3. The service interface generation method of claim 1, wherein the step of converting the data table into the output parameter of the service interface according to the first preset rule comprises:
determining whether to automatically generate service interface information corresponding to the data table according to a first preset rule;
if yes, acquiring the service interface information;
if not, receiving input service interface information;
and converting the data table into an output parameter of a service interface according to the service interface information.
4. The service interface generation method of claim 3, wherein the step of converting the data table into output parameters of the service interface according to the service interface information comprises:
reading all fields in the data table according to the service interface information, traversing all the fields, determining output parameters corresponding to the traversed fields, taking field names corresponding to the traversed fields as names corresponding to the output parameters, and taking field types corresponding to the traversed fields as types corresponding to the output parameters.
5. The service interface generation method of claim 1, wherein the step of converting the data table into input parameters of the service interface according to the first preset rule comprises:
reading different fields in the data table with the preset number according to a first preset rule, traversing the different fields, determining input parameters corresponding to the traversed fields, taking field names corresponding to the traversed fields as names corresponding to the input parameters, and taking field types corresponding to the traversed fields as types corresponding to the input parameters.
6. The service interface generation method of claim 1, wherein the step of determining the query condition corresponding to the input parameter according to the input parameter comprises:
when a plurality of input parameters exist, configuring a combination relation among the input parameters, configuring a logic relation between the input parameters and parameter values corresponding to the input parameters, and taking a set of the combination relation and the logic relation as a query condition.
7. The method for generating a service interface according to claim 1, wherein after the step of converting the data table into the output parameters of the service interface according to the first preset rule, the method further comprises:
acquiring a quantity value of the output parameter, and judging whether the quantity value is greater than a preset value;
if the quantity value is larger than a preset value, acquiring a ratio of the quantity value to the preset value, and determining an integer value corresponding to the ratio, wherein the integer value is larger than the ratio;
and paging the output parameters according to the integral value.
8. A service interface generation apparatus, characterized in that the service interface generation apparatus comprises:
the data conversion module is used for acquiring a data table according to a service interface generation instruction when the service interface generation instruction is received, and converting the data table into an output parameter and an input parameter of a service interface according to a first preset rule;
the statement generation module is used for determining a query condition corresponding to the input parameter according to the input parameter; generating a dynamic structured query statement according to the input parameters, the output parameters and the query condition;
and the mapping storage module is used for establishing a mapping relation between the service interface information and the dynamic structured query statement according to the service interface information corresponding to the data table so as to generate a service interface.
9. A computer comprising a memory, a processor, and a service interface generation program stored on the memory and executable on the processor, wherein: the service interface generation program, when executed by the processor, implements the steps of the service interface generation method of any one of claims 1 to 7.
10. A readable storage medium, having stored thereon a service interface generation program which, when executed by a processor, implements the steps of the service interface generation method according to any one of claims 1 to 7.
CN202111307687.XA 2021-11-05 2021-11-05 Service interface generation method, device, computer and readable storage medium Pending CN114036178A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111307687.XA CN114036178A (en) 2021-11-05 2021-11-05 Service interface generation method, device, computer and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111307687.XA CN114036178A (en) 2021-11-05 2021-11-05 Service interface generation method, device, computer and readable storage medium

Publications (1)

Publication Number Publication Date
CN114036178A true CN114036178A (en) 2022-02-11

Family

ID=80136507

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111307687.XA Pending CN114036178A (en) 2021-11-05 2021-11-05 Service interface generation method, device, computer and readable storage medium

Country Status (1)

Country Link
CN (1) CN114036178A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117453732A (en) * 2023-12-25 2024-01-26 智业软件股份有限公司 CDSS doctor's advice data query optimization method and system

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117453732A (en) * 2023-12-25 2024-01-26 智业软件股份有限公司 CDSS doctor's advice data query optimization method and system
CN117453732B (en) * 2023-12-25 2024-03-01 智业软件股份有限公司 CDSS doctor's advice data query optimization method and system

Similar Documents

Publication Publication Date Title
CN110717319B (en) Self-service report generation method, device, computing equipment and system
CN106951430B (en) Account table query method and device
EP3835968B1 (en) Creating data in a data store using a dynamic ontology
US8479052B2 (en) Exposing application performance counters for .NET applications through code instrumentation
US7743066B2 (en) Anonymous types for statically typed queries
CA2684822C (en) Data transformation based on a technical design document
US8019791B2 (en) Method and system for transforming metadata modeled in the common information model into grid control target metadata
CN112685433B (en) Metadata updating method and device, electronic equipment and computer-readable storage medium
CN110427188B (en) Configuration method, device, equipment and storage medium of single-test assertion program
CN111061464B (en) Analysis code generation method, device, equipment and storage medium
CN111061678B (en) Service data processing method, device, computer equipment and storage medium
CN104679500B (en) Method and device for realizing automatic generation of entity class
CN111443901B (en) Java reflection-based service expansion method and device
CN111259067A (en) Method, device and equipment for realizing DAO interface based on Spring
CN111818175A (en) Enterprise service bus configuration file generation method, device, equipment and storage medium
CN112988770A (en) Method and device for updating serial number, electronic equipment and storage medium
CN116244387A (en) Entity relationship construction method, device, electronic equipment and storage medium
CN114036178A (en) Service interface generation method, device, computer and readable storage medium
CN111240953A (en) Log processing method and device and readable storage medium
CN114253995A (en) Data tracing method, device, equipment and computer readable storage medium
KR101810518B1 (en) Object query system and method using BIM data of IFC format
CN112825068B (en) Data blood margin generation method and device
CN109726213B (en) Program code conversion method, device, medium and computing equipment
CN111126008A (en) XSD-based code generation method and device, computer equipment and storage medium
CN115934537A (en) Interface test tool generation method, device, equipment, medium and product

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