CN111414350B - Service generation method and device - Google Patents

Service generation method and device Download PDF

Info

Publication number
CN111414350B
CN111414350B CN202010193386.8A CN202010193386A CN111414350B CN 111414350 B CN111414350 B CN 111414350B CN 202010193386 A CN202010193386 A CN 202010193386A CN 111414350 B CN111414350 B CN 111414350B
Authority
CN
China
Prior art keywords
database
data table
service
configuration file
generating
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.)
Active
Application number
CN202010193386.8A
Other languages
Chinese (zh)
Other versions
CN111414350A (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202010193386.8A priority Critical patent/CN111414350B/en
Publication of CN111414350A publication Critical patent/CN111414350A/en
Application granted granted Critical
Publication of CN111414350B publication Critical patent/CN111414350B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/21Design, administration or maintenance of databases
    • 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/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases

Abstract

The application relates to the technical field of computers, in particular to a service generation method and device, and a configuration file of a service is obtained, wherein the configuration file at least comprises database description information and resource attributes, and the resource attributes represent data table structure information in a database; generating a database and a data table of the service according to the configuration file; according to the configured operation method template, an operation method and an external interface which are related to the data table are generated for the service, so that the service can be automatically generated through the configuration file, the service generation efficiency is improved, and the development cost and time are reduced.

Description

Service generation method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a service generating method and apparatus.
Background
Currently, with the continuous development of background technology, the background Service architecture is from a single Service architecture to a Service-oriented architecture (SOA), and then to a micro Service architecture, so that Service division is more and more refined. Typically, data processed by a single micro-service is relatively simple, for example, CRUD operations of data, namely adding (Create), reading (Read), updating (Update) and deleting (Delete) operations, can meet service requirements in many cases, and in the prior art, developers need to repeatedly write CRUD logic codes for different services, so that development cost and time are increased, and development efficiency is reduced.
Disclosure of Invention
The embodiment of the application provides a service generation method and device, which are used for improving service development efficiency and reducing cost and time.
The specific technical scheme provided by the embodiment of the application is as follows:
one embodiment of the present application provides a service generation method, including:
acquiring a configuration file of a service, wherein the configuration file at least comprises database description information and resource attributes, and the resource attributes represent data table structure information in a database;
generating a database and a data table of the service according to the configuration file;
and generating an operation method and an external interface associated with the data table for the service according to the configured operation method template.
Another embodiment of the present application provides a service generating apparatus, including:
the system comprises an acquisition module, a service management module and a service management module, wherein the acquisition module is used for acquiring a configuration file of the service, the configuration file at least comprises database description information and resource attributes, and the resource attributes represent data table structure information in a database;
the first generation module is used for generating a database and a data table of the service according to the configuration file;
and the second generation module is used for generating an operation method and an external interface associated with the data table for the service according to the configured operation method template.
Optionally, the method further includes a first verification module, configured to: before the first generation module generates the database and the data table of the service according to the configuration file, at least one of the following is executed:
performing validity check on the configuration file, and determining that the grammar of the configuration file is the correct grammar;
and determining that the configuration file contains complete necessary information.
Optionally, the configuration file further includes login verification information; then further comprising a second checking module for: before the first generating module generates the database and the data table of the service according to the configuration file, identity verification is carried out according to login verification information in the configuration file, and the database corresponding to the database description information is determined to have access rights.
Optionally, the database description information includes at least a database server address and a database name, and when generating the database of the service according to the configuration file, the first generating module is configured to:
when a database corresponding to the database name is found according to the database server address, acquiring the database;
and when the database corresponding to the database name is not found according to the database server address, creating a corresponding database under the database server address according to the database name.
Optionally, the resource attribute includes at least a name of a data table and field information of a field included in the data table, and when the data table of the service is generated according to the configuration file, the first generating module is configured to:
when the data table corresponding to the data table name exists in the database of the service according to the data table name, comparing the field information in the existing data table with the field information contained in the configuration file, and updating the existing data table;
and when the data table corresponding to the data table name exists in the database of the service according to the data table name, creating a corresponding data table in the database of the service according to the data table name and the field information.
Optionally, when generating the operation method and the external interface associated with the data table for the service according to the configured operation method template, the second generation module is configured to:
generating a resource structure object aiming at the data table, generating an operation method associated with the resource structure object according to a pre-configured operation method template, and generating an external interface aiming at each operation method respectively.
Optionally, the method further includes a compiling module for: the generated service is compiled and run, and whether the generated service is correct or not is detected.
Another embodiment of the present application provides an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of any one of the service generation methods described above when the program is executed.
A computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of any of the service generation methods described above.
In the embodiment of the application, the configuration file of the service is obtained, wherein the configuration file at least comprises database description information and resource attribute, the resource attribute represents data table structure information in the database, further, the database and the data table of the service are generated according to the configuration file, and an operation method and an external interface related to the data table are generated for the service according to a configured operation method template, so that the database and the data table of the service can be automatically generated based on the configuration file, the related operation method and the external interface can be generated, the quick creation of the service can be realized through one key of the configuration file without manual operation, the service generation efficiency is improved, and the development cost and the development time are reduced.
Drawings
Fig. 1 is an application architecture diagram of a service generating method in an embodiment of the present application;
FIG. 2 is a flowchart of a service generation method according to an embodiment of the present application;
FIG. 3 is a flowchart of another service generation method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of a service generating device in an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device in an embodiment of the present application.
Detailed Description
The following description of the technical solutions in the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
For ease of understanding of embodiments of the present application, several concepts will be briefly described below:
go language: the Go language is a statically strong type, compiled, concurrent programming language developed by Google, and has garbage collection functions.
Object relationship mapping (Object Relational Mapping, ORM): objects in the object oriented language program are automatically persisted into the relational database using metadata describing the mapping between the objects and the database.
CRUD: refer to the acronyms of several words added (Create), read, update, and Delete when doing the calculation process.
Representational state transitions (representational state transfer, RESTful): is a design style and development manner of a web application, based on HTTP can be defined using an extensible markup language (eXtensible Markup Language, XML) format or a JS object profile (JavaScript Object Notation, JSON) format, the RESTful architecture should follow a unified interface principle, the unified interface contains a limited set of predefined operations, whatever resources are accessed by using the same interface, the interface should use standard hypertext transfer protocol (Hyper Text Transport Protocol, HTTP) methods, such as lookup (GET), PUT and POST, and follow the semantics of these methods, where GET is used to query this resource, PUT is used to overlay and modify the resource, if two requests are identical, the latter request will overlay the first request, POST is used to modify the resource, and the latter request will not overlay the first request.
Service-oriented architecture (SOA): is a component model that splits the different functional units of an application (called services) and links them by well-defined interfaces and protocols between these services.
Micro-services: the micro-service architecture is a new technology for deploying applications and services in the cloud, and the micro-services can run in a 'self program', communicate with an HTTP application program interface (Application Programming Interface, API) through lightweight equipment, and mainly have the function of decomposing functions into discrete services, so that the coupling of the system is reduced, and more flexible service support is provided.
Database (Database): a repository that organizes, stores and manages data according to a data structure, is stored together in a manner that can be shared among multiple users and has as little redundancy as possible, and is a collection of data independent of each other from an application.
Data table: or called a table, is one of the most important components of the database, and the database is only a framework, and the data table is the essential content of the database.
Currently, with the continuous development of background technology, the background service architecture is from a single service architecture to an SOA at first, and then to a micro service architecture, and service division is more and more refined. Generally, data processed by a single micro-service is relatively simple, for example, CRUD operation of the data can meet service requirements in many cases, while in the prior art, developers need to repeatedly write CRUD logic codes for different services, repeated work does not effectively improve the capability of the developers, but also can disperse development efforts of teams, thereby increasing development cost and time and reducing development efficiency, so that how to provide a method for generating a service framework by configuring one key is particularly important. And the Go language is becoming more popular at present, the team using the Go language as the development language is increasing, the implementation is simpler, and the implementation based on the Go language is also necessary.
In addition, the related technology also provides a Jhipster method, wherein the Jhipster is a completely open source code, an application generator is widely used, a Spring boot+angular/action item can be conveniently created, but the Jhipster is mainly used for generating Java applications, generates micro services by inputting parameters required for designating micro services to be generated through command input of a control console by a Jhipster tool based on the Spring Boot, namely, providing component type parameters, and a user inputs and creates the parameters step by step according to the provided parameters and steps, so that writing and changing of a code layer cannot be supported, the user cannot flexibly write or configure resources, the implementation is inflexible, and the method cannot be used for generating the Go language micro services.
Therefore, in view of the above problems, the embodiments of the present application provide a service generating method, in which a user may customize a configuration file, including database description information and resource attributes required by a service, and further generate a database and a data table of the service according to the configuration file of the service, and generate an operation method and an external interface associated with the data table for the service according to a configured operation method template, so that the database data table of the service can be automatically generated through the configuration file, and the associated operation method and external interface can be automatically assigned to the data table, thereby realizing the generation of a service framework without manual creation, improving service development efficiency, and reducing cost and time.
Referring to fig. 1, an application architecture diagram of a service generating method in an embodiment of the present application includes a terminal 100 and a server 200.
The terminal 100 may be any intelligent device such as a smart phone, a tablet computer, a portable personal computer, etc., various application programs may be installed on the terminal 100, various services may be accessed, and certain computing capabilities are provided, for example, after the service is generated and the end of the server 200 in the embodiment of the present application is completed, a user may access different services through the terminal 100.
The server 200 can provide various network services for the terminal 100, and for different application programs, the server 200 can be regarded as a corresponding background server, wherein the server 200 can be a server, a server cluster formed by a plurality of servers or a cloud computing center.
The terminal 100 and the server 200 may be connected to each other through the internet to realize communication therebetween. Alternatively, the Internet may use standard communication techniques, protocols, or a combination of both. The internet is typically the internet, but may be any network including, but not limited to, a local area network (Local Area Network, LAN), metropolitan area network (Metropolitan Area Network, MAN), wide area network (Wide Area Network, WAN), mobile, wired or wireless network, private network, or any combination of virtual private networks. In some embodiments, data exchanged over the network is represented using techniques and/or formats including HyperText Mark-up Language (HTML), extensible markup Language (Extensible Markup Language, XML), and the like. All or some of the links may also be encrypted using conventional encryption techniques such as secure socket layer (Secure Socket Layer, SSL), transport layer security (Transport Layer Security, TLS), virtual private network (Virtual Private Network, VPN), internet protocol security (Internet Protocol Security, IPsec), and the like. In other embodiments, custom and/or dedicated data communication techniques may also be used in place of or in addition to the data communication techniques described above.
It should be noted that, in the embodiment of the present application, the service generating method is mainly used for generating a basic frame of a service, for example, including a database and a data table of the service, and may also generate an external interface and an operation method, after the service frame is generated, other specific details or functions need to be given and deployed at the server 200 end to be used, and the service frame is generated, that is, the service generating method in the embodiment of the present application may be executed by the terminal 100 side or by the server 200 side, which is not limited in this embodiment of the present application.
For example, a configuration file of a service can be obtained through a script file command at the terminal 100 side, so as to generate a database and a data table of the service, and an operation method and an external interface are generated according to an operation method template, so that the generation of a service frame can be realized, and after the service frame is generated, the correctness of the service can be tested through compiling and running, and the generated service frame can be deployed to the server 200 for the user to use through the terminal 100.
For another example, the method may be implemented directly on the server 200 side, where the server 200 obtains a configuration file of a service, generates a database and a data table of the service, generates an associated operation method and an external interface, and implements generation of a service framework, and after compiling and running, the generated service framework may be deployed on the server 200, so that the service may be used, for example, the terminal 100 may access the service through the server 200.
In addition, the service generating method in the embodiment of the application can be realized based on the Go language, the realization is simpler, and the embodiment of the application is not limited.
It should be noted that, the application architecture diagram in the embodiment of the present application is to more clearly illustrate the technical solution in the embodiment of the present application, and is not limited to the technical solution provided in the embodiment of the present application, and is not limited to micro services, but for other application architectures and business applications, the technical solution provided in the embodiment of the present application is also applicable to similar problems.
In the embodiments of the present application, an application architecture shown in fig. 1 is taken as an example to schematically illustrate an application of a service generating method, and in addition, in the embodiments of the present application, a service is, for example, a micro service, but this is not a limitation.
Based on the foregoing embodiments, referring to fig. 2, a flowchart of a service generating method in an embodiment of the present application is shown, where the method includes:
step 200: and acquiring a configuration file of the service, wherein the configuration file at least comprises database description information and resource attributes, and the resource attributes represent data table structure information in a database.
In this embodiment of the present application, the configuration file of the service may be related configuration information of the service defined autonomously by the user according to the need, and at least includes database description information and resource attribute of the service, where the database description information includes at least a database server address and a database name, the resource attribute includes at least a database table name and field information of a field included in the database table, specifically, the database server address is used to designate a connected database, that is, the required database may be addressed by the database server address, the database name is used to designate the created and required database, and the resource attribute is used to designate the name of the database to be created and the field and the type under the database. In addition, the configuration file may further include login verification information, where the login verification information includes a user name, a password, and the like, and may be used to perform identity verification.
Moreover, in the embodiments of the present application, a declarative language may be used as a format of a configuration file, where declarative language programming is a programming paradigm, and a program is generally regarded as a theory of formal logic and a calculation is generally regarded as an inference in a logic space, so that, in the declarative language, parallel programming may be simplified, for example, a common declarative language may be written in a parallel program (for example, a database query language (for example, a structured query language (Structured Query Language, SQL, XQuery), a regular expression, a logic program, a functional programming and configuration management system, and the embodiment of the present application is not limited thereto.
Further, after the configuration file of the service is obtained, before executing step 210, validity verification may be performed on the configuration file, to verify whether the configuration file has a syntax error and does not include complete necessary information, and in this embodiment, several possible implementations are provided, before generating the database and the data table of the service according to the configuration file, the method further includes: 1) Verifying the validity of the configuration file, and determining that the grammar of the configuration file is the correct grammar; 2) And carrying out validity check on the configuration file, and determining that the configuration file contains complete necessary information. 3) Verifying the validity of the configuration file, and determining that the grammar of the configuration file is the correct grammar; and determines that the configuration file contains the complete necessary information.
That is, in the embodiment of the present application, after determining that the configuration file syntax is correct and includes the complete necessary information, for example, the database description information and the resource attribute, the subsequent step 210 is continued, so that the correctness of the configuration file can be ensured.
Further, if the configuration file further includes login verification information, in this embodiment of the present application, identity verification may be further performed, and because the associated database is found or created by the address of the database server and the name of the database, whether the database has access rights under the address may be further verified by the login verification information, so as to improve security and reliability. And carrying out identity verification according to the login verification information in the configuration file, and determining that the database corresponding to the database description information has access rights.
In this way, in the embodiment of the application, by analyzing the configuration file, extracting the relevant configuration information in the configuration file, and verifying the validity and identity of the configuration file, the reliability of the subsequent generated service can be ensured, and thus the service can be automatically generated after verification is passed.
Step 210: and generating a database and a data table of the service according to the configuration file.
Step 210 is performed in two ways:
a first part: and generating a database of the service according to the configuration file.
The method specifically comprises the following steps: 1) And when the database corresponding to the database name is found according to the database server address, acquiring the database.
2) When the database corresponding to the database name is not found according to the database server address, a corresponding database is created under the database server address according to the database name.
In this embodiment of the present application, whether a corresponding database name is created at a database server address may be first connected and queried according to the database server address, if it is determined that the database name is created, the creation flow may be skipped, it is determined that the database corresponding to the database name is a database associated with a service, if it is determined that the database name is not created, the creation flow is executed, and a database corresponding to the database name is created at the database server address as the database associated with the service.
A second part: and generating a data table of the service according to the configuration file.
The method specifically comprises the following steps: 1) And when the data table corresponding to the data table name exists in the database of the service according to the data table name, comparing the field information in the existing data table with the field information contained in the configuration file, and updating the existing data table.
In practice, one database may include one or more data tables, so in this embodiment of the present application, the name of the data table in the configuration file may be one or more, and not limited, and of course, a plurality of databases may be included, or corresponding relationships between different data tables and databases may be set in the configuration file, so that the corresponding data table may be searched in the corresponding database, if it is determined that there is a difference in field information of the data table, for example, the field information includes a field name, a field value, a field type, etc., and the existing data table may be automatically updated.
When updating the data table, the field information may be automatically added or modified through comparison, in addition, in order to improve reliability, deletion of the field information may be performed manually, for example, an existing data table includes field information that is not included in the data table in the configuration file, and an existing data table includes more field information and does not affect use of the service.
2) When the data table corresponding to the data table name exists in the database of the service according to the data table name, the corresponding data table is created in the database of the service according to the data table name and the field information.
I.e. it is determined that the corresponding data table is not found in the database, a data table creation procedure is performed, and the corresponding data table may be created in the database.
Therefore, in the embodiment of the application, the database and the data table of the service can be automatically created through the configuration file, and the service is not needed to be manually created on the server, so that the efficiency is improved, and the time and the cost are reduced.
Step 220: and generating an operation method and an external interface associated with the data table for the service according to the configured operation method template.
When executing step 220, the method specifically includes: generating a resource structure object aiming at the data table, generating an operation method associated with the resource structure object according to a pre-configured operation method template, and respectively generating an external interface aiming at each operation method.
The generating of the resource structure object may be implemented by using Go language, which is not limited in the embodiment of the present application.
When generating the operation method associated with the resource structure object, for example, the relevant keywords of the field information in the data table in the configuration file can be replaced by the relevant keywords in the operation method template according to the operation method template, and the operation method associated with the resource structure object is generated, namely, the operation method of the resource structure object is generated, wherein the operation method is, for example, a CRUD method, and is not limited, the operation method template code can call a CRUD interface, so that the CRUD method can be repeatedly written for different services without manual work, and multiplexing can be automatically generated.
In addition, in the embodiment of the application, the external interface is only used for an external interface for access, the actual service logic implementation is an associated operation method, one operation method has an external interface, the external interface can also be automatically generated through a template, the associated operation method is defined by a request packet and a response packet of the external interface, wherein the external interface can be a RESTful interface, and the embodiment of the application is not limited.
In this way, the service can be automatically generated through the configuration file, and the associated operation method, external interfaces and the like can be generated through defining resources and the like needing to be operated through the configuration file, so that the time and development cost are reduced.
Further, after the service is generated, compiling is further required to verify a result of the service generation, and in particular, a possible implementation manner is provided in the embodiment of the present application, after the operation method and the external interface associated with the data table are generated for the service according to the configured operation method template, the method further includes: the generated service is compiled and run, and whether the generated service is correct or not is detected.
After the service is generated, the result generated by the verification service is compiled automatically, whether the service is correct or not can be verified effectively, and the reliability of subsequent deployment and use is improved, so that developers can check errors in time and correct the errors.
In the embodiment of the application, the configuration file of the service is obtained, the database and the data table of the service are generated according to the configuration file, and then the operation method and the external interface related to the data table are generated for the service according to the configured operation method template, so that the service can be automatically generated, for example, the service can be realized based on the Go language, a set of micro-service framework template of the Go language is provided, the database and the data table required by the service can be quickly generated through the configuration file, and the related operation method and the external interface can be generated according to the template, so that the repeated development labor is reduced, and therefore, the micro-service code framework with the complete interface function can be generated through the configuration file, the service development efficiency is improved, and the cost and the time are reduced.
Based on the foregoing embodiments, a specific application scenario is described below, and referring to fig. 3, a flowchart of another service generation method in the embodiment of the present application is shown, where the method includes:
step 300: starting.
Step 301: checking whether the configuration file is legal, if so, executing step 302, otherwise, executing step 307.
Specifically, 1) it is possible to check whether the syntax of the configuration file is correct; or 2) checking whether the configuration file does not contain complete necessary information; or 3) can check whether the grammar of the configuration file is correct or not, and whether the configuration file does not contain complete necessary information or not.
Step 302: and analyzing the configuration file.
Configuration information in the configuration file is obtained in this way, including database description information, resource attributes and the like.
Wherein the resource attribute represents data table structure information in the database.
Step 303: a database of services is generated.
The type of the database in the embodiment of the present application is not limited, and may be MySQL, postgreSQL, sqlite3, SQL Server, etc.
Step 304: a data table of the service is generated.
Specifically, according to the name of the data table, searching is carried out in the corresponding database of the service, if the service exists, the service is compared and updated, and if the service does not exist, the service is created in the corresponding database.
Step 305: an operating method and an external interface associated with the data table are generated for the service.
The operation method is, for example, CRUD method, and the external interface is RESTful interface, which is not limited in the embodiment of the present application.
Step 306: the generated service is compiled and run, and whether the generated service is correct or not is detected.
Step 307: and (5) ending.
In this way, in the embodiment of the application, the service can be automatically generated through the configuration file, the databases, the data table, the CRUD method operation code logic and the external interfaces required by the service are generated, the databases of different types are not limited, the use of the databases can be abstracted into a unified call, namely, the configuration file can be generated and realized through one key, manual repeated operation is not needed, the cost and time are reduced, the efficiency is improved, and the compiling can be performed to detect the correctness of the service, so that the developer can debug the generated service, and the correctness and reliability of the generated service are improved.
Based on the same inventive concept, the embodiment of the present application further provides a service generating device, which may be, for example, a server or a terminal in the foregoing embodiment, where the service generating device may be a hardware structure, a software module, or a hardware structure plus a software module. Based on the foregoing embodiments, referring to fig. 4, the service generating device in the embodiment of the present application specifically includes:
an obtaining module 40, configured to obtain a configuration file of the service, where the configuration file at least includes database description information and resource attribute, and the resource attribute represents data table structure information in the database;
a first generating module 41, configured to generate a database and a data table of the service according to the configuration file;
and the second generating module 42 is configured to generate an operation method and an external interface associated with the data table for the service according to the configured operation method template.
Optionally, the first verification module 43 is further configured to: before the first generation module 41 generates the database and the data table of the service according to the configuration file, at least one of the following is performed:
verifying the validity of the configuration file, and determining that the grammar of the configuration file is the correct grammar;
the configuration file is determined to contain the complete necessary information.
Optionally, the configuration file further includes login verification information; then a second checking module 44 is also included for: before the first generating module 41 generates the database and the data table of the service according to the configuration file, identity verification is performed according to the login verification information in the configuration file, so as to determine that the database corresponding to the database description information has access rights.
Optionally, the database description information includes at least a database server address and a database name, and when generating the database of the service according to the configuration file, the first generating module 41 is configured to:
when a database corresponding to the database name is found according to the address of the database server, acquiring the database;
when the database corresponding to the database name is not found according to the database server address, a corresponding database is created under the database server address according to the database name.
Optionally, the resource attribute includes at least a name of the data table and field information of a field included in the data table, and when generating the data table of the service according to the configuration file, the first generating module 41 is configured to:
according to the name of the data table, when the data table corresponding to the name of the data table exists in the database of the service, comparing the field information in the existing data table with the field information contained in the configuration file, and updating the existing data table;
when the data table corresponding to the data table name exists in the database of the service according to the data table name, the corresponding data table is created in the database of the service according to the data table name and the field information.
Optionally, when generating the operation method and the external interface associated with the data table for the service according to the configured operation method template, the second generating module 42 is configured to:
generating a resource structure object aiming at the data table, generating an operation method associated with the resource structure object according to a pre-configured operation method template, and respectively generating an external interface aiming at each operation method.
Optionally, the compiling module 45 is further configured to: the generated service is compiled and run, and whether the generated service is correct or not is detected.
Based on the above embodiments, referring to fig. 5, a schematic structural diagram of an electronic device in an embodiment of the present application is shown.
Embodiments of the present application provide an electronic device that may include a processor 510 (Center Processing Unit, CPU), a memory 520, an input device 530, an output device 540, etc., where the input device 530 may include a keyboard, a mouse, a touch screen, etc., and the output device 540 may include a display device, such as a liquid crystal display (Liquid Crystal Display, LCD), a Cathode Ray Tube (CRT), etc.
Memory 520 may include Read Only Memory (ROM) and Random Access Memory (RAM) and provides processor 510 with program instructions and data stored in memory 520. In the present embodiment, the memory 520 may be used to store a program of any of the service generation methods in the present embodiment.
The processor 510 is configured to execute any of the service generation methods according to the embodiments of the present application by calling the program instructions stored in the memory 520, and the processor 510.
Based on the above embodiments, in the embodiments of the present application, there is provided a computer-readable storage medium having stored thereon a computer program, which when executed by a processor, implements the service generation method in any of the method embodiments described above.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the application.
It will be apparent to those skilled in the art that various modifications and variations can be made to the embodiments of the present application without departing from the spirit and scope of the embodiments of the present application. Thus, if such modifications and variations of the embodiments of the present application fall within the scope of the claims and the equivalents thereof, the present application is intended to encompass such modifications and variations.

