CN110989999A - Code generation method and device, electronic equipment and medium - Google Patents

Code generation method and device, electronic equipment and medium Download PDF

Info

Publication number
CN110989999A
CN110989999A CN201911219388.3A CN201911219388A CN110989999A CN 110989999 A CN110989999 A CN 110989999A CN 201911219388 A CN201911219388 A CN 201911219388A CN 110989999 A CN110989999 A CN 110989999A
Authority
CN
China
Prior art keywords
code
entity class
codes
entity
determining
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
CN201911219388.3A
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.)
Wanghai Kangxin Beijing Technology Co Ltd
Original Assignee
Wanghai Kangxin Beijing Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wanghai Kangxin Beijing Technology Co Ltd filed Critical Wanghai Kangxin Beijing Technology Co Ltd
Priority to CN201911219388.3A priority Critical patent/CN110989999A/en
Publication of CN110989999A publication Critical patent/CN110989999A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/33Intelligent editors

Abstract

The embodiment of the application provides a code generation method, a code generation device, electronic equipment and a medium. The method comprises the following steps: the method comprises the steps of determining first entity class codes corresponding to all database tables respectively based on a first entity class code template edited in advance and at least one database table, determining first entity class names corresponding to all database tables respectively based on the first entity class codes corresponding to all database tables respectively, and generating at least one processing code based on a processing code template edited in advance and the first entity class names. According to the embodiment of the application, the at least one processing code is automatically generated based on the at least one database table, the processing code can be automatically generated when the number of the database tables is large, and the problem that manual code compiling consumes more human resources and time resources is solved, so that the workload of manual code compiling is reduced, the cost of developing new services is reduced, and the user experience is improved.

Description

