CN108228166B - Template-based back-end code generation method and system - Google Patents

Template-based back-end code generation method and system Download PDF

Info

Publication number
CN108228166B
CN108228166B CN201810214268.3A CN201810214268A CN108228166B CN 108228166 B CN108228166 B CN 108228166B CN 201810214268 A CN201810214268 A CN 201810214268A CN 108228166 B CN108228166 B CN 108228166B
Authority
CN
China
Prior art keywords
template
service
module
target
preset
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
CN201810214268.3A
Other languages
Chinese (zh)
Other versions
CN108228166A (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.)
Shanghai liankun Technology Co., Ltd
Original Assignee
Seashell Housing Beijing Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Seashell Housing Beijing Technology Co Ltd filed Critical Seashell Housing Beijing Technology Co Ltd
Priority to CN201810214268.3A priority Critical patent/CN108228166B/en
Publication of CN108228166A publication Critical patent/CN108228166A/en
Application granted granted Critical
Publication of CN108228166B publication Critical patent/CN108228166B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Abstract

The invention provides a template-based back-end code generation method and a template-based back-end code generation system, wherein the method comprises the following steps: acquiring a service module contained in a service demand according to the service demand provided by a user, and inquiring a service template corresponding to the service module from a preset template library; and when the service template corresponding to the service module is inquired, importing the service template into a back-end code editing interface by using a preset template import grammar to generate a back-end code corresponding to the service requirement. The method and the system effectively avoid the code redundancy phenomenon in the back-end development through the reuse of the template, and improve the overall development efficiency to a certain extent; meanwhile, by importing the templates in the front-end template library, developers can write the back-end codes and test the back-end codes at the same time without recompiling and releasing, and the whole development period is effectively shortened.

Description

