CN110147225A - A kind of code generating method, device and computer equipment, storage medium - Google Patents

A kind of code generating method, device and computer equipment, storage medium Download PDF

Info

Publication number
CN110147225A
CN110147225A CN201910261300.8A CN201910261300A CN110147225A CN 110147225 A CN110147225 A CN 110147225A CN 201910261300 A CN201910261300 A CN 201910261300A CN 110147225 A CN110147225 A CN 110147225A
Authority
CN
China
Prior art keywords
code
template file
file
template
traffic
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910261300.8A
Other languages
Chinese (zh)
Inventor
王建华
何四燕
曹佩敬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201910261300.8A priority Critical patent/CN110147225A/en
Publication of CN110147225A publication Critical patent/CN110147225A/en
Pending legal-status Critical Current

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
    • G06F8/315Object-oriented languages
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Human Computer Interaction (AREA)
  • Stored Programmes (AREA)

Abstract

The invention belongs to technical field of data processing, it is related to a kind of code generating method, device and computer equipment, storage medium, the described method includes: reading at least one traffic table and at least one template file corresponding at least one described traffic table, each template file belongs to the Different Logic layer in same software architecture, includes the interface code for calling between Different Logic layer in each template file;Corresponding table structure information is obtained based on each traffic table;It determines the dynamic variable in each template file, assignment is carried out to the dynamic variable in the corresponding template file according to the table structure information, to generate the call relation of the code file of Different Logic layer and the code file of each logical layer.Scheme provided by the invention generates skeleton code in conjunction with the two by the traffic table and template file of each logical layer under the same framework of reading, and developer can develop on the basis of skeleton code, promote development efficiency.

Description