Claims (13)

1. A service generation method, comprising:
acquiring a configuration file of a service, wherein the configuration file at least comprises database description information and resource attributes, and the resource attributes at least comprise a data table name and field information of fields contained in a data table;
generating a database and a data table of the service according to the configuration file;
generating an operation method and an external interface associated with the data table for the service according to the configured operation method template;
wherein generating an operation method and an external interface associated with the data table for the service according to the configured operation method template comprises:
generating a resource structure object for the data table;
and according to the operation method template, replacing the corresponding keywords in the operation method template by the related keywords of the field information in the configuration file, associating the keywords with the resource structure object, generating operation methods associated with the resource structure object, and generating an external interface for each operation method respectively.
2. The method of claim 1, further comprising, prior to generating the database and data table of the service from the configuration file, at least one of:
performing validity check on the configuration file, and determining that the grammar of the configuration file is the correct grammar;
and determining that the configuration file contains complete necessary information.
3. The method according to claim 1 or 2, wherein the configuration file further comprises login check information; then before generating the database and the data table of the service according to the configuration file, the method further comprises:
and carrying out identity verification according to the login verification information in the configuration file, and determining that the database corresponding to the database description information has access rights.
4. The method of claim 1, wherein the database description information includes at least a database server address and a database name, and generating the database of the service based on the configuration file comprises:
when a database corresponding to the database name is found according to the database server address, acquiring the database;
and when the database corresponding to the database name is not found according to the database server address, creating a corresponding database under the database server address according to the database name.
5. The method according to claim 1 or 4, wherein the resource attribute includes at least a data table name, and field information of a field included in the data table, and generating the data table of the service according to the configuration file includes:
when the data table corresponding to the data table name exists in the database of the service according to the data table name, comparing the field information in the existing data table with the field information contained in the configuration file, and updating the existing data table;
and when the data table corresponding to the data table name exists in the database of the service according to the data table name, creating a corresponding data table in the database of the service according to the data table name and the field information.
6. The method of claim 1, further comprising, after generating an operation method and an external interface associated with the data table for the service according to a configured operation method template:
the generated service is compiled and run, and whether the generated service is correct or not is detected.
7. A service generating apparatus, comprising:
the system comprises an acquisition module, a service management module and a service management module, wherein the acquisition module is used for acquiring a configuration file of the service, the configuration file at least comprises database description information and resource attributes, and the resource attributes at least comprise data table names and field information of fields contained in a data table;
the first generation module is used for generating a database and a data table of the service according to the configuration file;
the second generation module is used for generating an operation method and an external interface associated with the data table for the service according to the configured operation method template;
the second generating module is specifically configured to:
generating a resource structure object for the data table;
and according to the operation method template, replacing the corresponding keywords in the operation method template by the related keywords of the field information in the configuration file, associating the keywords with the resource structure object, generating operation methods associated with the resource structure object, and generating an external interface for each operation method respectively.
8. The apparatus of claim 7, wherein the configuration file further includes login check information; then further comprising a second checking module for: before the first generating module generates the database and the data table of the service according to the configuration file, identity verification is carried out according to login verification information in the configuration file, and the database corresponding to the database description information is determined to have access rights.
9. The apparatus of claim 7, wherein the database description information includes at least a database server address and a database name, and wherein when generating the database of the service according to the configuration file, the first generation module is configured to:
when a database corresponding to the database name is found according to the database server address, acquiring the database;
and when the database corresponding to the database name is not found according to the database server address, creating a corresponding database under the database server address according to the database name.
10. The apparatus according to claim 7 or 9, wherein the resource attribute includes at least a data table name, and field information of a field included in the data table, and when generating the data table of the service according to the configuration file, the first generation module is configured to:
when the data table corresponding to the data table name exists in the database of the service according to the data table name, comparing the field information in the existing data table with the field information contained in the configuration file, and updating the existing data table;
and when the data table corresponding to the data table name exists in the database of the service according to the data table name, creating a corresponding data table in the database of the service according to the data table name and the field information.
11. The apparatus as recited in claim 7, further comprising:
and the compiling module is used for compiling and running the generated service and detecting whether the generated service is correct.
12. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method of any of claims 1-6 when the program is executed.
13. A computer-readable storage medium having stored thereon a computer program, characterized by: which computer program, when being executed by a processor, carries out the steps of the method according to any one of claims 1-6.
CN202010193386.8A 2020-03-18 2020-03-18 Service generation method and device Active CN111414350B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010193386.8A CN111414350B (en) 2020-03-18 2020-03-18 Service generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010193386.8A CN111414350B (en) 2020-03-18 2020-03-18 Service generation method and device

