CN110968307A - Micro-service construction method and device based on intelligent generation of basic codes - Google Patents
Micro-service construction method and device based on intelligent generation of basic codes Download PDFInfo
- Publication number
- CN110968307A CN110968307A CN201811149888.XA CN201811149888A CN110968307A CN 110968307 A CN110968307 A CN 110968307A CN 201811149888 A CN201811149888 A CN 201811149888A CN 110968307 A CN110968307 A CN 110968307A
- Authority
- CN
- China
- Prior art keywords
- code
- name
- replaceable
- configuration file
- layer
- 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
Links
- 238000010276 construction Methods 0.000 title claims abstract description 19
- 238000000034 method Methods 0.000 claims abstract description 23
- 238000012545 processing Methods 0.000 claims abstract description 3
- 238000006243 chemical reaction Methods 0.000 claims description 16
- 238000011161 development Methods 0.000 abstract description 4
- 230000008676 import Effects 0.000 description 14
- 238000010200 validation analysis Methods 0.000 description 4
- 230000018109 developmental process Effects 0.000 description 3
- 210000001072 colon Anatomy 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000006870 function Effects 0.000 description 2
- 238000012423 maintenance Methods 0.000 description 2
- 230000002688 persistence Effects 0.000 description 2
- 239000000126 substance Substances 0.000 description 2
- 230000033772 system development Effects 0.000 description 2
- 235000010627 Phaseolus vulgaris Nutrition 0.000 description 1
- 244000046052 Phaseolus vulgaris Species 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/447—Target code generation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/35—Creation or generation of source code model driven
Abstract
The document discloses a micro-service construction method and a device based on intelligent generation of basic codes, wherein the method comprises the following steps: for each base layer of the software framework, the following processing is performed: generating a code prototype for the base layer; the code prototype comprises an execution code part and an annotation part; the execution code section comprises at least one replaceable area, or the execution code section and the annotation section comprise at least one replaceable area; the replaceable area comprises a boundary identifier and replaceable content; generating a configuration file for a base layer, wherein the configuration file comprises parameter names and specific values; carrying out specific value replacement on the replaceable area in the code prototype according to the configuration file to generate code content; and generating the JAVA class corresponding to the base layer according to the code content. The invention can greatly reduce the compiling work of basic codes, effectively shorten the project development time and the initial team standard time, and has concise and consistent code style.
Description
Technical Field
The invention relates to the technical field of internet, in particular to a micro-service construction method and device based on an intelligent generation basic code.
Background
In the current REST-style micro-service system development process, due to the reasons of different team coding styles, different technical depths, repeated writing of similar codes, different source-opening technologies adopted for realizing a certain function and the like, various problems of difficult code maintenance, excessive similar codes, fuzzy and messy naming semantics and the like exist in a final manufactured project, so that not only can the subsequent maintenance cost be increased, but also the codes of the project are bloated and disordered.
In the field of automatic code generation, eclipse and idea self-contained code generation functions are basically used at present, only methods such as get/set/toString/hashCode and the like of member variables in manually defined beans can be generated, real system development is not greatly facilitated, service codes of all basic layers of a software architecture still need to be handwritten, the problems still exist, and code quality and development speed cannot be effectively improved.
Disclosure of Invention
In order to solve the technical problem, the invention provides a micro-service construction method and a device based on an intelligent generation basic code.
The invention provides a micro-service construction method based on intelligent generation of basic codes, which comprises the following steps:
for each base layer of the software framework, the following processing is performed:
generating a code prototype for the base layer; the code prototype comprises an execution code part and an annotation part; the execution code section comprises at least one replaceable area, or the execution code section and the annotation section comprise at least one replaceable area; the replaceable area comprises a boundary identifier and replaceable content;
generating a configuration file for a base layer, wherein the configuration file comprises parameter names and specific values;
carrying out specific value replacement on the replaceable area in the code prototype according to the configuration file to generate code content;
and generating the JAVA class corresponding to the base layer according to the code content.
The micro-service construction method based on the intelligent generation basic code also has the following characteristics:
the generating a code prototype for the base layer includes:
generating the name of the code packet corresponding to the basic layer;
determining an external class of the JAVA class corresponding to the base layer, and referring to the external class;
setting annotation content; including part or all of the replaceable region in the annotation content;
setting a code, the code comprising part or all of the replaceable area.
The micro-service construction method based on the intelligent generation basic code also has the following characteristics:
when the base layer is a model layer or a base layer other than a model layer, the performing specific value replacement on the replaceable area in the code prototype according to the configuration file includes:
when the replaceable content comprises the parameter name in the configuration file of the model layer, replacing the replaceable area with a specific value corresponding to the parameter name in the configuration file of the model layer;
replacing the replaceable area with information representing an annotation of a data table in a configuration file of the model layer when the replaceable content includes an identification representing annotating the model layer;
when the replaceable content comprises an identifier for describing the class name of the model layer, the replaceable area is replaced after the information for representing the name of the data table in the configuration file of the model layer is subjected to naming rule conversion;
when the replaceable content comprises column information for describing a data table, a code segment is constructed according to a preset description format by using the information for representing the columns of the data table in the configuration file of the model layer and the information for representing the columns of the data table after naming rule conversion, and the replaceable area is replaced by using the code segment.
The micro-service construction method based on the intelligent generation basic code also has the following characteristics:
the code segment comprises a plurality of subsegments, the number of the subsegments is the same as that of columns of the data table, and each subsegment comprises a column name definition code, a column name annotation definition code and a column name of a private character string class.
The micro-service construction method based on the intelligent generation basic code also has the following characteristics:
when the base layer is a base layer other than the model layer, the performing specific value replacement on the replaceable area in the code prototype according to the parameter definition information in the configuration file includes:
when the replaceable content comprises the parameter name in the configuration file of the model layer or the basic layer, replacing the replaceable area by a specific value corresponding to the parameter name in the configuration file of the model layer or the basic layer;
when the replaceable content comprises an identification used for representing a base layer to which an annotation belongs, information used for representing the annotation of a data table in a configuration file of the model layer and the name of the base layer are used for forming a combined name, and the replaceable area is replaced by the combined name;
when the replaceable content comprises an identifier for describing the class name of the base layer, the information for representing the name of the data table in the configuration file of the model layer and a preset basic class name are used for forming a combined name, and the replaceable area is replaced by the combined name.
The micro-service construction device based on the intelligent generation basic code provided by the invention comprises:
the code prototype generating module is used for generating a code prototype for the base layer; the code prototype comprises an execution code part and an annotation part; the execution code section comprises at least one replaceable area, or the execution code section and the annotation section comprise at least one replaceable area; the replaceable area comprises a boundary identifier and replaceable content;
the configuration file generation module is used for generating a configuration file for the basic layer, wherein the configuration file comprises a parameter name and a specific value;
the code content generation module is used for carrying out specific value replacement on the replaceable area in the code prototype according to the configuration file to generate code content;
and the JAVA class generating module is used for generating the JAVA class corresponding to the base layer according to the code content.
The micro-service construction device based on the intelligent generation basic code also has the following characteristics:
the code prototype generation module comprises a name generation unit, an external class reference unit, a comment generation unit and a code generation unit;
the name generating unit is used for generating the name of the code packet corresponding to the basic layer;
the external class reference unit is used for determining an external class of the JAVA class corresponding to the base layer and referencing the external class;
the annotation generating unit is used for setting annotation content; including part or all of the replaceable region in the annotation content;
the code generating unit is used for setting a code, and the code comprises part or all of the replaceable area.
The micro-service construction device based on the intelligent generation basic code also has the following characteristics:
the code content generating module is further configured to, when the base layer is a model layer, perform specific value replacement on the replaceable area in the code prototype according to the configuration file by using the following method:
when the replaceable content comprises the parameter name in the configuration file of the model layer, replacing the replaceable area with a specific value corresponding to the parameter name in the configuration file of the model layer;
replacing the replaceable area with information representing an annotation of a data table in a configuration file of the model layer when the replaceable content includes an identification representing annotating the model layer;
when the replaceable content comprises an identifier for describing the class name of the model layer, the replaceable area is replaced after the information for representing the name of the data table in the configuration file of the model layer is subjected to naming rule conversion;
when the replaceable content comprises column information for describing a data table, a code segment is constructed according to a preset description format by using the information for representing the columns of the data table in the configuration file of the model layer and the information for representing the columns of the data table after naming rule conversion, and the replaceable area is replaced by using the code segment.
The micro-service construction device based on the intelligent generation basic code also has the following characteristics:
the code segment comprises a plurality of subsegments, the number of the subsegments is the same as that of columns of the data table, and each subsegment comprises a column name definition code, a column name annotation definition code and a column name of a private character string class.
The micro-service construction device based on the intelligent generation basic code also has the following characteristics:
the code content generating module is further configured to, when the base layer is a base layer other than the model layer, perform specific value replacement on the replaceable area in the code prototype according to the parameter definition information in the configuration file by using the following method:
when the replaceable content comprises the parameter name in the configuration file of the model layer or the basic layer, replacing the replaceable area by a specific value corresponding to the parameter name in the configuration file of the model layer or the basic layer;
when the replaceable content comprises an identification used for representing a base layer to which an annotation belongs, information used for representing the annotation of a data table in a configuration file of the model layer and the name of the base layer are used for forming a combined name, and the replaceable area is replaced by the combined name;
when the replaceable content comprises an identifier for describing the class name of the base layer, the information for representing the name of the data table in the configuration file of the model layer and a preset basic class name are used for forming a combined name, and the replaceable area is replaced by the combined name.
The invention generates basic codes aiming at each basic layer of a software architecture, sets a replaceable region, and replaces the replaceable region by using information in a configuration file, thereby automatically generating JAVA classes corresponding to each basic layer.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate an embodiment of the invention and, together with the description, serve to explain the invention and not to limit the invention. In the drawings:
FIG. 1 is a flowchart of a microservice construction method based on intelligent generation of base code in an embodiment;
FIG. 2 is a block diagram of a microservice construction method based on intelligent generation of basic code in the embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
As shown in fig. 1, in the micro-service construction method based on the intelligent generation of the basic code, for each basic layer of the software framework, the method includes:
step 101, generating a code prototype for a basic layer; the code prototype comprises an execution code part and an annotation part; the execution code section includes at least one replaceable area, or the execution code section and the annotation section include at least one replaceable area; the replaceable area comprises a boundary identifier and replaceable content;
102, generating a configuration file for a basic layer, wherein the configuration file comprises a parameter name and a specific value;
103, carrying out specific value replacement on the replaceable area in the code prototype according to the configuration file to generate code content;
and 104, generating the JAVA class corresponding to the basic layer according to the code content.
Wherein the content of the first and second substances,
the base layer of the software framework comprises: model layer, dao layer, service layer, servicempl layer and controller layer.
Generating a code prototype for the base layer in step 101 specifically includes:
step 1011, generating the name of the code packet corresponding to the basic layer;
step 1012, determining an external class of the JAVA class corresponding to the base layer, and referring to the external class;
step 1013, setting annotation content; including part or all of the replaceable region in annotation content; the annotation content may be JPA annotation, Swagger annotation, Lombok annotation. The above three comments, as follows: the method comprises the steps of automatically generating a data table, generating a swagger document and automatically generating get/set/hashcode/toString.
Step 1014, setting a code, wherein the code comprises part or all of the replaceable area.
When the base layer is a model layer, the step 103 of performing specific value replacement on the replaceable area in the code prototype according to the configuration file includes:
when the replaceable content comprises the parameter name in the configuration file of the model layer, replacing the replaceable area with a specific value corresponding to the parameter name in the configuration file of the model layer;
replacing the replaceable area with information representing an annotation of a data table in a configuration file of the model layer when the replaceable content includes an identification representing annotating the model layer;
when the replaceable content comprises an identifier for describing the class name of the model layer, the replaceable area is replaced after the information for representing the name of the data table in the configuration file of the model layer is subjected to naming rule conversion;
when the replaceable content comprises column information for describing a data table, a code segment is constructed according to a preset description format by using the information for representing the columns of the data table in the configuration file of the model layer and the information for representing the columns of the data table after naming rule conversion, and the replaceable area is replaced by using the code segment.
The code segment comprises a plurality of subsegments, the number of the subsegments is the same as that of columns of the data table, and each subsegment comprises a column name definition code, a column name annotation definition code and a column name of a private string class.
Examples are as follows:
example 1
Here, a Model layer prototype is specifically illustrated as follows:
generating the name of the code packet corresponding to the base layer:
package omc.models;
determining an external class of a JAVA class corresponding to a base layer, and referencing the external class:
import io.swagger.annatations.ApiModel;
import io.swagger.annatations.ApiModelProperty;
import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.util.List;
import lombok.Data;
setting the annotation content:
/**
*##DESC_MODEL##
*
*Created by##AUTHOR##on##DATE##
*/
setting a code:
@Entity
@Table(name=“##TABLE_NAME##”)
@ApiModel(value=“##DESC_MODEL##”)
@Data
Public class##CLASS_NAME_MODEL##extends BaseEntity{
##COLUMN_DESIGNS##
}
the configuration file includes: code author, code generation time, data table name, data table column definition. As shown in the following code:
Author=san.zhang
Date=2018-07-23
partner Table _ name
Partner name | email: String partner email
Zhang was san. author, 2018-07-23 was generated, data indicated partner, data table note partner, and data columns are two: partner _ name, String type, mapped to varchar type in mysql, annotated as partner name; email, String type, mapping to varchar type in mysql, annotated as partner email, multiple column definitions are separated by half angle.
In partner, the left side of the colon represents the name of the parameter and the right side of the colon represents the corresponding annotation.
In column name of partner | email: String: partner email, the vertical line is used to distinguish different column parameters.
The replaceable area includes boundaries constructed with boundaries identified as four #, and replaceable content between two # s.
And when the replaceable content comprises the parameter name in the parameter definition information, replacing the replaceable area by a specific value corresponding to the parameter name in the parameter definition information. For example, # # AUTHOR # # is replaced with the value corresponding to aouthor in the configuration file; at # DATE #, replacing with the value corresponding to DATE in the configuration file; and # TABLE _ NAME # # is replaced with the value corresponding to Table _ NAME in the configuration file.
Replacing the replaceable area with information representing annotations of a data table in a configuration file of a annotation model layer when the replaceable content includes an identification representing the annotation model layer; e.g. the label used to indicate the annotation MODEL layer is DESC _ mode, then the annotation in the profile, i.e. the partner, is replaced with a Table _ name _ partner at # DESC _ mode # #.
When the alternative content includes an identifier for describing a class name of the model layer, the alternative area is replaced after name rule conversion using information for representing a name of the data table in the configuration file of the model layer. The naming rule conversion refers to default rules such as class naming, member variable hump type naming, setget method naming and the like. For example, the CLASS NAME used to describe the MODEL layer is identified as CLASS _ NAME _ mode, and at # # CLASS _ NAME _ mode #, the NAME of Table _ NAME, that is, Partner, is used for CLASS naming, and is replaced after being converted into Partner.
When the replaceable content comprises column information for describing the data table, a code segment is constructed according to a preset description format by using the information for representing the columns of the data table in the configuration file of the model layer and the information for representing the columns of the data table after naming rule conversion, and the replaceable area is replaced by the code segment. The naming rule conversion refers to default rules such as class naming, member variable hump type naming, setget method naming and the like. For example, the predetermined description format of the # COLUMN _ signatures # section is:
@ Column (name ═ first Column name')
@ ApiModelProperty (value ═ first column Note ")
The name of the first column of the private String is converted by a naming rule;
@ Column (name ═ second Column name')
@ ApiModelProperty (value ═ second column Note ")
The name of the second row of the private String is converted by a naming rule;
after the replacement by the method, the method comprises the following steps:
@Column(name=“partner”)
@ ApiModelProperty (value ═ partner name')
private String partnerName;
@Column(name=“email”)
@ ApiModelProperty (value ═ partner email ")
After the method is used, the code after the code prototype of the Model is replaced is as follows:
package omc.models;
import io.swagger.annatations.ApiModel;
import io.swagger.annatations.ApiModelProperty;
import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.util.List;
import lombok.Data;
/**
partner
*
*Created by san.zhang on 2018-07-23
*/
@Entity
@Table(name=“partner”)
@ ApiModel (value ═ partner)
@Data
Public class Partner extends BaseEntity{
@Column(name=“partner”)
@ ApiModelProperty (value ═ partner name')
private String partnerName;
@Column(name=“email”)
@ apimodel property (value ═ partner email ") }
Example two
Here, the DAO layer prototype is exemplified, specifically as follows:
when the replaceable content comprises the parameter name in the configuration file of the model layer, replacing the replaceable area by a specific value corresponding to the parameter name in the configuration file of the model layer; for example, # # AUTHOR # # is replaced with the value corresponding to aouthor in the configuration file; # DATE # # is replaced with the value corresponding to the DATE in the configuration file.
When the replaceable content comprises an identification used for representing a base layer to which the annotation belongs, the information used for representing the annotation of the data table in the configuration file of the model layer and the name of the base layer form a combined name, and the replaceable area is replaced by the combined name; for example: at # DESC _ DAO #, the partner DAO layer operation classes are combined into a partner DAO layer operation class using the partner and DAO layer operation classes.
When the replaceable content includes an identifier for describing a class name of the base layer, a combined name is formed using information for representing a name of the data table in the configuration file of the model layer and a preset base class name, and the replaceable area is replaced with the combined name. For example, # # CLASS _ NAME _ DAO #, a PartnerDoo is combined using Partner and DAO.
The following code was obtained using this method:
fig. 2 is a block diagram of a microservice constructing apparatus based on an intelligent generation of basic code, as shown in fig. 2, the apparatus comprising:
the code prototype generating module is used for generating a code prototype for the base layer; the code prototype comprises an execution code part and an annotation part; the execution code section comprises at least one replaceable area, or the execution code section and the annotation section comprise at least one replaceable area; the replaceable area comprises a boundary identifier and replaceable content;
the configuration file generation module is used for generating a configuration file for the basic layer, wherein the configuration file comprises a parameter name and a specific value;
the code content generation module is used for carrying out specific value replacement on the replaceable area in the code prototype according to the configuration file to generate code content;
and the JAVA class generating module is used for generating the JAVA class corresponding to the base layer according to the code content.
Wherein the content of the first and second substances,
the code prototype generation module comprises a name generation unit, an external class reference unit, a comment generation unit and a code generation unit;
the name generating unit is used for generating the name of the code packet corresponding to the basic layer;
the external class reference unit is used for determining an external class of the JAVA class corresponding to the base layer and referencing the external class;
the annotation generating unit is used for setting annotation content; including part or all of the replaceable region in the annotation content;
the code generation unit is used for setting a code, and the code comprises part or all of the replaceable area.
For the molded layer:
the code content generation module is further used for carrying out specific value replacement on the replaceable area in the code prototype according to the configuration file by using the following method when the base layer is a model layer:
when the replaceable content comprises the parameter name in the configuration file of the model layer, replacing the replaceable area with a specific value corresponding to the parameter name in the configuration file of the model layer;
replacing the replaceable area with information representing an annotation of a data table in a configuration file of the model layer when the replaceable content includes an identification representing annotating the model layer;
when the replaceable content comprises an identifier for describing the class name of the model layer, the information for representing the name of the data table in the configuration file of the model layer is used for carrying out naming rule conversion and then replacing the replaceable area;
when the replaceable content comprises column information for describing the data table, a code segment is constructed according to a preset description format by using the information for representing the columns of the data table in the configuration file of the model layer and the information for representing the columns of the data table after naming rule conversion, and the replaceable area is replaced by using the code segment. The code segment comprises a plurality of subsections, the number of the subsections is the same as that of columns of the data table, and each subsection comprises a column name definition code, a column name annotation definition code and a column name of a private character string class.
For base layers other than model layers:
the code content generation module is also used for carrying out specific value replacement on the replaceable area in the code prototype according to the parameter definition information in the configuration file by using the following method when the base layer is a base layer except for the model layer:
when the replaceable content comprises the parameter name in the configuration file of the model layer or the basic layer, replacing the replaceable area by a specific value corresponding to the parameter name in the configuration file of the model layer or the basic layer;
when the replaceable content comprises an identification used for representing a base layer to which the annotation belongs, the information used for representing the annotation of the data table in the configuration file of the model layer and the name of the base layer are used for forming a combined name, and the replaceable area is replaced by the combined name;
when the replaceable content includes an identifier for describing a class name of the base layer, a combined name is formed using information for representing a name of a data table in a configuration file of the model layer and a preset base class name, and the replaceable area is replaced with the combined name.
The invention has the following advantages:
(1) the user only needs to input the name, time, data list name and data list definition of the author according to the fixed format to automatically generate the corresponding code, and the code compiling time is greatly saved.
(2) The template can define the method name, class name and member variable name in a uniform style, and finally the generated code is concise and consistent.
(3) The code template made through strict test can completely prevent the artificial writing error in the generated basic code, and zero bug is achieved.
(4) Standardize team development, improve development efficiency, improve code quality.
The above-described aspects may be implemented individually or in various combinations, and such variations are within the scope of the present invention.
It will be understood by those skilled in the art that all or part of the steps of the above methods may be implemented by instructing the relevant hardware through a program, and the program may be stored in a computer readable storage medium, such as a read-only memory, a magnetic or optical disk, and the like. Alternatively, all or part of the steps of the foregoing embodiments may also be implemented by using one or more integrated circuits, and accordingly, each module/unit in the foregoing embodiments may be implemented in the form of hardware, and may also be implemented in the form of a software functional module. The present invention is not limited to any specific form of combination of hardware and software.
It is to be noted that, in this document, the terms "comprises", "comprising" or any other variation thereof are intended to cover a non-exclusive inclusion, so that an article or apparatus including a series of elements includes not only those elements but also other elements not explicitly listed or inherent to such article or apparatus. Without further limitation, an element defined by the phrase "comprising … …" does not exclude the presence of additional like elements in the article or device comprising the element.
The above embodiments are merely to illustrate the technical solutions of the present invention and not to limit the present invention, and the present invention has been described in detail with reference to the preferred embodiments. It will be understood by those skilled in the art that various modifications and equivalent arrangements may be made without departing from the spirit and scope of the present invention and it should be understood that the present invention is to be covered by the appended claims.
Claims (10)
1. A micro-service construction method based on intelligent generation basic codes is characterized by comprising the following steps:
for each base layer of the software framework, the following processing is performed:
generating a code prototype for the base layer; the code prototype comprises an execution code part and an annotation part; the execution code section comprises at least one replaceable area, or the execution code section and the annotation section comprise at least one replaceable area; the replaceable area comprises a boundary identifier and replaceable content;
generating a configuration file for a base layer, wherein the configuration file comprises parameter names and specific values;
carrying out specific value replacement on the replaceable area in the code prototype according to the configuration file to generate code content;
and generating the JAVA class corresponding to the base layer according to the code content.
2. The micro-service building method based on intelligent generation of basic code according to claim 1,
the generating a code prototype for the base layer includes:
generating the name of the code packet corresponding to the basic layer;
determining an external class of the JAVA class corresponding to the base layer, and referring to the external class;
setting annotation content; including part or all of the replaceable region in the annotation content;
setting a code, the code comprising part or all of the replaceable area.
3. The micro-service building method based on intelligent generation of basic code according to claim 1,
when the base layer is a model layer or a base layer other than a model layer, the performing specific value replacement on the replaceable area in the code prototype according to the configuration file includes:
when the replaceable content comprises the parameter name in the configuration file of the model layer, replacing the replaceable area with a specific value corresponding to the parameter name in the configuration file of the model layer;
replacing the replaceable area with information representing an annotation of a data table in a configuration file of the model layer when the replaceable content includes an identification representing annotating the model layer;
when the replaceable content comprises an identifier for describing the class name of the model layer, the replaceable area is replaced after the information for representing the name of the data table in the configuration file of the model layer is subjected to naming rule conversion;
when the replaceable content comprises column information for describing a data table, a code segment is constructed according to a preset description format by using the information for representing the columns of the data table in the configuration file of the model layer and the information for representing the columns of the data table after naming rule conversion, and the replaceable area is replaced by using the code segment.
4. The micro-service building method based on intelligent generation of basic code according to claim 3,
the code segment comprises a plurality of subsegments, the number of the subsegments is the same as that of columns of the data table, and each subsegment comprises a column name definition code, a column name annotation definition code and a column name of a private character string class.
5. The micro-service building method based on intelligent generation of basic code according to claim 1,
when the base layer is a base layer other than the model layer, the performing specific value replacement on the replaceable area in the code prototype according to the parameter definition information in the configuration file includes:
when the replaceable content comprises the parameter name in the configuration file of the model layer or the basic layer, replacing the replaceable area by a specific value corresponding to the parameter name in the configuration file of the model layer or the basic layer;
when the replaceable content comprises an identification used for representing a base layer to which an annotation belongs, information used for representing the annotation of a data table in a configuration file of the model layer and the name of the base layer are used for forming a combined name, and the replaceable area is replaced by the combined name;
when the replaceable content comprises an identifier for describing the class name of the base layer, the information for representing the name of the data table in the configuration file of the model layer and a preset basic class name are used for forming a combined name, and the replaceable area is replaced by the combined name.
6. A micro-service building device based on intelligent generation of basic codes is characterized by comprising the following components:
the code prototype generating module is used for generating a code prototype for the base layer; the code prototype comprises an execution code part and an annotation part; the execution code section comprises at least one replaceable area, or the execution code section and the annotation section comprise at least one replaceable area; the replaceable area comprises a boundary identifier and replaceable content;
the configuration file generation module is used for generating a configuration file for the basic layer, wherein the configuration file comprises a parameter name and a specific value;
the code content generation module is used for carrying out specific value replacement on the replaceable area in the code prototype according to the configuration file to generate code content;
and the JAVA class generating module is used for generating the JAVA class corresponding to the base layer according to the code content.
7. The intelligent generation based microservice building apparatus of claim 6,
the code prototype generation module comprises a name generation unit, an external class reference unit, a comment generation unit and a code generation unit;
the name generating unit is used for generating the name of the code packet corresponding to the basic layer;
the external class reference unit is used for determining an external class of the JAVA class corresponding to the base layer and referencing the external class;
the annotation generating unit is used for setting annotation content; including part or all of the replaceable region in the annotation content;
the code generating unit is used for setting a code, and the code comprises part or all of the replaceable area.
8. The intelligent generation based microservice building apparatus of claim 6,
the code content generating module is further configured to, when the base layer is a model layer, perform specific value replacement on the replaceable area in the code prototype according to the configuration file by using the following method:
when the replaceable content comprises the parameter name in the configuration file of the model layer, replacing the replaceable area with a specific value corresponding to the parameter name in the configuration file of the model layer;
replacing the replaceable area with information representing an annotation of a data table in a configuration file of the model layer when the replaceable content includes an identification representing annotating the model layer;
when the replaceable content comprises an identifier for describing the class name of the model layer, the replaceable area is replaced after the information for representing the name of the data table in the configuration file of the model layer is subjected to naming rule conversion;
when the replaceable content comprises column information for describing a data table, a code segment is constructed according to a preset description format by using the information for representing the columns of the data table in the configuration file of the model layer and the information for representing the columns of the data table after naming rule conversion, and the replaceable area is replaced by using the code segment.
9. The intelligent generation based microservice building apparatus of claim 8,
the code segment comprises a plurality of subsegments, the number of the subsegments is the same as that of columns of the data table, and each subsegment comprises a column name definition code, a column name annotation definition code and a column name of a private character string class.
10. The intelligent generation based microservice building apparatus of claim 6,
the code content generating module is further configured to, when the base layer is a base layer other than the model layer, perform specific value replacement on the replaceable area in the code prototype according to the parameter definition information in the configuration file by using the following method:
when the replaceable content comprises the parameter name in the configuration file of the model layer or the basic layer, replacing the replaceable area by a specific value corresponding to the parameter name in the configuration file of the model layer or the basic layer;
when the replaceable content comprises an identification used for representing a base layer to which an annotation belongs, information used for representing the annotation of a data table in a configuration file of the model layer and the name of the base layer are used for forming a combined name, and the replaceable area is replaced by the combined name;
when the replaceable content comprises an identifier for describing the class name of the base layer, the information for representing the name of the data table in the configuration file of the model layer and a preset basic class name are used for forming a combined name, and the replaceable area is replaced by the combined name.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811149888.XA CN110968307A (en) | 2018-09-29 | 2018-09-29 | Micro-service construction method and device based on intelligent generation of basic codes |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811149888.XA CN110968307A (en) | 2018-09-29 | 2018-09-29 | Micro-service construction method and device based on intelligent generation of basic codes |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110968307A true CN110968307A (en) | 2020-04-07 |
Family
ID=70027576
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811149888.XA Pending CN110968307A (en) | 2018-09-29 | 2018-09-29 | Micro-service construction method and device based on intelligent generation of basic codes |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110968307A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113609138A (en) * | 2021-09-30 | 2021-11-05 | 成都数联云算科技有限公司 | Class and database table matching method, device, equipment and medium |
CN115438524A (en) * | 2022-11-09 | 2022-12-06 | 北京蓝天航空科技股份有限公司 | Code generation method, device, equipment and storage medium |
CN115437641A (en) * | 2022-11-07 | 2022-12-06 | 北京蓝天航空科技股份有限公司 | Code generation method, device, equipment and storage medium based on interface data |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101114226A (en) * | 2007-08-28 | 2008-01-30 | 北京中企开源信息技术有限公司 | Code automatically generating device based on model component, system and method |
CN101604241A (en) * | 2009-07-10 | 2009-12-16 | 杭州电子科技大学 | A kind of code generating method of embedded system |
CN101697120A (en) * | 2009-11-05 | 2010-04-21 | 河南辉煌科技股份有限公司 | Relational database based generation method of J2EE code |
CN102508669A (en) * | 2011-11-14 | 2012-06-20 | 浙江鸿程计算机系统有限公司 | Automatic program code generating method |
CN103135976A (en) * | 2011-11-30 | 2013-06-05 | 阿里巴巴集团控股有限公司 | Code automatic generation method and device |
CN103500087A (en) * | 2013-09-17 | 2014-01-08 | 福建亿榕信息技术有限公司 | Code generation method and device based on maven plug-in and freemarker template |
CN104331285A (en) * | 2014-10-30 | 2015-02-04 | 北京思特奇信息技术股份有限公司 | Automatic code generation method and system |
CN106469064A (en) * | 2016-09-04 | 2017-03-01 | 深圳市云智易联科技有限公司 | Code generating method and code generating unit |
CN106874019A (en) * | 2017-03-17 | 2017-06-20 | 微梦创科网络科技(中国)有限公司 | The generation method and skeletal code maker of a kind of skeletal code |
-
2018
- 2018-09-29 CN CN201811149888.XA patent/CN110968307A/en active Pending
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101114226A (en) * | 2007-08-28 | 2008-01-30 | 北京中企开源信息技术有限公司 | Code automatically generating device based on model component, system and method |
CN101604241A (en) * | 2009-07-10 | 2009-12-16 | 杭州电子科技大学 | A kind of code generating method of embedded system |
CN101697120A (en) * | 2009-11-05 | 2010-04-21 | 河南辉煌科技股份有限公司 | Relational database based generation method of J2EE code |
CN102508669A (en) * | 2011-11-14 | 2012-06-20 | 浙江鸿程计算机系统有限公司 | Automatic program code generating method |
CN103135976A (en) * | 2011-11-30 | 2013-06-05 | 阿里巴巴集团控股有限公司 | Code automatic generation method and device |
CN103500087A (en) * | 2013-09-17 | 2014-01-08 | 福建亿榕信息技术有限公司 | Code generation method and device based on maven plug-in and freemarker template |
CN104331285A (en) * | 2014-10-30 | 2015-02-04 | 北京思特奇信息技术股份有限公司 | Automatic code generation method and system |
CN106469064A (en) * | 2016-09-04 | 2017-03-01 | 深圳市云智易联科技有限公司 | Code generating method and code generating unit |
CN106874019A (en) * | 2017-03-17 | 2017-06-20 | 微梦创科网络科技(中国)有限公司 | The generation method and skeletal code maker of a kind of skeletal code |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113609138A (en) * | 2021-09-30 | 2021-11-05 | 成都数联云算科技有限公司 | Class and database table matching method, device, equipment and medium |
CN115437641A (en) * | 2022-11-07 | 2022-12-06 | 北京蓝天航空科技股份有限公司 | Code generation method, device, equipment and storage medium based on interface data |
CN115438524A (en) * | 2022-11-09 | 2022-12-06 | 北京蓝天航空科技股份有限公司 | Code generation method, device, equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
EP3433732B1 (en) | Converting visual diagrams into code | |
CN108292231B (en) | Method and system for generating applications from data | |
Kaliszyk et al. | Holstep: A machine learning dataset for higher-order logic theorem proving | |
US11137871B2 (en) | System and method for interface display screen manipulation | |
CN105511873B (en) | User interface control display method and device | |
KR101597780B1 (en) | Method and apparatus for visually implementing software code | |
US20120266131A1 (en) | Automatic program generation device, method, and computer program | |
CN108351796A (en) | Unified interface specification for interacting and executing model with model in various runtime environments | |
US20190332358A1 (en) | Method and system for automated creation of graphical user interfaces | |
CN110968307A (en) | Micro-service construction method and device based on intelligent generation of basic codes | |
US20130144920A1 (en) | Creating a configuration file template | |
CN108469955B (en) | Annotation-based Android injection framework implementation method | |
CN112328226B (en) | Embedded system automatic test code generation method and device | |
Steimann et al. | Generic model assist | |
US20210365258A1 (en) | Method and system for updating legacy software | |
Bonaventura et al. | Graphical modeling and simulation of discrete-event systems with CD++ Builder | |
CN115878092A (en) | Code generation method, device and medium based on micro-service architecture | |
CN111124380A (en) | Front-end code generation method | |
JP2022082524A (en) | Method and apparatus for providing information using learning model through machine learning | |
CN112582073B (en) | Medical information acquisition method, device, electronic equipment and medium | |
US11822896B2 (en) | Contextual diagram-text alignment through machine learning | |
Klinbua et al. | Translating tosca into docker-compose yaml file using antlr | |
US11886810B2 (en) | System and method for electronic document interaction with external resources | |
CN115686589A (en) | Entity class file updating system and method, corresponding computer equipment and storage medium | |
CN109254774A (en) | The management method and device of code in software development 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 | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20200407 |
|
RJ01 | Rejection of invention patent application after publication |