CN112130849B - Code automatic generation method and device - Google Patents

Code automatic generation method and device Download PDF

Info

Publication number
CN112130849B
CN112130849B CN202011034179.4A CN202011034179A CN112130849B CN 112130849 B CN112130849 B CN 112130849B CN 202011034179 A CN202011034179 A CN 202011034179A CN 112130849 B CN112130849 B CN 112130849B
Authority
CN
China
Prior art keywords
model
verification
business
business data
codes
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011034179.4A
Other languages
Chinese (zh)
Other versions
CN112130849A (en
Inventor
张鹏
陈立伟
范新生
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CCB Finetech Co Ltd
Original Assignee
CCB Finetech 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 CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202011034179.4A priority Critical patent/CN112130849B/en
Publication of CN112130849A publication Critical patent/CN112130849A/en
Application granted granted Critical
Publication of CN112130849B publication Critical patent/CN112130849B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/35Creation or generation of source code model driven
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/10Office automation; Time management
    • G06Q10/103Workflow collaboration or project management

Abstract

The application discloses a method and a device for automatically generating codes, wherein the method comprises the following steps: obtaining a code generation instruction of a target application, wherein the code generation instruction comprises the following steps: the business process model and the business data model of the target application; determining a first model corresponding to the business data model in a preset model warehouse, and inputting the business data model into the first model; determining a second model corresponding to the business process model in the model warehouse, and inputting the business process model into the second model; and generating codes corresponding to the target application according to the entered model warehouse. The application can automatically generate most codes except the business logic codes required by the application, reduces the workload of developers and is beneficial to delivering projects rapidly and with high quality.

Description

Code automatic generation method and device
Technical Field
The application belongs to the technical field of software development, and particularly relates to a method and a device for automatically generating codes.
Background
At present, in project delivery of enterprise application development, the conditions of short project period, quick demand iteration, uneven quality of developers and the like exist. Aiming at the current situation, how to quickly generate partial codes so as to achieve quick and high-quality project delivery is a technical problem which needs to be solved in the field.
Disclosure of Invention
The application provides a method and a device for automatically generating codes in order to solve the technical problems in the background technology.
To achieve the above object, according to one aspect of the present application, there is provided a code automatic generation method comprising:
obtaining a code generation instruction of a target application, wherein the code generation instruction comprises the following steps: the business process model and the business data model of the target application;
determining a first model corresponding to the business data model in a preset model warehouse, and inputting the business data model into the first model;
determining a second model corresponding to the business process model in the model warehouse, and inputting the business process model into the second model;
and generating codes corresponding to the target application according to the entered model warehouse.
Optionally, the entering the business data model into the first model specifically includes:
and taking the business data model as a basic data model and inputting the business data model into the first model by combining preset technical data.
Optionally, the model repository includes: metadata model, physical model, service model, and verification model; the metadata model includes: metadata, fields, and code values; the physical model includes: table, index, table relationship, table field, and index field; the service model includes: module, class field, class method entry, service attribute, and service call; the verification model comprises: domain verification, class field verification, class method entry verification, class method verification, class verification and verification message.
Optionally, the first model includes: metadata model, physical model, and verification model.
Optionally, the second model includes: a service model and a verification model.
Optionally, the generated code includes: library statements, data access codes, basic service codes, standard service codes, enumeration class codes, interface service codes, interface check codes, test codes, and interface documents.
In order to achieve the above object, according to another aspect of the present application, there is provided an automatic code generating apparatus comprising:
the code generation instruction acquisition unit is used for acquiring a code generation instruction of the target application, wherein the code generation instruction comprises the following components: the business process model and the business data model of the target application;
the first model input unit is used for determining a first model corresponding to the business data model in a preset model warehouse and inputting the business data model into the first model;
the second model input unit is used for determining a second model corresponding to the business process model in the model warehouse and inputting the business process model into the second model;
and the code generating unit is used for generating codes corresponding to the target application according to the entered model warehouse.
In order to achieve the above object, according to another aspect of the present application, there is also provided a computer device including a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps in the above-mentioned code automatic generation method when executing the computer program.
In order to achieve the above object, according to another aspect of the present application, there is also provided a computer-readable storage medium storing a computer program which, when executed in a computer processor, implements the steps in the above-described code automatic generation method.
The beneficial effects of the application are as follows: the code automatic generation method can automatically generate partial codes except the business logic codes required by the application, reduces the workload of developers, and is beneficial to delivering projects rapidly and with high quality.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art. In the drawings:
FIG. 1 is a flow chart of a method for automatically generating code according to an embodiment of the present application;
FIG. 2 is a flow chart of business data model entry in accordance with an embodiment of the present application;
FIG. 3 is a block diagram showing the construction of an apparatus for automatically generating a code according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a computer device according to an embodiment of the application.
Detailed Description
In order that those skilled in the art will better understand the present application, a technical solution in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present application, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, shall fall within the scope of the present application.
It will be appreciated by those skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
It is noted that the terms "comprises" and "comprising," and any variations thereof, in the description and claims of the present application and in the foregoing figures, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that, without conflict, the embodiments of the present application and features of the embodiments may be combined with each other. The application will be described in detail below with reference to the drawings in connection with embodiments.
Fig. 1 is a flowchart of a code automatic generation method according to an embodiment of the present application, and as shown in fig. 1, the code automatic generation method of the present embodiment includes steps S1 to S4.
Step S1, acquiring a code generation instruction of a target application, wherein the code generation instruction comprises the following steps: and the business process model and the business data model of the target application.
In the embodiment of the application, a demand analysis personnel extracts a business flow model and a business data model according to the application demand of a user, and further generates a code generation instruction.
Step S2, determining a first model corresponding to the business data model in a preset model warehouse, and inputting the business data model into the first model.
In the embodiment of the application, the code generation instruction includes model information corresponding to the service data model in a preset model warehouse, and further, a model (i.e., the first model) corresponding to the service data model in the preset model warehouse can be determined according to the model information.
In the embodiment of the present application, the model repository includes a plurality of types of models, and specifically, the model repository may include: metadata model, physical model, service model, and verification model.
In an alternative embodiment of the present application, the metadata model includes: metadata, fields, code values, etc.
In an alternative embodiment of the present application, the physical model includes: table, index, table relationship, table field, index field, etc.
In an alternative embodiment of the present application, the service model includes: modules, classes, class fields, class methods, class method parametrics, service attributes, service calls, and the like.
In an alternative embodiment of the present application, the verification model includes: domain verification, class field verification, class method entry verification, class method verification, class verification, verification information and other models.
In the embodiment of the present application, the models corresponding to the business data model in the model repository may be a metadata model, a physical model, and a verification model, that is, the first model includes: metadata model, physical model, and verification model.
And step S3, determining a second model corresponding to the business process model in the model warehouse, and inputting the business process model into the second model.
In the embodiment of the application, the code generation instruction includes model information corresponding to the business process model in a preset model warehouse, and further, a model (i.e., the second model) corresponding to the business process model in the preset model warehouse can be determined according to the model information.
In the embodiment of the present application, the models corresponding to the business process model in the model repository may be a service model and a verification model, that is, the second model includes: a service model and a verification model.
And S4, generating codes corresponding to the target application according to the entered model warehouse.
In the embodiment of the application, after the model warehouse loads the previous model, most codes required by the application can be generated according to the model data by one key, and the application can be directly started after compiling, so that the front-end service is received. The developer can concentrate on the refinement of specific business processes according to business requirements without concern for basic configuration, verification, conversion and other works.
In the embodiment of the application, the codes which can be generated by the application comprise: library statements, data access codes, basic service codes, standard service codes, enumeration class codes, interface service codes, interface check codes, test codes, interface documents, and the like.
Fig. 2 is a flowchart of business data model entry according to an embodiment of the present application, and as shown in fig. 2, the step S2 specifically includes a step S21.
And S21, taking the business data model as a basic data model and inputting the business data model into the first model by combining preset technical data.
In one embodiment of the present application, the present application may build a code generation tool (software) according to the code generation method of the above embodiment, which may implement the above code generation method. In the alternative embodiment of the application, the code generation tool can be a plug-in of the IDE, and the design, verification, management, import, export, generation, compiling and operation can all be completed in the IDE, so that the design scheme is concise and efficient, and corresponds front and back and is an overall systematic solution and implementation effect.
As can be seen from the above embodiments, the code automatic generation method of the present application has the following advantages:
1. because the model is independent of the specific programming language and the database, the programming language independence and the database independence of the software product can be realized;
2. because the code generated by the model has normalization, the quality cost and the test cost of project delivery are reduced;
3. because the generated code shields the technical complexity of the bottom layer, the learning threshold and the project cost are reduced;
4. because the generated code integrates the functions of the platform and the framework, the developer is concentrated on solving the coding of the business logic;
5. because of the decoupling of the generated code and the business logic, the troubleshooting becomes accurate and simple.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
Based on the same inventive concept, the embodiment of the present application also provides an automatic code generating device, which can be used to implement the automatic code generating method described in the above embodiment, as described in the following embodiment. Since the principle of the code automatic generation apparatus for solving the problem is similar to that of the code automatic generation method, the embodiment of the code automatic generation apparatus can refer to the embodiment of the code automatic generation method, and the repetition is not repeated. As used below, the term "unit" or "module" may be a combination of software and/or hardware that implements the intended function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
Fig. 3 is a block diagram of a code automatic generation apparatus according to an embodiment of the present application, and as shown in fig. 3, the code automatic generation apparatus according to an embodiment of the present application includes:
a code generation instruction obtaining unit 1, configured to obtain a code generation instruction of a target application, where the code generation instruction includes: the business process model and the business data model of the target application;
a first model input unit 2, configured to determine a first model corresponding to the service data model in a preset model repository, and input the service data model into the first model;
a second model entry unit 3, configured to determine a second model corresponding to the business process model in the model repository, and enter the business process model into the second model;
and the code generating unit 4 is used for generating codes corresponding to the target application according to the entered model warehouse.
In one embodiment of the present application, the first model entry unit specifically includes:
the input module is used for taking the business data model as a basic data model and inputting the business data model into the first model by combining preset technical data.
To achieve the above object, according to another aspect of the present application, there is also provided a computer apparatus. As shown in fig. 4, the computer device comprises a memory, a processor, a communication interface and a communication bus, on which a computer program is stored which can be run on the processor, said processor implementing the steps in the method of the above embodiments when executing said computer program.
The processor may be a central processing unit (Central Processing Unit, CPU). The processor may also be any other general purpose processor, digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof.
The memory is used as a non-transitory computer readable storage medium for storing non-transitory software programs, non-transitory computer executable programs, and units, such as corresponding program units in the above-described method embodiments of the application. The processor executes the various functional applications of the processor and the processing of the composition data by running non-transitory software programs, instructions and modules stored in the memory, i.e., implementing the methods of the method embodiments described above.
The memory may include a memory program area and a memory data area, wherein the memory program area may store an operating system, at least one application program required for a function; the storage data area may store data created by the processor, etc. In addition, the memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory may optionally include memory located remotely from the processor, the remote memory being connectable to the processor through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more units are stored in the memory, which when executed by the processor, performs the method in the above embodiments.
The details of the computer device may be correspondingly understood by referring to the corresponding relevant descriptions and effects in the above embodiments, and will not be repeated here.
In order to achieve the above object, according to another aspect of the present application, there is also provided a computer-readable storage medium storing a computer program which, when executed in a computer processor, implements the steps in the above-described code automatic generation method. It will be appreciated by those skilled in the art that implementing all or part of the above-described embodiment method may be implemented by a computer program to instruct related hardware, where the program may be stored in a computer readable storage medium, and the program may include the above-described embodiment method when executed. Wherein the storage medium may be a magnetic Disk, an optical Disk, a Read-Only Memory (ROM), a random access Memory (RandomAccessMemory, RAM), a Flash Memory (Flash Memory), a Hard Disk (HDD), a Solid State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
It will be apparent to those skilled in the art that the modules or steps of the application described above may be implemented in a general purpose computing device, they may be concentrated on a single computing device, or distributed across a network of computing devices, or they may alternatively be implemented in program code executable by computing devices, such that they may be stored in a memory device for execution by the computing devices, or they may be separately fabricated into individual integrated circuit modules, or multiple modules or steps within them may be fabricated into a single integrated circuit module. Thus, the present application is not limited to any specific combination of hardware and software.
The above description is only of the preferred embodiments of the present application and is not intended to limit the present application, but various modifications and variations can be made to the present application by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims (7)

1. An automatic code generation method, comprising:
obtaining a code generation instruction of a target application, wherein the code generation instruction comprises the following steps: the business process model and the business data model of the target application, the corresponding model information of the business data model in a preset model warehouse and the corresponding model information of the business process model in the preset model warehouse; the business process model and the business data model demand analyst are extracted according to the application demands of the user;
determining a first model corresponding to the business data model in a preset model warehouse, and inputting the business data model into the first model, wherein the first model comprises: a metadata model, a physical model, and a verification model; the metadata model includes: metadata, fields, and code values; the physical model includes: table, index, table relationship, table field, and index field; the verification model comprises: domain verification, class field verification, class method entry verification, class method verification, class verification and verification message;
determining a second model corresponding to the business process model in the model warehouse, and entering the business process model into the second model, wherein the second model comprises: a service model and a verification model; the service model includes: module, class field, class method entry, service attribute, and service call;
and generating codes corresponding to the target application according to the entered model warehouse.
2. The automatic code generating method according to claim 1, wherein the entering the business data model into the first model specifically comprises:
and taking the business data model as a basic data model and inputting the business data model into the first model by combining preset technical data.
3. The automatic code generation method according to claim 1, wherein the generated code includes: library statements, data access codes, basic service codes, standard service codes, enumeration class codes, interface service codes, interface check codes, test codes, and interface documents.
4. An automatic code generating apparatus, comprising:
the code generation instruction acquisition unit is used for acquiring a code generation instruction of the target application, wherein the code generation instruction comprises the following components: the business process model and the business data model of the target application, the corresponding model information of the business data model in a preset model warehouse and the corresponding model information of the business process model in the preset model warehouse; the business process model and the business data model demand analyst are extracted according to the application demands of the user;
the first model input unit is used for determining a first model corresponding to the business data model in a preset model warehouse and inputting the business data model into the first model, wherein the first model comprises: a metadata model, a physical model, and a verification model; the metadata model includes: metadata, fields, and code values; the physical model includes: table, index, table relationship, table field, and index field; the verification model comprises: domain verification, class field verification, class method entry verification, class method verification, class verification and verification message;
a second model entry unit, configured to determine a second model corresponding to the business process model in the model repository, and enter the business process model into the second model, where the second model includes: a service model and a verification model; the service model includes: module, class field, class method entry, service attribute, and service call;
and the code generating unit is used for generating codes corresponding to the target application according to the entered model warehouse.
5. The code automatic generation apparatus according to claim 4, wherein the first model entry unit includes:
the input module is used for taking the business data model as a basic data model and inputting the business data model into the first model by combining preset technical data.
6. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of any of claims 1 to 3 when executing the computer program.
7. A computer readable storage medium storing a computer program, characterized in that the computer program when executed in a computer processor implements the method of any one of claims 1 to 3.
CN202011034179.4A 2020-09-27 2020-09-27 Code automatic generation method and device Active CN112130849B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011034179.4A CN112130849B (en) 2020-09-27 2020-09-27 Code automatic generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011034179.4A CN112130849B (en) 2020-09-27 2020-09-27 Code automatic generation method and device

Publications (2)

Publication Number Publication Date
CN112130849A CN112130849A (en) 2020-12-25
CN112130849B true CN112130849B (en) 2023-08-22

Family

ID=73840328

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011034179.4A Active CN112130849B (en) 2020-09-27 2020-09-27 Code automatic generation method and device

Country Status (1)

Country Link
CN (1) CN112130849B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114693220B (en) * 2022-05-30 2022-09-20 深圳市爱云信息科技有限公司 Algorithm warehouse management method and system based on digital twin DaaS platform

Citations (6)

* Cited by examiner, † Cited by third party
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
CN109558127A (en) * 2018-11-28 2019-04-02 中国海洋石油集团有限公司 A kind of code generating method, device, equipment and storage medium
CN109783084A (en) * 2019-01-18 2019-05-21 广州思坦德计算机信息科技有限公司 A kind of computer code automatic generation method, system, device and storage medium
CN109947399A (en) * 2019-01-25 2019-06-28 深圳壹账通智能科技有限公司 Code structure generation method, device, computer installation and readable storage medium storing program for executing
CN111078213A (en) * 2018-10-18 2020-04-28 马上消费金融股份有限公司 Code generation method and code generation device
CN111427561A (en) * 2020-03-26 2020-07-17 中国建设银行股份有限公司 Service code generation method and device, computer equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
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
CN111078213A (en) * 2018-10-18 2020-04-28 马上消费金融股份有限公司 Code generation method and code generation device
CN109558127A (en) * 2018-11-28 2019-04-02 中国海洋石油集团有限公司 A kind of code generating method, device, equipment and storage medium
CN109783084A (en) * 2019-01-18 2019-05-21 广州思坦德计算机信息科技有限公司 A kind of computer code automatic generation method, system, device and storage medium
CN109947399A (en) * 2019-01-25 2019-06-28 深圳壹账通智能科技有限公司 Code structure generation method, device, computer installation and readable storage medium storing program for executing
CN111427561A (en) * 2020-03-26 2020-07-17 中国建设银行股份有限公司 Service code generation method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN112130849A (en) 2020-12-25

Similar Documents

Publication Publication Date Title
US20180285417A1 (en) Intelligent query parameterization of database workloads
CN108280023B (en) Task execution method and device and server
CN105719126B (en) system and method for scheduling Internet big data tasks based on life cycle model
CN110908997A (en) Data blood margin construction method and device, server and readable storage medium
CN106293891B (en) Multidimensional investment index monitoring method
CN109299074B (en) Data verification method and system based on templated database view
US9311345B2 (en) Template based database analyzer
CN104679500B (en) Method and device for realizing automatic generation of entity class
CN115374102A (en) Data processing method and system
CN104050182A (en) Configurable rule for monitoring data of in-memory database
CN113268500A (en) Service processing method and device and electronic equipment
CN114707474A (en) Report generation method and device, electronic equipment and computer readable storage medium
CN111767217A (en) JS unit test case generation method and device
CN112130849B (en) Code automatic generation method and device
CN110019207B (en) Data processing method and device and script display method and device
CN110941422B (en) Code automatic generation method, code generator and readable storage medium
US20140372488A1 (en) Generating database processes from process models
CN115203435A (en) Entity relation generation method and data query method based on knowledge graph
CN113378007B (en) Data backtracking method and device, computer readable storage medium and electronic device
CN111309297A (en) Script development system and method
Cortellessa et al. Three performance models at work: a software designer perspective
CN117472641B (en) Data quality detection method and device, electronic equipment and storage medium
Xu et al. A task scenario oriented test requirement modeling method for complex SOA-based system
CN111125148B (en) Paging query method and device for database
CN114020508A (en) Data processing method and device, electronic 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
GR01 Patent grant
GR01 Patent grant