Template-based back-end code generation method and system
Technical Field
The invention relates to the technical field of computers, in particular to a template-based back-end code generation method and a template-based back-end code generation system.
Background
In the existing internet website development, an MVC framework is generally used to divide a code into a view layer, a data layer and a control layer during back-end development so as to realize decoupling between data presentation and data processing. In actual development, business logic is usually merged with a control layer and a data layer, and a phenomenon of code redundancy is ubiquitous.
For example, most of the request processing flows of general system websites are as follows: processing request parameters- > verifying user authority- > obtaining data- > processing data according to service logic and organizing into a certain form- > returning results in a certain form, wherein the total number of the 5 modes is included. Each request service can be viewed as a combination of one or more of these modes. However, at present, programmers write codes for different request services in a manner that the codes need to be written repeatedly for the same mode, and the phenomenon of code redundancy is serious.
Although the same structure code can be refined by adding more layers, such as a Bizness layer, a Service layer and a DAO layer, according to the phenomenon of code redundancy existing in the above-mentioned back-end development, the boundaries between the layers become more and more fuzzy with the intervention of different developers over time. Moreover, the code styles of different developers are not consistent, resulting in increased learning and maintenance costs.
In addition, in the existing back-end development, code changes caused by business logic modification each time need to be recompiled and released to be on-line to be effective, so that the whole development period is prolonged.
Disclosure of Invention
The invention provides a template-based back-end code generation method and system, aiming at overcoming the problems of code redundancy, low development efficiency and long development period existing in back-end development in the prior art.
In one aspect, the present invention provides a template-based backend code generation method, including:
s1, acquiring a service module contained in the service requirement according to the service requirement provided by a user, and inquiring a service template corresponding to the service module from a preset template library;
and S2, when the service template corresponding to the service module is inquired, importing the service template into a back end code editing interface by using a preset template import grammar, and generating a back end code corresponding to the service requirement.
Preferably, the step S2 is followed by:
s3, obtaining the target service corresponding to the service requirement, packaging the back end code corresponding to the service requirement into the target template corresponding to the target service, and storing the mark of the target service and the target template in the template library in a correlation manner.
Preferably, the step S3 is followed by:
s4, receiving a request of a user for the target service, obtaining the template content of the target template corresponding to the target service from the template library, obtaining the functional module contained in the template content, calling a preset analysis engine according to the functional module, analyzing the template content by using the analysis engine, and feeding back the analysis result to the user.
Preferably, the parsing the template content with the parsing engine in step S4 further comprises:
analyzing the template content by using a Freemarker engine to obtain a corresponding JSON array; and analyzing the JSON array by using the analysis engine, and calling a corresponding data source analyzer according to the data source type in the template content to analyze the JSON array to obtain an analysis result.
Preferably, the step S1 of querying the service template corresponding to the service module from a preset template library further includes:
acquiring identification information of the service module, inquiring a template identification which is the same as the identification information from a preset database according to the identification information, and acquiring a corresponding service template according to the template identification.
Preferably, the step S2 further includes: when the service template corresponding to the service module is not inquired, acquiring a service code edited by a programmer according to the service module, packaging the service code into the service template corresponding to the service module, and storing the identification information of the service module and the service template in the template library in an associated manner.
In one aspect, the present invention provides a template-based backend code generation system, including:
the template query module is used for acquiring a service module contained in the service requirement according to the service requirement provided by a user and querying a service template corresponding to the service module from a preset template library;
and the code generation module is used for importing the service template into a back-end code editing interface by using a preset template import syntax when the service template corresponding to the service module is inquired, and generating a back-end code corresponding to the service requirement.
Preferably, the method further comprises the following steps:
and the encapsulation storage module is used for acquiring the target service corresponding to the service requirement, encapsulating the back-end code corresponding to the service requirement into a target template corresponding to the target service, and storing the identifier of the target service and the target template in the template library in an associated manner.
Preferably, the method further comprises the following steps:
and the template analysis module is used for receiving a request of a user for the target service, acquiring the template content of a target template corresponding to the target service from the template library, acquiring a functional module contained in the template content, calling a corresponding analysis engine according to the functional module, analyzing the template content by using the analysis engine, and feeding back an analysis result to the user.
In one aspect, the present invention provides a device for a template-based backend code generation method, including:
at least one processor; and
at least one memory communicatively coupled to the processor, wherein:
the memory stores program instructions executable by the processor, the processor being capable of performing any of the methods described above when invoked by the processor.
The invention provides a template-based back-end code generation method and a template-based back-end code generation system.A service module contained in a service demand is acquired according to the service demand provided by a user, and a service template corresponding to the service module is inquired from a preset template library; when the service template corresponding to the service module is inquired, the preset template import grammar is utilized to import the service template into the back-end code editing interface, and the back-end code corresponding to the service requirement can be generated. The method effectively avoids the code redundancy phenomenon existing in the back-end development through the reuse of the template, and improves the overall development efficiency to a certain extent; meanwhile, by importing the templates in the front-end template library, developers can write the back-end codes and test the back-end codes at the same time without recompiling and releasing, and the whole development period is effectively shortened.
Drawings
Fig. 1 is a schematic overall flow chart of a template-based backend code generation method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of an overall structure of a template-based backend code generation system according to an embodiment of the present invention;
fig. 3 is a schematic structural framework diagram of an apparatus of a template-based backend code generation method according to an embodiment of the present invention.
Detailed Description
The following detailed description of embodiments of the present invention is provided in connection with the accompanying drawings and examples. The following examples are intended to illustrate the invention but are not intended to limit the scope of the invention.
Fig. 1 is a schematic overall flow chart of a method for generating a back-end code based on a template according to an embodiment of the present invention, and as shown in fig. 1, the present invention provides a method for generating a back-end code based on a template, including:
s1, acquiring a service module contained in the service requirement according to the service requirement provided by a user, and inquiring a service template corresponding to the service module from a preset template library;
and S2, when the service template corresponding to the service module is inquired, importing the service template into a back end code editing interface by using a preset template import grammar, and generating a back end code corresponding to the service requirement.
Specifically, in the process of system development, a developer acquires a service requirement provided by a user, inputs the service requirement into the system, analyzes a service module included in the service requirement according to the service requirement, and queries a service template corresponding to the service module from a preset template library. The preset template library is a front-end database, and developers write corresponding back-end codes aiming at different business requirements in the historical development process, and encapsulate the back-end codes into business templates which are stored in the preset template library.
Further, when a service template corresponding to a service module is queried in a preset template library, the queried service template is imported into a back-end code editing interface by using a preset template import syntax, that is, codes do not need to be rewritten for the service module, but only the template import code corresponding to the service module needs to be written by using the preset template import syntax, so that the back-end code corresponding to the service requirement can be generated. The template import syntax is preset by a developer, and a specific expression form of the template import syntax can be set according to actual requirements, which is not specifically limited herein. For example, the grammar for template import may be embodied in the form of:
Figure BDA0001598129260000051
wherein type represents the type of the template; the name represents the name of the template, and the template is uniquely identified through the type of the template and the name of the template.
In order to better understand the above method steps, the following examples are now described:
for example, in a real estate system, the service requirements provided by a user are: sending the viewing amount of the newly added house source to the user in the form of an email, and aiming at the service demand system, analyzing that the service demand comprises two service modules which are respectively: (1) acquiring the source of the newly added house with the watching amount; (2) and sending the information to the user in the form of mail. On the basis, according to the two service modules, the service templates corresponding to the two service modules are inquired from a preset template library. If the two service modules are realized in the historical development process, the preset template library stores the service templates corresponding to the two service modules. When the service templates corresponding to the two service modules are inquired, the preset template grammar is used for compiling the import code, so that the service templates corresponding to the two service modules are imported into a back-end code editing interface, and the back-end code corresponding to the service requirement can be organized.
The invention provides a template-based back-end code generation method, which comprises the steps of acquiring a service module contained in a service demand according to the service demand provided by a user, and inquiring a service template corresponding to the service module from a preset template library; when the service template corresponding to the service module is inquired, the preset template import grammar is utilized to import the service template into the back-end code editing interface, and the back-end code corresponding to the service requirement can be generated. The method effectively avoids the code redundancy phenomenon existing in the back-end development through the reuse of the template, and improves the overall development efficiency to a certain extent; meanwhile, by importing the templates in the front-end template library, developers can write the back-end codes and test the back-end codes at the same time without recompiling and releasing, and the whole development period is effectively shortened.
Based on any one of the above embodiments, there is provided a template-based backend code generation method, where after the step S2, the method further includes: s3, obtaining the target service corresponding to the service requirement, packaging the back end code corresponding to the service requirement into the target template corresponding to the target service, and storing the mark of the target service and the target template in the template library in a correlation manner.
Specifically, on the basis of the above technical solution, after the back-end code corresponding to the service requirement is generated, in order to facilitate subsequent multiplexing of the back-end code corresponding to the service requirement, in this embodiment, a target service corresponding to the service requirement is determined according to the service requirement, and a service identifier corresponding to the target service is obtained; and meanwhile, encapsulating the back-end code corresponding to the service requirement into a target template corresponding to the target service, and finally storing the identifier of the target service and the target template in a preset template library in an associated manner.
Further, in the subsequent development process, when a developer needs to write a back-end code for a new service requirement, if the target service exists in a service module included in the new service requirement, the developer can directly import a target template corresponding to the target service from a template library by using a preset template import syntax, so that the multiplexing of the target template can be realized.
According to the template-based back-end code generation method, after the back-end codes corresponding to the business requirements are generated, the back-end codes corresponding to the business requirements are packaged into the templates which are correspondingly stored in the preset template library, so that developers can conveniently multiplex the back-end codes corresponding to the business requirements in the subsequent development process, and the development efficiency is improved.
Based on any one of the above embodiments, there is provided a template-based backend code generation method, where after the step S3, the method further includes: s4, receiving a request of a user for the target service, obtaining the template content of the target template corresponding to the target service from the template library, obtaining the functional module contained in the template content, calling a preset analysis engine according to the functional module, analyzing the template content by using the analysis engine, and feeding back the analysis result to the user.
Specifically, on the basis of storing the target template corresponding to the target service in a preset template library, when a user initiates a request for the target service, the system receives the request of the user for the target service, and obtains the target template corresponding to the target service from the preset template library, thereby obtaining the template content corresponding to the target template. The template content may be HTML, XML or JSON text, and may also include freemaker template code, which is not limited herein.
Further, in this embodiment, the template content corresponding to each template in the preset template library is written according to a unified service logic, where the unified service logic may be, for example: step one, processing request parameters and verifying user authority; step two, acquiring data from each data source; and step three, processing the data according to the service logic, organizing the data into a certain form and the like. Wherein the step corresponds to the realization of the initialized function; step two, the function of data acquisition is realized; and step three realizes the function of data processing. That is, each template content corresponds to a plurality of function modules, and separators can be set between the function modules in the programming process, so as to separate the function modules.
On the basis of the above technical solution, in this embodiment, the function modules included in the template content corresponding to the target service are obtained according to the separators in the template content, that is, the template content is divided into a plurality of function modules according to specific function implementations. Different functional modules need different analysis engines to analyze the functional modules, so that the corresponding analysis engines are called for the obtained functional modules, the corresponding analysis engines are used for analyzing each functional module one by one, finally, the content of the whole template is analyzed, corresponding analysis results are obtained, and the analysis results are fed back to a user, namely, the user request is responded. The analysis engines are preset for each functional module and are pre-stored in the database, so that when different service requests are processed, the corresponding analysis engines can be called from the database for analysis for the same functional module, namely, the multiplexing of the analysis engines is realized.
According to the template-based back-end code generation method, when the request of a user for the target service is processed, the template content of the target template corresponding to the target service can be directly obtained from the template library without recompiling and releasing, so that the whole development period is effectively shortened; and meanwhile, the functional module contained in the template content is obtained, and the preset analysis engine is called correspondingly according to the functional module to analyze the template content, so that the multiplexing of the analysis engine is effectively realized, and the overall development efficiency is further improved.
Based on any one of the above embodiments, in providing a template-based backend code generation method, the parsing, by using the parsing engine, the template content in step S4 further includes: analyzing the template content by using a Freemarker engine to obtain a corresponding JSON array; and analyzing the JSON array by using the analysis engine, and calling a corresponding data source analyzer according to the data source type in the template content to analyze the JSON array to obtain an analysis result.
Specifically, the specific implementation process of parsing the template content by using the parsing engine is as follows:
firstly, a Freemarker engine is used for carrying out preliminary analysis on template contents, special characters representing numerical values in the template contents are analyzed into specific numerical values, and then JSON arrays corresponding to the template contents are obtained. On the basis, the JSON array is analyzed by using the obtained analysis engine corresponding to each functional module, the data source type contained in the template content is obtained simultaneously in the analysis process, the corresponding data source analyzer is called according to the data source type to analyze each element in the JSON array, the analysis result is finally obtained, and the analysis result can be stored in a mapping table in a key value pair mode. In addition, in other embodiments, when the template content is preliminarily analyzed, in addition to invoking the freemaker engine, a Velocity engine may also be invoked, which may be set according to actual requirements, and this is not specifically limited here.
According to the template-based rear-end code generation method, when a user request for a target service is processed, template contents of a target template corresponding to the target service are obtained from a template library, the template contents are preliminarily analyzed by a Freemarker engine to obtain a corresponding JSON array, the JSON array is analyzed by an analysis engine, a corresponding data source analyzer is called according to data source types in the template contents to analyze the JSON array, an analysis result is finally obtained, analysis of the template contents is effectively achieved, reuse of the analysis engine is effectively achieved, and overall development efficiency is further improved.
Based on any of the above embodiments, a template-based backend code generation method is provided, where the querying, in step S1, a service template corresponding to the service module from a preset template library further includes: acquiring identification information of the service module, inquiring a template identification which is the same as the identification information from a preset database according to the identification information, and acquiring a corresponding service template according to the template identification.
Specifically, in a preset template library, for each template stored therein, a template identifier corresponding to each template is stored in an associated manner, the template identifier includes a template type and a template name, and each template is uniquely identified by the template type and the template name. On this basis, when the service template corresponding to the service module needs to be queried from the pre-stored database, the specific process is as follows: firstly, obtaining the identification information of a service module, then inquiring a template identification which is the same as the identification information from a preset database according to the identification information, and then obtaining a corresponding service template according to the template identification.
In addition, in the preset template library, for each template stored therein, a template summary and the like corresponding to each template may be stored in association, and the setting may be performed according to actual requirements, which is not specifically limited herein.
The template-based back-end code generation method provided by the invention uniquely identifies each module in the preset template library, can inquire the template identification with the same identification information as the service module from the preset database when inquiring the service template corresponding to the service module, and then obtains the corresponding service template according to the template identification, thereby effectively realizing the reuse of the template, avoiding the code redundancy phenomenon existing in the back-end development and improving the overall development efficiency to a certain extent.
Based on any one of the above embodiments, there is provided a template-based backend code generation method, where the step S2 further includes: when the service template corresponding to the service module is not inquired, acquiring a service code edited by a programmer according to the service module, packaging the service code into the service template corresponding to the service module, and storing the identification information of the service module and the service template in the template library in an associated manner.
Specifically, a service module included in a service requirement is analyzed according to the service requirement provided by a user, a service template corresponding to the service module is queried from a preset template library, and when the service template corresponding to the service module is not queried, a programmer needs to write a corresponding service code according to the service module. On the basis, the system acquires the service code edited by the programmer according to the service module, encapsulates the service code into a service template corresponding to the service module, uses the identification information of the service module as a template identification, and stores the template identification and the service template in a preset template library in an associated manner, so that the subsequent multiplexing of the service template is facilitated.
For example, common service templates include an initialization template, a data acquisition template, and a data processing template, and some service requirements may include the following service modules: the data processing result needs to be output in the form of mail. If the service template corresponding to the service module does not exist in the template library at this time, the programmer needs to write the service code corresponding to the service module, encapsulate the service code into the service template corresponding to the service module, and store the identification information of the service module and the service template in the template library in an associated manner.
The invention provides a template-based back-end code generation method, which comprises the steps of analyzing a service module contained in a service demand according to the service demand provided by a user, inquiring a service template corresponding to the service module from a preset template library, acquiring a service code edited by a programmer according to the service module, packaging the service code into the service template corresponding to the service module, and storing identification information of the service module and the service template in the template library in an associated manner, thereby being beneficial to realizing the reuse of the template in the subsequent process, effectively avoiding the code redundancy phenomenon existing in the back-end development process, and improving the overall development efficiency to a certain extent; meanwhile, the template is stored in the front-end template library, so that a developer can write the back-end code and test the back-end code at the same time without compiling and releasing the back-end code, and the whole development period is effectively shortened.
Fig. 2 is a schematic diagram of an overall structure of a template-based backend code generation system according to an embodiment of the present invention, and as shown in fig. 2, the present invention provides a template-based backend code generation system, including:
the template query module 1 is used for acquiring a service module contained in a service demand according to the service demand provided by a user, and querying a service template corresponding to the service module from a preset template library;
and the code generation module 2 is used for importing the service template into a back-end code editing interface by using a preset template import syntax when the service template corresponding to the service module is inquired, and generating a back-end code corresponding to the service requirement.
Specifically, the present invention provides a template-based backend code generation system, which includes a template query module 1 and a code generation module 2, and the template-based backend code generation method in any of the above embodiments is implemented by each module, and is specifically implemented as follows:
in the process of system development, a developer acquires a service requirement provided by a user, the developer inputs the service requirement into the module query module 1, the module query module 1 analyzes a service module contained in the service requirement according to the service requirement, and then queries a service template corresponding to the service module from a preset template library. The preset template library is a front-end database, and developers write corresponding back-end codes aiming at different business requirements in the historical development process, and encapsulate the back-end codes into business templates which are stored in the preset template library.
Further, when the template query module 1 queries a service template corresponding to a service module in a preset template library, the code generation module 2 imports the queried service template into a back-end code editing interface by using a preset template import syntax, that is, codes do not need to be rewritten for the service module, but only the template import code corresponding to the service module is compiled by using the preset template import syntax, so that the back-end code corresponding to the service requirement can be generated. The template import syntax is preset by a developer, and a specific expression form of the template import syntax can be set according to actual requirements, which is not specifically limited herein. For example, the grammar for template import may be embodied in the form of:
Figure BDA0001598129260000111
wherein type represents the type of the template; the name represents the name of the template, and the template is uniquely identified through the type of the template and the name of the template.
The invention provides a template-based back-end code generation system, which acquires a service module contained in a service demand according to the service demand provided by a user, and queries a service template corresponding to the service module from a preset template library; when the service template corresponding to the service module is inquired, the preset template import grammar is utilized to import the service template into the back-end code editing interface, and the back-end code corresponding to the service requirement can be generated. The method effectively avoids the code redundancy phenomenon existing in the back-end development through the reuse of the template, and improves the overall development efficiency to a certain extent; meanwhile, by importing the templates in the front-end template library, developers can write the back-end codes and test the back-end codes at the same time without recompiling and releasing, and the whole development period is effectively shortened.
Based on any of the above embodiments, there is provided a template-based backend code generation system, further including: and the encapsulation storage module 3 is used for acquiring the target service corresponding to the service requirement, encapsulating the back-end code corresponding to the service requirement into a target template corresponding to the target service, and storing the identifier of the target service and the target template in the template library in an associated manner.
Specifically, on the basis of the above technical solution, after the code generation module 2 generates the backend code corresponding to the service requirement, in order to facilitate subsequent multiplexing of the backend code corresponding to the service requirement, in this embodiment, the encapsulation storage module 3 is used to determine the target service corresponding to the service requirement according to the service requirement, and obtain the service identifier corresponding to the target service; and meanwhile, encapsulating the back-end code corresponding to the service requirement into a target template corresponding to the target service, and finally storing the identifier of the target service and the target template in a preset template library in an associated manner.
Further, in the subsequent development process, when a developer needs to write a back-end code for a new service requirement, if the target service exists in a service module included in the new service requirement, the developer can directly import a target template corresponding to the target service from a template library by using a preset template import syntax, so that the multiplexing of the target template can be realized.
According to the template-based back-end code generation system, after the back-end codes corresponding to the business requirements are generated, the back-end codes corresponding to the business requirements are packaged into the templates which are correspondingly stored in the preset template library, so that developers can conveniently multiplex the back-end codes corresponding to the business requirements in the subsequent development process, and the development efficiency is improved.
Based on any of the above embodiments, there is provided a template-based backend code generation system, further including: and the template analysis module 4 is used for receiving a request of a user for the target service, acquiring the template content of a target template corresponding to the target service from the template library, acquiring a functional module contained in the template content, calling a corresponding analysis engine according to the functional module, analyzing the template content by using the analysis engine, and feeding back an analysis result to the user.
Specifically, on the basis of storing the target template corresponding to the target service in a preset template library, when a user initiates a request for the target service, the template analysis module 4 is used to receive the request of the user for the target service, and obtain the target template corresponding to the target service from the preset template library, so as to obtain the template content corresponding to the target template. The template content may be HTML, XML or JSON text, and may also include freemaker template code, which is not limited herein.
Further, in this embodiment, the template content corresponding to each template in the preset template library is written according to a unified service logic, where the unified service logic may be, for example: step one, processing request parameters and verifying user authority; step two, acquiring data from each data source; and step three, processing the data according to the service logic, organizing the data into a certain form and the like. Wherein the step corresponds to the realization of the initialized function; step two, the function of data acquisition is realized; and step three realizes the function of data processing. That is, each template content corresponds to a plurality of function modules, and separators can be set between the function modules in the programming process, so as to separate the function modules.
On the basis of the above technical solution, in this embodiment, the template parsing module 4 is used to obtain the functional modules included in the template content corresponding to the target service according to the separators in the template content, that is, the template content is divided into a plurality of functional modules according to specific functions. Different functional modules need different analysis engines to analyze the functional modules, so that the corresponding analysis engines are called for the obtained functional modules, the corresponding analysis engines are used for analyzing each functional module one by one, finally, the content of the whole template is analyzed, corresponding analysis results are obtained, and the analysis results are fed back to a user, namely, the user request is responded. The analysis engines are preset for each functional module and are pre-stored in the database, so that when different service requests are processed, the corresponding analysis engines can be called from the database for analysis for the same functional module, namely, the multiplexing of the analysis engines is realized.
According to the template-based back-end code generation system, when the request of a user for the target service is processed, the template content of the target template corresponding to the target service can be directly obtained from the template library without recompiling and releasing, so that the whole development period is effectively shortened; and meanwhile, the functional module contained in the template content is obtained, and the preset analysis engine is called correspondingly according to the functional module to analyze the template content, so that the multiplexing of the analysis engine is effectively realized, and the overall development efficiency is further improved.
Fig. 3 is a block diagram illustrating an apparatus of a template-based backend code generation method according to an embodiment of the present invention. Referring to fig. 3, the apparatus of the template-based backend code generation method includes: a processor (processor)31, a memory (memory)32, and a bus 33; wherein, the processor 31 and the memory 32 complete the communication with each other through the bus 33; the processor 31 is configured to call program instructions in the memory 32 to perform the methods provided by the above-mentioned method embodiments, for example, including: acquiring a service module contained in a service demand according to the service demand provided by a user, and inquiring a service template corresponding to the service module from a preset template library; and when the service template corresponding to the service module is inquired, importing the service template into a back-end code editing interface by using a preset template import grammar to generate a back-end code corresponding to the service requirement.
The present embodiment discloses a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the method provided by the above-mentioned method embodiments, for example, comprising: acquiring a service module contained in a service demand according to the service demand provided by a user, and inquiring a service template corresponding to the service module from a preset template library; and when the service template corresponding to the service module is inquired, importing the service template into a back-end code editing interface by using a preset template import grammar to generate a back-end code corresponding to the service requirement.
The present embodiments provide a non-transitory computer-readable storage medium storing computer instructions that cause the computer to perform the methods provided by the above method embodiments, for example, including: acquiring a service module contained in a service demand according to the service demand provided by a user, and inquiring a service template corresponding to the service module from a preset template library; and when the service template corresponding to the service module is inquired, importing the service template into a back-end code editing interface by using a preset template import grammar to generate a back-end code corresponding to the service requirement.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
The above-described embodiments of the device and the like of the template-based backend code generation method are merely illustrative, where the units described as separate components may or may not be physically separate, and the components displayed as the units may or may not be physical units, may be located in one place, or may also be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
In summary, the method and system for generating a backend code based on a template according to the present invention acquire a service module included in a service requirement according to the service requirement provided by a user, and query a service template corresponding to the service module from a preset template library; when the service template corresponding to the service module is inquired, the preset template import grammar is utilized to import the service template into the back-end code editing interface, and the back-end code corresponding to the service requirement can be generated. The method effectively avoids the code redundancy phenomenon existing in the back-end development through the reuse of the template, and improves the overall development efficiency to a certain extent; meanwhile, by importing the templates in the front-end template library, developers can write the back-end codes and test the back-end codes at the same time without recompiling and releasing, and the whole development period is effectively shortened.
Finally, the method of the present application is only a preferred embodiment and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (6)