A kind of code generating method, device and computer equipment, storage medium
Technical field
The invention belongs to technical field of data processing more particularly to a kind of code generating method, device and computer equipment, Storage medium.
Background technique
The exploitation of Web project is all by frame construction, and frame construction completes basic determination procedure person and needs to write generation The part of code and the structure for determining these codes.By taking spring MVC frame as an example, include in spring MVC frame Control layer (controller), operation layer (service), data operation layer (DAO), physical layer (entity), view layer (view) etc. logical layers, control layer provide interface and carry out the interaction between client and server and can return to view to regarding Figure layer, operation layer realize specific service logic, including operation data operation layer and physical layer, data operation layer are then straight It connects and database is operated, realize the data interaction between entity and tables of data.
In the realization code of each logical layer, there are some same or similar processing methods or interfaces, for example each patrol Volume layer is all corresponding with traffic table, and each traffic table all changes the method looked into there are additions and deletions, generally for these methods, each The code of all logical layers corresponding to main traffic table can all have corresponding realization, therefore programmer needs according to table structure The code of the corresponding each logical layer of each traffic table is write, but additions and deletions are changed and look into these methods and weight will be present in interface The problem of developing again, it is therefore desirable to which a kind of scheme can reduce overlapping development rate, to promote development efficiency.
Summary of the invention
To solve the above-mentioned problems, the embodiment of the present invention provides a kind of code generating method, device and computer equipment, deposits Storage media, same or similar processing method or interface exist in the Different Logic layer to solve software architecture in the prior art Overlapping development situation, the problem for causing development efficiency low.
In a first aspect, the embodiment of the present invention provides a kind of code generating method, comprising:
At least one traffic table and at least one template file corresponding at least one described traffic table are read, Each template file of middle acquisition is belonging respectively to the Different Logic layer in same software architecture, in each template file Include the interface code for calling between Different Logic layer;
Corresponding table structure information is obtained based on each traffic table;
The dynamic variable in each template file is determined, according to the table structure information of acquisition to corresponding described Dynamic variable in template file carries out assignment, to generate the code file of Different Logic layer and the code file of each logical layer Call relation.
As the enforceable mode of the present invention, described at least one traffic table of acquisition and at least one described traffic table The step of at least one corresponding template file includes:
Data read command is received, preconfigured traffic table and template are stored with according to data read command connection At least one database of file;
Obtain the address information of the traffic table and template file that need to be read in the database;
Required at least one traffic table and at least is read from least one described database according to the address information One template file.
It is described to be read from least one described database according to the address information as the enforceable mode of the present invention The step of required at least one traffic table and at least one template file includes:
The corresponding traffic table of each logical layer and template are inquired from least one described database according to address information File;
When inquiring same logical layer and being corresponding with more than two traffic tables or two template files, judgement belongs to same More than two traffic tables of logical layer whether there is association between each other, if then reading all traffic tables, otherwise read newest Traffic table;
And judge that the more than two template files for belonging to same logical layer whether there is association between each other, if then reading All template files are taken, newest template file is otherwise read.
It is described that corresponding table structure packet is obtained based on each traffic table as the enforceable mode of the present invention It includes:
Whole table names are extracted from each traffic table, and extract data information associated with each table name, it will be each A table name is converted into JAVA class name, and each JAVA class name and corresponding associated data information are packaged, Obtain table structure information;
Correspondingly, the table structure information according to acquisition to the dynamic variable in the corresponding template file into The step of row assignment includes:
The table structure information is parsed, at least one JAVA class name and data associated with each JAVA class name letter are obtained Breath;
The variable name of the dynamic variable in corresponding template file is replaced according to each JAVA class name, and according to each JAVA The corresponding associated data information of class name carries out assignment to the dynamic variable after replacing variable name in corresponding template file.
As the enforceable mode of the present invention, the table structure information according to acquisition is to the corresponding template text The step of dynamic variable in part carries out assignment further include:
Dynamic variable and the matching relationship of obtained JAVA class name all in the template file are determined, if the table knot The parsing result of structure information there are JAVA class names do not have in the template file matched dynamic variable or the template text There are dynamic variables not to have matched JAVA class name in the parsing result of the table structure information in part, then prompts code building Mistake.
As the enforceable mode of the present invention, in the code file for the code file and each logical layer for generating Different Logic layer Call relation the step of after, further includes:
The code file of each logical layer of generation is debugged, prompts to need in the code file after the completion of debugging Want the position of modifications and extensions.
As the enforceable mode of the present invention, obtain at least one traffic table and at least one described traffic table phase Before the step of at least one corresponding template file, include the steps that the template file for configuring each logical layer, the template file Configuration process include:
According to existing item code extract each logical layer universal method or interface corresponding to code, and extract respectively patrol The method or the corresponding code of interface that volume layer is exclusive and high frequency occurs;
Determine the parameter information in the code extracted;
The parameter information based on extraction, the interface code called between Different Logic layer and each logical layer is general Parameter configuration in method code or exclusive method code be can dynamic assignment dynamic variable, generate the template text of each logical layer Part.
Second aspect, the embodiment of the present invention provide a kind of code generating unit, comprising:
Read module reads at least one traffic table and at least one mould corresponding at least one described traffic table Plate file, wherein each template file obtained is belonging respectively to the Different Logic layer in same software architecture, it is each described Include the interface code for calling between Different Logic layer in template file;
Data obtaining module obtains corresponding table structure information based on each traffic table;
Code generation module determines the dynamic variable in each template file, is believed according to the table structure of acquisition It ceases and assignment is carried out to the dynamic variable in the corresponding template file, to generate the code file and each logic of Different Logic layer The call relation of the code file of layer.
The third aspect, the embodiment of the present invention provide a kind of computer equipment, comprising:
At least one processor;And
The memory being connect at least one described processor communication;Wherein,
The memory is stored with the instruction that can be executed by least one described processor, and described instruction is by described at least one When a processor executes, so that the step of at least one described processor is able to carry out code generating method as described above.
Fourth aspect, the embodiment of the present invention provide a kind of storage medium for being stored with computer-readable instruction, the calculating When machine readable instruction is executed by least one processor, so that at least one processor executes code generating method as described above The step of.
The code generating method, device and the computer equipment that there is provided according to embodiments of the present invention, storage medium, pass through reading The traffic table and template file of Different Logic layer under same framework are generated in software architecture by traffic table combination template file and are respectively patrolled The code file for collecting layer, can be obtained the skeleton code of software architecture, subsequent development personnel are on the basis of skeleton code into one Step developed, so as to largely save the time that programmer writes code, reduce overlapping development the case where, promoted developer Development efficiency project-based code skeleton is only needed for different web projects, logic is carried out to code skeleton and is split To corresponding traffic table and template file, automatically generating for code can be realized based on this method, there is stronger versatility.
Detailed description of the invention
In order to illustrate more clearly of the solution of the present invention, one will be made to attached drawing needed in embodiment description below A simple introduction, it should be apparent that, drawings in the following description are some embodiments of the invention, for ordinary skill For personnel, without creative efforts, it is also possible to obtain other drawings based on these drawings.
Fig. 1 is the flow chart of code generating method provided in an embodiment of the present invention;
Fig. 2 is the flow chart provided in an embodiment of the present invention for obtaining traffic table and template file;
Fig. 3 is the flow chart of the configuration process of template file provided in an embodiment of the present invention;
Fig. 4 is the structural block diagram of code generating unit provided in an embodiment of the present invention;
Fig. 5 is another structural block diagram of code generating unit provided in an embodiment of the present invention;
Fig. 6 is the another structural block diagram of code generating unit provided in an embodiment of the present invention;
Fig. 7 be another embodiment of the present invention provides code generating unit structural block diagram;
Fig. 8 is the structural block diagram of computer equipment provided in an embodiment of the present invention.
Specific embodiment
In order to enable those skilled in the art to better understand the solution of the present invention, below in conjunction in the embodiment of the present invention Attached drawing, technical scheme in the embodiment of the invention is clearly and completely described.Unless otherwise defined, used herein All technical and scientific terms have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
" embodiment " phrase that each position in the description occurs might not each mean identical embodiment, It is not the independent or alternative embodiment with other embodiments mutual exclusion.What those skilled in the art explicitly and implicitly understood It is that embodiment described herein can be combined with other embodiments.
As shown in Figure 1, the embodiment of the present invention provides a kind of code generating method, it can be used for generating the frame generation of software architecture Code, in subordinate's embodiment of the present invention, is mainly explained, specifically, the code by taking spring MVC framework as an example Generation method includes:
S1, at least one traffic table and at least one template corresponding at least one described traffic table text are read Part, wherein each template file obtained is belonging respectively to the Different Logic layer in same software architecture, each template Include the interface code for calling between Different Logic layer in file;Wherein it is possible to be the corresponding business of a logical layer Table is also possible to the corresponding traffic table of two or more logical layers, such as the target object when certain logic layer operations When identical, then these logical layers may get identical traffic table, if operation object is different, but operation object has pass Connection, then the corresponding traffic table obtained of these logical layers can also have association.
S2, corresponding table structure information is obtained based on each traffic table;In the present embodiment, the table structure information It may include specifically the data informations such as table name and literary name section relevant to table name, field length, type.
S3, dynamic variable in each template file is determined, according to the table structure information of acquisition to corresponding Dynamic variable in the template file carries out assignment, to generate the code file of Different Logic layer and the code text of each logical layer The call relation of part;The generating process of the call relation is corresponded to based on the assignment procedure of the dynamic variable in each template file It realizes.
In embodiments of the present invention, different software architectures may have different layering logic layers, but just fixed software Its layering logic layers is usually fixed for framework, for example spring MVC framework includes control layer, operation layer, data manipulation The logical layers such as layer, physical layer, the generating process of the code file of each logical layer is identical in same software architecture, according to generation Each logical layer the available software architecture of code file skeleton code, for example each logical layer of spring MVC framework is corresponding Template file be respectively control layer template, operation layer template, physical layer template, data operation layer template etc., then ultimately generate Code file accordingly include control layer code file, operation layer code file, physical layer code file, data operation layer generation Code file etc., these code files form the skeleton code of spring MVC framework.
Meanwhile in the call relation in same framework between Different Logic layer be usually it is fixed, therefore each logical layer it Between the frame of interface code that calls be usually it is fixed, interface code can be embodied directly in template file to be formed and respectively be patrolled The call relation of volume layer, call relation ratio in spring MVC framework if any controller call service, Service calls DAO and entity etc..Since code generating method provided in an embodiment of the present invention is not limited to spring MVC framework can carry out logic fractionation to the composition of software architecture, each of after fractionation for other kinds of software architecture Logic unit or logical layer correspond to a template file, these template files and corresponding traffic table are based on, by this hair The code generating method that bright embodiment provides produces the skeleton code of software architecture.In embodiments of the present invention, code file It can be saved according to preconfigured store path to specified storage location after generation, be checked for subsequent calls;Code text Part can also be directly inputted into software project after generation, with the skeleton code based on software architecture to software project other parts Code write.
As can be seen from the above embodiments, traffic table is considered as carrying out template file the configuration file of dynamic assignment, In spring MVC framework, the data informations such as table name, literary name section, field length, type that traffic table is included can be used for mould Dynamic variable in plate file carries out assignment, it should be noted that in other software framework, traffic table is in form or interior It may be different from the traffic table in spring MVC framework in appearance, therefore the form of traffic table or content do not limited herein, adopted It can be applied to code generating method provided by the invention in different software architectures, wanting for customization and versatility can be met It asks, the skeleton code for meeting project can be generated according to different Project settings template files.Certainly, in some schemes, exist Configuration file in other software framework for carrying out assignment to the dynamic variable in template file may not be traffic table.
In some embodiment of the invention, as shown in Fig. 2, described in step S1 obtain at least one traffic table and with institute The step of stating at least one traffic table corresponding at least one template file can include:
S11, receive data read command, according to the data read command connection be stored with preconfigured traffic table and At least one database of template file;It may include the connecting interface information of database in the data read command, according to this Connecting interface information may be connected to specified data library;For connecting the situation of two or more databases, a data Library is at least a logical layer offer traffic table or template file belongs to same software architecture not in some embodiments Quantity with logical layer can be corresponded with quantity database, the corresponding traffic table of Different Logic layer and template file respectively since It is obtained in disparate databases.
The address information of the traffic table and template file that S12, acquisition need to be read in the database;In the present embodiment, institute Stating address information can obtain with the generation of the data read command, for example the data read command is user in operation window Generation when interactive operation is carried out on mouth, then the address information can specifically be grasped via user in the editor of address information typing window It obtains, address information can have different forms, such as the control layer template file in spring MVC framework, business Layer template file, data operation layer template file, address information can be corresponding to physical layer template file Com.pingan.njit.um.web, com.pingan.njit.um.service, com.pingan.njit.um.dao, com.pingan.njit.um.entity。
S13, read from least one described database according to the address information required at least one traffic table and At least one template file.In some embodiments, this step S13 is specific can include: according to address information from described at least one The corresponding traffic table of each logical layer and template file are inquired in a database;When inquire same logical layer it is corresponding there are two Or when more than two traffic tables or two or more template files, judgement belong to two or two of same logical layer with Upper traffic table whether there is association between each other, if then reading all traffic tables, otherwise read newest traffic table, and sentence Disconnected two or more template files for belonging to same logical layer whether there is association between each other, if then reading all moulds Otherwise plate file reads newest template file, herein newest traffic table and newest template file refer to generate the time or Person's renewal time traffic table or template file nearest apart from current operating temporal node, since the code of template file can be with State in Continuous optimization, obtaining newest traffic table and template file can guarantee that the code ultimately produced is more to optimize Code, help to improve the accuracy rate and success rate of code building.
In embodiments of the present invention, the process of table structure information is read in step S2 from traffic table predominantly according to table name The process of the data informations such as literary name section relevant to table name, field length, type is obtained from traffic table.In some embodiments In, it is described to be based on each traffic table to obtain corresponding table structure information including: to extract all from each traffic table Table name, and data information associated with each table name is extracted, JAVA class name is converted by each table name, such as The class name of controller, service etc. then carry out each JAVA class name and corresponding associated data information Encapsulation obtains the table structure information, can be convenient data transmission using Information encapsulation.
Further, after the table structure information encapsulated, step S3 is according to the table structure information of acquisition to phase Dynamic variable in the template file answered carries out assignment can include: parses the table structure information, obtains at least one JAVA class name and data information associated with each JAVA class name;It is replaced in corresponding template file according to each JAVA class name Dynamic variable variable name, and according to the corresponding associated data information of each JAVA class name in corresponding template file Dynamic variable after replacing variable name carries out assignment, to generate a complete code file.
In a further embodiment, the table structure information according to acquisition is in the corresponding template file Dynamic variable the step of carrying out assignment further include: determine dynamic variable all in the template file and obtained JAVA class The matching relationship of name, if that there are JAVA class names is not matched in the template file for the parsing result of the table structure information It is not matched in the parsing result of the table structure information that there are dynamic variables in dynamic variable or the template file JAVA class name then prompts code file generation error.In embodiments of the present invention, the step of determining matching relationship can be It is carried out before the step of replacing the variable name of the dynamic variable in corresponding template file according to each JAVA class name, it can also be with It is to carry out miscue after the completion of code file generates, generation error prompt can refer on the basis of generating code file at this time Show the position malfunctioned in template file, facilitates developer subsequent and code is checked and modified according to miscue.
In some embodiment of the invention, in the code file for the code file and each logical layer for generating Different Logic layer Further include being debugged to the code file of each logical layer of generation after the step of call relation, is mentioned after the completion of debugging Show the position that modifications and extensions are needed in the code file.In other schemes, can also while generating code into Specifically, debugging in code generation process to current generated code, and there is generation in debugging process in row debugging When code debugging errors, prompt information is exported in real time, the prompt information record has the code position of debugging errors, so as in code It is modified after the completion of generation according to position of the prompt information to debugging errors in code.
In some embodiment of the invention, at least one traffic table and opposite at least one described traffic table is being obtained Before the step of at least one template file answered, includes the steps that the template file for configuring each logical layer, specifically to configure each mould The interface of configuration increase, deletion, modification, lookup etc. is needed in the general configuration of plate file, such as control layer template, needs to pass in interface The parameter information entered needs the service information called in interface, needs to receive in interface and the message body type returned etc., The parameters such as middle interface name, service variable name, parameter name, message body type are all that dynamically, these dynamics are joined in step s3 Number will be assigned by traffic table information.In the present embodiment, as shown in figure 3, the configuration process of the template file can include:
S01, according to existing item code extract each logical layer universal method or interface corresponding to code, and extract The method or the corresponding code of interface that each logical layer is exclusive and high frequency occurs;The universal method includes some basic table behaviour Make or service logic, wherein basic table handling such as include increase newly, batch is newly-increased, modification, delete, uniline inquiry, multirow are looked into The code of inquiry, multi-condition inquiry, paging query etc., these table handlings and service logic belongs to high frequency generation in whole system frame Code or the relatively-stationary code of structure, therefore can individually be extracted, certainly, no original item code the case where Under, it can be obtained by writing corresponding code for these general or high frequency methods or interface.
Parameter information in S02, the determining code extracted;These parameter informations include interface parameters and each logical layer Conventional parameter, such as above-mentioned interface name, the conventional parameter name in each logical layer universal method or exclusive method, message body class Type etc..
S03, the parameter information based on extraction, by the interface code called between Different Logic layer and each logical layer Parameter configuration in universal method code or exclusive method code be can dynamic assignment dynamic variable, generate the mould of each logical layer Plate file.
Optionally, after step s 3, when the skeleton code according to generation writes supplement code, if being deposited in supplement code In the method that the new exclusive and high frequency of the general method of new each logical layer or the corresponding code of interface or each logical layer occurs Or when the corresponding code of interface, these codes can be extracted from supplement code, and be added into existing template file and generate New template file completes the update to template file, and updated template file will be refined more, can reduce subsequent code Error rate in generating process.
In embodiments of the present invention, since the template file of each logical layer is individually present, and between each logical layer The generating process of call relation corresponds to realization based on the assignment procedure of the dynamic variable in each template file, therefore is reading industry Business table and template file, and can be realized with multithreading according to the process that traffic table and template file generate code, such as The code of each logical layer under same software architecture can be generated simultaneously, rather than sequentially generated, it is raw to can effectively improve code in this way At efficiency.
The code generating method provided according to embodiments of the present invention, by the business for reading Different Logic layer under same framework Table and template file are generated the code file of each logical layer in software architecture by traffic table combination template file, can be obtained soft The skeleton code of part framework, subsequent development personnel further progress on the basis of skeleton code is developed, so as to largely save The case where programmer writes the time of code, reduces overlapping development, promotes the development efficiency of developer, for different web Project only needs project-based code skeleton, carries out logic to code skeleton and splits to obtain corresponding traffic table and template file, Automatically generating for code can be realized based on this method, there is stronger versatility.
The embodiment of the present invention provides a kind of code generating unit, as shown in figure 4, read module 41, data obtaining module 42 With code generation module 43, in which:
The read module 41 is for reading at least one traffic table and corresponding at least one described traffic table At least one template file, wherein each template file obtained is belonging respectively to the Different Logic in same software architecture Layer, the interface code for calling between Different Logic layer is included in each template file;Wherein, the read module 41 The traffic table of acquisition can correspond to a logical layer, can also correspond to two or more logical layers, such as when certain logical layers are grasped When the target object of work is identical, then the read module 41 may get identical traffic table for these logical layers, if Operation object is different, but operation object has association, then the corresponding traffic table of these logical layers can also have association.
The data obtaining module 42 is used to obtain corresponding table structure information based on each traffic table;In this implementation In example, the table structure information specifically may include the data such as table name and literary name section relevant to table name, field length, type letter Breath.
The code generation module 43 is used to determine the dynamic variable in each template file, according to acquisition Table structure information carries out assignment to the dynamic variable in the corresponding template file, to generate the code file of Different Logic layer With the call relation of the code file of each logical layer.
In some embodiment of the invention, as shown in figure 5, the read module 41 specifically include instruction receiving unit 411, Database connection unit 412, address information acquiring unit 413 and reading unit 414, wherein in embodiments of the present invention, described Instruction receiving unit 411 and reading unit 414 are all connected with the database connection unit 412 and address information acquiring unit 413, Described instruction receiving unit 411 reads instruction for receiving data, and the database connection unit 412 is used for according to the data Read at least one database that instruction connection is stored with preconfigured traffic table and template file;The address information obtains Unit 413 is for obtaining the address information of the traffic table that need to be read and template file in the database;The reading unit 414 is used In required at least one traffic table and at least one mould are read from least one described database according to the address information Plate file.
Further, the reading unit 414 reads institute from least one described database according to the address information At least one traffic table for needing and when at least one template file, is specifically used for: according to address information from least one described number According to inquiring the corresponding traffic table of each logical layer and template file in library;When inquire same logical layer it is corresponding there are two or two When a above traffic table or two or more template files, judgement belongs to two or more industry of same logical layer Business table whether there is association between each other, if then reading all traffic tables, otherwise read newest traffic table;And judgement belongs to It whether there is association between each other in two or more template files of same logical layer, if then reading all template texts Otherwise part reads newest template file.It can guarantee the generation ultimately produced by obtaining newest traffic table and template file Code is more optimized code, helps to improve the accuracy rate and success rate of code building.
In some embodiment of the invention, as shown in fig. 6, the data obtaining module 42 includes extraction unit 421, conversion Unit 422 and encapsulation unit 423, wherein the extraction unit 421 is used to extract whole table names from each traffic table, and Data information associated with each table name is extracted, the converting unit 422 is used to convert JAVA class for each table name Name, the encapsulation unit 423 are obtained for each JAVA class name and corresponding associated data information to be packaged Table structure information.
It is corresponding, as shown in fig. 6, the code generation module 43 includes resolution unit 431 and assignment unit 432, institute Resolution unit 431 is stated for parsing the table structure information, obtains at least one JAVA class name and related to each JAVA class name The data information of connection;The assignment unit 432, which is used to replace the dynamic in corresponding template file according to each JAVA class name, to be become The variable name of amount, and according to the corresponding associated data information of each JAVA class name to replacing variable in corresponding template file Dynamic variable after name carries out assignment.
Further, in some embodiments, as shown in fig. 6, the code generation module 43 further includes matching unit 433, specifically for the matching relationship of dynamic variable all in the determination template file and obtained JAVA class name, if described There are JAVA class names not to have matched dynamic variable or the mould in the template file for the parsing result of table structure information There are dynamic variables not to have matched JAVA class name in the parsing result of the table structure information in plate file, then prompts code Generation error.
In some embodiment of the invention, it as shown in fig. 7, the code generating unit further includes debugging module 44, is used for The code generation module 43 generate Different Logic layer code file and each logical layer code file call relation it Afterwards, the code file of each logical layer of generation is debugged, prompts to need to repair in the code file after the completion of debugging The position for changing and extending.
In some embodiment of the invention, it as shown in fig. 7, the code generating unit further includes configuration module 45, is used for The read module 41 reads at least one traffic table and at least one template corresponding at least one described traffic table The template file of each logical layer is configured before file.In the present embodiment, the configuration module 45 include code extraction unit 451, Parameter determination unit 452 and template file generation unit 453, the code extraction unit 451 were used for according to existing project generation Code extracts code corresponding to each logical layer universal method or interface, and extracts the method that each logical layer is exclusive and high frequency occurs Or the corresponding code of interface;The parameter determination unit 452 is for determining the parameter information in the code extracted;The template text Part generation unit 453 is used for the parameter information based on extraction, by the interface code called between Different Logic layer and respectively Parameter configuration in logical layer universal method code or exclusive method code be can dynamic assignment dynamic variable, generate each logic The template file of layer.
The code generating unit provided according to embodiments of the present invention reads difference under same framework by read module 41 and patrols The traffic table and template file of layer are collected, then traffic table and template file are combined by data obtaining module 42 and code generation module 43 The code file for generating each logical layer in software architecture, can be obtained the skeleton code of software architecture, subsequent development personnel are in frame Further progress is developed on the basis of frame code, so as to largely save the time that programmer writes code, reduces overlapping development The case where, the development efficiency of developer is promoted, for different web projects, project-based code skeleton is only needed, to code Frame carries out logic and splits to obtain corresponding traffic table and template file, can realize automatically generating for code based on the device, With stronger versatility.
The embodiment of the present invention also provides a kind of computer equipment, as shown in figure 8, the computer equipment includes at least one Processor 81, and the memory 82 with the communication connection of at least one described processor 81, show a processor 81 in Fig. 8, The memory 82 is stored with the instruction that can be executed by least one described processor 81, and described instruction is by described at least one It manages device 81 to execute, so that the step of at least one described processor 81 is able to carry out code generating method as described above.
Specifically, the memory 82 in the embodiment of the present invention is non-volatile computer readable storage medium storing program for executing, can be used for depositing Non-volatile software program, non-volatile computer executable program and module are stored up, such as the generation in the above embodiments of the present application Corresponding program instruction/the module of code generating method;The processor 81 is stored in non-volatile in memory 82 by operation Software program, instruction and module thereby executing various function application and carry out data processing, i.e. the realization above method is implemented Code generating method described in example.
In some embodiments, the memory 82 may include program storage area and data storage area, wherein program is deposited Storage area can application program required for storage program area, at least one function;It data storage area can store code generation method Treatment process in the data etc. that are created.In addition, memory 82 may include high-speed random access memory, can also include Nonvolatile memory, for example, at least a disk memory, flush memory device or other non-volatile solid state memory parts;
In some embodiments, it includes the remote memory remotely located relative to processor 81 that memory 82 is optional, this A little remote memories can be by being connected to the network to the computer equipment for executing domain filter processing, and the example of aforementioned network includes But be not limited to internet, intranet, local area network, mobile radio communication and combinations thereof.
In embodiments of the present invention, the computer equipment for executing code generating method can also include input unit 83 and defeated Device 84 out;Wherein, input unit 83 can obtain the operation information of user on a computing device, and output device 84 may include showing Display screen etc. shows equipment.In embodiments of the present invention, the processor 81, memory 82, input unit 83 and output device 84 It can be connected by bus or other modes, in Fig. 8 for being connected by bus.
The computer equipment provided according to embodiments of the present invention, energy when executing the code in memory 82 by processor 81 The step of enough executing code generating method in above-described embodiment, and the technical effect with above method embodiment, not in this reality The technical detail of detailed description in example is applied, reference can be made to technology contents provided in the application embodiment of the method.
The embodiment of the present invention also provides a kind of storage medium for being stored with computer-readable instruction, the computer-readable finger When enabling by the execution of at least one processor, so that the step of at least one processor executes code generating method as described above, When executing the step of the method, the technical effect with above method embodiment, not detailed description in the present embodiment Technical detail, reference can be made to technology contents provided in the application embodiment of the method.
The embodiment of the present invention also provides a kind of computer program product, and the product can be performed in the application embodiment of the method Provided code generating method has the corresponding functional module of execution method and beneficial effect.It is not detailed in the present embodiment The technical detail of description, reference can be made to technology contents provided in the application embodiment of the method.
It should be noted that each functional module in the above embodiment of the present invention can integrate in a processing unit In, it is also possible to modules and physically exists alone, can also be integrated in one unit with two or more modules.It is above-mentioned Integrated unit both can take the form of hardware realization, can also realize in the form of hardware adds SFU software functional unit.
The above-mentioned integrated unit being realized in the form of SFU software functional unit can store and computer-readable deposit at one In storage media.Above-mentioned SFU software functional unit is stored in a storage medium, including some instructions are used so that a computer Device (can be personal computer, server or network equipment etc.) or intelligent terminal or processor (Processor) Execute the part steps of each embodiment the method for the present invention.And storage medium above-mentioned include: USB flash disk, it is mobile hard disk, read-only Memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or The various media that can store program code such as person's CD.
In above-described embodiment provided by the present invention, it should be understood that disclosed device and method can pass through it Its mode is realized.For example, the apparatus embodiments described above are merely exemplary, for example, the division of the module, only Only a kind of logical function partition, there may be another division manner in actual implementation, for example, two or more modules or Component can be combined or can be integrated into another system, or some features can be ignored or not executed.
The module as illustrated by the separation member may or may not be physically separated, aobvious as module The component shown may or may not be physical module, it can and it is in one place, or may be distributed over two Or in more than two network units.Some or all of the modules therein can be selected to realize this implementation according to the actual needs The purpose of example scheme.
Obviously, embodiments described above is only a part of the embodiment of the present invention, instead of all the embodiments, attached Presently preferred embodiments of the present invention is given in figure, but is not intended to limit the scope of the patents of the invention.The present invention can be with many differences Form realize, on the contrary, purpose of providing these embodiments is keeps the understanding to the disclosure more thorough Comprehensively.Although the present invention is described in detail referring to the foregoing embodiments, for coming for those skilled in the art, Can still modify to technical solution documented by aforementioned each specific embodiment, or to part of technical characteristic into Row equivalence replacement.All equivalent structures done using description of the invention and accompanying drawing content, are directly or indirectly used in other Relevant technical field, similarly within the invention patent protection scope.