Publications (2)

Publication Number Publication Date
CN111414350A CN111414350A (en) 2020-07-14
CN111414350B true CN111414350B (en) 2023-05-12

Family

ID=71493082

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010193386.8A Active CN111414350B (en) 2020-03-18 2020-03-18 Service generation method and device

Country Status (1)

Country Link
CN (1) CN111414350B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112235132B (en) * 2020-09-27 2023-04-28 广州视源电子科技股份有限公司 Method, device, medium and server for dynamically configuring service
CN112764826A (en) * 2020-12-30 2021-05-07 中国人寿保险股份有限公司上海数据中心 tuxedo resource batch processing method, system, equipment and medium
CN114115839A (en) * 2022-01-28 2022-03-01 云账户技术(天津)有限公司 ORM code processing method and device, electronic equipment and readable storage medium
CN114968214B (en) * 2022-07-12 2022-10-28 云账户技术(天津)有限公司 Code automatic generation method and device, storage medium and terminal equipment
CN115422280B (en) * 2022-11-04 2023-02-14 杭州西湖新基建数字技术有限公司 Interface method for increasing, deleting and modifying data of uncertain data structure

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU6167701A (en) * 2000-05-20 2001-12-03 Equipe Comm Corp A network device for supporting multiple upper layer network protocols over a single network connection
CN101013424A (en) * 2005-12-27 2007-08-08 国际商业机器公司 System and method for executing search in a relational database
CN102135883A (en) * 2011-03-14 2011-07-27 山东大学 Software-as-a-service (SaaS) application generation and deployment supporting method and device
CN106874247A (en) * 2017-01-03 2017-06-20 北京神州绿盟信息安全科技股份有限公司 A kind of report form generation method and device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7017162B2 (en) * 2001-07-10 2006-03-21 Microsoft Corporation Application program interface for network software platform
CN103077032B (en) * 2013-01-06 2019-08-27 北京百度网讯科技有限公司 The operating method of application program and the client of application program
CN104267932B (en) * 2014-08-12 2017-11-07 广州华多网络科技有限公司 database operation method, device and server
CN106844643A (en) * 2017-01-13 2017-06-13 王洋 A kind of Database Dynamic generation method based on template engine
CN108427550B (en) * 2018-02-13 2021-09-03 深圳太极云软技术有限公司 Web service generation method, device and equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU6167701A (en) * 2000-05-20 2001-12-03 Equipe Comm Corp A network device for supporting multiple upper layer network protocols over a single network connection
US7130870B1 (en) * 2000-05-20 2006-10-31 Ciena Corporation Method for upgrading embedded configuration databases
CN101013424A (en) * 2005-12-27 2007-08-08 国际商业机器公司 System and method for executing search in a relational database
CN102135883A (en) * 2011-03-14 2011-07-27 山东大学 Software-as-a-service (SaaS) application generation and deployment supporting method and device
CN106874247A (en) * 2017-01-03 2017-06-20 北京神州绿盟信息安全科技股份有限公司 A kind of report form generation method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
autogenic:automated generation of self configuring microservices;kehrer S等;closer;35-46 *
基于Android的电子工程师小助手的设计与实现;曹路;秦传波;李任杰;;物联网技术;第7卷(第01期);105-107 *