1. A template-based back-end code generation method, comprising:
s1, acquiring a service module contained in the service requirement according to the service requirement provided by a user, and inquiring a service template corresponding to the service module from a preset template library;
s2, when the service template corresponding to the service module is inquired, importing the service template into a back end code editing interface by using a preset template import grammar to generate a back end code corresponding to the service requirement;
the step S2 is followed by:
s3, acquiring a target service corresponding to the service requirement, packaging a back end code corresponding to the service requirement into a target template corresponding to the target service, and storing the identifier of the target service and the target template in the template library in an associated manner;
the step S3 is followed by:
s4, receiving a request of a user for the target service, obtaining the template content of the target template corresponding to the target service from the template library, obtaining the functional module contained in the template content, calling a preset analysis engine according to the functional module, analyzing the template content by using the analysis engine, and feeding back the analysis result to the user.
2. The method according to claim 1, wherein the parsing the template content with the parsing engine in step S4 further comprises:
analyzing the template content by using a Freemarker engine to obtain a corresponding JSON array; and analyzing the JSON array by using the analysis engine, and calling a corresponding data source analyzer according to the data source type in the template content to analyze the JSON array to obtain an analysis result.
3. The method according to claim 1, wherein the step S1 of querying the service template corresponding to the service module from a preset template library further comprises:
acquiring identification information of the service module, inquiring a template identification which is the same as the identification information from a preset database according to the identification information, and acquiring a corresponding service template according to the template identification.
4. The method according to claim 1, wherein the step S2 further comprises: when the service template corresponding to the service module is not inquired, acquiring a service code edited by a programmer according to the service module, packaging the service code into the service template corresponding to the service module, and storing the identification information of the service module and the service template in the template library in an associated manner.
5. A template-based back-end code generation system, comprising:
the template query module is used for acquiring a service module contained in the service requirement according to the service requirement provided by a user and querying a service template corresponding to the service module from a preset template library;
the code generation module is used for importing the service template into a back-end code editing interface by utilizing a preset template import grammar when the service template corresponding to the service module is inquired, and generating a back-end code corresponding to the service requirement;
the encapsulation storage module is used for acquiring a target service corresponding to the service requirement, encapsulating a back-end code corresponding to the service requirement into a target template corresponding to the target service, and storing the identifier of the target service and the target template in the template library in an associated manner;
and the template analysis module is used for receiving a request of a user for the target service, acquiring the template content of a target template corresponding to the target service from the template library, acquiring a functional module contained in the template content, calling a corresponding analysis engine according to the functional module, analyzing the template content by using the analysis engine, and feeding back an analysis result to the user.
6. An apparatus of a template-based backend code generation method, comprising:
at least one processor; and
at least one memory communicatively coupled to the processor, wherein:
the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of any of claims 1 to 4.
CN201810214268.3A 2018-03-15 2018-03-15 Template-based back-end code generation method and system Active CN108228166B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810214268.3A CN108228166B (en) 2018-03-15 2018-03-15 Template-based back-end code generation method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810214268.3A CN108228166B (en) 2018-03-15 2018-03-15 Template-based back-end code generation method and system

