CN108228166A - A kind of back-end code generation method and system based on template - Google Patents

A kind of back-end code generation method and system based on template Download PDF

Info

Publication number
CN108228166A
CN108228166A CN201810214268.3A CN201810214268A CN108228166A CN 108228166 A CN108228166 A CN 108228166A CN 201810214268 A CN201810214268 A CN 201810214268A CN 108228166 A CN108228166 A CN 108228166A
Authority
CN
China
Prior art keywords
template
business
service
module
end code
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.)
Granted
Application number
CN201810214268.3A
Other languages
Chinese (zh)
Other versions
CN108228166B (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
Lianjia 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 Lianjia Beijing Technology Co Ltd filed Critical Lianjia 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

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 present invention provides a kind of back-end code generation method and system based on template, and wherein method includes:The business demand provided according to user obtains the business module that business demand includes, the corresponding service template of inquiry business module from pre-set template library;When inquiring the corresponding service template of business module, import grammer using preset template and service template is imported into back-end code editing interface, the corresponding back-end code of generation business demand.This method and system effectively prevent the code redundancy phenomenon in the presence of rear end is developed by the multiplexing of template, improve whole development efficiency to a certain extent;Simultaneously by importing the template in front-end template library, be conducive to developer and tested while back-end code is write, without recompilating and issuing, effectively shorten the whole development cycle.

Description

A kind of back-end code generation method and system based on template
Technical field
The present invention relates to field of computer technology, more particularly, to a kind of back-end code generation method based on template And system.
Background technology
In the exploitation of existing internet site, code is divided into view layer, number usually using MVC frames when rear end is developed According to layer and key-course, to realize that it is decoupling between data processing that data are presented.In actual development, service logic would generally It is merged with key-course, data Layer, and the phenomenon that generally existing code redundancy.
For example, the most of request processing flows in General System website are:Processing required parameter->Verification user right-> Acquisition data->According to business logic processing data and be organized into certain forms->Result with certain forms is returned, is included in total 5 patterns.Each requested service can regard combination one or more in these patterns as.However, current procedure person's needle Identical pattern is both needed to repeat to write code in the code for writing different requested services, code redundancy phenomenon is serious.
The phenomenon that code redundancy in the presence of being developed for above-mentioned rear end, although at present can be by increasing more points Layer refines identical structural code, for example, increase Bizness layers, Service layers, DAO layers, but over time, Different developers intervene, and the boundary between these levels can be obscured increasingly.Moreover, the code spice of different developers is not Unanimously, learning cost and maintenance cost is caused to increase.
In addition, in being developed in existing rear end, code change caused by the modification of each service logic is required for recompilating, Publication reaches the standard grade and can just come into force, and the entire development cycle is caused to extend.
Invention content
The present invention in order to the code redundancy phenomenon and development efficiency that overcome the exploitation of rear end in the prior art existing are low and The problem of development cycle is long provides a kind of back-end code generation method and system based on template.
On the one hand, the present invention provides a kind of back-end code generation method based on template, including:
S1, the business demand provided according to user obtain the business module that the business demand includes, from pre-set The corresponding service template of the business module is inquired in template library;
S2, when inquiring the corresponding service template of the business module, preset template is utilized to import grammer will The service template imports back-end code editing interface, generates the corresponding back-end code of the business demand.
Preferably, it is further included after the step S2:
S3 obtains the corresponding target service of the business demand, and the corresponding back-end code of the business demand is packaged into The corresponding target template of the target service, by the mark of the target service and the target template associated storage in the mould In plate library.
Preferably, it is further included after the step S3:
S4 receives request of the user to the target service, it is corresponding that the target service is obtained from the template library The template content of target template obtains the function module included in the template content, is corresponded to and called according to the function module Pre-set analytics engine parses the template content, and analysis result is fed back to the use using the analytics engine Family.
Preferably, the template content is parsed using the analytics engine described in step S4 to further comprise:
The template content is parsed using Freemarker engines, obtains corresponding JSON arrays;Drawn using the parsing The parsing JSON arrays are held up, and the data source types in the template content call corresponding data source parser to institute It states JSON arrays to be parsed, obtains analysis result.
Preferably, the corresponding service template of the business module is inquired described in step S1 from pre-set template library Further comprise:
Obtain the identification information of the business module, inquired from pre-set database according to the identification information with The identical template identification of the identification information obtains corresponding service template according to the template identification.
Preferably, the step S2 is further included:When not inquiring the corresponding service template of the business module, journey is obtained The service code is packaged into the corresponding business of the business module by sequence person according to the service code of the business module editor Template, by the identification information of the business module and the service template associated storage in the template library.
On the one hand, the present invention provides a kind of back-end code generation system based on template, including:
Template query module, the business demand for being provided according to user obtain the business mould that the business demand includes Block inquires the corresponding service template of the business module from pre-set template library;
Code generation module, for when inquiring the corresponding service template of the business module, utilization to be preset Template imports grammer and the service template is imported back-end code editing interface, generates the business demand corresponding rear end generation Code.
Preferably, it further includes:
Encapsulation storage module, it is for obtaining the corresponding target service of the business demand, the business demand is corresponding Back-end code is packaged into the corresponding target template of the target service, and the mark of the target service and the target template are closed Connection is stored in the template library.
Preferably, it further includes:
Template parsing module, for receiving request of the user to the target service, from the template library described in acquisition The template content of the corresponding target template of target service, obtains the function module included in the template content, according to the work( Energy module calls corresponding analytics engine, and the template content is parsed, and analysis result is fed back to using the analytics engine The user.
On the one hand, the present invention provides a kind of equipment of the back-end code generation method based on template, including:
At least one processor;And
At least one processor being connect with the processor communication, wherein:
The memory is stored with the program instruction that can be performed by the processor, and the processor calls described program to refer to It enables and is able to carry out any of the above-described method.
A kind of back-end code generation method and system based on template provided by the invention, the business need provided according to user It asks and obtains the business module that business demand includes, the corresponding service template of inquiry business module from pre-set template library; When inquiring the corresponding service template of business module, import grammer using preset template and service template is imported into rear end Code Edit interface, you can the corresponding back-end code of generation business demand.After this method is effectively prevented by the multiplexing of template Code redundancy phenomenon in the presence of the exploitation of end, improves whole development efficiency to a certain extent;Simultaneously by importing front end Template in template library is conducive to developer and is tested while back-end code is write, without recompilating and issuing, Effectively shorten the whole development cycle.
Description of the drawings
Fig. 1 is a kind of overall flow schematic diagram of back-end code generation method based on template of the embodiment of the present invention;
Fig. 2 is that a kind of back-end code based on template of the embodiment of the present invention generates the overall structure diagram of system;
Fig. 3 is a kind of structural framing signal of the equipment of back-end code generation method based on template of the embodiment of the present invention Figure.
Specific embodiment
With reference to the accompanying drawings and examples, the specific embodiment of the present invention is described in further detail.Implement below Example is used to illustrate the present invention, but be not limited to the scope of the present invention.
Fig. 1 is a kind of overall flow schematic diagram of back-end code generation method based on template of the embodiment of the present invention, such as Shown in Fig. 1, the present invention provides a kind of back-end code generation method based on template, including:
S1, the business demand provided according to user obtain the business module that the business demand includes, from pre-set The corresponding service template of the business module is inquired in template library;
S2, when inquiring the corresponding service template of the business module, preset template is utilized to import grammer will The service template imports back-end code editing interface, generates the corresponding back-end code of the business demand.
Specifically, during system development, developer obtains the business demand that user provides, and developer is by industry In business demand input system, system analyzes the business module that business demand includes according to business demand, then from pre-set The corresponding service template of inquiry business module in template library.Wherein, pre-set template library be front end data library, developer In history development process, corresponding back-end code is write, and back-end code is packaged into business mould for different business demand Plate is stored in pre-set template library.
Further, it when inquiring the corresponding service template of business module in pre-set template library, then utilizes Preset template imports grammer and the service template inquired is imported back-end code editing interface, i.e., need not be directed to above-mentioned industry Business module rewrites code again, and only needs to write the corresponding mould of above-mentioned business module using preset template importing grammer Plate imports code, you can the corresponding back-end code of generation business demand.Wherein, template, which imports grammer, is set in advance by developer Fixed, the specific manifestation form that template imports grammer can be configured according to actual demand, be not specifically limited herein.Example Such as, the specific manifestation form for the grammer that template imports can be:
Wherein, type represents the type of template;Name represents the title of template, passes through the type of template and the title of template Unique mark is carried out to template.
Above method step in order to better understand is now illustrated with following examples:
For example, in house property system, the business demand that user provides is:The newly-increased source of houses band amount of seeing is sent out in the form of mail User is given, can analyze the business demand for the business demand system includes two business modules, respectively:(1) it obtains Take the newly-increased source of houses band amount of seeing;(2) user is sent in the form of mail.On this basis, according to above-mentioned two business module, from The corresponding service template of above-mentioned two business module is inquired in pre-set template library.If it was realized in history development process Above-mentioned two business module then then preserves the corresponding service template of above-mentioned two business module in pre-set template library. When inquiring the corresponding service template of above-mentioned two business module, then write using preset template grammar and import generation Code, so as to which the corresponding service template of above-mentioned two business module is imported back-end code editing interface, you can be organized into above-mentioned industry The corresponding back-end code of business demand.
A kind of back-end code generation method based on template provided by the invention is obtained according to the business demand that user provides The business module that business demand includes, the corresponding service template of inquiry business module from pre-set template library;Work as inquiry During service template corresponding to business module, import grammer using preset template and service template is imported into back-end code volume Editing interface, you can the corresponding back-end code of generation business demand.This method effectively prevents rear end by the multiplexing of template and develops In the presence of code redundancy phenomenon, improve whole development efficiency to a certain extent;Simultaneously by importing front-end template library In template, be conducive to developer and tested while back-end code is write, without recompilating and issuing, effectively contract The short whole development cycle.
Based on any of the above-described embodiment, a kind of back-end code generation method based on template is provided, after the step S2 It further includes:S3 obtains the corresponding target service of the business demand, and the corresponding back-end code of the business demand is packaged into institute The corresponding target template of target service is stated, by the mark of the target service and the target template associated storage in the template In library.
Specifically, based on the above technical solution, after the corresponding back-end code of above-mentioned business demand is generated, For the ease of being subsequently multiplexed to the corresponding back-end code of the business demand, in the present embodiment, determined according to the business demand The corresponding target service of the business demand, and obtain the corresponding service identification of target service;It is simultaneously that the business demand is corresponding Back-end code is packaged into the corresponding target template of target service, and most the mark of target service and target template associated storage exist at last In pre-set template library.
Further, in subsequent development process, when developer need to write back-end code for new business demand When, if can be directly using advance there are above-mentioned target service, developer in the business module that new business demand includes The template of setting imports grammer and the corresponding target template of above-mentioned target service is imported from template library, you can realizes above-mentioned target mould The multiplexing of plate.
A kind of back-end code generation method based on template provided by the invention, in generation business demand corresponding rear end generation After code, the corresponding back-end code of business demand is packaged into template correspondence and is stored in pre-set template library, convenient for exploitation Personnel are multiplexed the corresponding back-end code of the business demand during subsequent development, are conducive to improve development efficiency.
Based on any of the above-described embodiment, a kind of back-end code generation method based on template is provided, after the step S3 It further includes:S4 receives request of the user to the target service, the corresponding mesh of the target service is obtained from the template library The template content of template is marked, obtains the function module included in the template content, is corresponded to and is called in advance according to the function module The analytics engine first set parses the template content, and analysis result is fed back to the user using the analytics engine.
Specifically, on the basis of the corresponding target template of above-mentioned target service is stored in pre-set template library, When user initiates request for above-mentioned target service, system receives request of the user to target service, and from pre-set The corresponding target template of target service is obtained in template library, and then obtains the corresponding template content of target template.Wherein in template It can be HTML or XML or JSON texts to hold, and can also include Freemarker masterplate codes, be not specifically limited herein.
Further, in the present embodiment, the corresponding template content of each template in pre-set template library be by It is write according to uniform traffic logic, wherein uniform traffic logic for example can be:Step 1: processing required parameter and verification User right;Step 2: obtain data from each data source;Step 3: it according to business logic processing data and is organized into certain Form etc..Wherein step 1 correspondence is accomplished that the function of initialization;Step 2 is accomplished that the function of data acquisition;Step 3 It is accomplished that the function of data processing.I.e. each template content corresponds to multiple function modules, and can be each in compiling procedure Separator is set between a function module, in order to be separated to each function module.
Based on the above technical solution, in the present embodiment, according to the separation in the corresponding template content of target service Symbol obtains function module wherein included, i.e., template content being realized, cutting is multiple function modules according to specific function.No Same function module needs different analytics engines to parse it, therefore, for the function module calling pair of above-mentioned acquisition The analytics engine answered, recycles corresponding analytics engine to parse each function module one by one, finally realizes entire template The parsing of content obtains corresponding analysis result, and analysis result is fed back to user, i.e., the request of user is responded. Wherein, analytics engine is pre-set for each function module, and is prestored in the database, so, in processing not With service request when, for identical function module, corresponding analytics engine can be called to be parsed from database, i.e., Realize the multiplexing of analytics engine.
A kind of back-end code generation method based on template provided by the invention, in request of the processing user to target service When, the template content of the corresponding target template of target service can be obtained directly from template library, without recompilating and issuing, Effectively shorten the whole development cycle;The function module included in template content is obtained simultaneously, is corresponded to and adjusted according to function module Template content is parsed with pre-set analytics engine, the multiplexing of analytics engine is effectively realized, further improves Whole development efficiency.
Based on any of the above-described embodiment, a kind of back-end code generation method based on template is provided, it is sharp described in step S4 The template content is parsed with the analytics engine to further comprise:The template content is parsed using Freemarker engines, Obtain corresponding JSON arrays;The JSON arrays, and the number in the template content are parsed using the analytics engine Corresponding data source parser is called to parse the JSON arrays according to Source Type, obtain analysis result.
Specifically, it is above-mentioned using analytics engine parsing template content the specific implementation process is as follows:
Preliminary Analysis is carried out to template content first with Freemarker engines, the spy of numerical value will be represented in template content Different character resolution obtains the corresponding JSON arrays of template content into specific numerical value.On this basis, above-mentioned acquisition is utilized Each function module corresponding analytics engine parsing JSON arrays, in resolving, while obtain in template content and include Data source types, and corresponding data source parser is called to carry out each element in JSON arrays according to data source types Parsing, finally obtains analysis result, while can store analysis result in the mapping table in the form of key-value pair.In addition, In other embodiment, when carrying out Preliminary Analysis to template content, other than calling Freemarker engines, it may call upon Velocity engines can be configured according to actual demand, be not specifically limited herein.
A kind of back-end code generation method based on template provided by the invention, in request of the processing user to target service When, the template content of the corresponding target template of target service is obtained from template library, and tentatively solve using Freemarker engines Template content is analysed, obtains corresponding JSON arrays, JSON arrays, and the data in template content are parsed using analytics engine Source Type calls corresponding data source parser to parse JSON arrays, finally obtains analysis result, effectively realizes pair The parsing of template content, and the multiplexing of analytics engine is effectively realized, further improve whole development efficiency.
Based on any of the above-described embodiment, provide a kind of back-end code generation method based on template, described in step S1 from The corresponding service template of the business module is inquired in pre-set template library to further comprise:Obtain the business module Identification information inquires the template mark identical with the identification information according to the identification information from pre-set database Know, corresponding service template is obtained according to the template identification.
Specifically, in pre-set template library, for each template wherein stored, each template of associated storage Corresponding template identification, template identification includes template type and template name, by template type and template name to each mould Plate carries out unique mark.On this basis, when need from pre-stored database the corresponding business mould of inquiry business module During plate, detailed process is as follows:The identification information of business module is obtained first, further according to identification information from pre-set database The middle inquiry template identification identical with identification information, corresponding service template is obtained further according to template identification.
In addition, in pre-set template library, it, can be with each mould of associated storage for each template wherein stored Corresponding template general introduction of plate etc., can be configured according to actual demand, be not specifically limited herein.
A kind of back-end code generation method based on template provided by the invention, to each in pre-set template library Module carries out unique mark, in the corresponding service template of inquiry business module, can be inquired from pre-set database The template identification identical with the identification information of business module obtains corresponding service template further according to template identification, effectively realizes The multiplexing of template avoids the code redundancy phenomenon in the presence of the exploitation of rear end, improves whole exploitation to a certain extent Efficiency.
Based on any of the above-described embodiment, a kind of back-end code generation method based on template is provided, the step S2 is also wrapped It includes:When not inquiring the corresponding service template of the business module, industry of the programmer according to the business module editor is obtained Business code, the corresponding service template of the business module is packaged by the service code, and the mark of the business module is believed Breath and the service template associated storage are in the template library.
Specifically, the business demand provided according to user analyzes the business module that business demand includes, then is set from advance The corresponding service template of inquiry business module in the template library put, when not inquiring the corresponding service template of business module, journey Sequence person then needs to write corresponding service code according to business module.On this basis, system acquisition procedure person is according to business module The service code of editor, and service code is packaged into the corresponding service template of business module, and the mark of business module is believed Breath is used as template identification, and by template identification and service template associated storage in pre-set template library, so as to be conducive to Subsequently service template is multiplexed.
For example, common service template includes initialization template, data acquisition template and data processing template, and certain industry Business demand may include following business module:It needs to export data processed result with mail he.If at this time in template library not There are the corresponding service templates of above-mentioned business module, then programmer need to write the corresponding service code of above-mentioned business module, and incite somebody to action Service code is packaged into the corresponding service template of above-mentioned business module, and the identification information of above-mentioned business module and service template are closed Connection is stored in template library.
A kind of back-end code generation method based on template provided by the invention is analyzed according to the business demand that user provides Go out the business module that business demand includes, then the corresponding service template of inquiry business module from pre-set template library, when When not inquiring the corresponding service template of business module, service code of the programmer according to business module editor is obtained, by business Code wrap is into the corresponding service template of business module, by the identification information of business module and service template associated storage in template In library, be conducive to subsequently realize the multiplexing of template, effectively prevent the code redundancy phenomenon in the presence of the exploitation of rear end, certain journey Whole development efficiency is improved on degree;Simultaneously by the way that template is stored in front-end template library, be conducive to developer and compiling It is tested while writing back-end code, without recompilating and issuing, effectively shortens the whole development cycle.
Fig. 2 is that a kind of back-end code based on template of the embodiment of the present invention generates the overall structure diagram of system, such as Shown in Fig. 2, the present invention provides a kind of back-end code generation system based on template, including:
Template query module 1, the business demand for being provided according to user obtain the business mould that the business demand includes Block inquires the corresponding service template of the business module from pre-set template library;
Code generation module 2, for when inquiring the corresponding service template of the business module, utilization to be preset Template imports grammer and the service template is imported back-end code editing interface, generates the business demand corresponding rear end generation Code.
Specifically, the present invention provides a kind of back-end code generation system based on template, including template query module 1 and generation Code generation module 2 realizes the back-end code generation method based on template in any of the above-described embodiment by each module, specific real It is now as follows:
During system development, developer obtains the business demand that user provides, and developer is by business demand Input module enquiry module 1, module polls module 1 analyze the business module that business demand includes according to business demand, then from The corresponding service template of inquiry business module in pre-set template library.Wherein, pre-set template library is front end data Library, developer write corresponding back-end code, and back-end code is sealed in history development process, for different business demand Service template is dressed up to be stored in pre-set template library.
Further, when template query module 1 inquires the corresponding business of business module in pre-set template library During template, code generation module 2 then imports grammer using preset template and the service template inquired is imported rear end generation Code editing interface that is, without rewriting code again for above-mentioned business module, and only needs to import using preset template Grammer writes the corresponding template of above-mentioned business module and imports code, you can the corresponding back-end code of generation business demand.Wherein, mould Plate import grammer be it is preset by developer, template import grammer specific manifestation form can according to actual demand into Row setting, is not specifically limited herein.For example, the specific manifestation form for the grammer that template imports can be:
Wherein, type represents the type of template;Name represents the title of template, passes through the type of template and the title of template Unique mark is carried out to template.
A kind of back-end code generation system based on template provided by the invention, obtains according to the business demand that user provides The business module that business demand includes, the corresponding service template of inquiry business module from pre-set template library;Work as inquiry During service template corresponding to business module, import grammer using preset template and service template is imported into back-end code volume Editing interface, you can the corresponding back-end code of generation business demand.This method effectively prevents rear end by the multiplexing of template and develops In the presence of code redundancy phenomenon, improve whole development efficiency to a certain extent;Simultaneously by importing front-end template library In template, be conducive to developer and tested while back-end code is write, without recompilating and issuing, effectively contract The short whole development cycle.
Based on any of the above-described embodiment, a kind of back-end code generation system based on template is provided, is further included:Sealed storage The corresponding back-end code of the business demand for obtaining the corresponding target service of the business demand, is packaged into institute by module 3 The corresponding target template of target service is stated, by the mark of the target service and the target template associated storage in the template In library.
Specifically, based on the above technical solution, to generate above-mentioned business demand in code generation module 2 corresponding After back-end code, for the ease of being subsequently multiplexed to the corresponding back-end code of the business demand, in the present embodiment, envelope is utilized Dress memory module 3 determines the corresponding target service of the business demand, and obtain the corresponding industry of target service according to the business demand Business mark;The corresponding back-end code of the business demand is packaged into the corresponding target template of target service simultaneously, most target at last The mark and target template associated storage of business are in pre-set template library.
Further, in subsequent development process, when developer need to write back-end code for new business demand When, if can be directly using advance there are above-mentioned target service, developer in the business module that new business demand includes The template of setting imports grammer and the corresponding target template of above-mentioned target service is imported from template library, you can realizes above-mentioned target mould The multiplexing of plate.
A kind of back-end code generation system based on template provided by the invention, in generation business demand corresponding rear end generation After code, the corresponding back-end code of business demand is packaged into template correspondence and is stored in pre-set template library, convenient for exploitation Personnel are multiplexed the corresponding back-end code of the business demand during subsequent development, are conducive to improve development efficiency.
Based on any of the above-described embodiment, a kind of back-end code generation system based on template is provided, is further included:Template parses Module 4 for receiving request of the user to the target service, obtains the corresponding mesh of the target service from the template library The template content of template is marked, obtains the function module included in the template content, is called according to the function module corresponding Analytics engine parses the template content, and analysis result is fed back to the user using the analytics engine.
Specifically, on the basis of the corresponding target template of above-mentioned target service is stored in pre-set template library, When user initiates request for above-mentioned target service, request of the user to target service is received using template parsing module 4, and The corresponding target template of target service is obtained from pre-set template library, and then is obtained in the corresponding template of target template Hold.Wherein template content can be HTML or XML or JSON texts, can also include Freemarker masterplate codes, herein not It is specifically limited.
Further, in the present embodiment, the corresponding template content of each template in pre-set template library be by It is write according to uniform traffic logic, wherein uniform traffic logic for example can be:Step 1: processing required parameter and verification User right;Step 2: obtain data from each data source;Step 3: it according to business logic processing data and is organized into certain Form etc..Wherein step 1 correspondence is accomplished that the function of initialization;Step 2 is accomplished that the function of data acquisition;Step 3 It is accomplished that the function of data processing.I.e. each template content corresponds to multiple function modules, and can be each in compiling procedure Separator is set between a function module, in order to be separated to each function module.
Based on the above technical solution, it is corresponding according to target service using template parsing module 4 in the present embodiment Separator in template content obtains function module wherein included, i.e., template content being realized, cutting is according to specific function Multiple function modules.Different function modules needs different analytics engines to parse it, therefore, for above-mentioned acquisition Function module calls corresponding analytics engine, corresponding analytics engine is recycled to parse each function module one by one, most The parsing of entire template content is realized eventually, obtains corresponding analysis result, and analysis result is fed back into user, i.e., to user's Request is responded.Wherein, analytics engine is pre-set for each function module, and is prestored in the database, So when handling different service requests, for identical function module, corresponding parsing can be called to draw from database It holds up and is parsed, that is, realize the multiplexing of analytics engine.
A kind of back-end code generation system based on template provided by the invention, in request of the processing user to target service When, the template content of the corresponding target template of target service can be obtained directly from template library, without recompilating and issuing, Effectively shorten the whole development cycle;The function module included in template content is obtained simultaneously, is corresponded to and adjusted according to function module Template content is parsed with pre-set analytics engine, the multiplexing of analytics engine is effectively realized, further improves Whole development efficiency.
Fig. 3 shows a kind of structure diagram of the equipment of back-end code generation method based on template of the embodiment of the present invention. Reference Fig. 3, the equipment of the back-end code generation method based on template, including:Processor (processor) 31, memory (memory) 32 and bus 33;Wherein, the processor 31 and memory 32 complete mutual communication by the bus 33; The processor 31 is used to call the program instruction in the memory 32, to perform the side that above-mentioned each method embodiment is provided Method, such as including:The business demand provided according to user obtains the business module that business demand includes, from pre-set template The corresponding service template of inquiry business module in library;When inquiring the corresponding service template of business module, using presetting Template import grammer service template imported into back-end code editing interface, the corresponding back-end code of generation business demand.
The present embodiment discloses a kind of computer program product, and the computer program product includes being stored in non-transient calculating Computer program on machine readable storage medium storing program for executing, the computer program include program instruction, when described program instruction is calculated When machine performs, computer is able to carry out the method that above-mentioned each method embodiment is provided, such as including:The industry provided according to user Business demand obtains the business module that business demand includes, the corresponding business mould of inquiry business module from pre-set template library Plate;When inquiring the corresponding service template of business module, import grammer using preset template and import service template Back-end code editing interface, the corresponding back-end code of generation business demand.
The present embodiment provides a kind of non-transient computer readable storage medium storing program for executing, the non-transient computer readable storage medium storing program for executing Computer instruction is stored, the computer instruction makes the computer perform the method that above-mentioned each method embodiment is provided, example Such as include:The business demand provided according to user obtains the business module that business demand includes, from pre-set template library The corresponding service template of inquiry business module;When inquiring the corresponding service template of business module, preset mould is utilized Plate imports grammer and service template is imported back-end code editing interface, the corresponding back-end code of generation business demand.
One of ordinary skill in the art will appreciate that:Realizing all or part of step of above method embodiment can pass through The relevant hardware of program instruction is completed, and aforementioned program can be stored in a computer read/write memory medium, the program When being executed, step including the steps of the foregoing method embodiments is performed;And aforementioned storage medium includes:ROM, RAM, magnetic disc or light The various media that can store program code such as disk.
The embodiments such as the equipment of back-end code generation method based on template described above are only schematical, Described in the unit that illustrates as separating component may or may not be physically separate, to be shown as unit portion Part may or may not be physical unit, you can be located at a place or can also be distributed to multiple network lists In member.Some or all of module therein can be selected according to the actual needs to realize the purpose of this embodiment scheme.This Field those of ordinary skill is not in the case where paying performing creative labour, you can to understand and implement.
Through the above description of the embodiments, those skilled in the art can be understood that each embodiment can It is realized by the mode of software plus required general hardware platform, naturally it is also possible to pass through hardware.Based on such understanding, on Technical solution is stated substantially in other words to embody the part that the prior art contributes in the form of software product, it should Computer software product can store in a computer-readable storage medium, such as ROM/RAM, magnetic disc, CD, including several fingers It enables and (can be personal computer, server or the network equipment etc.) so that computer equipment is used to perform each implementation Method described in certain parts of example or embodiment.
Summary, a kind of back-end code generation method and system based on template provided by the invention, carries according to user The business demand of confession obtains the business module that business demand includes, and inquiry business module is corresponding from pre-set template library Service template;When inquiring the corresponding service template of business module, grammer is imported by business mould using preset template Plate imports back-end code editing interface, you can the corresponding back-end code of generation business demand.This method is multiplexed with by template Effect avoids the code redundancy phenomenon in the presence of the exploitation of rear end, improves whole development efficiency to a certain extent;Lead to simultaneously The template imported in front-end template library is crossed, is conducive to developer and is tested while back-end code is write, without again Compiling and publication, effectively shorten the whole development cycle.
Finally, the present processes are only preferable embodiment, are not intended to limit the scope of the present invention.It is all Within the spirit and principles in the present invention, any modification, equivalent replacement, improvement and so on should be included in the protection of the present invention Within the scope of.

Claims (10)

1. a kind of back-end code generation method based on template, which is characterized in that including:
S1, the business demand provided according to user obtains the business module that the business demand includes, from pre-set template The corresponding service template of the business module is inquired in library;
S2, when inquiring the corresponding service template of the business module, using preset template import grammer will described in Service template imports back-end code editing interface, generates the corresponding back-end code of the business demand.
2. it according to the method described in claim 1, it is characterized in that, is further included after the step S2:
S3 obtains the corresponding target service of the business demand, the corresponding back-end code of the business demand is packaged into described The corresponding target template of target service, by the mark of the target service and the target template associated storage in the template library In.
3. it according to the method described in claim 2, it is characterized in that, is further included after the step S3:
S4 receives request of the user to the target service, the corresponding target of the target service is obtained from the template library The template content of template obtains the function module included in the template content, is corresponded to and is called in advance according to the function module The analytics engine of setting parses the template content, and analysis result is fed back to the user using the analytics engine.
4. according to the method described in claim 3, it is characterized in that, using described in analytics engine parsing described in step S4 Template content further comprises:
The template content is parsed using Freemarker engines, obtains corresponding JSON arrays;Utilize the analytics engine solution The JSON arrays are analysed, and the data source types in the template content call corresponding data source parser to described JSON arrays are parsed, and obtain analysis result.
5. it according to the method described in claim 1, it is characterized in that, is inquired from pre-set template library described in step S1 The corresponding service template of the business module further comprises:
Obtain the identification information of the business module, inquired from pre-set database according to the identification information with it is described The identical template identification of identification information obtains corresponding service template according to the template identification.
6. according to the method described in claim 1, it is characterized in that, the step S2 is further included:When not inquiring the business During the corresponding service template of module, service code of the programmer according to the business module editor is obtained, by the service code The corresponding service template of the business module is packaged into, the identification information of the business module with the service template is associated with and is deposited Storage is in the template library.
7. a kind of back-end code generation system based on template, which is characterized in that including:
Template query module, the business demand for being provided according to user obtain the business module that the business demand includes, from The corresponding service template of the business module is inquired in pre-set template library;
Code generation module, for when inquiring the corresponding service template of the business module, utilizing preset template It imports grammer and the service template is imported into back-end code editing interface, generate the corresponding back-end code of the business demand.
8. system according to claim 7, which is characterized in that further include:
Encapsulation storage module, for obtaining the corresponding target service of the business demand, by the corresponding rear end of the business demand The mark of the target service with the target template is associated with and deposits into the corresponding target template of the target service by code wrap Storage is in the template library.
9. system according to claim 8, which is characterized in that further include:
Template parsing module for receiving request of the user to the target service, obtains the target from the template library The template content of the corresponding target template of business, obtains the function module included in the template content, according to the function mould Block calls corresponding analytics engine, and the template content is parsed using the analytics engine, and analysis result is fed back to described User.
10. a kind of equipment of the back-end code generation method based on template, which is characterized in that including:
At least one processor;And
At least one processor being connect with the processor communication, wherein:
The memory is stored with the program instruction that can be performed by the processor, and the processor calls described program instruction energy Enough methods performed as described in claim 1 to 6 is any.
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 true CN108228166A (en) 2018-06-29
CN108228166B 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)

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109104360A (en) * 2018-09-19 2018-12-28 平安科技(深圳)有限公司 E-mail sending method, 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
CN109582302A (en) * 2018-12-05 2019-04-05 江苏风云科技服务有限公司 Establishment of item system and automation projects creation method
CN109656549A (en) * 2018-11-30 2019-04-19 广州净松软件科技有限公司 Construction method, device, computer equipment and the storage medium of observation system
CN109800549A (en) * 2018-12-29 2019-05-24 北京奇安信科技有限公司 A kind of login process method and device based on general login module
CN110489109A (en) * 2019-08-13 2019-11-22 上海乂学教育科技有限公司 The method and device of code reuse
CN110597508A (en) * 2019-08-14 2019-12-20 平安国际智慧城市科技股份有限公司 Interface dynamic configuration method, device and storage medium
CN111162977A (en) * 2019-12-20 2020-05-15 青岛聚好联科技有限公司 Method and device for accessing terminal of Internet of things to cloud service
CN111177558A (en) * 2019-12-30 2020-05-19 北京百度网讯科技有限公司 Channel service construction method and device
CN111273942A (en) * 2018-12-04 2020-06-12 武汉斗鱼网络科技有限公司 Code generation method, storage medium, electronic device and system
CN112241285A (en) * 2019-07-16 2021-01-19 腾讯科技(深圳)有限公司 Configuration method, device and equipment of operation program
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
WO2021217911A1 (en) * 2020-04-27 2021-11-04 平安国际智慧城市科技股份有限公司 Method and apparatus for constructing service website project, and computer device and storage medium

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102426519A (en) * 2011-08-26 2012-04-25 北京邮电大学 Linked data-based multiplexing method of business process execution language (BPEL) templates and services and system thereof
CN104965714A (en) * 2015-07-27 2015-10-07 广州杰赛科技股份有限公司 Code generation method and system of application software
CN106777970A (en) * 2016-12-15 2017-05-31 北京锐软科技股份有限公司 The integrated system and method for a kind of medical information system data template
CN106874388A (en) * 2017-01-11 2017-06-20 中科院微电子研究所昆山分所 A kind of heterogeneous system data cascade operation method for auto constructing based on relevant database
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
US20170300305A1 (en) * 2013-03-13 2017-10-19 Microsoft Technology Licensing, Llc Executable guidance experiences based on implicitly generated guidance models
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

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102426519A (en) * 2011-08-26 2012-04-25 北京邮电大学 Linked data-based multiplexing method of business process execution language (BPEL) templates and services and system thereof
US20170300305A1 (en) * 2013-03-13 2017-10-19 Microsoft Technology Licensing, Llc Executable guidance experiences based on implicitly generated guidance models
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
CN106777970A (en) * 2016-12-15 2017-05-31 北京锐软科技股份有限公司 The integrated system and method for a kind of medical information system data template
CN106874388A (en) * 2017-01-11 2017-06-20 中科院微电子研究所昆山分所 A kind of heterogeneous system data cascade operation method for auto constructing based on relevant database
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

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
ALAIN TAMAYO,CARLOS GRANELL,LAURA DÍAZ等: "Personalised code generation from large schema sets for geospatial mobile applications", 《SPRINGERLINK》 *
孙聚: "基于FreeMarker引擎的代码生成工具的设计与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109104360A (en) * 2018-09-19 2018-12-28 平安科技(深圳)有限公司 E-mail sending method, system, computer equipment and storage medium
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
CN109656549A (en) * 2018-11-30 2019-04-19 广州净松软件科技有限公司 Construction method, device, computer equipment and the storage medium of observation system
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
CN110597508A (en) * 2019-08-14 2019-12-20 平安国际智慧城市科技股份有限公司 Interface dynamic configuration method, device and storage medium
CN111162977A (en) * 2019-12-20 2020-05-15 青岛聚好联科技有限公司 Method and device for accessing terminal of Internet of things to cloud service
CN111177558A (en) * 2019-12-30 2020-05-19 北京百度网讯科技有限公司 Channel service construction method and device
CN111177558B (en) * 2019-12-30 2023-08-08 北京百度网讯科技有限公司 Channel service construction method and device
WO2021217911A1 (en) * 2020-04-27 2021-11-04 平安国际智慧城市科技股份有限公司 Method and apparatus for constructing service website project, and computer device 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

Also Published As

Publication number Publication date
CN108228166B (en) 2020-07-07

Similar Documents

Publication Publication Date Title
CN108228166A (en) A kind of back-end code generation method and system based on template
CN107688591B (en) A kind of actuarial treating method and apparatus
CN108595583A (en) Dynamic chart class page data crawling method, device, terminal and storage medium
CN103646049B (en) The method and system of automatically generated data form
CN110018829A (en) Improve the method and device of PL/SQL language interpreter execution efficiency
CN106682036A (en) Data exchange system and exchange method thereof
CN104572644A (en) Database updating device and database updating method
CN110580189A (en) method and device for generating front-end page, computer equipment and storage medium
CN103023693A (en) Behaviour log data management system and behaviour log data management method
CN105868311A (en) Data analyzing method and device
CN106557470A (en) data extraction method and device
CN113312108A (en) SWIFT message checking method and device, electronic equipment and storage medium
CN109146095A (en) The treating method and apparatus of multiservice system problem
CN108074033A (en) Processing method, system, electronic equipment and the storage medium of achievement data
CN108460068A (en) Method, apparatus, storage medium and the terminal that report imports and exports
CN110866029A (en) sql statement construction method, device, server and readable storage medium
CN103176778A (en) Method and device for webpage development
CN106294128B (en) A kind of automated testing method and device exporting report data
CN114357943A (en) Universal efficient Excel reading processing method, tool, medium and equipment
CN108268468A (en) The analysis method and system of a kind of big data
CN109144950A (en) The storage method and device of business datum
CN107463669A (en) The method and device for the web data that parsing reptile crawls
CN114564624A (en) Feature matching rule construction method, feature matching device, feature matching equipment and feature matching medium
CN108365976A (en) The optimization method and device of network service
CN107368500A (en) Data pick-up method and system

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.