Also Published As

Publication number Publication date
CN111414350A (en) 2020-07-14

Similar Documents

Publication Publication Date Title
CN111414350B (en) Service generation method and device
US10592319B2 (en) API notebook tool
US11347779B2 (en) User interface for regular expression generation
US8468391B2 (en) Utilizing log event ontology to deliver user role specific solutions for problem determination
US9646041B2 (en) Testing of inactive design-time artifacts
US8533666B2 (en) Interactive design environments to visually model, debug and execute resource oriented programs
US9229697B2 (en) Speculative object shapes
CN103577168A (en) Test case creation system and method
Wittern et al. Opportunities in software engineering research for web API consumption
US10977011B2 (en) Structured development for web application frameworks
US20210208854A1 (en) System and method for enhancing component based development models with auto-wiring
US11611627B2 (en) Action flow fragment management
CN109710220B (en) Relational database query method, relational database query device, relational database query equipment and storage medium
US20240062855A1 (en) Systems and methods for automated edit check generation in clinical trial datasets
CN111125064B (en) Method and device for generating database schema definition statement
US11232105B2 (en) Unified metrics computation platform
US9606844B2 (en) Remotely-hosted interactive client-server session
US10558624B2 (en) System and method for datastore management framework
US11307850B2 (en) Efficient change analysis in poly-lingual corpus hierarchies
Aryal MERN stack with modern web practices
US20230267163A1 (en) Runtime completion of web component metadata
US20240028590A1 (en) Systems and methods for querying data
CN117234899A (en) Regression testing method, device, equipment and computer medium
CN114090105A (en) System building method and device
García Ardiles A client-server architecture for distributed and scalable multimedia content analysis: an Android app for assisting phone users in shooting aesthetically valuable pictures

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
GR01 Patent grant
GR01 Patent grant