Code generation method and device, electronic equipment and medium
Technical Field
The present application relates to the field of software development technologies, and in particular, to a code generation method, apparatus, electronic device, and medium.
Background
With the continuous development of internet technology, informatization has been integrated into the aspects of our lives, more and more people participate in the information technology industry and in programming work, and programmers realize certain functions on corresponding development tools by writing codes.
In the prior art, when a programmer develops a new service, at least one database table is designed according to requirements, and for each database table, the programmer needs to manually write codes corresponding to the database table to realize functions such as addition, deletion, modification, search and the like. Generally, when a programmer manually writes codes corresponding to a database table, the programmer is required to manually write at least one processing code of a data access layer code, a business layer code, a micro-service layer code and a controller layer code, and when the number of the database tables is large, manually writing any processing code of the data access layer code, the business layer code, the micro-service layer code and the controller layer code consumes more human resources and time resources, and the workload of manually writing the codes is large, so that the cost of developing new services is high, and the user experience is poor.
Disclosure of Invention
The application provides a code generation method, a code generation device, an electronic device and a medium, which can solve at least one technical problem.
In a first aspect, a code generation method is provided, and the method includes:
determining first entity class codes respectively corresponding to the database tables based on a first entity class code template edited in advance and at least one database table;
determining each first entity class name based on the first entity class codes respectively corresponding to each database table;
at least one processing code is generated based on the pre-edited processing code template and each first entity class name.
In a second aspect, there is provided a code generation apparatus, the apparatus comprising:
the first determining module is used for determining a first entity class code corresponding to each database table based on a first entity class code template edited in advance and at least one database table;
the second determining module is used for determining each first entity class name based on the first entity class codes respectively corresponding to each database table;
and the generating module is used for generating at least one processing code based on the pre-edited processing code template and each first entity class name.
In a third aspect, an electronic device is provided, which includes:
one or more processors;
a memory;
one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to: and executing the corresponding operation according to the code generation method shown in the first aspect.
In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the code generation method shown in the first aspect.
The beneficial effect that technical scheme that this application provided brought is:
compared with the prior art, the code generation method, the code generation device, the electronic equipment and the medium have the advantages that the first entity class codes corresponding to the database tables are determined based on the first entity class code template edited in advance and at least one database table, the first entity class names are determined based on the first entity class codes corresponding to the database tables, and at least one processing code is generated based on the processing code template edited in advance and the first entity class names.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings used in the description of the embodiments of the present application will be briefly described below.
Fig. 1 is a schematic flowchart of a code generation method according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of a code generation apparatus according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to embodiments of the present application, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the drawings are exemplary only for the purpose of explaining the present application and are not to be construed as limiting the present application.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may also be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. As used herein, the term "and/or" includes all or any element and all combinations of one or more of the associated listed items.
To make the objects, technical solutions and advantages of the present application more clear, embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
An embodiment of the present application provides a code generation method, which may be executed by a terminal device or a server, as shown in fig. 1, where the method includes:
step S101, determining first entity class codes respectively corresponding to each database table based on a first entity class code template edited in advance and at least one database table.
For the embodiment of the application, a one-to-one mapping relationship exists between the first entity class code and the database table, that is, one database table corresponds to one first entity class code. In the embodiment of the application, a first entity class code corresponding to any database table is determined by using a first entity class code template edited in advance and the database table.
Step S102, determining each first entity class name based on the first entity class code corresponding to each database table.
For the embodiment of the application, the first entity class name corresponding to any database table can be determined based on the first entity class code corresponding to the any database table. In the embodiment of the application, the table name of any database table is the first entity class name corresponding to the database table.
Step S103, generating at least one processing code based on the processing code template edited in advance and each first entity class name.
For the embodiment of the present application, the processing code may be generated based on a pre-edited processing code template and any entity class name, or the processing code may be generated based on a pre-edited processing code template and at least two entity class names, that is, the processing code and the entity class name may have a one-to-one mapping relationship or a one-to-many mapping relationship, which is not limited in the embodiment of the present application.
For the embodiment of the application, abstract and generic technologies are used to write abstract class codes with functions of add operation, delete operation, modify operation, and search operation, that is, a pre-edited processing code template includes an interface of add operation and its implementation code, an interface of delete operation and its implementation code, an interface of modify operation and its implementation code, and an interface of search operation and its implementation code. In the embodiment of the application, the generated processing code has the processing functions of performing addition operation, deletion operation, modification operation and search operation on the database table.
Compared with the prior art, the code generation method has the advantages that the first entity class codes corresponding to the database tables are determined based on the first entity class code templates edited in advance and the at least one database table, the first entity class names are determined based on the first entity class codes corresponding to the database tables, and the at least one processing code is generated based on the processing code templates edited in advance and the first entity class names.
In another possible implementation manner of the embodiment of the present application, step S101 may specifically include: determining replaceable codes in the first entity code template, respectively extracting metadata information of each database table from at least one database table, and respectively replacing the replaceable codes in the first entity code template by the metadata information of each database table to obtain the first entity code corresponding to each database table.
For the embodiment of the application, a plurality of database tables can be determined based on preconfigured database link information, at least one database table is determined based on a selection operation of a user for the plurality of database tables, and metadata information of each database table is extracted from the at least one database table respectively, wherein the metadata information of any database table includes a table name of the any database table, description information of the database table, a field name, a field type, field description information, primary key information, and the like. In the embodiment of the application, the metadata information of any database table is used for replacing the replaceable codes in the first entity class code template, so that the first entity class code corresponding to the any database table is obtained.
Further, after the above steps S101 and S102 are executed, step S103 may be executed as follows:
in another possible implementation manner of the embodiment of the present application, if the processing code includes a data access layer code, step S103 may include: and determining replaceable codes in the pre-edited data access layer code template, and replacing the replaceable codes in the data access layer code template by using each first entity class name to obtain at least one data access layer code.
For the embodiment of the application, the code template of the data access layer comprises an interface for adding operation and a realization code thereof, an interface for deleting operation and a realization code thereof, an interface for modifying operation and a realization code thereof, and an interface for searching operation and a realization code thereof. In the embodiment of the application, a template rendering technology is used for performing template rendering on each first entity class and the data access layer code template to generate the data access layer code, that is, each first entity class name is used for replacing a replaceable code in the data access layer code template to obtain at least one data access layer code. In the embodiment of the application, a one-to-one mapping relationship or a one-to-many mapping relationship exists between the data access layer code and the first entity class name.
For the embodiment of the application, the data access layer code is used for reading data in the database table and transferring the data to the business layer code.
For the embodiment of the present application, the processing code may include a service layer code in addition to a data access layer code, and the manner of determining the service layer code is as follows:
in another possible implementation manner of the embodiment of the present application, if the processing code may further include a service layer code, before step S103, the method may further include: a class name for each data access layer code is determined based on at least one data access layer code.
Wherein, step S103 may further include: and determining replaceable codes in a service layer code template edited in advance, and replacing the replaceable codes in the service layer code template by using each first entity class name and the class name of each data access layer code to obtain at least one service layer code.
For embodiments of the present application, when the processing code includes a data access layer code and a business layer code, a class name of each data access layer code may be determined based on at least one data access layer code. The method may include generating at least one data access layer code in the manner of the above-described embodiment of the present application, or obtaining at least one data access layer code in a manner of the prior art, so as to determine a class name of each data access layer code according to the at least one data access layer code.
For the embodiment of the application, the service layer code template includes an interface for adding operation and a realization code thereof, an interface for deleting operation and a realization code thereof, an interface for modifying operation and a realization code thereof, and an interface for searching operation and a realization code thereof. In the embodiment of the application, a template rendering technology is used to perform template rendering on each first entity class and a service layer code template to generate a service layer code, that is, each first entity class name and the class name of each data access layer code are used to replace a replaceable code in the service layer code template to obtain at least one service layer code. In the embodiment of the application, a one-to-one mapping relationship or a one-to-many mapping relationship exists between the service layer code and the data access layer class name; a one-to-one mapping relationship or a one-to-many mapping relationship exists between the business layer code and the first entity class name.
For the embodiment of the application, the business layer code is used for processing and converting the data in the database table.
For the embodiment of the present application, the processing code may include a controller layer code in addition to a data access layer code and a service layer code, and the manner of determining the controller layer code is as follows:
in another possible implementation manner of the embodiment of the present application, if the processing code further includes a controller layer code, before step S103, the method may further include:
and determining second entity class codes corresponding to the database tables respectively based on the pre-edited second entity class code template and at least one database table, determining second entity class names based on the second entity class codes corresponding to the database tables respectively, and determining the class names of the business layer codes based on at least one business layer code.
And the attribute name of the second entity class code is different from the attribute name of the first entity class code.
For the embodiment of the present application, the replaceable codes in the second entity type code template may be determined, the metadata information of each database table is extracted from at least one database table, and the metadata information of each database table is used to replace the replaceable codes in the second entity type code template, so as to obtain the second entity type codes corresponding to each database table.
Further, the second entity class names are determined based on the second entity class codes respectively corresponding to the database tables, and the class names of the business layer codes are determined based on at least one business layer code.
Wherein, step S103 may further include: determining replaceable codes in a pre-edited controller layer code template; and replacing the replaceable codes in the controller layer code template by using the first entity class names, the second entity class names and the class names of the service layer codes to obtain at least one controller layer code.
For the embodiment of the present application, when the processing code includes a data access layer code, a service layer code, and a controller layer code, at least one service layer code may be generated by using the method of the above embodiment of the present application, or at least one service layer code may be obtained by using a method in the prior art, so as to determine the class name of each service layer code according to the at least one service layer code.
For the embodiment of the application, the controller layer code template includes an interface for adding operation and a realization code thereof, an interface for deleting operation and a realization code thereof, an interface for modifying operation and a realization code thereof, and an interface for searching operation and a realization code thereof. In the embodiment of the present application, a template rendering technology is used to perform template rendering on each first entity class, each second entity class and a controller layer code template, so as to generate a controller layer code, that is, a replaceable code in the controller layer code template is replaced by using each first entity class name, each second entity class name and a class name of each service layer code, so as to obtain at least one controller layer code. In the embodiment of the application, a one-to-one mapping relationship or a one-to-many mapping relationship exists between the controller layer code and the service layer class name; one-to-one mapping relation or one-to-many mapping relation exists between the controller layer codes and the first entity class names; and a one-to-one mapping relation or a one-to-many mapping relation exists between the controller layer codes and the second entity class names.
The controller layer code template comprises a mapping relation between the attribute name in the first entity class and the attribute name in the second entity class.
For the embodiment of the application, the controller layer code is used for data interaction between the back end and the back end.
For the embodiment of the present application, the processing code may include a microservice layer code in addition to a data access layer code, a business layer code, and a controller layer code, and the manner of determining the microservice layer code is as follows:
in another possible implementation manner of the embodiment of the present application, if the processing code further includes a microservice layer code, before step S103, the method may further include: and determining third entity class codes corresponding to the database tables respectively based on the pre-edited third entity class code template and at least one database table, and determining third entity class names based on the third entity class codes corresponding to the database tables respectively.
The attribute name of the third entity class code is different from the attribute name of the first entity class code, and the attribute name of the third entity class code is different from the attribute name of the second entity class code.
For the embodiment of the present application, the replaceable codes in the third entity type code template may be determined, the metadata information of each database table is respectively extracted from at least one database table, and the metadata information of each database table is used to respectively replace the replaceable codes in the third entity type code template, so as to obtain the third entity type codes corresponding to each database table.
Step S103 may further include: determining replaceable codes in a micro service layer code template edited in advance; and replacing the replaceable codes in the micro-service layer code template by using each first entity class name, each third entity class name and the class name of each service layer code to obtain at least one micro-service layer code.
For the embodiment of the present application, when the processing code includes a data access layer code, a service layer code, a micro service layer code, and a controller layer code, at least one service layer code may be generated in the manner of the above embodiment of the present application, or at least one service layer code may be obtained in the manner of the prior art, so as to determine the class name of each service layer code according to the at least one service layer code.
For the embodiment of the application, the micro service layer code template comprises an interface for adding operation and a realization code thereof, an interface for deleting operation and a realization code thereof, an interface for modifying operation and a realization code thereof, and an interface for searching operation and a realization code thereof. In the embodiment of the application, a template rendering technology is used to perform template rendering on each first entity class, each third entity class and a controller layer code template to generate a controller layer code, that is, each first entity class name, each third entity class name and the class name of each service layer code are used to replace a replaceable code in a micro service layer code template to obtain at least one micro service layer code. In the embodiment of the application, a one-to-one mapping relationship or a one-to-many mapping relationship exists between the micro service layer code and the business layer class name; a one-to-one mapping relation or a one-to-many mapping relation exists between the micro service layer codes and the first entity class names; and a one-to-one mapping relation or a one-to-many mapping relation exists between the microservice layer code and the third entity class name.
The micro service layer code template comprises a mapping relation between the attribute name in the first entity class and the attribute name in the third entity class.
For the embodiment of the application, the micro service layer code is used for data interaction between the back end and the front end.
For the embodiment of the present application, when the processing code includes a data access layer code, a service layer code, a microservice layer code, and a controller layer code, the manner of determining the controller layer code is as follows:
another possible implementation manner of the embodiment of the present application, after obtaining at least one microservice layer code, may further include: determining a class name of each micro service layer code based on at least one micro service layer code; and replacing the replaceable codes in the controller layer code template by using the class name, the second entity class name and the third entity class name of each microservice layer code to obtain at least one controller layer code.
For the embodiment of the present application, when the processing code includes a data access layer code, a business layer code, a microservice layer code, and a controller layer code, at least one microservice layer code may be generated in the manner of the above-described embodiment of the present application, or at least one microservice layer code may be obtained in the manner of the prior art, so as to determine the class name of each microservice layer code according to the at least one microservice layer code.
For the embodiment of the application, the controller layer code template includes an interface for adding operation and a realization code thereof, an interface for deleting operation and a realization code thereof, an interface for modifying operation and a realization code thereof, and an interface for searching operation and a realization code thereof. In the embodiment of the present application, a template rendering technology is used to perform template rendering on each second entity class, each third entity class, and the controller layer code template, so as to generate a controller layer code, that is, a class name of each microservice layer code, each second entity class name, and each third entity class name are used to replace a replaceable code in the controller layer code template, so as to obtain at least one controller layer code. In the embodiment of the application, a one-to-one mapping relationship or a one-to-many mapping relationship exists between the controller layer code and the class name of the micro service layer; one-to-one mapping relation or one-to-many mapping relation exists between the controller layer codes and the second entity class names; and a one-to-one mapping relation or a one-to-many mapping relation exists between the controller layer codes and the third entity class names.
The controller layer code template comprises a mapping relation between the attribute name in the second entity class and the attribute name in the third entity class.
The code generation method is specifically set forth from the perspective of the method steps, and the following introduces the code generation apparatus from the perspective of the virtual module or the virtual unit, specifically as follows:
an embodiment of the present application provides a code generation apparatus, and as shown in fig. 2, the code generation apparatus 20 may include: a first determining module 201, a second determining module 202, and a generating module 203, wherein,
the first determining module 201 is configured to determine, based on a first entity class code template edited in advance and at least one database table, first entity class codes corresponding to the database tables respectively.
The second determining module 202 is configured to determine each first entity class name based on the first entity class code corresponding to each database table.
And the generating module 203 is used for generating at least one processing code based on the pre-edited processing code template and each first entity class name.
In another possible implementation manner of the embodiment of the present application, the first determining module 201 includes a first determining unit, an extracting unit, and a first replacing unit, wherein,
a first determining unit for determining the replaceable codes in the first entity class code template.
And the extraction unit is used for respectively extracting the metadata information of each database table from at least one database table.
And the first replacing unit is used for replacing the replaceable codes in the first entity code template by utilizing the metadata information of each database table to obtain the first entity codes corresponding to each database table.
In another possible implementation manner of the embodiment of the present application, when the processing code includes a data access layer code, the generating module 203 includes a second determining unit and a second replacing unit, wherein,
and the second determining unit is used for determining the replaceable codes in the pre-edited data access layer code template.
And the second replacing unit is used for replacing the replaceable codes in the data access layer code template by using the first entity class names to obtain at least one data access layer code.
In another possible implementation manner of this embodiment of the application, when the processing code further includes a service layer code, the code generation apparatus 20 further includes a third determining module, wherein,
and the third determining module is used for determining the class name of each data access layer code based on at least one data access layer code.
Wherein the generating module 203 further comprises a third determining unit and a third replacing unit, wherein,
and the third determining unit is used for determining the replaceable codes in the service layer code template edited in advance.
And the third replacing unit is used for replacing the replaceable codes in the service layer code template by using the class names of the first entity classes and the data access layer codes to obtain at least one service layer code.
In another possible implementation manner of the embodiment of the present application, when the processing code further includes a controller layer code, the code generation apparatus 20 further includes a fourth determination module, a fifth determination module, and a sixth determination module, wherein,
and the fourth determining module is used for determining the second entity class codes corresponding to the database tables respectively based on the pre-edited second entity class code template and at least one database table.
And the attribute name of the second entity class code is different from the attribute name of the first entity class code.
And the fifth determining module is used for determining each second entity class name based on the second entity class codes respectively corresponding to each database table.
And the sixth determining module is used for determining the class name of each service layer code based on at least one service layer code.
Wherein the generating module 203 further comprises a fourth determining unit and a fourth replacing unit, wherein,
and the fourth determination unit is used for determining the replaceable codes in the pre-edited controller layer code template.
And the fourth replacing unit is used for replacing the replaceable codes in the controller layer code template by using the first entity class names, the second entity class names and the class names of the service layer codes to obtain at least one controller layer code.
In another possible implementation manner of the embodiment of the present application, when the processing code further includes a micro service layer code, the code generation apparatus 20 further includes a seventh determining module and an eighth determining module, wherein,
and the seventh determining module is used for determining the third entity class codes corresponding to the database tables respectively based on the pre-edited third entity class code template and at least one database table.
The attribute name of the third entity class code is different from the attribute name of the first entity class code, and the attribute name of the third entity class code is different from the attribute name of the second entity class code.
And the eighth determining module is used for determining each third entity class name based on the third entity class code corresponding to each database table.
Wherein the generating module 203 further comprises a fifth determining unit and a fifth replacing unit, wherein,
and the fifth determining unit is used for determining replaceable codes in the micro service layer code template edited in advance.
And the fifth replacing unit is used for replacing the replaceable codes in the micro-service layer code template by using each first entity class name, each third entity class name and the class name of each service layer code to obtain at least one micro-service layer code.
In another possible implementation manner of the embodiment of the present application, the code generation apparatus 20 further includes a ninth determining module and a replacing module, wherein,
and the ninth determining module is used for determining the class name of each micro service layer code based on at least one micro service layer code.
And the replacing module is used for replacing the replaceable codes in the controller layer code template by using the class names of the micro service layer codes, the second entity class names and the third entity class names to obtain at least one controller layer code.
For the embodiment of the application, the first determining module, the second determining module, the third determining module, the fourth determining module, the fifth determining module and the sixth determining module, the seventh determining module, the eighth determining module, and the ninth determining module may be the same determining module, or different determining modules, or may be combined into the same determining module at will, the second determining unit, the third determining unit, the fourth determining unit, and the fifth determining unit may be the same determining unit, or different determining units, or may be combined into the same determining unit at will, and the second replacing unit, the third replacing unit, the fourth replacing unit, and the fifth replacing unit may be the same replacing unit, or different replacing units, or may be combined into the same replacing unit at will, which is not limited in this embodiment of the application.
The code generation apparatus 20 of this embodiment can execute the code generation method shown in any of the above embodiments of this application, and the implementation principles thereof are similar and will not be described herein again.
Compared with the prior art, the code generation device determines the first entity class codes corresponding to the database tables respectively based on the first entity class code template edited in advance and the at least one database table, determines the first entity class names based on the first entity class codes corresponding to the database tables respectively, and generates the at least one processing code based on the processing code template edited in advance and the first entity class names, so that the automatic generation of the processing code based on the database tables is realized, the defect that more human resources and time resources are consumed when the processing code is manually written in the prior art is overcome, the workload of manually writing the code is greatly reduced, the cost of developing a new service is reduced, and the efficiency of developing the new service is improved.
The code generation apparatus of the present application is described above from the perspective of a virtual module or a virtual unit, and the electronic device of the present application is described below from the perspective of a physical device.
An embodiment of the present application provides an electronic device, as shown in fig. 3, an electronic device 4000 shown in fig. 3 includes: a processor 4001 and a memory 4003. Processor 4001 is coupled to memory 4003, such as via bus 4002. Optionally, the electronic device 4000 may further comprise a transceiver 4004. In addition, the transceiver 4004 is not limited to one in practical applications, and the structure of the electronic device 4000 is not limited to the embodiment of the present application.
Processor 4001 may be a CPU, general purpose processor, DSP, ASIC, FPGA or other programmable logic device, transistor logic device, hardware component, or any combination thereof. Which may implement or perform the various illustrative logical blocks, modules, and circuits described in connection with the disclosure. The processor 4001 may also be a combination that performs a computational function, including, for example, a combination of one or more microprocessors, a combination of a DSP and a microprocessor, or the like.
Bus 4002 may include a path that carries information between the aforementioned components. Bus 4002 may be a PCI bus, EISA bus, or the like. The bus 4002 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 3, but this does not mean only one bus or one type of bus.
Memory 4003 may be, but is not limited to, a ROM or other type of static storage device that can store static information and instructions, a RAM or other type of dynamic storage device that can store information and instructions, an EEPROM, a CD-ROM or other optical disk storage, an optical disk storage (including compact disk, laser disk, optical disk, digital versatile disk, blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer.
The memory 4003 is used for storing application codes for executing the scheme of the present application, and the execution is controlled by the processor 4001. Processor 4001 is configured to execute application code stored in memory 4003 to implement what is shown in any of the foregoing method embodiments.
An embodiment of the present application provides an electronic device, where the electronic device includes: a memory and a processor; at least one program stored in the memory for execution by the processor, which when executed by the processor, implements: according to the method and the device, the first entity class codes corresponding to the database tables are determined based on the first entity class code templates edited in advance and the at least one database table, the first entity class names are determined based on the first entity class codes corresponding to the database tables, and the at least one processing code is generated based on the processing code templates edited in advance and the first entity class names.
The electronic device of the present application is described above from the perspective of a physical device, and the computer-readable storage medium of the present application is described below from the perspective of a storage medium.
The present application provides a computer-readable storage medium, on which a computer program is stored, which, when running on a computer, enables the computer to execute the corresponding content in the foregoing method embodiments. Compared with the prior art, the method and the device have the advantages that the first entity type codes corresponding to the database tables are determined based on the first entity type code templates edited in advance and the at least one database table, the first entity type names are determined based on the first entity type codes corresponding to the database tables, and the at least one processing code is generated based on the processing code templates edited in advance and the first entity type names.
It should be understood that, although the steps in the flowcharts of the figures are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and may be performed in other orders unless explicitly stated herein. Moreover, at least a portion of the steps in the flow chart of the figure may include multiple sub-steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, which are not necessarily performed in sequence, but may be performed alternately or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
The foregoing is only a partial embodiment of the present application, and it should be noted that, for those skilled in the art, several modifications and decorations can be made without departing from the principle of the present application, and these modifications and decorations should also be regarded as the protection scope of the present application.

Claims (10)

1. A code generation method, comprising:
determining first entity class codes respectively corresponding to the database tables based on a first entity class code template edited in advance and at least one database table;
determining each first entity class name based on the first entity class codes respectively corresponding to each database table;
and generating at least one processing code based on the pre-edited processing code template and the first entity class names.
2. The method of claim 1, wherein the determining the first entity class code corresponding to each database table based on the pre-edited first entity class code template and at least one database table comprises:
determining replaceable codes in the first entity class code template;
respectively extracting metadata information of each database table from the at least one database table;
and replacing the replaceable codes in the first entity code template by using the metadata information of each database table to obtain the first entity codes corresponding to each database table.
3. The method according to claim 1 or 2, wherein if the processing code comprises a data access layer code, the generating at least one processing code based on a pre-edited processing code template and the respective first entity class name comprises:
determining replaceable codes in a pre-edited data access layer code template;
and replacing the replaceable codes in the data access layer code template by using the first entity class names to obtain at least one data access layer code.
4. The method of claim 3, wherein before generating at least one processing code based on the pre-edited processing code template and the respective first entity class names if the processing code further comprises a business layer code, the method further comprises:
determining a class name for each data access layer code based on the at least one data access layer code;
wherein the generating at least one processing code based on the pre-edited processing code template and the respective first entity class names further comprises:
determining replaceable codes in a service layer code template edited in advance;
and replacing the replaceable codes in the service layer code template by using the first entity class names and the class names of the data access layer codes to obtain at least one service layer code.
5. The method of claim 4, wherein if the process code further comprises controller-level code, before generating at least one process code based on the pre-edited process code template and the respective first entity class names, the method further comprises:
determining second entity type codes corresponding to the database tables respectively based on a second entity type code template edited in advance and the at least one database table, wherein the attribute names of the second entity type codes are different from the attribute names of the first entity type codes;
determining each second entity class name based on the second entity class codes respectively corresponding to each database table;
determining a class name of each service layer code based on the at least one service layer code;
wherein the generating at least one processing code based on the pre-edited processing code template and the respective first entity class names further comprises:
determining replaceable codes in a pre-edited controller layer code template;
and replacing the replaceable codes in the controller layer code template by using the first entity class names, the second entity class names and the class names of the service layer codes to obtain at least one controller layer code.
6. The method of claim 5, wherein before generating at least one processing code based on the pre-edited processing code template and the respective first entity class names if the processing code further comprises microservice layer code, the method further comprises:
determining a third entity class code corresponding to each database table respectively based on a pre-edited third entity class code template and the at least one database table, wherein the attribute name of the third entity class code is different from the attribute name of the first entity class code, and the attribute name of the third entity class code is different from the attribute name of the second entity class code;
determining each third entity class name based on the third entity class codes respectively corresponding to each database table;
wherein the generating at least one processing code based on the pre-edited processing code template and the respective first entity class names further comprises:
determining replaceable codes in a micro service layer code template edited in advance;
and replacing the replaceable codes in the micro service layer code template by using the first entity class names, the third entity class names and the class names of the service layer codes to obtain at least one micro service layer code.
7. The method of claim 6, wherein after obtaining at least one microservice layer code, further comprising:
determining a class name of each micro service layer code based on the at least one micro service layer code;
and replacing the replaceable codes in the controller layer code template by using the class names of the micro service layer codes, the second entity class names and the third entity class names to obtain at least one controller layer code.
8. A code generation apparatus, comprising:
the first determining module is used for determining a first entity class code corresponding to each database table based on a first entity class code template edited in advance and at least one database table;
a second determining module, configured to determine each first entity class name based on the first entity class code corresponding to each database table;
and the generating module is used for generating at least one processing code based on the pre-edited processing code template and each first entity class name.
9. An electronic device, comprising:
one or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more programs configured to: executing the code generation method according to any of claims 1 to 7.
10. A computer-readable storage medium on which a computer program is stored, the program, when executed by a processor, implementing the code generation method of any one of claims 1 to 7.
CN201911219388.3A 2019-12-03 2019-12-03 Code generation method and device, electronic equipment and medium Pending CN110989999A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911219388.3A CN110989999A (en) 2019-12-03 2019-12-03 Code generation method and device, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911219388.3A CN110989999A (en) 2019-12-03 2019-12-03 Code generation method and device, electronic equipment and medium

Publications (1)

Publication Number Publication Date
CN110989999A true CN110989999A (en) 2020-04-10

Family

ID=70089686

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911219388.3A Pending CN110989999A (en) 2019-12-03 2019-12-03 Code generation method and device, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN110989999A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111666073A (en) * 2020-06-12 2020-09-15 远光软件股份有限公司 Graphical model construction method and device based on domain-driven design
CN112711405A (en) * 2020-12-28 2021-04-27 山东浪潮通软信息科技有限公司 Method, equipment and storage medium for generating add-delete-modify-check application program interface

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109359112A (en) * 2018-10-15 2019-02-19 行吟信息科技(上海)有限公司 A kind of automatic generation method and code generator of code

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109359112A (en) * 2018-10-15 2019-02-19 行吟信息科技(上海)有限公司 A kind of automatic generation method and code generator of code

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111666073A (en) * 2020-06-12 2020-09-15 远光软件股份有限公司 Graphical model construction method and device based on domain-driven design
CN111666073B (en) * 2020-06-12 2023-09-29 远光软件股份有限公司 Graphical model construction method and device based on field driving design
CN112711405A (en) * 2020-12-28 2021-04-27 山东浪潮通软信息科技有限公司 Method, equipment and storage medium for generating add-delete-modify-check application program interface

Similar Documents

Publication Publication Date Title
CN112036736A (en) Workflow creating method and device
CN113076096B (en) Desktop application program development method, device, equipment and storage medium
CN111124379B (en) Page generation method and device, electronic equipment and storage medium
CN111061475B (en) Software code generating method, device, computer equipment and storage medium
CN105528418B (en) A kind of design documentation generation method and device
CN111241454A (en) Method, system and device for generating webpage code
CN115617327A (en) Low code page building system, method and computer readable storage medium
CN104731588B (en) Page layout document generating method and page layout file creating apparatus
CN113672204A (en) Interface document generation method, system, electronic equipment and storage medium
CN106557307B (en) Service data processing method and system
CN110543303A (en) Visual business platform
CN110955410A (en) Automatic code generation method, device, equipment and medium
CN110989999A (en) Code generation method and device, electronic equipment and medium
CN114115883A (en) Method for quickly constructing front-end application by using middle station service capability
CN104516864A (en) Report generating method and report generating device
US10621288B2 (en) Interoperable hierarchical model for conducting multiuser CAx operations
CN113094125B (en) Business process processing method, device, server and storage medium
CN112035230A (en) Method and device for generating task scheduling file and storage medium
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN115270731A (en) Collaborative editing method and device for mixed document
CN110515653B (en) Document generation method and device, electronic equipment and computer readable storage medium
CN111459474B (en) Templated data processing method and device
CN104156209A (en) Cross-platform application interface modeling method and device
CN114449063A (en) Message processing method, device and equipment
CN113254455A (en) Dynamic configuration method and device of database, computer equipment and storage medium

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