Code generation method and related equipment
By creating domain models and interface models in Eclipse and automatically generating code, the problems of high cost and low efficiency of web application development in the existing technology are solved, and automatic code generation and development efficiency are improved.
Patent Information
- Application Number
- CN202410982230.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-12-06
AI Technical Summary
The development of Web application based on HTML5 in the prior art relies on manual compilation, resulting in high development costs and low development efficiency, and the business object model is closely bound to the technical architecture, making it difficult to reuse, resulting in duplicate development and redundant code.
By creating domain models and interface models, use the model designer plug-in in the Eclipse integrated development environment to visually construct, automatically generate code, and reduce development difficulty and cost.
It improves development efficiency, reduces the amount of code writing and the chance of errors, simplifies the development process, reduces development costs, and realizes automatic code generation.
Smart Images

Figure CN119088370A_ABST
Abstract
Description
Technical Field
[0001] One or more embodiments of the present application relate to the technical field of code generation, and in particular, to a code generation method and related devices. Background Art
[0002] In the prior art, the development of Web applications based on HTML5 technology is generally generated by manual compilation.
[0003] For example, the development of some Web applications in related technologies depends on the Eclipse IDE server. When developing Web applications, the microservice main project is first introduced, and then a microservice sub-project is created to implement microservice development. After that, static pages are generated based on the prototype of the Web application, VUE client pages are generated manually, and project special effects definition functions are implemented through hard coding.
[0004] However, related technologies rely on developers to directly write code to define project features, which results in high development costs. Test verification can only be performed after the code is packaged and released, which results in low development efficiency. In addition, the business object model is tightly bound to the technical architecture, making it difficult to reuse the model, which in turn leads to repeated development of similar features in different projects, resulting in a large amount of redundant code.
[0005] In summary, the relevant technologies have the problems of high development cost and low development efficiency. Summary of the invention
[0006] In view of this, an object of one or more embodiments of the present application is to provide a code generation method and related devices to solve the problems raised by the background technology.
[0007] Based on the above objectives, one or more embodiments of the present application provide a code generation method, including:
[0008] Create domain models for microservice projects;
[0009] Based on the domain model, create an interface model;
[0010] Based on the interface model and the domain model, code is generated.
[0011] Optionally, before creating the domain model, include:
[0012] Install the model designer plug-in in the Eclipse integrated development environment;
[0013] Create a microservice project.
[0014] Optionally, creating a domain model includes: creating entity objects, entity attributes, entity operations, entity relationships, and entity data validation rules.
[0015] Optionally, the creating the interface model includes: creating a data source, creating a main framework of the interface model and setting characteristics.
[0016] Optionally, the creating an interface model includes:
[0017] Enter the view interface of the domain model;
[0018] Through the view interface, model design, scene design and feature setting are performed on the domain model to obtain the interface model.
[0019] Optionally, it also includes:
[0020] Through the view interface, new features are set for the interface model to define features of the interface model.
[0021] Optionally, it also includes:
[0022] Based on the characteristic definition, a characteristic configuration file is exported, wherein the configuration file includes a cross-reference characteristic configuration file, a data retrieval expression characteristic configuration file, a characteristic object characteristic configuration file, a data model configuration file and a rule characteristic configuration file.
[0023] Based on the same inventive concept, one or more embodiments of the present application further provide a code generation device, including:
[0024] The first model creation module is configured to create a domain model for the microservice project;
[0025] The second model creation module is configured to create an interface model based on the domain model;
[0026] The export module is configured to generate code based on the interface model and the domain model.
[0027] Based on the same inventive concept, one or more embodiments of the present application also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a code generation method as described in any one of the above items is implemented.
[0028] Based on the same inventive concept, one or more embodiments of the present application further provide a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute any of the above-mentioned code generation methods.
[0029] From the above description, it can be seen that the code generation method provided by one or more embodiments of the present application creates a domain model for a microservice project; creates an interface model based on the domain model; and generates code based on the interface model and the domain model.
[0030] The code generation method provided in one or more embodiments of the present application realizes automatic code generation by visually constructing a domain model and an interface model, thereby reducing the difficulty of application development, improving development efficiency, and saving development costs.
[0031] The code generation device, electronic device and computer-readable storage medium provided in the present application can implement the steps of the above-mentioned code generation method, and therefore also have the beneficial effects of the above-mentioned code generation method. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate one or more embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only one or more embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0033] Figure 1 A flowchart of a code generation method according to one or more embodiments of the present application;
[0034] Figure 2 A schematic diagram of the structure of a code generating device according to one or more embodiments of the present application;
[0035] Figure 3 A schematic diagram of the hardware structure of an electronic device according to one or more embodiments of the present application. DETAILED DESCRIPTION
[0036] In order to make the objectives, technical solutions and advantages of the present disclosure more clearly understood, the present disclosure is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0037] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in one or more embodiments of the present application should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in one or more embodiments of the present application do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0038] Domain-Driven Design (DDD) technology is a design concept for dealing with highly complex domains, and is also an architecture design methodology and design pattern. DDD emphasizes that the business model runs through the entire application architecture to better meet business needs and solve problems.
[0039] The core idea of DDD technology is to define the domain model through domain-driven design methods, thereby determining the business and application boundaries and ensuring the consistency of the business model and the code model. The domain model is a software model about a specific business domain, usually implemented through an object model. These objects contain both data and behavior and express accurate business meanings.
[0040] In the process of implementing this application, the applicant found that it is possible to design applications based on DDD technology, visualize application design and application-specific definitions, and automatically generate application code. By using a unified language and a clear domain model, developers can understand and implement business requirements more quickly, thereby improving development efficiency and reducing development costs.
[0041] In this application, a Web application project implemented based on HTML5 (H5 for short) refers to an application that uses forms to record data collection and data interaction attribute elements. The above elements have various characteristics and properties that are used to define the behavior and appearance of the elements. Project feature definition refers to the use of regular expressions to verify whether the value of a form item conforms to a specific pattern. Project features specifically include: cross-checking, calculations, rules, automatic encoding, etc. Defining project features helps ensure that the data entered by the user conforms to a specific format or requirement.
[0042] Through the technical solution of this application, technicians can use domain model modeling to define project characteristics, and can perform characteristic verification in design mode. Finally, they can generate application engineering through code to simplify the development process and improve development efficiency.
[0043] In addition, the embodiment of the present application can effectively reduce the amount of code written by developers, thereby effectively reducing the probability of errors in code writing and improving software quality. Further, the embodiment of the present application can shield the underlying technical details of code writing and reduce the difficulty of software application development.
[0044] refer to Figure 1 The code generation method of one or more embodiments of the present application comprises the following steps:
[0045] Step S101: Create a domain model for a microservice project.
[0046] The technical solution of the present application is implemented in the Eclipse integrated development environment. In some embodiments, before creating a domain model for a microservice project, the technical solution of the present application first installs a model designer plug-in in the Eclipse integrated development environment, and the model designer plug-in can be used to visually build a domain model, an interface model, and a project feature definition. In addition, real-time verification of the project feature definition can also be achieved.
[0047] Specifically, in some embodiments, the model designer plug-in can be Eclipse SDK and its plug-in development environment (PDE), and Java Development Toolkit (JDT), with an OSGi architecture, and uses the OSGi framework Equinox implemented by Eclipse.
[0048] After installing the model designer plug-in, you can use the plug-in to create a microservice project and create a domain model based on the microservice project. DDD strategic design will establish a domain model, which can be used to guide the design and splitting of microservices. In some embodiments, microservice sub-projects can be established under the above microservice project according to actual application scenarios.
[0049] Specifically, through the model design tool, a new model design drawing can be added and a corresponding design drawing em file can be generated.
[0050] In some embodiments, creating the above domain model may include: creating entity objects, entity attributes, entity operations, entity relationships, and entity data validation rules. Among them, entity attributes may include entity action attributes, etc.; business operations may include operations corresponding to action attributes, such as adding, editing, deleting, querying, etc.; entity relationships refer to one-to-one, one-to-many, or many-to-many relationships between entities.
[0051] Step S102: Create an interface model based on the above domain model.
[0052] As mentioned above, creating a domain model can generate a corresponding design drawing em file. On this basis, using the project file to open the generated em file can enter the model's view interface, and through model design, scene design and feature setting, an interface model can be obtained. The above interface model can include a scene model and a data model.
[0053] Through the design of the interface model, the shape, size, color, and style of each element of the interface displayed by the application can be designed.
[0054] It should be noted that the scenario model, domain model and data model of this application can be converted to each other. This application also supports importing table structures from databases and reversely generating data models, domain models and scenario models. In addition, this application also supports the customization of the generation format, cross-reference relationship and other characteristics of the entity model's characteristics (items, attributes and fields).
[0055] The creation of the interface model may include: creating a data source, creating the interface model main framework and feature settings.
[0056] The step of creating an interface model may include: entering the view interface of the above-mentioned domain model; and performing model design, scene design and feature setting on the above-mentioned domain model through the above-mentioned view interface to obtain the above-mentioned interface model.
[0057] In addition, in some embodiments, additional properties may be set for the interface model through a view interface to define properties of the interface model.
[0058] In some embodiments, the above interface model may include one or any combination of an editable table template, a table plus form template, a master-detail table template or a tree table template. The technician only needs to select the model to realize the layout of the software interface.
[0059] Step S103: Generate code based on the above interface model and the above domain model.
[0060] The code in this step includes back-end logic code, front-end logic code or custom logic development. After obtaining the code, you can also compile the code and / or publish the code.
[0061] After obtaining the target interface model through the view interface, the code can be automatically generated. Based on the above interface model and the above domain model, the code is exported to generate a project directory.
[0062] In particular, if a specific definition is made, a code sub-package and a configuration file directory can be generated in the project after the code is exported. The above feature definition can include: features, feature categories, scenarios, parameter settings and layers. Among them, the feature categories can include: verification type, calculation type, event type and description type.
[0063] For example, the characteristics can be saved for project changes, and the corresponding characteristic category is event type; cross-checking, the corresponding characteristic category is verification type; business document items, the corresponding characteristic category is description type; operation, the corresponding characteristic category is calculation type; management object items, the corresponding characteristic category is description type; rules, the corresponding characteristic category is verification type; automatic coding, the corresponding characteristic category is calculation type; latest status verification, the corresponding characteristic category is verification type.
[0064] The above configuration files may include: a cross-reference property configuration file, a data retrieval expression property configuration file, a property object property configuration file, a data model configuration file and a rule property configuration file.
[0065] In some embodiments, real-time feature verification can also be performed. Specifically, the startup microservice can support feature parsing and online model data preview. The staff can verify the results of the feature definition in real time.
[0066] It should be noted that the domain model established based on DDD technology is for system analysis and design personnel and business requirements analysts. That is, system analysis and design personnel and business requirements analysts can create domain models and interface models according to the needs of business functions without mastering programming technology. Developers can automatically generate code according to the needs of business functions. The technical solution of this application saves a lot of programming work for developers, and thus effectively improves the development efficiency of applications.
[0067] It can be understood that the method can be executed by any device, equipment, platform, or device cluster having computing and processing capabilities.
[0068] The technical carriers involved in the payment described in the embodiments of the present application may include, for example, Near Field Communication (NFC), WIFI, 3G / 4G / 5G, POS card swiping technology, QR code scanning technology, bar code scanning technology, Bluetooth, infrared, short message service (SMS), multimedia message service (MMS), etc.
[0069] The biological features involved in the biological identification described in the embodiments of the present application may include, for example, eye prints, voice prints, fingerprints, palm prints, heartbeats, pulses, chromosomes, DNA, human tooth marks, etc. Eye prints may include irises, sclera, and other biological features.
[0070] It should be noted that the method of one or more embodiments of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of one or more embodiments of the present application, and the multiple devices will interact with each other to complete the described method.
[0071] It should be noted that the above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0072] Based on the same inventive concept, corresponding to any of the above embodiments and methods, Figure 2 As shown, the present application also provides a code generating device.
[0073] The first model creation module 11 is configured to create a domain model for a microservice project;
[0074] The second model creation module 12 is configured to create an interface model based on the domain model;
[0075] The export module 13 is configured to generate code based on the interface model and the domain model.
[0076] Optionally, before creating the domain model, include:
[0077] Install the model designer plug-in in the Eclipse integrated development environment;
[0078] Create a microservice project.
[0079] Optionally, creating a domain model includes: creating entity objects, entity attributes, entity operations, entity relationships, and entity data validation rules.
[0080] Optionally, the creating the interface model includes: creating a data source, creating a main framework of the interface model and setting characteristics.
[0081] Optionally, the creating an interface model includes:
[0082] Enter the view interface of the domain model;
[0083] Through the view interface, model design, scene design and feature setting are performed on the domain model to obtain the interface model.
[0084] Optionally, it also includes:
[0085] Through the view interface, new features are set for the interface model to define features of the interface model.
[0086] Optionally, it also includes:
[0087] Based on the characteristic definition, a characteristic configuration file is exported, wherein the configuration file includes a cross-reference characteristic configuration file, a data retrieval expression characteristic configuration file, a characteristic object characteristic configuration file, a data model configuration file and a rule characteristic configuration file.
[0088] For the convenience of description, the above devices are described in terms of functions and modules. Of course, when implementing one or more embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0089] The apparatus of the above-mentioned embodiment is used to implement the corresponding method in the above-mentioned embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0090] Figure 3 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.
[0091] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.
[0092] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solution provided in the embodiment of the present application is implemented by software or firmware, the relevant program code is stored in the memory 1020 and is called and executed by the processor 1010.
[0093] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0094] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0095] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
[0096] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiment of the present application, and does not necessarily include all the components shown in the figure.
[0097] The electronic device of the above embodiment is used to implement the corresponding method in the above embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0098] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0099] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present disclosure (including the claims) is limited to these examples. Based on the concept of the present disclosure, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of different aspects of one or more embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0100] In addition, to simplify the description and discussion, and in order not to make one or more embodiments of the present application difficult to understand, the known power / ground connections to the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device can be shown in the form of a block diagram to avoid making one or more embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which one or more embodiments of the present application will be implemented (that is, these details should be fully within the scope of understanding of those skilled in the art). In the case of elaborating specific details (e.g., circuits) to describe exemplary embodiments of the present disclosure, it is obvious to those skilled in the art that one or more embodiments of the present application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered illustrative rather than restrictive.
[0101] Although the present disclosure has been described in conjunction with specific embodiments of the present disclosure, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
[0102] One or more embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present application should be included in the scope of protection of this disclosure.
Claims
1. A code generation method, It is characterized in that include: Create domain models for microservice projects; Based on the domain model, create an interface model; Based on the interface model and the domain model, code is generated.
2. The method according to claim 1, It is characterized in that Before creating a domain model, include: Install the model designer plug-in in the Eclipse integrated development environment; Create a microservice project.
3. The method according to claim 1, It is characterized in that The creation of the domain model includes: creating entity objects, entity attributes, entity operations, entity relationships and entity data validation rules.
4. The method according to claim 1, It is characterized in that The creation of the interface model includes: creating a data source, creating an interface model main framework and setting characteristics.
5. The method according to claim 4, It is characterized in that The creating interface model comprises: Enter the view interface of the domain model; Through the view interface, model design, scene design and feature setting are performed on the domain model to obtain the interface model.
6. The method according to claim 5, It is characterized in that Also includes: Through the view interface, new features are set for the interface model to define features of the interface model.
7. The method according to claim 6, It is characterized in that Also includes: Based on the characteristic definition, a characteristic configuration file is exported, wherein the configuration file includes a cross-reference characteristic configuration file, a data retrieval expression characteristic configuration file, a characteristic object characteristic configuration file, a data model configuration file and a rule characteristic configuration file.
8. A code generating device, It is characterized in that include: The first model creation module is configured to create a domain model for the microservice project; The second model creation module is configured to create an interface model based on the domain model; The export module is configured to generate code based on the interface model and the domain model.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium, It is characterized in that The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to cause the computer to execute any one of claims 1 to 7.
Citation Information
Cited By
Content generation method and apparatus, device, and storage medium
WO2026188435A1