Publications (2)

Publication Number Publication Date
CN108228166A CN108228166A (en) 2018-06-29
CN108228166B true CN108228166B (en) 2020-07-07

Family

ID=62658524

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810214268.3A Active CN108228166B (en) 2018-03-15 2018-03-15 Template-based back-end code generation method and system

Country Status (1)

Country Link
CN (1) CN108228166B (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109104360B (en) * 2018-09-19 2022-11-25 平安科技(深圳)有限公司 Mail sending method, mail sending system, computer equipment and storage medium
CN109522012A (en) * 2018-10-29 2019-03-26 珠海迎迎科技有限公司 A kind of real time workshop device and real time workshop method
CN109656549B (en) * 2018-11-30 2022-05-27 广州净松软件科技有限公司 Construction method and device of monitoring system, computer equipment and storage medium
CN111273942A (en) * 2018-12-04 2020-06-12 武汉斗鱼网络科技有限公司 Code generation method, storage medium, electronic device and system
CN109582302A (en) * 2018-12-05 2019-04-05 江苏风云科技服务有限公司 Establishment of item system and automation projects creation method
CN109800549A (en) * 2018-12-29 2019-05-24 北京奇安信科技有限公司 A kind of login process method and device based on general login module
CN112241285A (en) * 2019-07-16 2021-01-19 腾讯科技(深圳)有限公司 Configuration method, device and equipment of operation program
CN110489109A (en) * 2019-08-13 2019-11-22 上海乂学教育科技有限公司 The method and device of code reuse
CN110597508B (en) * 2019-08-14 2023-04-28 深圳赛安特技术服务有限公司 Interface dynamic configuration method, device and storage medium
CN111162977B (en) * 2019-12-20 2022-04-15 青岛聚好联科技有限公司 Method and device for accessing terminal of Internet of things to cloud service
CN111177558B (en) * 2019-12-30 2023-08-08 北京百度网讯科技有限公司 Channel service construction method and device
CN111563220A (en) * 2020-04-27 2020-08-21 平安国际智慧城市科技股份有限公司 Business website project construction method and device, computer equipment and storage medium
CN112528619A (en) * 2020-12-23 2021-03-19 微医云(杭州)控股有限公司 Page template file generation method and device, electronic equipment and storage medium
CN113467789A (en) * 2021-07-21 2021-10-01 山谷网安科技股份有限公司 Method for rapidly deploying functional module in OA software implementation process

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104965714A (en) * 2015-07-27 2015-10-07 广州杰赛科技股份有限公司 Code generation method and system of application software
CN107180338A (en) * 2017-05-22 2017-09-19 深圳市小牛在线互联网信息咨询有限公司 Business performs method, device, storage medium and computer equipment
CN107220036A (en) * 2016-03-22 2017-09-29 中兴通讯股份有限公司 A kind of visual development method and system of component and template
CN107256144A (en) * 2017-04-28 2017-10-17 努比亚技术有限公司 Front and back code automatic generation method, terminal and computer-readable recording medium
CN107678736A (en) * 2017-10-09 2018-02-09 用友网络科技股份有限公司 A kind of business Page Template shows method, system and computer installation
CN107766037A (en) * 2017-10-23 2018-03-06 齐琦 MVC frameworks based on PHP

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102426519B (en) * 2011-08-26 2014-03-26 北京邮电大学 Linked data-based multiplexing method of business process execution language (BPEL) templates and services, and system thereof
US9715372B2 (en) * 2013-03-13 2017-07-25 Microsoft Technology Licensing, Llc Executable guidance experiences based on implicitly generated guidance models
CN106777970B (en) * 2016-12-15 2018-12-07 北京锐软科技股份有限公司 A kind of integrated system and method for medical information system data template
CN106874388B (en) * 2017-01-11 2020-08-11 中科院微电子研究所昆山分所 Relational database-based heterogeneous system data cascade operation automatic construction method

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104965714A (en) * 2015-07-27 2015-10-07 广州杰赛科技股份有限公司 Code generation method and system of application software
CN107220036A (en) * 2016-03-22 2017-09-29 中兴通讯股份有限公司 A kind of visual development method and system of component and template
CN107256144A (en) * 2017-04-28 2017-10-17 努比亚技术有限公司 Front and back code automatic generation method, terminal and computer-readable recording medium
CN107180338A (en) * 2017-05-22 2017-09-19 深圳市小牛在线互联网信息咨询有限公司 Business performs method, device, storage medium and computer equipment
CN107678736A (en) * 2017-10-09 2018-02-09 用友网络科技股份有限公司 A kind of business Page Template shows method, system and computer installation
CN107766037A (en) * 2017-10-23 2018-03-06 齐琦 MVC frameworks based on PHP

Also Published As

Publication number Publication date
CN108228166A (en) 2018-06-29

Similar Documents

Publication Publication Date Title
CN108228166B (en) Template-based back-end code generation method and system
JP6755954B2 (en) Interface data presentation method and equipment
US10310828B2 (en) System and method for providing and executing a domain-specific language for cloud services infrastructure
US11537606B2 (en) Solution for implementing computing service based on structured query language statement
US20180137184A1 (en) Sql interceptor for use with third party data analytics packages
CN108369591B (en) System and method for caching and parameterizing IR
WO2022126983A1 (en) Electronic report file export method, apparatus and device, and storage medium
WO2017156916A1 (en) Data access method and device
CN110673839B (en) Distributed tool configuration construction generation method and system
CN111026634A (en) Interface automation test system, method, device and storage medium
US20150127706A1 (en) Systems and Methods for Data Extraction
WO2020052582A1 (en) Method and apparatus for intelligently invoking dubbo remote service, and device and medium
US20210109848A1 (en) System and method for implementing an automated regression testing module
CN102426612A (en) Condition object query method and system
CN115905740A (en) Multi-data source service engine interface interconnection method
CN115469881A (en) Configuration publishing and calling method and system for low-code platform service function
CN113238740A (en) Code generation method, code generation device, storage medium, and electronic apparatus
CN110825764B (en) SQL script generation method, system, storage medium and processor
Cesari et al. A tool for rapid development of WS-BPEL applications
CN113608955A (en) Log recording method, device, equipment and storage medium
CN111881043A (en) Page testing method and device, storage medium and processor
CN106648610B (en) Method and device for remotely calling and responding functional interface
CN114047914A (en) Interface configuration method and device, electronic equipment and computer readable storage medium
CN111625465A (en) Program generation method, device and system and electronic equipment
CN106446024B (en) Method and device for automatically generating data model

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 100085 Floor 102-1, Building No. 35, West Second Banner Road, Haidian District, Beijing

Applicant after: Seashell Housing (Beijing) Technology Co., Ltd.

Address before: 100085 Floor 102-1, Building No. 35, West Second Banner Road, Haidian District, Beijing

Applicant before: Chain home network (Beijing) Technology Co., Ltd.

GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20200828

Address after: No.3 building, No.101 Beicun Road, Fengxian District, Shanghai

Patentee after: Shanghai liankun Technology Co., Ltd

Address before: 100085 Floor 102-1, Building No. 35, West Second Banner Road, Haidian District, Beijing

Patentee before: Seashell Housing (Beijing) Technology Co.,Ltd.