Code generation method and device
Through code generation methods and devices, data models and table structures are established, and code generation is generated by combining materials and templates, the problems of low efficiency of enterprise software development and waste of resources are solved, rapid development and low-cost application creation are realized, and internal communication costs are reduced. , improving market competitiveness.
Patent Information
- Application Number
- CN202011318391.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-23
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2040-11-23
AI Technical Summary
Enterprises are facing problems such as shortage of software developers, low development efficiency, waste of resources and internal communication difficulties, which leads to enterprises being unable to respond quickly to market demand and user changes and lack of market competitiveness.
Provide a code generation method and device, by establishing a data model, generating table structure and page templates, combining materials and templates to generate code, support online visual development and free operation and maintenance release, lowering development thresholds, improving code development efficiency, and utilizing enterprises Have business assets to reduce communication costs between roles.
It realizes the complete functions of rapid application construction, online visual development, and zero-threshold creation, connects the front and backends and databases, and generates code that can be directly used for production, reducing development costs and communication differences, and improving the company's rapid development capabilities.
Smart Images

Figure CN112416326B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software technology, and in particular to a code generation method and device. Background Art
[0002] At present, with the popularization of the Internet, the rapid growth of Internet users, and the rise of the digital wave, the digital transformation of enterprises is imminent. Faced with the serious shortage of software developers, the informatization construction of enterprises is difficult and progressing slowly, which is mainly reflected in the following aspects:
[0003] First, development technology and development tools are iterating rapidly, and software developers need to invest a lot of time in learning skills, and the development efficiency is difficult to match the iteration speed required by enterprise applications. The slow iteration speed of enterprise applications makes it impossible for enterprises to respond to the ever-changing needs of the market and users in a timely manner, and their market competitiveness is insufficient.
[0004] Second, each department in the enterprise operates independently, resulting in repeated development of the same or similar functional modules, repeated reinvention of the wheel, inability to accumulate business experience and IT assets, low reuse rate, and serious waste of resources;
[0005] Third, it is difficult for people with different divisions of labor within the company to communicate with each other. Business personnel, product managers, testers, designers, developers and other roles often confirm requirements through documents or some simple design drafts, resulting in a gap between the final product and expectations.
[0006] In summary, there is currently no reasonable solution to the above problems. Therefore, there is an urgent need to provide a new solution to improve code development efficiency, lower the threshold for code development, rationally utilize the company's existing business and technical assets, and reduce the communication costs between internal roles in the company. Summary of the invention
[0007] The present invention belongs to the field of big data technology. According to the code generation method and device provided by the present invention, the efficiency of code development can be improved, the threshold of code development can be lowered, and the existing business and technical assets of the enterprise can be reasonably utilized to reduce the communication cost between internal roles of the enterprise.
[0008] In order to achieve the above object, a code generation method is provided, comprising:
[0009] Establish the data model corresponding to the function to be realized;
[0010] Generate a table structure according to the data model;
[0011] Combine the required page templates according to the required materials and templates.
[0012] Generate code according to the data model, table structure and page template.
[0013] Preferably, the page template required according to the required material and template combination includes:
[0014] In a non-code editing form, combine the required page templates according to the required materials and templates.
[0015] Preferably, generating code according to the data model, the table structure and the page template includes:
[0016] Generate a technology stack according to the data model, table structure and page template; the technology stack includes configuration files, front-end code, back-end code and database table structure;
[0017] The code is generated according to the technology stack.
[0018] Preferably, generating the code according to the technology stack includes:
[0019] Inserting the configuration file into a location corresponding to the configuration file in the project structure to generate a valid configuration file;
[0020] Inserting the foreground code into a position corresponding to the foreground code in the project structure to generate a valid foreground code;
[0021] Inserting the background code into a position corresponding to the background code in the project structure to generate effective background code;
[0022] The code is generated according to the effective configuration file, the effective foreground code, the effective background code and the database table structure.
[0023] Preferably, the code generation method further comprises: modifying the code in an integrated development environment.
[0024] In a second aspect, the present invention provides a code generation device, the device comprising:
[0025] A data model building unit, used to build a data model corresponding to the function to be realized;
[0026] A table structure generating unit, used to generate a table structure according to the data model;
[0027] The page template combination unit is used to combine the required page templates according to the required materials and templates.
[0028] A code generation unit is used to generate code according to the data model, table structure and page template.
[0029] Preferably, the page template combination unit is specifically used to combine the required page template according to the required materials and templates in a non-code editing form.
[0030] Preferably, the page template combination unit includes:
[0031] A technology stack generation module, used to generate a technology stack according to the data model, table structure and page template; the technology stack includes configuration files, front-end code, back-end code and database table structure;
[0032] A code generation module, used to generate the code according to the technology stack;
[0033] The code generation module includes:
[0034] An effective configuration file generation module, used for inserting the configuration file into a position corresponding to the configuration file in the project structure to generate an effective configuration file;
[0035] An effective foreground code generation module, used for inserting the foreground code into a position corresponding to the foreground code in the project structure to generate an effective foreground code;
[0036] An effective background code generation module is used to insert the background code into a position corresponding to the background code in the project structure to generate an effective background code;
[0037] A code generation submodule, used to generate the code according to the effective configuration file, the effective foreground code, the effective background code and the database table structure;
[0038] The code generating device also includes: a code modifying unit, which is used to modify the code in an integrated development environment.
[0039] In a third aspect, the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the steps of the code generation method are implemented when the processor executes the program.
[0040] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the code generation method when executed by a processor.
[0041] From the above description, it can be seen that the code generation method and device provided in the embodiment of the present invention first establish a data model corresponding to the function to be implemented; generate a table structure based on the data model; then, combine the required page templates based on the required materials and templates, and finally generate code based on the data model, table structure and page template. In order to improve code development efficiency, lower the threshold for code development, rationally utilize the company's existing business and technical assets, and reduce the communication costs between internal roles in the company, the present invention provides a method for improving code development efficiency. By supporting users to quickly build applications, online visual development, online maintenance-free release, zero-threshold creation of complete functions, and reuse of business assets, it helps companies quickly develop applications. Its advantages are as follows:
[0042] 1. Connect the front-end and back-end with the database to generate complete functional module codes that can be directly used in production. Traditional code generation often only provides a basic framework, and you need to fill the business logic into the framework yourself. Moreover, there is usually only a front-end or back-end framework, and the database and most of the logic code still need to be implemented by yourself;
[0043] 2. Visual construction, zero threshold to create complete functions. You can create complete and usable functions by dragging and dropping pages and visually configuring pages. Traditional visual construction generally automatically generates a page with a front-end layout, and you need to implement interaction with the back-end, back-end code, and database yourself.
[0044] 3. The development platform is the production platform. The developed modules can be quickly deployed without operation and maintenance experience. In the past, the semi-finished code provided by code efficiency tools was still in code form after modification. The code needed to be deployed by itself and verified after deployment. However, the present invention can be directly developed, deployed, tested and released on the platform.
[0045] 4. For business personnel, product managers and other positions that do not have development skills, demand communication with developers can often only be described through documents. The system constructed by the present invention can directly build an executable functional prototype through the interface, avoiding the problem of inconsistent requirements caused by differences in document understanding. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the embodiments of the present invention 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 some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0047] Figure 1 The code generation method provided in the embodiment of the present invention is shown in FIG. Figure 1 ;
[0048] Figure 2 This is a flow chart of step 300 of the code generation method in an embodiment of the present invention;
[0049] Figure 3 This is a flow chart of step 400 of the code generation method in an embodiment of the present invention;
[0050] Figure 4 This is a flow chart of step 402 of the code generation method in an embodiment of the present invention;
[0051] Figure 5 The code generation method provided in the embodiment of the present invention is shown in FIG. Figure 2 ;
[0052] Figure 6 It is a structural schematic diagram of a code generation system in a specific application example of the present invention;
[0053] Figure 7 It is a structural schematic diagram of a basic platform device in a specific application example of the present invention;
[0054] Figure 8 It is a structural schematic diagram of a visual development device in a specific application example of the present invention;
[0055] Fig. 9 It is a structural schematic diagram of a code creation device in a specific application example of the present invention;
[0056] Fig.10 It is a structural schematic diagram of a code optimization device in a specific application example of the present invention;
[0057] Fig.11 It is a structural schematic diagram of a code deployment device in a specific application example of the present invention;
[0058] Fig.12 It is a flowchart of a code generation method in a specific application example of the present invention;
[0059] Fig.13 The structure of the code generating device in the embodiment of the present invention is shown in FIG. Figure 1 ;
[0060] Fig.14 It is a structural schematic diagram of a page template combination unit in an embodiment of the present invention;
[0061] Fig.15 A schematic diagram of the structure of a code generation module in an embodiment of the present invention;
[0062] Fig.16 The structure of the code generating device in the embodiment of the present invention is shown in FIG. Figure 2 ;
[0063] Fig.17 FIG. 4 is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0065] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0066] It should be noted that the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or apparatuses.
[0067] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0068] The embodiment of the present invention provides a specific implementation of a code generation method, see Figure 1 , the method specifically includes the following contents:
[0069] Step 100: Establish a data model corresponding to the function to be implemented.
[0070] Specifically, the corresponding business data model can be established according to the functions to be achieved by the generated code. First, determine the scope of the current demand. Since business processes usually interact with other processes in a complex way, it is very important to draw clear boundaries; second, clarify the business fields required for the current page, and set the type and length of the business fields; finally, set the dependencies between business fields.
[0071] Step 200: Generate a table structure according to the data model.
[0072] It is understandable that the table structure here is also called the database table structure, which consists of three parts: the table name, the fields in the table, and the records in the table. Designing a data table structure means defining the data table file name, determining which fields the data table contains, the field name, field type, and width of each field, and inputting these data into the computer. Preferably, in step 200, the table structure can be automatically generated according to the data model. Specifically, according to the business main attributes, business field type, length and dependency, the corresponding database table creation statement is generated according to the requirements specified in the third normal form; the table creation statement is executed using the persistence layer framework technology to complete the creation of the table structure.
[0073] Step 300: Combine the required page template according to the required materials and templates.
[0074] Specifically, materials or templates can be combined into the required page template (page form) through non-code editing forms such as page dragging and interface selection. The existing business data model is associated with the corresponding data on the page, thereby completing the visual development of the module.
[0075] Step 400: Generate code according to the data model, table structure and page template.
[0076] From the above description, it can be seen that the code generation method provided in the embodiment of the present invention first establishes a data model corresponding to the function to be implemented; generates a table structure based on the data model; then, combines the required page templates based on the required materials and templates, and finally generates code based on the data model, table structure and page template. In order to improve code development efficiency, lower the threshold for code development, rationally utilize the company's existing business and technical assets, and reduce the communication costs between internal roles in the company, the present invention provides a method for improving code development efficiency. By supporting users to quickly build applications, online visual development, online maintenance-free publishing, zero-threshold creation of complete functions, and reuse of business assets, it helps companies quickly develop applications. Its advantages are as follows:
[0077] 1. Connect the front-end and back-end with the database to generate complete functional module codes that can be directly used in production. Traditional code generation often only provides a basic framework, and you need to fill the framework with business logic. In addition, there is usually only a front-end or back-end framework, and the database and most of the logic code still need to be implemented by yourself;
[0078] 2. Visual construction, zero threshold to create complete functions. You can create complete and usable functions by dragging and dropping pages and visually configuring pages. Traditional visual construction generally automatically generates a page with a front-end layout, and you need to implement interaction with the back-end, back-end code, and database yourself.
[0079] 3. The development platform is the production platform. The developed modules can be quickly deployed without operation and maintenance experience. In the past, the semi-finished code provided by code efficiency tools was still in code form after modification. The code needed to be deployed by yourself and verified after deployment. However, the present invention can be directly developed, deployed, tested and released on the platform.
[0080] 4. For business personnel, product managers and other positions that do not have development skills, communication with developers on requirements can often only be done through documents. The system constructed by the present invention can directly build an executable functional prototype through the interface, avoiding the problem of inconsistent requirements caused by differences in document understanding.
[0081] In one embodiment, see Figure 2 , step 300 further comprises:
[0082] Step 301: Create a required page template based on required materials and template combinations in a non-code editing form.
[0083] It is understandable that the non-code editing form in step 301 refers to a digital development platform that does not require a code foundation and is suitable for business personnel, IT developers and other types of personnel to quickly build a digital development platform that adapts to the various changes in enterprise needs. Users can complete system development, testing and deployment within a few days or even hours, and can adjust or update at any time. Specifically, the non-code editing form includes page dragging, interface selection, etc.
[0084] In one embodiment, see Figure 3 , step 400 further comprises:
[0085] Step 401: Generate a technology stack according to the data model, table structure and page template; the technology stack includes configuration files, front-end code, back-end code and database table structure;
[0086] A technology stack refers to the combination of multiple technologies as an organic whole to achieve a certain purpose or function. It can also include these technologies and the experience of using them together. For example, to develop a medical management system, html+css+javascript+jquery+springmvc+hibernate+spring+linux+mysql, etc. are used. These technologies can be called a technology stack.
[0087] Step 402: Generate the code according to the technology stack.
[0088] In one embodiment, see Figure 4 , step 402 further comprises:
[0089] Step 4021: inserting the configuration file into a position corresponding to the configuration file in the project structure to generate a valid configuration file;
[0090] Step 4022: inserting the foreground code into a position corresponding to the foreground code in the project structure to generate a valid foreground code;
[0091] Step 4023: inserting the background code into a position corresponding to the background code in the project structure to generate a valid background code;
[0092] Step 4024: Generate the code according to the effective configuration file, the effective foreground code, the effective background code and the database table structure.
[0093] In one embodiment, see Figure 5 , the code generation method also includes:
[0094] Step 500: Modify the code in an integrated development environment.
[0095] It is understandable that the code generated in the above steps is already executable. If there is personalized or more complex business logic processing, the generated code can be downloaded for editing. Specifically, it can be opened directly through the online IDE for online editing, or downloaded to the local computer for editing in the local IDE. After editing, it can be uploaded to the platform again, and the platform will integrate the code files of each module and automatically insert them into the corresponding directory.
[0096] To further illustrate the present solution, the present application provides a specific application example of the code generation method, and the specific application example specifically includes the following contents.
[0097] First, this specific application example provides a code generation system, see Figure 6 The system includes a basic platform device 1, a visual development device 2, a code creation device 3, a code optimization device 4, and a code deployment device 5. The basic platform device 1 is connected to the visual development device 2; the visual development device 2 is connected to the code creation device 3; the code creation device 3 is connected to the code optimization device 4 and the code deployment device 5; the code optimization device 4 is connected to the code deployment device 5.
[0098] Figure 7 is a schematic diagram of the internal structure of the basic platform device 1, such as Figure 7 As shown, the basic platform device 1 includes a foreground basic framework 11, a backend basic framework 12, a database basic framework 13 and a preset general module 14, wherein:
[0099] Front-end basic framework 11: Using the host front-end technology, the front-end basic general module is implemented:
[0100] Backend basic framework 12: Using the host backend technology, the backend basic common modules are implemented;
[0101] Database basic framework 13: Using mainstream database technology, the basic table structure and data required for platform operation are realized;
[0102] Preset common modules 14: Common modules such as login, user, and authority are preset.
[0103] Figure 8 is a schematic diagram of the internal structure of the visualization development device 2, such as Figure 8 As shown, the visualization development device 2 includes a data modeling unit 21, a business template unit 22 and a visualization building unit 23, wherein:
[0104] Data modeling unit 21: used to create the business data model required by the module and automatically generate the table structure according to the model;
[0105] Business template unit 22: contains page materials and business templates required for visualization development;
[0106] Visual construction unit 23: The materials or templates contained in the business template unit 22 can be combined into the required page form through non-code editing forms such as page dragging and interface selection. The existing business data model is associated with the corresponding data unit on the page, and the visual development of the module is completed.
[0107] Fig. 9 is a schematic diagram of the internal structure of the code creation device 3, such as Fig. 9 As shown, the code creation device 3 includes a configuration file generation unit 31, a table structure generation unit 32, a front-end generation unit 33, and a back-end generation unit 34. Among them:
[0108] Configuration file generating unit 31: generates the required configuration file and inserts the file into the corresponding position of the project structure;
[0109] Table structure generating unit 32: generates the required database table structure;
[0110] Front-end generation unit 33: generates the required front-end engineering files and inserts the files into the corresponding positions of the project structure;
[0111] Backend generation unit 34: generates the required backend engineering files and inserts the files into the corresponding positions of the project structure.
[0112] Fig.10 The figure shows the internal composition of the code optimization device 4, which includes a code download unit 41, an online editing unit 42, and a code upload unit 43, wherein:
[0113] Code downloading unit 41: can download the files generated in the code creation device 3 to the local computer and edit them through the local code development IDE;
[0114] Online editing unit 42: can load the file generated in the code creation device 3 through the browser IDE and edit it online;
[0115] Code uploading unit 43: The file that has been edited twice in the code downloading unit 41 or the online editing unit 42 can be re-uploaded to the location corresponding to the project structure through this unit.
[0116] Fig.11 The figure shows the internal composition of the code deployment device 5. The code deployment device 5 includes a function deployment unit 51, a function verification unit 52, and a function release unit 53, wherein:
[0117] Function deployment unit 51: deploys the code created in the above code creation device 3 or code optimization device 4 to the platform;
[0118] Function verification unit 52: the function deployment unit 51 is not visible to ordinary users yet, and can be authorized by the system administrator to access the platform by a designated role to verify the function;
[0119] Function publishing unit 53: For functions verified by the function verification unit 52, the function publishing unit 53 can create corresponding menus and access permissions. The published functions are visible to ordinary users after logging in.
[0120] See also Fig.12 , based on the code generation system, the code generation method provided by this specific application example includes:
[0121] Step S101: Start the code efficient development basic platform.
[0122] Step S102: The platform automatically loads the corresponding basic module.
[0123] Step S103: Log in to the platform through the login module.
[0124] Step S104: For ordinary users who are not system administrators, after logging in, they can only see the functions that have been successfully released, and cannot see the functions related to code development such as online development.
[0125] Step S105: After the system administrator logs in, the functional modules can be quickly developed through visual online development.
[0126] Step S106: First, create the data model required by the functional module.
[0127] Step S107: Combine the front-end pages by visual dragging, page configuration, etc.
[0128] Step S108: Associating the foreground page component with the data in the data model.
[0129] Step S109: In addition to assembling pages by yourself, you can also develop based on existing business templates.
[0130] Step S110: Generate the codes for the front-end, back-end, database, configuration files, etc. through the code generation device.
[0131] Step S111: The generated code is already executable. If there is personalized or more complex business logic processing, the generated code can be downloaded for editing.
[0132] Step S112: The code downloaded in step S111 can be directly opened through an online IDE for online editing.
[0133] Step S113: The code downloaded in step S111 can also be downloaded to a local computer and edited in a local IDE.
[0134] Step S114: The code edited in step S112 or step S113 can be re-uploaded to the platform, and the platform will integrate the code files of each module and automatically insert them into the corresponding directory.
[0135] Step S115: The code developed in step S110 or step S114 can be directly deployed in the current platform. The function just deployed can only be accessed by the system administrator, and the system administrator can authorize a specified role to access the function.
[0136] Step S116: The deployed functions can be verified by the system administrator or personnel with designated roles.
[0137] Step S117: After completing the function verification, the function can be officially released to the platform by setting the menu and permissions. The released function can be accessed by ordinary users in step S104.
[0138] Based on the above method, this specific application example also provides an application scenario of the method: first, a basic platform device is performed, and a basic platform covering modules such as login, user management, authority management, and online development is built based on various mainstream technologies in the industry; then a visual development device is performed, and according to the basic platform, a system administrator account can be used to log in, and after logging in, the online development function can be used. Through the visual construction method, the underlying technical bottleneck can be bypassed, and a relatively common functional module can be created with zero threshold; in addition to building a module from scratch, it can also be modified based on an existing business template to achieve the reuse of existing assets; then a code creation device is performed, and after a functional module is edited in a visual way, the code creation device is used to automatically create a configuration file, a front-end code, a back-end code, a database table structure, and other codes covering various technology stacks to form a functionally complete module; in the created module, if personalized functions are required, the code can be downloaded and modified in the local IDE, or directly modified through the online IDE, and the original code and functions can be replaced after uploading; finally, a code deployment device is performed, and in the created module, the code deployment device can be used to add it to the basic platform, and the function can be quickly launched by setting menus and permissions, and non-administrator users can see the developed module when logging in.
[0139] From the above description, it can be seen that the code generation method provided in the embodiment of the present invention first establishes a data model corresponding to the function to be implemented; generates a table structure based on the data model; then, combines the required page templates based on the required materials and templates, and finally generates code based on the data model, table structure and page template. In order to improve code development efficiency, lower the threshold for code development, rationally utilize the company's existing business and technical assets, and reduce the communication costs between internal roles in the company, the present invention provides a method for improving code development efficiency. By supporting users to quickly build applications, online visual development, online maintenance-free publishing, zero-threshold creation of complete functions, and reuse of business assets, it helps companies quickly develop applications. Its advantages are as follows:
[0140] 1. Connect the front-end and back-end with the database to generate complete functional module codes that can be directly used in production. Traditional code generation often only provides a basic framework, and you need to fill the framework with business logic. In addition, there is usually only a front-end or back-end framework, and the database and most of the logic code still need to be implemented by yourself;
[0141] 2. Visual construction, zero threshold to create complete functions. You can create complete and usable functions by dragging and dropping pages and visually configuring pages. Traditional visual construction generally automatically generates a page with a front-end layout, and you need to implement interaction with the back-end, back-end code, and database yourself.
[0142] 3. The development platform is the production platform. The developed modules can be quickly deployed without operation and maintenance experience. In the past, the semi-finished code provided by code efficiency tools was still in code form after modification. The code needed to be deployed by yourself and verified after deployment. However, the present invention can be directly developed, deployed, tested and released on the platform.
[0143] 4. For business personnel, product managers and other positions that do not have development skills, communication with developers on requirements can often only be done through documents. The system constructed by the present invention can directly build an executable functional prototype through the interface, avoiding the problem of inconsistent requirements caused by differences in document understanding.
[0144] Based on the same inventive concept, the present application embodiment also provides a code generation device, which can be used to implement the method described in the above embodiment, such as the following embodiment. Since the principle of the code generation device to solve the problem is similar to the code generation method, the implementation of the code generation device can refer to the code generation method implementation, and the repetitions are not repeated. As used below, the term "unit" or "module" can implement a combination of software and / or hardware of a predetermined function. Although the system described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware is also possible and conceived.
[0145] The embodiment of the present invention provides a specific implementation of a code generation device capable of implementing a code generation method, see Fig.13 , the code generation device specifically includes the following contents:
[0146] A data model building unit 10 is used to build a data model corresponding to the function to be implemented;
[0147] A table structure generating unit 20, configured to generate a table structure according to the data model;
[0148] The page template combination unit 30 is used to combine the required page template according to the required materials and templates.
[0149] The code generation unit 40 is used to generate code according to the data model, table structure and page template.
[0150] Preferably, the page template combination unit 30 is specifically used to combine the required page template according to the required materials and templates in a non-code editing form.
[0151] Preferably, see Fig.14 , the page template combination unit 30 includes:
[0152] A technology stack generation module 301 is used to generate a technology stack according to the data model, table structure and page template; the technology stack includes configuration files, front-end code, back-end code and database table structure;
[0153] A code generation module 302, configured to generate the code according to the technology stack;
[0154] See also Fig.15 , the code generation module 302 includes:
[0155] An effective configuration file generating module 3021 is used to insert the configuration file into a position corresponding to the configuration file in the project structure to generate an effective configuration file;
[0156] An effective foreground code generating module 3022 is used to insert the foreground code into a position corresponding to the foreground code in the project structure to generate an effective foreground code;
[0157] An effective background code generating module 3023 is used to insert the background code into a position corresponding to the background code in the project structure to generate an effective background code;
[0158] A code generation submodule 3024 is used to generate the code according to the effective configuration file, the effective foreground code, the effective background code and the database table structure;
[0159] Preferably, see Fig.16 The code generation device also includes: a code modification unit 50, which is used to modify the code in an integrated development environment.
[0160] From the above description, it can be seen that the code generation device provided by the embodiment of the present invention first establishes a data model corresponding to the function to be implemented; generates a table structure based on the data model; then, combines the required page templates based on the required materials and templates, and finally generates code based on the data model, table structure and page template. In order to improve code development efficiency, lower the threshold for code development, rationally utilize the company's existing business and technical assets, and reduce the communication costs between internal roles in the company, the present invention provides a device for improving code development efficiency. By supporting users to quickly build applications, online visual development, online maintenance-free publishing, zero-threshold creation of complete functions, and reuse of business assets, it helps companies quickly develop applications. Its advantages are as follows:
[0161] 1. Connect the front-end and back-end with the database to generate complete functional module codes that can be directly used in production. Traditional code generation often only provides a basic framework, and you need to fill the framework with business logic. In addition, there is usually only a front-end or back-end framework, and the database and most of the logic code still need to be implemented by yourself;
[0162] 2. Visual construction, zero threshold to create complete functions. You can create complete and usable functions by dragging and dropping pages and visually configuring pages. Traditional visual construction generally automatically generates a page with a front-end layout, and you need to implement interaction with the back-end, back-end code, and database yourself.
[0163] 3. The development platform is the production platform. The developed modules can be quickly deployed without operation and maintenance experience. In the past, the semi-finished code provided by code efficiency tools was still in code form after modification. The code needed to be deployed by yourself and verified after deployment. However, the present invention can be directly developed, deployed, tested and released on the platform.
[0164] 4. For business personnel, product managers and other positions that do not have development skills, communication with developers on requirements can often only be done through documents. The system constructed by the present invention can directly build an executable functional prototype through the interface, avoiding the problem of inconsistent requirements caused by differences in document understanding.
[0165] The embodiment of the present application also provides a specific implementation of an electronic device capable of implementing all steps of the code generation method in the above embodiment, see Fig.17 , electronic equipment specifically includes the following:
[0166] Processor (processor) 1201, memory (memory) 1202, communication interface (CommunicationsInterface) 1203 and bus 1204;
[0167] The processor 1201 , the memory 1202 , and the communication interface 1203 communicate with each other via the bus 1204 ; the communication interface 1203 is used to realize information transmission between relevant devices such as the server-side device, the power measurement device, and the user-side device.
[0168] The processor 1201 is used to call the computer program in the memory 1202. When the processor executes the computer program, all the steps in the code generation method in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0169] Step 100: Establish a data model corresponding to the function to be implemented;
[0170] Step 200: Generate a table structure according to the data model;
[0171] Step 300: Combine the required page template according to the required materials and templates.
[0172] Step 400: Generate code according to the data model, table structure and page template.
[0173] The embodiments of the present application also provide a computer-readable storage medium capable of implementing all the steps of the code generation method in the above embodiments. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, all the steps of the code generation method in the above embodiments are implemented. For example, when the processor executes the computer program, the following steps are implemented:
[0174] Step 100: Establish a data model corresponding to the function to be implemented;
[0175] Step 200: Generate a table structure according to the data model;
[0176] Step 300: Combine the required page template according to the required materials and templates.
[0177] Step 400: Generate code according to the data model, table structure and page template.
[0178] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the hardware + program embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0179] The above is a description of a specific embodiment of the specification. 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 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.
[0180] Although the present application provides method operation steps such as embodiments or flow charts, more or fewer operation steps may be included based on conventional or non-creative labor. The order of steps listed in the embodiments is only one way of executing the order of many steps and does not represent the only execution order. When the actual device or client product is executed, it can be executed in the order of the method shown in the embodiments or the drawings or in parallel (for example, in a parallel processor or multi-threaded processing environment).
[0181] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0182] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0183] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0184] The present invention uses specific embodiments to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A code generation method, It is characterized in that include: Establish the data model corresponding to the function to be realized; Generate a table structure according to the data model, wherein, according to the business main attributes, business field types, lengths and dependencies, generate corresponding table structure creation statements according to the requirements of the third normal form, wherein the table structure includes a table name, fields in the table and records in the table; Combine the required page templates according to the required materials and templates. Generate code according to the data model, table structure and page template; Generating code according to the data model, table structure and page template includes: Generate a technology stack according to the data model, table structure and page template; the technology stack includes configuration files, front-end code, back-end code and database table structure; generating the code according to the technology stack; Generating the code according to the technology stack includes: Inserting the configuration file into a location corresponding to the configuration file in the project structure to generate a valid configuration file; Inserting the foreground code into a position corresponding to the foreground code in the project structure to generate a valid foreground code; Inserting the background code into a position corresponding to the background code in the project structure to generate effective background code; The code is generated according to the effective configuration file, the effective foreground code, the effective background code and the database table structure.
2. The code generation method according to claim 1, It is characterized in that The page templates required according to the required materials and template combination include: In a non-code editing form, combine the required page templates according to the required materials and templates.
3. The code generation method according to claim 1, It is characterized in that Also includes: The code is modified in an integrated development environment.
4. A code generating device, It is characterized in that include: A data model building unit, used to build a data model corresponding to the function to be realized; A table structure generating unit, configured to generate a table structure according to the data model, wherein a corresponding table structure creation statement is generated according to the requirements of the third normal form according to the business main attributes, business field types, lengths and dependencies, and the table structure includes a table name, fields in the table and records in the table; The page template combination unit is used to combine the required page templates according to the required materials and templates. A code generation unit, used to generate code according to the data model, table structure and page template; The page template combination unit includes: A technology stack generation module, used to generate a technology stack according to the data model, table structure and page template; the technology stack includes configuration files, front-end code, back-end code and database table structure; A code generation module, used to generate the code according to the technology stack; The code generation module includes: An effective configuration file generation module, used for inserting the configuration file into a position corresponding to the configuration file in the project structure to generate an effective configuration file; An effective foreground code generation module, used for inserting the foreground code into a position corresponding to the foreground code in the project structure to generate an effective foreground code; An effective background code generation module is used to insert the background code into a position corresponding to the background code in the project structure to generate an effective background code; A code generation submodule, used to generate the code according to the effective configuration file, the effective foreground code, the effective background code and the database table structure; The code generating device also includes: a code modifying unit, which is used to modify the code in an integrated development environment.
5. The code generating device according to claim 4, It is characterized in that The page template combination unit is specifically used to combine the required page template according to the required materials and templates in a non-code editing form.
6. 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 steps of the code generation method according to any one of claims 1 to 3 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the code generation method according to any one of claims 1 to 3 are implemented.
