WO2019153549A1 - Api接口动态生成方法、装置、计算机设备及存储介质 - Google Patents
Api接口动态生成方法、装置、计算机设备及存储介质 Download PDFInfo
- Publication number
- WO2019153549A1 WO2019153549A1 PCT/CN2018/085326 CN2018085326W WO2019153549A1 WO 2019153549 A1 WO2019153549 A1 WO 2019153549A1 CN 2018085326 W CN2018085326 W CN 2018085326W WO 2019153549 A1 WO2019153549 A1 WO 2019153549A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- api interface
- view layer
- configuration model
- business
- layer node
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/35—Creation or generation of source code model driven
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/21—Design, administration or maintenance of databases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/25—Integrating or interfacing systems involving database management systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/44—Arrangements for executing specific programs
- G06F9/448—Execution paradigms, e.g. implementations of programming paradigms
- G06F9/4488—Object-oriented
- G06F9/449—Object-oriented method invocation or resolution
Definitions
- the present application relates to the field of database configuration management technologies, and in particular, to a method, an apparatus, a computer device, and a storage medium for dynamically generating an API interface.
- CMDB Configuration Management Database
- the application provides a method, a device, a computer device and a storage medium for dynamically generating an API interface, and aims to solve the problem that the external API interface of the CMDB system in the prior art needs to write a large number of SQL statements, and when the service is changed, the external API interface is also To be modified, the development of the external API interface of the CMDB system is extremely time consuming.
- the present application provides a method for dynamically generating an API interface, which includes: generating a configuration model according to external service requirement information, and saving the configuration model to an image database; generating an API interface according to the configuration model; The access information of the API interface calls the API interface, obtains the calling type of the external service request end to the API interface, and correspondingly feeds back the service data according to the calling type.
- the application provides an API interface dynamic generation apparatus, including:
- a configuration model generating unit configured to generate a configuration model according to external business requirement information, and save the configuration model to the graphic database
- An API interface generating unit configured to generate an API interface according to the configuration model
- the service data feedback unit is configured to: when the external service request end detects that the API interface is invoked according to the access information of the API interface, obtain the call type of the external service demand end to the API interface, and feed back the service data according to the call type.
- the present application further provides a computer device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, the processor implementing the computer program
- a computer device comprising a memory, a processor, and a computer program stored on the memory and operable on the processor, the processor implementing the computer program
- the present application also provides a storage medium, wherein the storage medium stores a computer program, the computer program comprising program instructions, the program instructions, when executed by a processor, causing the processor to execute the application
- the application provides a method, a device, a computer device and a storage medium for dynamically generating an API interface.
- This method does not need to write a large number of SQL statements to generate API interfaces. It only needs to quickly modify the configuration model to get the API interface that meets the requirements, saving the time spent developing a large number of SQL statements, and avoiding the interface change causing the application to stop and stop. problem.
- 1a is a schematic diagram of a three-layer structure of a specific graphics database in an embodiment of the present application
- FIG. 1b is a schematic flowchart of a method for dynamically generating an API interface according to an embodiment of the present application
- FIG. 2 is a schematic diagram of a sub-flow of a method for dynamically generating an API interface according to an embodiment of the present application
- FIG. 3 is another schematic flowchart of a method for dynamically generating an API interface according to an embodiment of the present application
- FIG. 4 is a schematic flowchart of another sub-flow of a method for dynamically generating an API interface according to an embodiment of the present disclosure
- FIG. 5 is a schematic block diagram of an apparatus for dynamically generating an API interface according to an embodiment of the present disclosure
- FIG. 6 is a schematic block diagram of a subunit of an API interface dynamic generation apparatus according to an embodiment of the present disclosure
- FIG. 7 is a schematic block diagram of another subunit of an API interface dynamic generating apparatus according to an embodiment of the present disclosure.
- FIG. 8 is a schematic block diagram of another subunit of an API interface dynamic generating apparatus according to an embodiment of the present disclosure.
- FIG. 9 is a schematic block diagram of a computer device according to an embodiment of the present application.
- kernel configuration can also be called a configuration model.
- the configuration model is a standard graphical structure. Refer to Figure 1a for the specific graphic structure. As shown in FIG. 1a, the configuration model is divided into three layers, as follows:
- the top layer is the page layer (ViewGroup), which is an abstraction of the basic information of the page, mainly including the basic information of the page, such as: page name, page encoding and other information.
- PageGroup is an abstraction of the basic information of the page, mainly including the basic information of the page, such as: page name, page encoding and other information.
- the middle layer is the business view layer (View), which is an abstraction of business data.
- View can be understood as a data table in the page, which mainly contains the name, code, View type and View component type of the business view.
- Each business view View is composed of one or more Entities of the ER layer.
- the View type mainly includes: a. Topology map type, mainly used to display data association view; b. Business data type, mainly used to display page table data.
- the component types of View mainly include: a. data table; b. other data display components, such as tree diagrams, histograms and other data display components.
- the bottom layer is the ER layer, which is mainly a representation of the relational database ER model. It is used to provide the basis for the management of the business data required by the business view layer View.
- the ER layer mainly contains Entity/Attribute (where Entity represents Entity, Attribute represents the attribute of the entity) and the relationship between Entity and Entity, and the relationship between Entity and its Attribute.
- Entity mainly contains information such as table name, table alias and other information, whether it is editable or not;
- Attribute mainly contains information such as attribute name, encoding, whether it is visible, and whether it can be edited.
- the CMDB application system is divided into three layers.
- the user-oriented and directly visible to the user is the page.
- the next layer of the page is the CMDB application system layer, and the next layer is the background graphics database and the relational database (graphic database, And the relational database is connected with the CMDB application system layer, that is, the CMDB application system layer can obtain data from the graphical database and the relational database).
- the graphics database includes multiple configuration models, and each configuration model is composed of the above three layers (ie, a page layer, a service view layer, and an ER layer), and each of the service model layers in the configuration model includes at least one service view. Layer nodes are displayed in the business view layer.
- FIG. 1b is a schematic flowchart of a method for dynamically generating an API interface according to an embodiment of the present application.
- the method is applied to terminals such as desktop computers, laptop computers, and tablet computers.
- the method includes steps S101 to S103.
- the server when acquiring external service demand information, it is possible to obtain information through various methods (such as receiving mail, QQ message, WeChat, short message, etc.). For example, if the external service demand side needs to obtain data about the information about the equipment room, the server (the CMDB application system) needs to provide an API interface that can query the information of the equipment room. At this time, the external service demand side sends the information to the server.
- the external service demand information includes information such as the name of the equipment room, the location, and the host in the equipment room; the external service demand information is sent to the CMDB application system by means of mail.
- the step S101 includes the following sub-steps:
- S1011 Parse the name of the service view layer node included in the external service requirement information, the name of the entity associated with the service view layer node, the relationship between the entities, and the service data in the relational database corresponding to each entity;
- S1012 Corresponding to generating a service view layer node in the configuration model according to the name of the service view layer node;
- the following key information in the external business requirement information is first parsed: the name of the business view layer node, the name of the entity associated with the business view layer, the relationship between the entities, and the business in the relational database corresponding to each entity. data;
- the business view layer node in the configuration model is generated according to the name of the business view layer node, and the entity in the configuration model is generated according to the name of the entity, and the corresponding model is generated in the configuration model according to the relationship between the entity and the business view layer node.
- a relationship connection line group ie, a relationship connection line between a node of the View layer and an entity included in the ER layer
- the generated configuration model is saved to the graphics database, and the configuration model mapping processing can be further performed to open a corresponding API interface for the user to perform data operations.
- the configuration model is a graphic model stored in the graphic database and can be directly opened for data operations
- the configuration model needs to be mapped into an API interface, and the API interface is sent to the external service demand side. Access to information in order to access the relational database connected to the graph database through the API interface.
- the configuration model is configured according to the actual data needs of the user, it can be flexibly adjusted to meet the data needs of the user.
- the configuration model is simple to configure, and simply adds the business view layer node and its attributes, the ER layer entity, the relationship between the entities, and the relationship between the entity and the business view layer node to complete the configuration without editing. Complex SQL statements.
- re-establishing the configuration model quickly can regenerate the API interface that meets the requirements, and avoids the problem that the interface change causes the application to start and stop.
- the step S102 includes the following sub-steps:
- the method further includes: sending the access information of the API interface to the external service demanding end; wherein the access information includes a request format, a request parameter, and a request address.
- the API interface is initially created according to the name of the service view layer node in the configuration model, and the access information of the API interface is further improved according to the attributes of the service view layer node, that is, the API interface is represented by the name of the service view layer node. Name, and edit the access information including the request format, request parameters, and request address in the property bar of the API interface, and then map the API interface and the business view layer node with the same name to complete the API interface.
- the access information of the API interface is sent to the external service request end, and the external service demand end can send a service request such as adding, deleting, and checking to the server, so as to perform corresponding operations on the data in the data type database.
- the access information sent to the external service demand side is as follows:
- the URL indicates the request address of the API interface
- the method:POST indicates that the data request mode of the API interface is a POST request
- the dataSet indicates that the data request format of the API interface is ⁇ "hostName”: "xx”, "hostIp”: “xx” ⁇ , ⁇ "hostName”: “xx”, "hostIp”: “xx” ⁇
- add/data indicates that the data call type for the API interface is increased data.
- the step S103 includes the following sub-steps:
- S1013 Obtain a service view layer node corresponding to an API interface accessed by an external service request end according to the request parameter included in the access information of the external service demand side;
- S1032 Generate a SQL script according to a table name of the service view layer and a call type of the API interface, where the call type includes an increase data request, a delete data request, an edit data request, and a query data request.
- S1033 Execute the SQL script to obtain business data from the relational database, and correspondingly feed back to the API interface.
- the View that is, the business view layer node of the business view layer is located according to the request parameter;
- the service invocation type specifically includes adding a data request, deleting a data request, editing a data request, and querying a data request;
- the first SQL script is generated according to the query data request, the view of the business view layer, and the keyword of the query (the first SQL script includes a select statement), and the first SQL script is executed in the data type.
- the query in the database obtains the corresponding service data, and feeds the service data to the external service demand end through the service view layer node;
- the second SQL script is generated according to the increase data request, the view of the business view layer, and the data to be added (the second SQL script includes an add statement), and the second SQL script is executed in the data type. Add corresponding service data in the database, and feed back the message that the data is successful to the external service demand end;
- a third SQL script is generated according to the delete data request, the view of the business view layer, and the data to be deleted (the third SQL script includes a delete statement), and the third SQL script is executed in the data type. Delete the corresponding service data in the database, and feed back the message that the data is successfully deleted to the external service demand end;
- a fourth SQL script is generated according to the edit data request, the view of the business view layer, and the data to be edited (the fourth SQL script includes an update statement), and the fourth SQL script is executed in the data type.
- the corresponding business data is modified in the database, and the message for successfully editing the data is fed back to the external service demand side.
- the method does not need to write a large number of SQL statements to generate an API interface, and only needs to quickly modify the configuration model to obtain an API interface that satisfies the requirements, which saves time spent developing a large number of SQL statements, and also avoids application changes caused by interface changes. Stop the problem.
- FIG. 5 is a schematic block diagram of an API interface dynamic generation apparatus according to an embodiment of the present application.
- the API interface dynamic generation device 100 can be installed in a desktop computer, a tablet computer, a laptop computer, or the like.
- the API interface dynamic generation apparatus 100 includes a configuration model generation unit 101, an API interface generation unit 102, and a service data feedback unit 103.
- the configuration model generating unit 101 is configured to generate a configuration model according to the external business requirement information, and save the configuration model to the graphic database.
- the server when acquiring external service demand information, it is possible to obtain information through various methods (such as receiving mail, QQ message, WeChat, short message, etc.). For example, if the external service demand side needs to obtain data about the information about the equipment room, the server (the CMDB application system) needs to provide an API interface that can query the information of the equipment room. At this time, the external service demand side sends the information to the server.
- the external service demand information includes information such as the name of the equipment room, the location, and the host in the equipment room; the external service demand information is sent to the CMDB application system by means of mail.
- the API interface generating unit 102 is configured to generate an API interface according to the configuration model.
- the configuration model is a graphic model stored in the graphic database and can be directly opened for data operations
- the configuration model needs to be mapped into an API interface, and the API interface is sent to the external service demand side. Access to information in order to access the relational database connected to the graph database through the API interface.
- the configuration model is configured according to the actual data needs of the user, it can be flexibly adjusted to meet the data needs of the user.
- the configuration model is simple to configure, and simply adds the business view layer node and its attributes, the ER layer entity, the relationship between the entities, and the relationship between the entity and the business view layer node to complete the configuration without editing. Complex SQL statements.
- re-establishing the configuration model quickly can regenerate the API interface that meets the requirements, and avoids the problem that the interface change causes the application to start and stop.
- the service data feedback unit 103 is configured to: if the external service request end detects that the API interface is invoked according to the access information of the API interface, obtain an invocation type of the external service request end to the API interface, and respond to the service data according to the call type.
- the configuration model generating unit 101 includes the following subunits:
- the parsing unit 1011 is configured to parse the name of the service view layer node included in the external service requirement information, the name of the entity associated with the service view layer node, the relationship between the entities, and the relational database corresponding to each entity Business data;
- the node generating unit 1012 is configured to generate a service view layer node in the configuration model according to the name of the service view layer node.
- the entity generating unit 1013 is configured to generate an entity in the configuration model according to the name of the entity associated with the service view layer node;
- the first connection unit 1014 is configured to generate a first relationship connection line group according to a relationship between the service view layer node and an entity associated with the service view layer node, and configure the model in the configuration model by using the first relationship connection line group
- the business view layer node is connected to the entity;
- the second connection unit 1015 is configured to generate a second relationship connection line group according to the association between the entities, and connect the entity in the configuration model with the associated entity by using the second relationship connection line group.
- the following key information in the external business requirement information is first parsed: the name of the business view layer node, the name of the entity associated with the business view layer, the relationship between the entities, and the business in the relational database corresponding to each entity. data;
- the business view layer node in the configuration model is generated according to the name of the business view layer node, and the entity in the configuration model is generated according to the name of the entity, and the corresponding model is generated in the configuration model according to the relationship between the entity and the business view layer node.
- a relationship connection line group ie, a relationship connection line between a node of the View layer and an entity included in the ER layer
- the generated configuration model is saved to the graphics database, and the configuration model mapping processing can be further performed to open a corresponding API interface for the user to perform data operations.
- the API interface generating unit 102 includes the following subunits:
- a creating unit 1021 configured to create an API interface according to a name of a business view layer node in the configuration model
- the mapping unit 1022 is configured to map the API interface with the business view layer node in the configuration model.
- the API interface generating unit 102 is further configured to: send the access information of the API interface to the external service request end; wherein the access information includes a request format, a request parameter, and a request address.
- the API interface is initialized according to the name of the service view layer node in the configuration model, and the access information of the API interface is further improved according to the attributes of the service view layer node, and the external service demand end can issue the addition, deletion, and modification to the server.
- the service data feedback unit 103 includes the following subunits:
- the request parameter obtaining unit 1031 is configured to obtain, according to the request parameter included in the access information of the external service demand side, the service view layer node corresponding to the API interface accessed by the external service demand end;
- the script generating unit 1032 is configured to generate a SQL script according to the table name of the business view layer and the calling type of the API interface; wherein the calling type includes adding a data request, deleting a data request, editing a data request, and querying a data request;
- the data obtaining unit 1033 is configured to execute the SQL script to obtain the service data from the relational database, and correspondingly feed back to the API interface.
- the View that is, the business view layer node of the business view layer is located according to the request parameter;
- the service invocation type specifically includes adding a data request, deleting a data request, editing a data request, and querying a data request;
- the first SQL script is generated according to the query data request, the view of the business view layer, and the keyword of the query (the first SQL script includes a select statement), and the first SQL script is executed in the data type.
- the query in the database obtains the corresponding service data, and feeds the service data to the external service demand end through the service view layer node;
- the second SQL script is generated according to the increase data request, the view of the business view layer, and the data to be added (the second SQL script includes an add statement), and the second SQL script is executed in the data type. Add corresponding service data in the database, and feed back the message that the data is successful to the external service demand end;
- a third SQL script is generated according to the delete data request, the view of the business view layer, and the data to be deleted (the third SQL script includes a delete statement), and the third SQL script is executed in the data type. Delete the corresponding service data in the database, and feed back the message that the data is successfully deleted to the external service demand end;
- a fourth SQL script is generated according to the edit data request, the view of the business view layer, and the data to be edited (the fourth SQL script includes an update statement), and the fourth SQL script is executed in the data type.
- the corresponding business data is modified in the database, and the message for successfully editing the data is fed back to the external service demand side.
- the device does not need to write a large number of SQL statements to generate an API interface, and only needs to quickly modify the configuration model to obtain an API interface that satisfies the requirements, which saves the time spent developing a large number of SQL statements, and also avoids the application of interface changes. Stop the problem.
- the above API interface dynamic generation device can be implemented in the form of a computer program that can be run on a computer device as shown in FIG.
- FIG. 9 is a schematic block diagram of a computer device according to an embodiment of the present application.
- the computer device 500 device can be a terminal.
- the terminal can be an electronic device such as a tablet computer, a notebook computer, a desktop computer, or a personal digital assistant.
- the computer device 500 includes a processor 502, a memory, and a network interface 505 connected by a system bus 501, wherein the memory can include a non-volatile storage medium 503 and an internal memory 504.
- the non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032.
- the computer program 5032 includes program instructions that, when executed, cause the processor 502 to perform an API interface dynamic generation method.
- the processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500.
- the internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When executed by the processor 502, the computer program 5032 can cause the processor 502 to perform an API interface dynamic generation method.
- the network interface 505 is used for network communication, such as sending assigned tasks and the like. It will be understood by those skilled in the art that the structure shown in FIG. 9 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation of the computer device 500 to which the solution of the present application is applied, and a specific computer device. 500 may include more or fewer components than shown, or some components may be combined, or have different component arrangements.
- the processor 502 is configured to run a computer program 5032 stored in the memory to implement a function of: generating a configuration model according to external business requirement information, and saving the configuration model to the graphic database; generating an API interface according to the configuration model;
- the external service request end invokes the API interface according to the access information of the API interface, obtains the call type of the external service demand end to the API interface, and correspondingly feeds back the service data according to the call type.
- the processor 502 also performs the operations of parsing the name of the business view layer node included in the external service requirement information, the name of the entity associated with the business view layer node, the relationship between the entities, and each Business data in a relational database corresponding to an entity; corresponding to the business view layer node in the configuration model according to the name of the business view layer node; corresponding to the name of the entity associated with the business view layer node, corresponding to the configuration model An entity; generating a first relationship connection line group according to a relationship between the business view layer node and an entity associated with the business view layer node, and performing the business view layer node and the entity in the configuration model by using the first relationship connection line group Connecting; generating a second relationship connection line group according to the association between the entities, and connecting the entity in the configuration model with the associated entity through the second relationship connection line group.
- the processor 502 also performs the operations of: creating an API interface according to the name of the business view layer node in the configuration model; and mapping the API interface with the business view layer node in the configuration model.
- the processor 502 further performs the following operations: sending the access information of the API interface to the external service requester; wherein the access information includes a request format, a request parameter, and a request address.
- the processor 502 is further configured to: obtain the service view layer node corresponding to the API interface accessed by the external service request end according to the request parameter included in the access information of the external service demand side;
- the name and the calling type of the API interface are corresponding to generate a SQL script; wherein the calling type includes adding a data request, deleting a data request, editing a data request, and querying a data request; executing a SQL script to obtain business data from a relational database, and corresponding Feedback to the API interface.
- the embodiment of the computer device shown in FIG. 9 does not constitute a limitation on the specific configuration of the computer device.
- the computer device may include more or fewer components than illustrated. Or combine some parts, or different parts.
- the computer device may include only a memory and a processor. In such an embodiment, the structure and functions of the memory and the processor are the same as those of the embodiment shown in FIG. 9, and details are not described herein.
- the processor 502 may be a central processing unit (CPU), and the processor 502 may also be another general-purpose processor, a digital signal processor (DSP), Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component, etc.
- the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
- a storage medium in another embodiment of the present application, is provided.
- the storage medium can be a non-transitory computer readable storage medium.
- the storage medium stores a computer program, wherein the computer program includes program instructions.
- the program instruction is executed by the processor, the API interface dynamic generation method of the embodiment of the present application is implemented.
- the storage medium may be an internal storage unit of the aforementioned device, such as a hard disk or a memory of the device.
- the storage medium may also be an external storage device of the device, such as a plug-in hard disk equipped on the device, a smart memory card (SMC), a secure digital (SD) card, and a flash memory card. (Flash Card), etc.
- the storage medium may also include both an internal storage unit of the device and an external storage device.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本申请实施例公开了一种API接口动态生成方法、装置、计算机设备及存储介质。该方法包括:根据外部业务需求信息生成配置模型,并保存至图形数据库中;根据配置模型生成API接口;若检测到外部业务需求端根据API接口的访问信息调用API接口,获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据。该方法无需编写大量的SQL语句生成API接口,只需快速的修改配置模型即可得到满足需求的API接口,节省了开发大量SQL语句所耗用的时间,也避免了接口变更导致应用起停的问题。
Description
本申请要求于2018年2月12日提交中国专利局、申请号为201810144185.1、申请名称为“API接口动态生成方法、装置、计算机设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本申请涉及数据库配置管理技术领域,尤其涉及一种API接口动态生成方法、装置、计算机设备及存储介质。
CMDB(Configuration Management Database,即配置管理数据库)作为一个互联网企业的所有配置核心,对外的数据交互极多。为了保证数据的准确性以及安全性,系统的对外交互主要是经过对外的API接口来提供外部系统的数据交互。目前常用的API接口存在以下不足之处:
1.大量SQL的编写;
2.业务变更,接口也要对应修改,并需要起停应用发版。
发明内容
本申请提供了一种API接口动态生成方法、装置、计算机设备及存储介质,旨在解决现有技术中CMDB系统的对外API接口生成需编写大量的SQL语句,且当业务变更时对外API接口也要修改,导致开发CMDB系统的对外API接口极为耗时的问题。
第一方面,本申请提供了一种API接口动态生成方法,其包括:根据外部业务需求信息生成配置模型,并保存至图形数据库中;根据配置模型生成API接口;若检测到外部业务需求端根据API接口的访问信息调用API接口,获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据。
第二方面,本申请提供了一种API接口动态生成装置,其包括:
配置模型生成单元,用于根据外部业务需求信息生成配置模型,并保存至 图形数据库中;
API接口生成单元,用于根据配置模型生成API接口;
业务数据反馈单元,用于若检测到外部业务需求端根据API接口的访问信息调用API接口,获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据。
第三方面,本申请又提供了一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现本申请提供的任一项所述的API接口动态生成方法。
第四方面,本申请还提供了一种存储介质,其中所述存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行本申请提供的任一项所述的API接口动态生成方法。
本申请提供一种API接口动态生成方法、装置、计算机设备及存储介质。该方法无需编写大量的SQL语句生成API接口,只需快速的修改配置模型即可得到满足需求的API接口,节省了开发大量SQL语句所耗用的时间,也避免了接口变更导致应用起停的问题。
为了更清楚地说明本申请实施例技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1a为本申请实施例中一具体图形数据库的三层结构示意图;
图1b为本申请实施例提供的一种API接口动态生成方法的示意流程图;
图2是本申请实施例提供的一种API接口动态生成方法的子流程示意图;
图3是本申请实施例提供的一种API接口动态生成方法的另一子流程示意图;
图4为本申请实施例提供的一种API接口动态生成方法的另一子流程示意流程图;
图5为本申请实施例提供的一种API接口动态生成装置的示意性框图;
图6为本申请实施例提供的一种API接口动态生成装置的子单元示意性框 图;
图7为本申请实施例提供的一种API接口动态生成装置的另一子单元示意性框图;
图8为本申请实施例提供的一种API接口动态生成装置的另一子单元示意性框图;
图9为本申请实施例提供的一种计算机设备的示意性框图。
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
为了方便理解,下面对本申请实施例中涉及的图形数据库,及CDMB应用系统及关系型数据库进行介绍。
在图形数据库中,存储有多个内核配置(内核配置也可称为配置模型)。配置模型是一种标准的图形结构,具体图形结构参考图1a。如图1a所示,所述配置模型被划分为三层,具体如下:
最上面一层是页面层(ViewGroup),该层是对页面基础信息的抽象,主要包含页面的基础信息,例如:页面名称,页面编码等信息。
中间一层是业务视图层(View),该层是对业务数据的抽象,每个View在页面当中可以理解成一个数据表格,主要包含业务视图的名称、编码、View类型以及View组件类型等信息,每个业务视图View都是由ER层的一个或多个Entity(实体)组成。其中,View类型主要包含:a.拓扑图类型,主要用于展示数据关联视图;b.业务数据类型,主要用于展示页面表格数据。View的组件类型主要包含:a.数据表格;b.其他数据展示组件,例如树状图、柱状图等其他数据展示组件。
最下面一层是ER层,主要是对关系型数据库E-R模型的表示,用于在对业务视图层View所需业务数据的管理提供基础,在ER层中主要包含Entity/Attribute(其中,Entity表示实体,Attribute表示实体的属性)以及Entity(实体)与Entity(实体)的关系,以及Entity与其Attribute(属性)的关系。 其中,Entity主要包含表名、表别名等信息是否可见、是否可编辑等信息;Attribute主要包含属性名称、编码、是否可见、是否可编辑等信息。
在了解图形数据库的基本知识后,下面对CMDB应用系统进行简要介绍。CMDB应用系统分为三层,其中面向用户且能被用户直接看到的是页面,页面的下一层是CMDB应用系统层,再下一层是后台的图形数据库及关系型数据库(图形数据库、及关系型数据库均与CMDB应用系统层通讯连接,也就是CMDB应用系统层能从图形数据库、及关系型数据库获取数据)。
其中,图形数据库包括多个配置模型,每一配置模型均由上述三层结构组成(即页面层、业务视图层、和ER层),每个配置模型中的业务视图层均包括至少一个业务视图层节点,并在业务视图层进行显示。
请参阅图1b,图1b是本申请实施例提供的一种API接口动态生成方法的示意流程图。该方法应用于台式电脑、手提电脑、平板电脑等终端中。如图1b所示,该方法包括步骤S101~S103。
S101、根据外部业务需求信息生成配置模型,并保存至图形数据库中。
在本实施例中,在获取外部业务需求信息时,是通过各种获取信息的方式均可行(如接收邮件、QQ消息、微信、短信等)。例如,外部业务需求端需要获取机房相关信息的数据,则需要通过服务端(服务端也即CMDB应用系统)提供一个能查询机房信息的API接口,此时由外部业务需求端向服务端所发送的外部业务需求信息包括机房名称、位置、机房里面有哪些主机等信息;该外部业务需求信息通过邮件的方式来发送至CMDB应用系统。
如图2所示,该步骤S101包括以下子步骤:
S1011、解析外部业务需求信息中所包括的业务视图层节点的名称、与业务视图层节点相关联的实体的名称,实体之间的联系、及每一实体所对应关系型数据库中的业务数据;
S1012、根据业务视图层节点的名称,对应生成配置模型中的业务视图层节点;
S1013、根据与业务视图层节点相关联的实体的名称,对应生成配置模型中的实体;
S1014、根据业务视图层节点和与业务视图层节点相关联的实体之间的联系对应生成第一关系连接线组,并通过第一关系连接线组将配置模型中的业务视 图层节点与实体进行连接;
S1015、根据实体之间的联系对应生成第二关系连接线组,并通过第二关系连接线组将配置模型中的实体与相关联实体进行连接。
即,首先解析外部业务需求信息中的以下关键信息:业务视图层节点的名称,与业务视图层相关联的实体的名称,实体之间的相互关系,每一实体所对应关系型数据库中的业务数据;
然后,根据业务视图层节点的名称对应生成配置模型中的业务视图层节点,根据实体的名称生成配置模型中的实体,根据实体与业务视图层节点之间的关系在配置模型中生成对应的第一关系连接线组(即View层的节点与E-R层中所包括实体之间的关系连接线),根据实体与实体之间的关系在配置模型中生成对应第二关系连接线组(及E-R层实体相互之间的关系连接线);
最后,将配置模型保存在图形数据库中。
通过上述过程,实现了配置模型的自动生成,或是人工配置而成。所生成的配置模型被保存至图形数据库中,即可进一步对该配置模型映射处理,以开放对应的API接口供用户进行数据操作。
S102、根据配置模型生成API接口。
在本实施例中,由于配置模型是存储在图形数据库中的图形模型,并能不直接对外开放而进行数据操作,故需将配置模型映射成为API接口,并向外部业务需求端发送API接口的访问信息,才能通过API接口访问与图形数据库所连接的关系型数据库。由于配置模型是根据用户的实际数据需求而配置,故能灵活调整以满足用户的数据需求。而且配置模型的配置操作简单,只需简单的添加业务视图层节点及其属性,ER层的实体,实体之间的联系,及实体与业务视图层节点之间的联系就能完成配置,无需编辑复杂的SQL语句。而且当外部业务需求信息发生变化时,重新快速建立配置模型即可重新生成满足要求的API接口,也避免了接口变更导致应用起停的问题。
如图3所示,该步骤S102包括以下子步骤:
S1021、根据配置模型中的业务视图层节点的名称创建API接口;
S1022、将API接口与配置模型中的业务视图层节点进行映射。
在一实施例中,所述步骤S102之后,还包括:将API接口的访问信息发送至外部业务需求端;其中访问信息包括请求格式、请求参数、请求地址。
在本实施例中,先根据配置模型中的业务视图层节点的名称初始化创建API接口,并根据业务视图层节点的属性进一步完善API接口的访问信息,即API接口以业务视图层节点的名称来命名,并在API接口的属性栏中编辑包括请求格式、请求参数、请求地址的访问信息,之后将具有相同名称的API接口和业务视图层节点进行一一映射即可完成API接口的生成。完成API接口的生成后,将API接口的访问信息发送至外部业务需求端,外部业务需求端才能向服务端发出增删改查等业务请求,从而对应的对数据型数据库中的数据进行相应操作。
例如,向外部业务需求端所发送的访问信息如下:
其中URL表示API接口的请求地址,method:POST表示该API接口的数据请求方式为POST请求,dataSet表示该API接口的数据请求格式为{“hostName”:“xx”,“hostIp”:“xx”},{“hostName”:“xx”,“hostIp”:“xx”},add/data表示对该API接口的数据调用类型为增加数据。
S103、若检测到外部业务需求端根据API接口的访问信息调用API接口,获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据。
如图4所示,该步骤S103包括以下子步骤:
S1031、根据外部业务需求端的访问信息中所包括的请求参数,获取外部业务需求端所访问API接口对应的业务视图层节点;
S1032、根据业务视图层的表名、及对API接口的调用类型对应生成SQL脚本;其中所述调用类型包括增加数据请求、删除数据请求、编辑数据请求及查询数据请求;
S1033、执行SQL脚本从关系型数据库中获取业务数据,并对应反馈至API接口。
在本实施例中,外部系统调用生成的API时,具有以下过程:
先根据请求参数定位到业务视图层的View(即业务视图层节点);
然后根据业务视图层的View生成对应的SQL脚本;
最后在获取到SQL脚本后,在mybatis框架中执行,从关系型数据库中对应得到结果集,并反馈操作。
其中,业务调用类型具体包括增加数据请求、删除数据请求、编辑数据请求、查询数据请求;
当判断调用类型为查询数据请求,则根据查询数据请求、及业务视图层的view及查询的关键词生成第一SQL脚本(第一SQL脚本中包括select语句),执行第一SQL脚本在数据型数据库中查询得到对应的业务数据,并将业务数据通过业务视图层节点反馈至外部业务需求端;
当判断调用类型为增加数据请求,则根据增加数据请求、及业务视图层的view及待增加的数据生成第二SQL脚本(第二SQL脚本中包括add语句),执行第二SQL脚本在数据型数据库中增加对应的业务数据,并将增加数据成功的消息反馈至外部业务需求端;
当判断调用类型为删除数据请求,则根据删除数据请求、及业务视图层的view及待删除的数据生成第三SQL脚本(第三SQL脚本中包括delete语句),执行第三SQL脚本在数据型数据库中删除对应的业务数据,并将删除数据成功的消息反馈至外部业务需求端;
当判断调用类型为编辑数据请求,则根据编辑数据请求、及业务视图层的view及待编辑的数据生成第四SQL脚本(第四SQL脚本中包括update语句),执行第四SQL脚本在数据型数据库中修改对应的业务数据,并将编辑数据成功的消息反馈至外部业务需求端。
可见,该方法无需编写大量的SQL语句生成API接口,只需快速的修改配置模型即可得到满足需求的API接口,节省了开发大量SQL语句所耗用的时间,也避免了接口变更导致应用起停的问题。
本申请实施例还提供一种API接口动态生成装置,该API接口动态生成装置用于执行前述任一项API接口动态生成方法。具体地,请参阅图5,图5是本申请实施例提供的一种API接口动态生成装置的示意性框图。API接口动态生成装置100可以安装于台式电脑、平板电脑、手提电脑、等终端中。
如图5所示,API接口动态生成装置100包括配置模型生成单元101、API接口生成单元102、业务数据反馈单元103。
配置模型生成单元101,用于根据外部业务需求信息生成配置模型,并保存至图形数据库中。
在本实施例中,在获取外部业务需求信息时,是通过各种获取信息的方式均可行(如接收邮件、QQ消息、微信、短信等)。例如,外部业务需求端需要获取机房相关信息的数据,则需要通过服务端(服务端也即CMDB应用系统)提供一个能查询机房信息的API接口,此时由外部业务需求端向服务端所发送的外部业务需求信息包括机房名称、位置、机房里面有哪些主机等信息;该外部业务需求信息通过邮件的方式来发送至CMDB应用系统。
API接口生成单元102,用于根据配置模型生成API接口。
在本实施例中,由于配置模型是存储在图形数据库中的图形模型,并能不直接对外开放而进行数据操作,故需将配置模型映射成为API接口,并向外部业务需求端发送API接口的访问信息,才能通过API接口访问与图形数据库所连接的关系型数据库。由于配置模型是根据用户的实际数据需求而配置,故能灵活调整以满足用户的数据需求。而且配置模型的配置操作简单,只需简单的添加业务视图层节点及其属性,ER层的实体,实体之间的联系,及实体与业务视图层节点之间的联系就能完成配置,无需编辑复杂的SQL语句。而且当外部业务需求信息发生变化时,重新快速建立配置模型即可重新生成满足要求的API接口,也避免了接口变更导致应用起停的问题。
业务数据反馈单元103,用于若检测到外部业务需求端根据API接口的访问信息调用API接口,获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据。
如图6所示,所述配置模型生成单元101包括以下子单元:
解析单元1011,用于解析外部业务需求信息中所包括的业务视图层节点的名称、与业务视图层节点相关联的实体的名称,实体之间的联系、及每一实体所对应关系型数据库中的业务数据;
节点生成单元1012,用于根据业务视图层节点的名称,对应生成配置模型中的业务视图层节点;
实体生成单元1013,用于根据与业务视图层节点相关联的实体的名称,对应生成配置模型中的实体;
第一连线单元1014,用于根据业务视图层节点和与业务视图层节点相关联的实体之间的联系对应生成第一关系连接线组,并通过第一关系连接线组将配置模型中的业务视图层节点与实体进行连接;
第二连线单元1015,用于根据实体之间的联系对应生成第二关系连接线组,并通过第二关系连接线组将配置模型中的实体与相关联实体进行连接。
即,首先解析外部业务需求信息中的以下关键信息:业务视图层节点的名称,与业务视图层相关联的实体的名称,实体之间的相互关系,每一实体所对应关系型数据库中的业务数据;
然后,根据业务视图层节点的名称对应生成配置模型中的业务视图层节点,根据实体的名称生成配置模型中的实体,根据实体与业务视图层节点之间的关系在配置模型中生成对应的第一关系连接线组(即View层的节点与E-R层中所包括实体之间的关系连接线),根据实体与实体之间的关系在配置模型中生成对应第二关系连接线组(及E-R层实体相互之间的关系连接线);
最后,将配置模型保存在图形数据库中。
通过上述过程,实现了配置模型的自动生成,或是人工配置而成。所生成的配置模型被保存至图形数据库中,即可进一步对该配置模型映射处理,以开放对应的API接口供用户进行数据操作。
如图7所示,所述API接口生成单元102包括以下子单元:
创建单元1021,用于根据配置模型中的业务视图层节点的名称创建API接口;
映射单元1022,用于将API接口与配置模型中的业务视图层节点进行映射。
其他申请实施例中,所述API接口生成单元102还用于:将API接口的访 问信息发送至外部业务需求端;其中访问信息包括请求格式、请求参数、请求地址。
在本实施例中,先根据配置模型中的业务视图层节点的名称初始化创建API接口,并根据业务视图层节点的属性进一步完善API接口的访问信息,外部业务需求端才能向服务端发出增删改查等业务请求,从而对应的对数据型数据库中的数据进行相应操作。
其他申请实施例中,如图8所示,所述业务数据反馈单元103包括以下子单元:
请求参数获取单元1031,用于根据外部业务需求端的访问信息中所包括的请求参数,获取外部业务需求端所访问API接口对应的业务视图层节点;
脚本生成单元1032,用于根据业务视图层的表名、及对API接口的调用类型对应生成SQL脚本;其中所述调用类型包括增加数据请求、删除数据请求、编辑数据请求及查询数据请求;
数据获取单元1033,用于执行SQL脚本从关系型数据库中获取业务数据,并对应反馈至API接口。
在本实施例中,外部系统调用生成的API时,具有以下过程:
先根据请求参数定位到业务视图层的View(即业务视图层节点);
然后根据业务视图层的View生成对应的SQL脚本;
最后在获取到SQL脚本后,在mybatis框架中执行,从关系型数据库中对应得到结果集,并反馈操作。
其中,业务调用类型具体包括增加数据请求、删除数据请求、编辑数据请求、查询数据请求;
当判断调用类型为查询数据请求,则根据查询数据请求、及业务视图层的view及查询的关键词生成第一SQL脚本(第一SQL脚本中包括select语句),执行第一SQL脚本在数据型数据库中查询得到对应的业务数据,并将业务数据通过业务视图层节点反馈至外部业务需求端;
当判断调用类型为增加数据请求,则根据增加数据请求、及业务视图层的view及待增加的数据生成第二SQL脚本(第二SQL脚本中包括add语句),执行第二SQL脚本在数据型数据库中增加对应的业务数据,并将增加数据成功的消息反馈至外部业务需求端;
当判断调用类型为删除数据请求,则根据删除数据请求、及业务视图层的view及待删除的数据生成第三SQL脚本(第三SQL脚本中包括delete语句),执行第三SQL脚本在数据型数据库中删除对应的业务数据,并将删除数据成功的消息反馈至外部业务需求端;
当判断调用类型为编辑数据请求,则根据编辑数据请求、及业务视图层的view及待编辑的数据生成第四SQL脚本(第四SQL脚本中包括update语句),执行第四SQL脚本在数据型数据库中修改对应的业务数据,并将编辑数据成功的消息反馈至外部业务需求端。
可见,该装置无需编写大量的SQL语句生成API接口,只需快速的修改配置模型即可得到满足需求的API接口,节省了开发大量SQL语句所耗用的时间,也避免了接口变更导致应用起停的问题。
上述API接口动态生成装置可以实现为一种计算机程序的形式,该计算机程序可以在如图9所示的计算机设备上运行。
请参阅图9,图9是本申请实施例提供的一种计算机设备的示意性框图。该计算机设备500设备可以是终端。该终端可以是平板电脑、笔记本电脑、台式电脑、个人数字助理等电子设备。
参阅图9,该计算机设备500包括通过系统总线501连接的处理器502、存储器和网络接口505,其中,存储器可以包括非易失性存储介质503和内存储器504。该非易失性存储介质503可存储操作系统5031和计算机程序5032。该计算机程序5032包括程序指令,该程序指令被执行时,可使得处理器502执行一种API接口动态生成方法。该处理器502用于提供计算和控制能力,支撑整个计算机设备500的运行。该内存储器504为非易失性存储介质503中的计算机程序5032的运行提供环境,该计算机程序5032被处理器502执行时,可使得处理器502执行一种API接口动态生成方法。该网络接口505用于进行网络通信,如发送分配的任务等。本领域技术人员可以理解,图9中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备500的限定,具体的计算机设备500可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
其中,所述处理器502用于运行存储在存储器中的计算机程序5032,以实现如下功能:根据外部业务需求信息生成配置模型,并保存至图形数据库中; 根据配置模型生成API接口;若检测到外部业务需求端根据API接口的访问信息调用API接口,获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据。
在一实施例中,处理器502还执行如下操作:解析外部业务需求信息中所包括的业务视图层节点的名称、与业务视图层节点相关联的实体的名称,实体之间的联系、及每一实体所对应关系型数据库中的业务数据;根据业务视图层节点的名称,对应生成配置模型中的业务视图层节点;根据与业务视图层节点相关联的实体的名称,对应生成配置模型中的实体;根据业务视图层节点和与业务视图层节点相关联的实体之间的联系对应生成第一关系连接线组,并通过第一关系连接线组将配置模型中的业务视图层节点与实体进行连接;根据实体之间的联系对应生成第二关系连接线组,并通过第二关系连接线组将配置模型中的实体与相关联实体进行连接。
在一实施例中,处理器502还执行如下操作:根据配置模型中的业务视图层节点的名称创建API接口;将API接口与配置模型中的业务视图层节点进行映射。
在一实施例中,处理器502还执行如下操作:将API接口的访问信息发送至外部业务需求端;其中访问信息包括请求格式、请求参数、请求地址。
在一实施例中,处理器502还执行如下操作:根据外部业务需求端的访问信息中所包括的请求参数,获取外部业务需求端所访问API接口对应的业务视图层节点;根据业务视图层的表名、及对API接口的调用类型对应生成SQL脚本;其中所述调用类型包括增加数据请求、删除数据请求、编辑数据请求及查询数据请求;执行SQL脚本从关系型数据库中获取业务数据,并对应反馈至API接口。
本领域技术人员可以理解,图9中示出的计算机设备的实施例并不构成对计算机设备具体构成的限定,在其他实施例中,计算机设备可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。例如,在一些实施例中,计算机设备可以仅包括存储器及处理器,在这样的实施例中,存储器及处理器的结构及功能与图9所示实施例一致,在此不再赘述。
应当理解,在本申请实施例中,处理器502可以是中央处理单元(Central Processing Unit,CPU),该处理器502还可以是其他通用处理器、数字信号处理 器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现成可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。其中,通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
在本申请的另一实施例中提供一种存储介质。该存储介质可以为非易失性的计算机可读存储介质。该存储介质存储有计算机程序,其中计算机程序包括程序指令。该程序指令被处理器执行时实现本申请实施例的API接口动态生成方法。
所述存储介质可以是前述设备的内部存储单元,例如设备的硬盘或内存。所述存储介质也可以是所述设备的外部存储设备,例如所述设备上配备的插接式硬盘,智能存储卡(Smart Media Card,SMC),安全数字(Secure Digital,SD)卡,闪存卡(Flash Card)等。进一步地,所述存储介质还可以既包括所述设备的内部存储单元也包括外部存储设备。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,上述描述的设备、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到各种等效的修改或替换,这些修改或替换都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以权利要求的保护范围为准。
Claims (20)
- 一种API接口动态生成方法,其特征在于,包括:根据外部业务需求信息生成配置模型,并保存至图形数据库中;根据配置模型生成API接口;若检测到外部业务需求端根据API接口的访问信息调用API接口,获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据。
- 根据权利要求1所述的API接口动态生成方法,其特征在于,所述根据外部业务需求信息生成配置模型,包括:解析外部业务需求信息中所包括的业务视图层节点的名称、与业务视图层节点相关联的实体的名称,实体之间的联系、及每一实体所对应关系型数据库中的业务数据;根据业务视图层节点的名称,对应生成配置模型中的业务视图层节点;根据与业务视图层节点相关联的实体的名称,对应生成配置模型中的实体;根据业务视图层节点和与业务视图层节点相关联的实体之间的联系对应生成第一关系连接线组,并通过第一关系连接线组将配置模型中的业务视图层节点与实体进行连接;根据实体之间的联系对应生成第二关系连接线组,并通过第二关系连接线组将配置模型中的实体与相关联实体进行连接。
- 根据权利要求1所述的API接口动态生成方法,其特征在于,所述根据配置模型生成API接口,包括:根据配置模型中的业务视图层节点的名称创建API接口;将API接口与配置模型中的业务视图层节点进行映射。
- 根据权利要求3所述的API接口动态生成方法,其特征在于,所述根据配置模型生成API接口之后,包括:将API接口的访问信息发送至外部业务需求端;其中访问信息包括请求格式、请求参数、请求地址。
- 根据权利要求4所述的API接口动态生成方法,其特征在于,所述获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据,包括:根据外部业务需求端的访问信息中所包括的请求参数,获取外部业务需求端所访问API接口对应的业务视图层节点;根据业务视图层的表名、及对API接口的调用类型对应生成SQL脚本;其中所述调用类型包括增加数据请求、删除数据请求、编辑数据请求及查询数据请求;执行SQL脚本从关系型数据库中获取业务数据,并对应反馈至API接口。
- 一种API接口动态生成装置,其特征在于,包括:配置模型生成单元,用于根据外部业务需求信息生成配置模型,并保存至图形数据库中;API接口生成单元,用于根据配置模型生成API接口;业务数据反馈单元,用于若检测到外部业务需求端根据API接口的访问信息调用API接口,获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据。
- 根据权利要求6所述的API接口动态生成装置,其特征在于,所述配置模型生成单元,包括:解析单元,用于解析外部业务需求信息中所包括的业务视图层节点的名称、与业务视图层节点相关联的实体的名称,实体之间的联系、及每一实体所对应关系型数据库中的业务数据;节点生成单元,用于根据业务视图层节点的名称,对应生成配置模型中的业务视图层节点;实体生成单元,用于根据与业务视图层节点相关联的实体的名称,对应生成配置模型中的实体;第一连线单元,用于根据业务视图层节点和与业务视图层节点相关联的实体之间的联系对应生成第一关系连接线组,并通过第一关系连接线组将配置模型中的业务视图层节点与实体进行连接;第二连线单元,用于根据实体之间的联系对应生成第二关系连接线组,并通过第二关系连接线组将配置模型中的实体与相关联实体进行连接。
- 根据权利要求6所述的API接口动态生成装置,其特征在于,所述API接口生成单元,包括:创建单元,用于根据配置模型中的业务视图层节点的名称创建API接口;映射单元,用于将API接口与配置模型中的业务视图层节点进行映射。
- 根据权利要求8所述的API接口动态生成装置,其特征在于,所述API接口生成单元还用于:将API接口的访问信息发送至外部业务需求端;其中访问信息包括请求格式、请求参数、请求地址。
- 根据权利要求9所述的API接口动态生成装置,其特征在于,所述业务数据反馈单元,包括:请求参数获取单元,用于根据外部业务需求端的访问信息中所包括的请求参数,获取外部业务需求端所访问API接口对应的业务视图层节点;脚本生成单元,用于根据业务视图层的表名、及对API接口的调用类型对应生成SQL脚本;其中所述调用类型包括增加数据请求、删除数据请求、编辑数据请求及查询数据请求;数据获取单元,用于执行SQL脚本从关系型数据库中获取业务数据,并对应反馈至API接口。
- 一种计算机设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现如权利要求1至5中任一项所述的API接口动态生成方法。
- 根据权利要求11所述的计算机设备,其特征在于,所述根据外部业务需求信息生成配置模型,包括:解析外部业务需求信息中所包括的业务视图层节点的名称、与业务视图层节点相关联的实体的名称,实体之间的联系、及每一实体所对应关系型数据库中的业务数据;根据业务视图层节点的名称,对应生成配置模型中的业务视图层节点;根据与业务视图层节点相关联的实体的名称,对应生成配置模型中的实体;根据业务视图层节点和与业务视图层节点相关联的实体之间的联系对应生成第一关系连接线组,并通过第一关系连接线组将配置模型中的业务视图层节点与实体进行连接;根据实体之间的联系对应生成第二关系连接线组,并通过第二关系连接线组将配置模型中的实体与相关联实体进行连接。
- 根据权利要求11所述的计算机设备,其特征在于,所述根据配置模型生成API接口,包括:根据配置模型中的业务视图层节点的名称创建API接口;将API接口与配置模型中的业务视图层节点进行映射。
- 根据权利要求13所述的计算机设备,其特征在于,所述根据配置模型生成API接口之后,包括:将API接口的访问信息发送至外部业务需求端;其中访问信息包括请求格式、请求参数、请求地址。
- 根据权利要求14所述的计算机设备,其特征在于,所述获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据,包括:根据外部业务需求端的访问信息中所包括的请求参数,获取外部业务需求端所访问API接口对应的业务视图层节点;根据业务视图层的表名、及对API接口的调用类型对应生成SQL脚本;其中所述调用类型包括增加数据请求、删除数据请求、编辑数据请求及查询数据请求;执行SQL脚本从关系型数据库中获取业务数据,并对应反馈至API接口。
- 一种存储介质,其特征在于,所述存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行以下操作:根据外部业务需求信息生成配置模型,并保存至图形数据库中;根据配置模型生成API接口;若检测到外部业务需求端根据API接口的访问信息调用API接口,获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据。
- 根据权利要求16所述的存储介质,其特征在于,所述根据外部业务需求信息生成配置模型,包括:解析外部业务需求信息中所包括的业务视图层节点的名称、与业务视图层节点相关联的实体的名称,实体之间的联系、及每一实体所对应关系型数据库中的业务数据;根据业务视图层节点的名称,对应生成配置模型中的业务视图层节点;根据与业务视图层节点相关联的实体的名称,对应生成配置模型中的实体;根据业务视图层节点和与业务视图层节点相关联的实体之间的联系对应生成第一关系连接线组,并通过第一关系连接线组将配置模型中的业务视图层节 点与实体进行连接;根据实体之间的联系对应生成第二关系连接线组,并通过第二关系连接线组将配置模型中的实体与相关联实体进行连接。
- 根据权利要求16所述的存储介质,其特征在于,所述根据配置模型生成API接口,包括:根据配置模型中的业务视图层节点的名称创建API接口;将API接口与配置模型中的业务视图层节点进行映射。
- 根据权利要求18所述的存储介质,其特征在于,所述根据配置模型生成API接口之后,包括:将API接口的访问信息发送至外部业务需求端;其中访问信息包括请求格式、请求参数、请求地址。
- 根据权利要求19所述的存储介质,其特征在于,所述获取外部业务需求端对API接口的调用类型,并根据调用类型对应反馈业务数据,包括:根据外部业务需求端的访问信息中所包括的请求参数,获取外部业务需求端所访问API接口对应的业务视图层节点;根据业务视图层的表名、及对API接口的调用类型对应生成SQL脚本;其中所述调用类型包括增加数据请求、删除数据请求、编辑数据请求及查询数据请求;执行SQL脚本从关系型数据库中获取业务数据,并对应反馈至API接口。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810144185.1 | 2018-02-12 | ||
CN201810144185.1A CN108388622B (zh) | 2018-02-12 | 2018-02-12 | Api接口动态生成方法、装置、计算机设备及存储介质 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2019153549A1 true WO2019153549A1 (zh) | 2019-08-15 |
Family
ID=63069375
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2018/085326 WO2019153549A1 (zh) | 2018-02-12 | 2018-05-02 | Api接口动态生成方法、装置、计算机设备及存储介质 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN108388622B (zh) |
WO (1) | WO2019153549A1 (zh) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110673859A (zh) * | 2019-08-30 | 2020-01-10 | 北京浪潮数据技术有限公司 | 一种图形数据库部署方法、装置、设备及可读存储介质 |
CN112860774A (zh) * | 2021-01-06 | 2021-05-28 | 宝能(西安)汽车研究院有限公司 | 信号接口匹配方法及装置、计算机设备和可读存储介质 |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111049877B (zh) * | 2019-10-21 | 2022-08-09 | 贝壳技术有限公司 | 一种大数据对外输出方法、装置及数据开放平台 |
CN110825388B (zh) * | 2019-11-15 | 2021-08-31 | 中科大数据研究院 | 一种将sql语句直接转换为对应rest接口的方法 |
CN111813405A (zh) * | 2020-06-29 | 2020-10-23 | 四川长虹电器股份有限公司 | 一种快速更新和发布目标数据接口的方法 |
CN114153864A (zh) * | 2020-09-07 | 2022-03-08 | 华为云计算技术有限公司 | 一种生成api的方法及装置 |
CN113268306B (zh) * | 2021-06-08 | 2024-03-19 | 金蝶软件(中国)有限公司 | 简历解析接口调用方法、装置及计算机存储介质 |
CN113590097B (zh) * | 2021-07-30 | 2022-11-29 | 中电金信软件有限公司 | 一种api接口的生成方法、装置、电子设备及存储介质 |
CN113792046A (zh) * | 2021-08-26 | 2021-12-14 | 唯品会(广州)软件有限公司 | 数据接口生成方法、数据查询方法及装置、设备 |
CN113726871B (zh) * | 2021-08-27 | 2024-02-02 | 猪八戒股份有限公司 | 一种自动化代码发布的调度方法及系统 |
CN114706910B (zh) * | 2022-02-23 | 2024-09-17 | 中国平安人寿保险股份有限公司 | 基于FlaskRestful框架的数据接口服务方法、装置、设备及介质 |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030163603A1 (en) * | 2002-02-22 | 2003-08-28 | Chris Fry | System and method for XML data binding |
CN106484421A (zh) * | 2016-10-11 | 2017-03-08 | 武汉斗鱼网络科技有限公司 | 一种快速生成api接口的方法及系统 |
CN106528175A (zh) * | 2016-11-29 | 2017-03-22 | 福州大学 | 面向bs架构的数据接口生成方法 |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102622227B (zh) * | 2011-09-13 | 2017-06-13 | 北京科技大学 | 一种支持动态配置的构件模型及构件工厂的装置 |
-
2018
- 2018-02-12 CN CN201810144185.1A patent/CN108388622B/zh active Active
- 2018-05-02 WO PCT/CN2018/085326 patent/WO2019153549A1/zh active Application Filing
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030163603A1 (en) * | 2002-02-22 | 2003-08-28 | Chris Fry | System and method for XML data binding |
CN106484421A (zh) * | 2016-10-11 | 2017-03-08 | 武汉斗鱼网络科技有限公司 | 一种快速生成api接口的方法及系统 |
CN106528175A (zh) * | 2016-11-29 | 2017-03-22 | 福州大学 | 面向bs架构的数据接口生成方法 |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110673859A (zh) * | 2019-08-30 | 2020-01-10 | 北京浪潮数据技术有限公司 | 一种图形数据库部署方法、装置、设备及可读存储介质 |
CN110673859B (zh) * | 2019-08-30 | 2022-06-17 | 北京浪潮数据技术有限公司 | 一种图形数据库部署方法、装置、设备及可读存储介质 |
CN112860774A (zh) * | 2021-01-06 | 2021-05-28 | 宝能(西安)汽车研究院有限公司 | 信号接口匹配方法及装置、计算机设备和可读存储介质 |
Also Published As
Publication number | Publication date |
---|---|
CN108388622A (zh) | 2018-08-10 |
CN108388622B (zh) | 2020-02-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019153549A1 (zh) | Api接口动态生成方法、装置、计算机设备及存储介质 | |
US20210216700A1 (en) | Information Processing Method and System | |
WO2020119485A1 (zh) | 一种页面显示方法、装置、设备及存储介质 | |
WO2019134340A1 (zh) | 薪资计算方法、应用服务器及计算机可读存储介质 | |
WO2023109138A1 (zh) | Linux系统中启动安卓应用的方法、装置和电子设备 | |
WO2020052337A1 (zh) | 信息处理方法、装置、存储介质及电子设备 | |
WO2019153514A1 (zh) | 业务系统动态生成方法、装置、计算机设备及存储介质 | |
WO2019153555A1 (zh) | Er关系生成方法、装置、计算机设备及存储介质 | |
KR101643436B1 (ko) | 웹 기반 도표 시각화를 위한 확장성 | |
CN114925084B (zh) | 分布式事务处理方法、系统、设备及可读存储介质 | |
CN112506854B (zh) | 页面模板文件的存储和页面生成方法、装置、设备及介质 | |
CN113626223A (zh) | 一种接口调用方法和装置 | |
WO2024016850A1 (zh) | 处理数据冲突的方法、系统、电子设备及计算机可读存储介质 | |
WO2019085780A1 (zh) | 一种云存储系统及用于云存储系统中实现自定义数据处理的方法 | |
WO2024193561A1 (zh) | 文档目录处理方法及相关设备 | |
US10719488B2 (en) | Configurable provider for layered repository | |
US11531525B2 (en) | System and method for packaging standalone application modules into re-usable application and infrastructure resources | |
US11595493B2 (en) | System and method for namespace masking in an integration flow | |
US10523677B2 (en) | Managing metadata for external content within a computing environment | |
WO2023143545A1 (zh) | 资源处理方法、装置、电子设备及计算机可读存储介质 | |
US20180341717A1 (en) | Providing instant preview of cloud based file | |
US20180124260A1 (en) | Providing content and attachment printing for communication | |
CN114489674A (zh) | 动态数据模型的数据校验方法和装置 | |
CN111325456B (zh) | 资产数据处理方法和装置、计算机系统和存储介质 | |
CN110888901B (zh) | 系统管理方法、装置、计算机设备和存储介质 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
32PN | Ep: public notification in the ep bulletin as address of the adressee cannot be established |
Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 17.11.2020) |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 18904611 Country of ref document: EP Kind code of ref document: A1 |