Claims (10)

1. a kind of code generating method characterized by comprising
At least one traffic table and at least one template file corresponding at least one described traffic table are read, wherein obtaining The each template file taken is belonging respectively to the Different Logic layer in same software architecture, includes in each template file Interface code for being called between Different Logic layer;
Corresponding table structure information is obtained based on each traffic table;
The dynamic variable in each template file is determined, according to the table structure information of acquisition to the corresponding template Dynamic variable in file carries out assignment, to generate the calling of the code file of Different Logic layer and the code file of each logical layer Relationship.
2. code generating method according to claim 1, which is characterized in that described at least one traffic table of acquisition and with The step of described at least one traffic table corresponding at least one template file includes:
Data read command is received, preconfigured traffic table and template file are stored with according to data read command connection At least one database;
Obtain the address information of the traffic table and template file that need to be read in the database;
Required at least one traffic table and at least one are read from least one described database according to the address information Template file.
3. code generating method according to claim 2, which is characterized in that it is described according to the address information from it is described to At least one required traffic table is read in a few database includes: with the step of at least one template file
The corresponding traffic table of each logical layer and template file are inquired from least one described database according to address information;
When inquiring same logical layer and being corresponding with more than two traffic tables or more than two template file, judgement belongs to same More than two traffic tables of logical layer whether there is association between each other, if then reading all traffic tables, otherwise read newest Traffic table;
And judge that the more than two template files for belonging to same logical layer whether there is association between each other, if then reading institute There is template file, otherwise reads newest template file.
4. code generating method according to any one of claims 1 to 3, which is characterized in that described to be based on each industry Business table obtains corresponding table structure information
Whole table names are extracted from each traffic table, and extract data information associated with each table name, by each institute It states table name and is converted into JAVA class name, each JAVA class name and corresponding associated data information are packaged, obtained Table structure information;
The table structure information according to acquisition carries out the step of assignment to the dynamic variable in the corresponding template file Suddenly include:
The table structure information is parsed, at least one JAVA class name and data information associated with each JAVA class name are obtained;
The variable name of the dynamic variable in corresponding template file is replaced according to each JAVA class name, and according to each JAVA class name Corresponding associated data information carries out assignment to the dynamic variable after replacing variable name in corresponding template file.
5. code generating method according to claim 4, which is characterized in that the table structure information according to acquisition The step of assignment is carried out to the dynamic variable in the corresponding template file further include:
Dynamic variable and the matching relationship of obtained JAVA class name all in the template file are determined, if the table structure is believed There are JAVA class names not to have in matched dynamic variable or the template file in the template file for the parsing result of breath There are dynamic variables not to have matched JAVA class name in the parsing result of the table structure information, then prompts code building wrong Accidentally.
6. code generating method according to claim 1, which is characterized in that generate Different Logic layer code file and After the step of call relation of the code file of each logical layer, further includes:
The code file of each logical layer of generation is debugged, prompts to need to repair in the code file after the completion of debugging The position for changing and extending.
7. code generating method according to claim 1, which is characterized in that obtain at least one traffic table and with institute Before the step of stating at least one traffic table corresponding at least one template file, the template file including configuring each logical layer The configuration process of step, the template file includes:
According to existing item code extract each logical layer universal method or interface corresponding to code, and extract each logical layer The method or the corresponding code of interface that exclusive and high frequency occurs;
Determine the parameter information in the code extracted;
The parameter information based on extraction, by the interface code called between Different Logic layer and each logical layer universal method Parameter configuration in code or exclusive method code be can dynamic assignment dynamic variable, generate the template file of each logical layer.
8. a kind of code generating unit characterized by comprising
Read module reads at least one traffic table and at least one template corresponding at least one described traffic table text Part, wherein each template file obtained is belonging respectively to the Different Logic layer in same software architecture, each template Include the interface code for calling between Different Logic layer in file;
Data obtaining module obtains corresponding table structure information based on each traffic table;
Code generation module determines the dynamic variable in each template file, according to the table structure information pair of acquisition Dynamic variable in the corresponding template file carries out assignment, with generate Different Logic layer code file and each logical layer The call relation of code file.
9. a kind of computer equipment characterized by comprising
At least one processor;And
The memory being connect at least one described processor communication;Wherein,
The memory is stored with the instruction that can be executed by least one described processor, and described instruction is by described at least one When managing device execution, so that at least one described processor executes the code generating method as described in any one of claims 1 to 7 The step of.
10. a kind of storage medium for being stored with computer-readable instruction, which is characterized in that the computer-readable instruction is by least When one processor executes, so that at least one processor executes the generation as described in any one of claims 1 to 7 claim The step of code generating method.
CN201910261300.8A 2019-04-02 2019-04-02 A kind of code generating method, device and computer equipment, storage medium Pending CN110147225A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910261300.8A CN110147225A (en) 2019-04-02 2019-04-02 A kind of code generating method, device and computer equipment, storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910261300.8A CN110147225A (en) 2019-04-02 2019-04-02 A kind of code generating method, device and computer equipment, storage medium

Publications (1)

Publication Number Publication Date
CN110147225A true CN110147225A (en) 2019-08-20

Family

ID=67589414

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910261300.8A Pending CN110147225A (en) 2019-04-02 2019-04-02 A kind of code generating method, device and computer equipment, storage medium

Country Status (1)

Country Link
CN (1) CN110147225A (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110472219A (en) * 2019-08-22 2019-11-19 浙江大搜车软件技术有限公司 Electronic document generation method, device, computer equipment and storage medium
CN110502242A (en) * 2019-08-26 2019-11-26 深圳前海环融联易信息科技服务有限公司 Code automatic generation method, device, computer equipment and storage medium
CN111026389A (en) * 2019-11-08 2020-04-17 中建八局第二建设有限公司 Automatic building method and system of WEB framework platform software based on JDBC database connection technology
CN111078208A (en) * 2019-12-12 2020-04-28 智器云南京信息科技有限公司 Data processing method and system under MVC (model view controller) architecture, storage medium and electronic equipment
CN111782207A (en) * 2020-06-23 2020-10-16 北京青云科技股份有限公司 Method, device and equipment for generating task stream code and storage medium
CN112015429A (en) * 2020-08-21 2020-12-01 杭州指令集智能科技有限公司 Code generation method, device and equipment
CN112394920A (en) * 2020-11-19 2021-02-23 联通智网科技有限公司 Application software development method, platform and electronic equipment
CN112433717A (en) * 2020-12-18 2021-03-02 杭州米络星科技(集团)有限公司 Code automatic generation method and device and electronic equipment
CN112463135A (en) * 2020-12-11 2021-03-09 中国人寿保险股份有限公司 Code generation method, code generator, electronic device, and storage medium
CN113110832A (en) * 2021-04-08 2021-07-13 北京联创新天科技有限公司 Intelligent efficient code generation method and device and storage medium
CN113590115A (en) * 2021-07-30 2021-11-02 北京国腾联信科技有限公司 Method and device for automatically generating service system code
CN117435178A (en) * 2023-12-20 2024-01-23 厦门东软汉和信息科技有限公司 Code generation system, method, device and storage medium
CN117519670A (en) * 2023-12-25 2024-02-06 杭银消费金融股份有限公司 Method and system for automatically generating RPC (remote procedure control) codes

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101697120A (en) * 2009-11-05 2010-04-21 河南辉煌科技股份有限公司 Relational database based generation method of J2EE code
CN103226478A (en) * 2013-05-22 2013-07-31 北京金和软件股份有限公司 Method for automatically generating and using code
CN105760168A (en) * 2016-02-23 2016-07-13 深圳竹信科技有限公司 Automatic code file generation method and system
CN105824619A (en) * 2016-03-10 2016-08-03 四川交通职业技术学院 Code generator integrated based on Spring MVC framework, Apache Shiro framework and MyBatis framework
CN107479883A (en) * 2017-08-07 2017-12-15 海闻科技有限公司 A kind of code generating method and code generator
CN107729003A (en) * 2017-11-20 2018-02-23 江苏神州信源系统工程有限公司 Automatic generation method, device and the electronic equipment of code
CN109240670A (en) * 2018-11-21 2019-01-18 北京锐安科技有限公司 Modular software development methodology, system, equipment and medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101697120A (en) * 2009-11-05 2010-04-21 河南辉煌科技股份有限公司 Relational database based generation method of J2EE code
CN103226478A (en) * 2013-05-22 2013-07-31 北京金和软件股份有限公司 Method for automatically generating and using code
CN105760168A (en) * 2016-02-23 2016-07-13 深圳竹信科技有限公司 Automatic code file generation method and system
CN105824619A (en) * 2016-03-10 2016-08-03 四川交通职业技术学院 Code generator integrated based on Spring MVC framework, Apache Shiro framework and MyBatis framework
CN107479883A (en) * 2017-08-07 2017-12-15 海闻科技有限公司 A kind of code generating method and code generator
CN107729003A (en) * 2017-11-20 2018-02-23 江苏神州信源系统工程有限公司 Automatic generation method, device and the electronic equipment of code
CN109240670A (en) * 2018-11-21 2019-01-18 北京锐安科技有限公司 Modular software development methodology, system, equipment and medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
林钰杰 等: "基于FreeMarker 的企业Web 应用代码生成器研究", 《信息技术》, no. 9, pages 103 - 110 *

Cited By (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110472219B (en) * 2019-08-22 2023-09-15 浙江大搜车软件技术有限公司 Electronic file generation method, electronic file generation device, computer equipment and storage medium
CN110472219A (en) * 2019-08-22 2019-11-19 浙江大搜车软件技术有限公司 Electronic document generation method, device, computer equipment and storage medium
CN110502242B (en) * 2019-08-26 2022-12-20 深圳前海环融联易信息科技服务有限公司 Code automatic generation method and device, computer equipment and storage medium
CN110502242A (en) * 2019-08-26 2019-11-26 深圳前海环融联易信息科技服务有限公司 Code automatic generation method, device, computer equipment and storage medium
CN111026389A (en) * 2019-11-08 2020-04-17 中建八局第二建设有限公司 Automatic building method and system of WEB framework platform software based on JDBC database connection technology
CN111078208A (en) * 2019-12-12 2020-04-28 智器云南京信息科技有限公司 Data processing method and system under MVC (model view controller) architecture, storage medium and electronic equipment
CN111782207A (en) * 2020-06-23 2020-10-16 北京青云科技股份有限公司 Method, device and equipment for generating task stream code and storage medium
CN112015429B (en) * 2020-08-21 2023-08-04 杭州指令集智能科技有限公司 Code generation method, device and equipment
CN112015429A (en) * 2020-08-21 2020-12-01 杭州指令集智能科技有限公司 Code generation method, device and equipment
CN112394920A (en) * 2020-11-19 2021-02-23 联通智网科技有限公司 Application software development method, platform and electronic equipment
CN112394920B (en) * 2020-11-19 2024-03-29 联通智网科技股份有限公司 Application software development method, platform and electronic equipment
CN112463135A (en) * 2020-12-11 2021-03-09 中国人寿保险股份有限公司 Code generation method, code generator, electronic device, and storage medium
CN112433717A (en) * 2020-12-18 2021-03-02 杭州米络星科技(集团)有限公司 Code automatic generation method and device and electronic equipment
CN113110832A (en) * 2021-04-08 2021-07-13 北京联创新天科技有限公司 Intelligent efficient code generation method and device and storage medium
CN113590115A (en) * 2021-07-30 2021-11-02 北京国腾联信科技有限公司 Method and device for automatically generating service system code
CN117435178A (en) * 2023-12-20 2024-01-23 厦门东软汉和信息科技有限公司 Code generation system, method, device and storage medium
CN117435178B (en) * 2023-12-20 2024-03-15 厦门东软汉和信息科技有限公司 Code generation system, method, device and storage medium
CN117519670A (en) * 2023-12-25 2024-02-06 杭银消费金融股份有限公司 Method and system for automatically generating RPC (remote procedure control) codes
CN117519670B (en) * 2023-12-25 2024-04-09 杭银消费金融股份有限公司 Method and system for automatically generating RPC (remote procedure control) codes

Similar Documents

Publication Publication Date Title
CN110147225A (en) A kind of code generating method, device and computer equipment, storage medium
CA2777443C (en) Automated enterprise software development
US7191429B2 (en) System and method for managing architectural layers within a software model
CA2446809C (en) General and reusable components for defining net-centric application program architectures
US8850390B2 (en) Status management for phased implementation of configuration changes
CN113836754A (en) Multi-agent simulation modeling oriented simulation method, device, equipment and medium
CN113641591A (en) Test case generation method and device and test method and device
CN109471580A (en) A kind of visualization 3D courseware editing machine and courseware edit methods
CN114912897A (en) Workflow execution method, workflow arrangement method and electronic equipment
CN102214103A (en) Method and system for establishing and performing task program based on functional unit
Cole SoS architecture
CN113449444B (en) Simulation method, computer device and storage medium for domain engineering
CN105302586A (en) Software upgrade processing method and device, terminal and server
Alam et al. Modelling a family of systems for crisis management with concern‐oriented reuse
CN114253546A (en) Code generation method and device, storage medium and electronic device
US20080022258A1 (en) Custom database system and method of building and operating the same
CN115617333A (en) Data updating method and device, electronic equipment and storage medium
CN112418796A (en) Sub-process node activation method and device, electronic equipment and storage medium
Singh Systems integration‐coping with legacy systems
US8631393B2 (en) Custom database system and method of building and operating the same
Kobryn et al. Modeling DoDAF compliant architectures
CN112817571B (en) Man-machine object fusion application modeling method based on scene storyboard
Cruz et al. Coordinating open distributed systems
Kobryn et al. 1.3. 1 modeling DoDAF compliant architectures the telelogic approach for complying with the DoD architectural framework
CN116610319B (en) Method and system for constructing map application based on low-code platform

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