CN116069303A - Code generation method, device, equipment and storage medium - Google Patents

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

Info

Publication number
CN116069303A
CN116069303A CN202310146081.5A CN202310146081A CN116069303A CN 116069303 A CN116069303 A CN 116069303A CN 202310146081 A CN202310146081 A CN 202310146081A CN 116069303 A CN116069303 A CN 116069303A
Authority
CN
China
Prior art keywords
code
information
configuration information
configuration
acquiring
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310146081.5A
Other languages
Chinese (zh)
Inventor
翁智松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Shupao Technology Co ltd
Original Assignee
Hangzhou Shupao Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Shupao Technology Co ltd filed Critical Hangzhou Shupao Technology Co ltd
Priority to CN202310146081.5A priority Critical patent/CN116069303A/en
Publication of CN116069303A publication Critical patent/CN116069303A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The application discloses a code generation method, a device, equipment and a storage medium, which relate to the technical field of computers and are used for solving the defect that the service requirements cannot be met at present, and comprise the following steps: acquiring material information selected by a user and material configuration information corresponding to each material; when the fact that the export button is clicked is detected, acquiring the material information through a code outputting service, and acquiring a corresponding target template based on the material information; and generating a material source code based on the material information, the material configuration information and the target template, and generating an engineering source code based on the material source code. The application source code of the front-end management background which is strong in readability and accords with the code specification is quickly generated through the visual arrangement technology, so that the operation difficulty is reduced, and the development speed and the development efficiency are improved.

Description

Code generation method, device, equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a code generating method, apparatus, device, and storage medium.
Background
In the project delivery process, the requirement layer of the management background is endless and is changed along with the change of the project progress; the management background has partial homogenization, such as data display, inquiry and modification; this type of service has very complex forms and procedures that traditional componentization cannot meet.
The low code platforms that are currently common are the following two: the first is a simple form building platform. The platform can generate a native form through visual configuration, and comprises an input box, a drop-down box, a text box, a multi-selection box, a check box and a check rule corresponding to the form. The drawbacks of this approach are: the method is separated from production practice, and the generated form is too simple to meet the service requirement; the generated native code cannot be directly used in the item using the UI framework. The second is to agree on a component configuration data format, configure components in the visual configuration page of the components, transmit configuration information to the running front-end application through the background interface, parse the configuration in the application and render the corresponding components. The drawbacks of this approach are: as the logic of the components becomes complex, the logic of the configuration and parsing becomes very complex, and the time costs and learning costs spent performing the configuration operations far exceed the time costs of direct handwriting code. In addition, this approach creates a significant challenge for the stability, usability of the system.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a code generation method, apparatus, device, and storage medium capable of reducing operation difficulty and improving development speed and development efficiency. The specific scheme is as follows:
In a first aspect, the present application discloses a code generation method, including:
acquiring material information selected by a user and material configuration information corresponding to each material;
when the fact that the export button is clicked is detected, acquiring the material information through a code outputting service, and acquiring a corresponding target template based on the material information;
and generating a material source code based on the material information, the material configuration information and the target template, and generating an engineering source code based on the material source code.
Optionally, before the acquiring the material information selected by the user and the material configuration information corresponding to each material, the method further includes:
uploading current materials through a material management page in a management platform of the presentation layer, and generating a material code corresponding to each material;
performing preset checking operation on the current material, and packing the checked current material into corresponding ESModule, material template and configuration item through packing service;
storing the ESModule and the material template in an object storage OSS of a material library, and storing the configuration item in a monglodb of the material library.
Optionally, before the acquiring the material information selected by the user and the material configuration information corresponding to each material, the method further includes:
Acquiring all the materials in the material warehouse to generate a material area;
generating a visual editor based on the material area, the dragging area and the configuration area;
and generating a canvas based on the visual editor, the material renderer, the interface editor and the global configuration, so that the user can select the material information meeting the current requirement on the canvas and obtain the corresponding material configuration information after configuring the material information.
Optionally, the obtaining the material information selected by the user and the material configuration information corresponding to each material includes:
acquiring the material information selected by the user, and acquiring a target material code corresponding to the material information through the material renderer when the fact that the user drags the material information from the material area to the dragging area is monitored;
and acquiring a material configuration item corresponding to the target material code from the configuration area by using the material renderer, and rendering the material configuration item to the dragging area so as to acquire the material configuration information corresponding to the target material code after the material configuration item is set by the configuration area by the user.
Optionally, when the export button is detected to be clicked, the material information is obtained through a code outputting service, and a corresponding target template is obtained based on the material information, including:
when the fact that the export button is clicked is detected, engineering configuration information corresponding to the material information is sent to the code outputting service through the canvas;
analyzing the engineering configuration information through the code outlet service to obtain interface configuration information, routing configuration information, page configuration information and global configuration information;
splitting the page configuration information into a preset number of single page configuration information, and splitting each single page configuration information into page global configuration information and the material configuration information;
and acquiring the target template from the material library based on the target material code corresponding to the material configuration information.
Optionally, after the parsing the engineering configuration information by the outbound service to obtain interface configuration information, routing configuration information, page configuration information and global configuration information, the method further includes:
acquiring a page global information source code based on the page global configuration information;
acquiring an interface source code based on the interface configuration information, acquiring a route source code based on the route configuration information, and acquiring a global configuration source code based on the global configuration information;
Determining the route source code, the interface source code and the page global information source code as page source codes;
correspondingly, the generating the engineering source code based on the material source code comprises the following steps:
combining the material source codes into the page source codes to obtain combined page source codes;
and merging the merged page source codes into the global configuration source codes to obtain the engineering source codes.
Optionally, after the canvas is generated based on the visual editor, the material renderer, the interface editor and the global configuration, the method further includes:
and converting the received standard swagger json interface file into a corresponding visual page through the interface editor, so that the user configures a data interface on the visual page displayed in the configuration area.
In a second aspect, the present application discloses a code generating apparatus, including:
the information acquisition module is used for acquiring material information selected by a user and material configuration information corresponding to each material;
the template acquisition module is used for acquiring the material information through a code outputting service when detecting that the export button is clicked, and acquiring a corresponding target template based on the material information;
The material source code generation module is used for generating material source codes based on the material information, the material configuration information and the target template;
and the engineering source code generation module is used for generating engineering source codes based on the material source codes.
In a third aspect, the present application discloses an electronic device comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the code generation method as previously disclosed.
In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the code generation method as previously disclosed.
It can be seen that the present application provides a code generation method, including: acquiring material information selected by a user and material configuration information corresponding to each material; when the fact that the export button is clicked is detected, acquiring the material information through a code outputting service, and acquiring a corresponding target template based on the material information; and generating a material source code based on the material information, the material configuration information and the target template, and generating an engineering source code based on the material source code. Therefore, the method and the device have the advantages that the template corresponding to the material information is preset, and then the front-end management background application source code which is high in readability and accords with the code specification is quickly generated on the basis of the template through the visual arrangement technology, so that the operation difficulty is reduced, and the development speed and the development efficiency are improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present invention, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a code generation method disclosed in the present application;
FIG. 2 is a schematic diagram of an overall architecture of an eCode platform disclosed herein;
FIG. 3 is a schematic diagram of a main page structure of the visual editor disclosed in the present application;
FIG. 4 is a schematic diagram of an interface editor disclosed herein;
FIG. 5 is a schematic diagram of the code-out flow disclosed in the present application;
FIG. 6 is a flowchart of a specific code generation method disclosed in the present application;
FIG. 7 is a schematic diagram of a code generating device provided in the present application;
fig. 8 is a block diagram of an electronic device provided in the present application.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
At present, in the project delivery process, the requirement layer of the management background is endless and is often changed along with the change of the project progress; the management background has partial homogenization, such as data display, inquiry and modification; this type of service has very complex forms and procedures that traditional componentization cannot meet. Therefore, the code generation method can reduce operation difficulty and improve development speed and development efficiency.
The embodiment of the invention discloses a code generation method, which is shown in fig. 1, and comprises the following steps:
step S11: and acquiring material information selected by a user and material configuration information corresponding to each material.
In this embodiment, material information selected by a user and material configuration information corresponding to each material are obtained. Specifically, the material information selected by the user is obtained, and when the fact that the user drags the material information from the material area to the dragging area is monitored, a target material code corresponding to the material information is obtained through the material renderer; and acquiring a material configuration item corresponding to the target material code from the configuration area by using the material renderer, and rendering the material configuration item to the dragging area so as to acquire the material configuration information corresponding to the target material code after the material configuration item is set by the configuration area by the user.
It can be understood that before acquiring the material information selected by the user and the material configuration information corresponding to each material, uploading the current material through a material management page in a management platform of the presentation layer, and generating a material code corresponding to each material; performing preset checking operation on the current material, and packing the checked current material into corresponding ESModule (ESM, javaScript modularization specification), material templates and configuration items through packing service; storing the ESModule and the material template in an object storage OSS of a material library, and storing the configuration item in a monglodb of the material library. Acquiring all the materials in the material warehouse to generate a material area; generating a visual editor based on the material area, the dragging area and the configuration area; and generating a canvas based on the visual editor, the material renderer, the interface editor and the global configuration, so that the user can select the material information meeting the current requirement on the canvas and obtain the corresponding material configuration information after configuring the material information. Further, after the canvas is generated, the received standard swagger json interface file is converted into a corresponding visual page through the interface editor, so that the user configures a data interface on the visual page displayed in the configuration area.
It can be understood that the eCode low code platform in the present application mainly includes the following 3 parts: the canvas application can be used for visual display and configuration of the front-end application; a "materials library" application containing a number of materials (front end universal business modules); the configuration items can be rendered into 'out-code' applications of front-end engineering source codes. Visual arrangement operations such as clicking, dragging, inputting configuration, front-end application configuration and the like can be performed on the canvas; transmitting and analyzing according to the appointed material configuration data format; the material library is compatible with common Vue.js, real.js technical stacks and original JavaScript through ESMoude and containerization technologies, and is compatible with Element and AntDesign UI frameworks; the front end source code which is generated by the code output service can be used for the engineering configured on the canvas, is easy to read and modify, does not have packing compression condition, can be used for carrying out secondary development modification for front end developers, and solves very complex requirements.
The overall architecture of the Code platform is shown in fig. 2, and the eCode platform includes a presentation layer, a communication layer, a service layer, and a data layer. Specifically, the display layer comprises canvas, a material library and a management platform; the communication layer comprises https communication and websocket communication; the service layer comprises code outputting service, material packing service, material management service, engineering management service and a user center; the data layer contains mongolidb and object storage oss. Wherein the canvas is a webapp. The user can perform visual arrangement operation on the canvas and transmit the arranged pages or engineering data to the code giving module through the request. The canvas mainly comprises four core parts of a visual editor, a material renderer, an interface editor and global configuration. The main page structure of the visual editor is shown in fig. 3, and mainly comprises a material area, a dragging area and a configuration area; the material area is used for displaying materials, and a user can drag the materials in the material area to the dragging area; in the dragging area, the user can carry out dragging sorting, copying, selecting and deleting operations on the materials on the dragging area; and in the configuration area, the user can perform configuration operation on the materials selected in the dragging area. The user can configure the data interface corresponding to the material on the configuration area of the material renderer. The main function of the material renderer is to render the material on the dragging area, and the working flow is as follows: the user drags the material from the material area to the dragging area; the material renderer acquires the material code; the material renderer pulls the material ESModule corresponding to the code from the material library; the material renderer acquires material configuration items from the configuration area; the material renderer renders the material package and the corresponding configuration items to the dragging area; and the user modifies the configuration in the configuration area and jumps to the step that the material renderer acquires the material configuration items from the configuration area. The interface editor can import a standard swaggerjson interface file and convert this json file into a corresponding visualization page. The interface editor is mainly composed of four parts, including an interface list, interface basic information, request parameters, and response parameters as shown in fig. 4. The interface list is a list display of interfaces, and can be used for incremental import and overlay import of swaggerjson, modification and deletion of the interfaces; the interface basic information displays basic information such as interface names, interface paths and the like; request parameters show request method and request parameter data format; the response parameters exhibit a return value data format. The global configuration includes two functions, namely page routing configuration and engineering information configuration.
It will be appreciated that as shown in fig. 2 above, the material store contains several materials: page template: such as a common list search presentation page; layout materials: layout materials such as tabs, grid, etc.; form material: form items, such as form items, check items; form material: such as rows, columns, operation items of a table; data material: charts such as bar charts, line charts, etc.; high-grade materials: such as some more complex business materials. Each material has a corresponding ESModule, material template, configuration item (a jsonschema is a language for describing a set of rules, here jsonschema is used)), and each material covers a range of business functions through a suitable configuration item, and the interaction logic of the material library with other applications is as follows: uploading materials in a material management page of a management platform by a user; the materials are packed into corresponding ESModule, material templates and configuration items through packing service; the packaging service uploads the ESModule, the material template and the configuration item to a material library; the material library will upload the ESModule and the material template to the object storage oss, and store the configuration item to monglodb; the canvas application initialization stage loads a material list in a material library; the material renderer applied to the canvas pulls ESModule of the material from the material library through the material code and renders the material; the visual editor configuration area of the canvas application pulls configuration items from the material library and renders the configuration items into a configuration item page; the user performs export engineering or single page export operation; the code outlet service obtains engineering configuration items, and obtains templates of corresponding materials in a material library through material codes in the configuration items; the code outlet clothes generate material source codes through the material templates and the configuration items.
In addition, the management platform comprises: engineering management: creating, modifying and deleting engineering; and (3) material management: creating, releasing, putting down and deleting materials; user management: user creation, role modification, rights modification.
Step S12: and when the fact that the export button is clicked is detected, acquiring the material information through the code outputting service, and acquiring a corresponding target template based on the material information.
In this embodiment, after acquiring the material information selected by the user and the material configuration information corresponding to each material, when detecting that the export button is clicked, acquiring the material information through the code outputting service, and acquiring the corresponding target template based on the material information. It can be understood that the material packing is to pack the packaged material provided by the user into the resource for canvas and code-out application, and the specific steps are as follows: the user provides a material containing a certain business logic and provides an interface description json file about the material; the user uploads the file to a material packing service through a material management module of a management platform; the material packing service performs rule check on the material source file, and if the material source file does not accord with the specified material rule, the process is terminated; the material packing service converts the material source file into a corresponding ESModule; the material packing service converts the material source file into a corresponding material template file; the material packaging service converts the material interface description json into a jsonschema configuration item. After the user finishes the current configuration operation, clicking the export button, at this time, the code outputting service obtains the current configured material information, and then queries the corresponding preset material template file according to the material information to obtain the target template.
Step S13: and generating a material source code based on the material information, the material configuration information and the target template, and generating an engineering source code based on the material source code.
In this embodiment, when it is detected that the export button is clicked, the material information is acquired through the code outputting service, and after a corresponding target template is acquired based on the material information, a material source code is generated based on the material information, the material configuration information and the target template, and an engineering source code is generated based on the material source code. The code outlet service is used for converting the project configured by the user in the canvas into front-end project source codes, and a complete code outlet flow is shown in fig. 5: the user performs engineering code-outputting operation; the canvas sends the engineering configuration to the code-out service; the engineering code is used for analyzing the engineering configuration, and splitting: interface configuration, routing configuration, page configuration comprising a plurality of pages, global configuration; the global configuration is converted into global configuration source codes in the engineering code outlet module; the interface configuration is sent to an interface code output module and converted into interface source codes; the route configuration is sent to a route code outlet module and converted into route source codes; the page configuration is split into a plurality of single page configurations, and the single page configurations are sequentially sent to a single page code-outputting module; the single page code-outputting module splits the page configuration into page global configuration and material configuration containing a plurality of materials; the page global configuration is converted into a page global information source code in a page code output module; the material configuration is split into a plurality of single material configurations, and the single material configurations are sequentially sent to the material code-out module; the material code output module acquires a material template from a material library according to the material code and generates a material source code; the material source codes are uniformly classified into page source codes; the page source codes are uniformly classified into engineering source codes; and finally, the engineering source code is downloaded to the local environment of the user as a download resource. It should be noted that if the user performs a single-page code-outputting operation, the canvas will send the page configuration to the single-page code-outputting module, and directly entering the single-page code-outputting module will split the page configuration into the global page configuration and the material configuration containing a plurality of materials, sequentially execute the subsequent steps, stop when the step of completing the unified classification of the material source codes into the page source codes is executed, and then download the page source codes directly as download resources to the local environment of the user.
In the prior art, the requirements of brand new project development and new pages in old projects cannot be processed at the same time, and the eCode in the application solves the problems through the functions of engineering code output and single page code output. The user can perform configuration (including all pages, routes, interfaces and global configuration) of the whole project on the eCode, so as to generate the whole project source code; the method can be used as a page editor, only one or more pages are configured, and then the derived page source codes are migrated to the old project, so that the flexible development mode meets the requirements in each period of the project. eCode generates ESModule of the display stage and material template of the code output stage through material packaging, and decouples two steps of page display and code output. Based on the requirement of page display, the materials are preferably distributed in an ESModule form, but the ESModule generated by packaging is unreadable, and if the ESModule is used in the code output stage, the generated source code cannot be read, so that the convenience of manually modifying the source code is not realized. The material is preferably in the form of templates based on the requirements of the code. The material source code generated in the template rendering mode has very strong readability, is the same as handwriting of a programmer and can be standardized. However, in page display, the template scheme can greatly increase the business complexity of the low-code platform, increase the cost of material packaging, and meanwhile, the business complexity always exists, and no matter how the business is developed, the complexity can be reflected on the complexity of a code structure or the complexity of platform configuration in a handwriting code, low-code or code-free platform. Therefore, the eCode low-code platform divides the materials into ESModule and material template by material packaging, generates most of service codes by using a low-code platform with a small amount of configuration, and then solves the problems by assisting in manually handwriting a small amount of complex service codes. And based on the material library, the management platform and the material packaging application, the eCode realizes an expandable material library mechanism, and can be connected to a low-code platform only by the materials which can be checked by the rule of the material packaging application, so that decoupling of the platform and the materials is realized. The eCode platform developer only needs to pay attention to core services such as canvas, code output and the like of the platform; the developer of the business department provides the business materials conforming to the rules without the intervention of platform developers. The labor division cooperation improves the code quality by the special personnel on the one hand; on the other hand, each developer can participate in the platform, so that the iterative updating of the platform is promoted, a large amount of materials are accumulated, and the production efficiency is improved.
The eCode platform can directly generate a low-code platform of front-end source codes through visual configuration, the platform improves applicability by being compatible with common front-end technical stacks, and the efficiency of developing homogenous service can be improved by using the packaged service modules; the visual configuration is used for reducing the operation difficulty and improving the development speed; source code that can be modified twice is produced to cope with some very complex scenarios.
It can be seen that the present application provides a code generation method, including: acquiring material information selected by a user and material configuration information corresponding to each material; when the fact that the export button is clicked is detected, acquiring the material information through a code outputting service, and acquiring a corresponding target template based on the material information; and generating a material source code based on the material information, the material configuration information and the target template, and generating an engineering source code based on the material source code. Therefore, the method and the device have the advantages that the template corresponding to the material information is preset, and then the front-end management background application source code which is high in readability and accords with the code specification is quickly generated on the basis of the template through the visual arrangement technology, so that the operation difficulty is reduced, and the development speed and the development efficiency are improved.
Referring to fig. 6, an embodiment of the present invention discloses a code generation method, and compared with the previous embodiment, the present embodiment further describes and optimizes a technical solution.
Step S21: and acquiring material information selected by a user and material configuration information corresponding to each material.
Step S22: and when the fact that the export button is clicked is detected, the engineering configuration information corresponding to the material information is sent to the code-out service through the canvas.
In this embodiment, after acquiring the material information selected by the user and the material configuration information corresponding to each material, when detecting that the export button is clicked, the engineering configuration information corresponding to the material information is sent to the code outputting service through the canvas. It can be understood that the code-out service includes engineering code-out, interface code-out, route code-out, single page code-out and material code-out.
Step S23: and analyzing the engineering configuration information through the code outlet service to obtain interface configuration information, routing configuration information, page configuration information and global configuration information.
In this embodiment, when it is detected that the export button is clicked, after the engineering configuration information corresponding to the material information is sent to the code outputting service through the canvas, the engineering configuration information is parsed through the code outputting service, so as to obtain interface configuration information, routing configuration information, page configuration information and global configuration information. It can be understood that after the engineering configuration information is parsed by the outbound service, a page global information source code is obtained based on the page global configuration information; acquiring an interface source code based on the interface configuration information, acquiring a route source code based on the route configuration information, and acquiring a global configuration source code based on the global configuration information; and determining the route source code, the interface source code and the page global information source code as page source codes.
Step S24: splitting the page configuration information into a preset number of single page configuration information, and splitting each single page configuration information into page global configuration information and the material configuration information.
Step S25: and acquiring the target template from the material library based on the target material code corresponding to the material configuration information.
Step S26: and generating a material source code based on the material information, the material configuration information and the target template, and generating an engineering source code based on the material source code.
In this embodiment, after generating a material source code based on the material information, the material configuration information and the target template, the material source code is merged into the page source code to obtain a merged page source code; and merging the merged page source codes into the global configuration source codes to obtain the engineering source codes.
For the specific content of the steps S21 and S24, reference may be made to the corresponding content disclosed in the foregoing embodiment, and no detailed description is given here.
Therefore, the embodiment of the application obtains the material information selected by the user and the material configuration information corresponding to each material; when the fact that the export button is clicked is detected, engineering configuration information corresponding to the material information is sent to the code outputting service through the canvas; analyzing the engineering configuration information through the code outlet service to obtain interface configuration information, routing configuration information, page configuration information and global configuration information; splitting the page configuration information into a preset number of single page configuration information, and splitting each single page configuration information into page global configuration information and the material configuration information; acquiring the target template from the material library based on the target material code corresponding to the material configuration information; and generating a material source code based on the material information, the material configuration information and the target template, and generating an engineering source code based on the material source code, thereby reducing the operation difficulty and improving the development speed and development efficiency.
Referring to fig. 7, the embodiment of the application further correspondingly discloses a code generating device, which includes:
the information acquisition module 11 is configured to acquire material information selected by a user and material configuration information corresponding to each material;
the template acquisition module 12 is used for acquiring the material information through a code outputting service when the fact that the export button is clicked is detected, and acquiring a corresponding target template based on the material information;
the material source code generation module 13 is used for generating material source codes based on the material information, the material configuration information and the target template;
the engineering source code generating module 14 is configured to generate engineering source codes based on the material source codes.
As can be seen, the present application includes: acquiring material information selected by a user and material configuration information corresponding to each material; when the fact that the export button is clicked is detected, acquiring the material information through a code outputting service, and acquiring a corresponding target template based on the material information; and generating a material source code based on the material information, the material configuration information and the target template, and generating an engineering source code based on the material source code. Therefore, the method and the device have the advantages that the template corresponding to the material information is preset, and then the front-end management background application source code which is high in readability and accords with the code specification is quickly generated on the basis of the template through the visual arrangement technology, so that the operation difficulty is reduced, and the development speed and the development efficiency are improved.
In some embodiments, the information obtaining module 11 specifically includes:
the material uploading unit is used for uploading the current material through a material management page in a management platform of the presentation layer;
the material code generating unit is used for generating a material code corresponding to each material;
the verification unit is used for executing preset verification operation on the current material;
the packing unit is used for packing the current materials which pass the verification into corresponding ESModule, material templates and configuration items through packing service;
the storage unit is used for storing the ESModule and the material template in an object storage OSS of a material library and storing the configuration item in a mongdb of the material library;
the material area generating unit is used for acquiring all the materials in the material library so as to generate a material area;
the visual editor generation unit is used for generating a visual editor based on the material area, the dragging area and the configuration area;
the canvas generation unit is used for generating a canvas based on the visual editor, the material renderer, the interface editor and the global configuration so that the user can select the material information meeting the current requirement on the canvas and obtain the corresponding material configuration information after configuring the material information;
The file conversion unit is used for converting the received standard swagger json interface file into a corresponding visual page through the interface editor so that the user can configure a data interface on the visual page displayed in the configuration area;
the material information acquisition unit is used for acquiring the material information selected by the user;
the target material code acquisition unit is used for acquiring a target material code corresponding to the material information through the material renderer when the fact that a user drags the material information from the material area to the dragging area is monitored;
a material configuration item acquisition unit, configured to acquire a material configuration item corresponding to the target material code from the configuration area by using the material renderer;
and the material configuration item rendering unit is used for rendering the material configuration item to the dragging area so as to acquire the material configuration information corresponding to the target material code after the user sets the material configuration item in the configuration area.
In some embodiments, the template acquisition module 12 specifically includes:
the project configuration information sending unit is used for sending project configuration information corresponding to the material information to the code outputting service through the canvas when the fact that the export button is clicked is detected;
The engineering configuration information analysis unit is used for analyzing the engineering configuration information through the code outputting service to obtain interface configuration information, routing configuration information, page configuration information and global configuration information;
the first source code acquisition unit is used for acquiring the global page information source code based on the global page configuration information;
the second source code acquisition unit is used for acquiring interface source codes based on the interface configuration information, acquiring route source codes based on the route configuration information and acquiring global configuration source codes based on the global configuration information;
the page source code determining unit is used for determining the route source code, the interface source code and the page global information source code as page source codes;
the information splitting unit is used for splitting the page configuration information into a preset number of single page configuration information and splitting each single page configuration information into page global configuration information and the material configuration information;
and the target template acquisition unit is used for acquiring the target template from the material library based on the target material code corresponding to the material configuration information.
In some embodiments, the material source code generating module 13 specifically includes:
And the material source code generating unit is used for generating material source codes based on the material information, the material configuration information and the target template.
In some embodiments, the engineering source code generating module 14 specifically includes:
the combined page source code generation unit is used for combining the material source codes into the page source codes to obtain combined page source codes;
and the engineering source code generating unit is used for merging the merged page source codes into the global configuration source codes to obtain the engineering source codes.
Further, the embodiment of the application also provides electronic equipment. Fig. 8 is a block diagram of an electronic device 20, according to an exemplary embodiment, and the contents of the diagram should not be construed as limiting the scope of use of the present application in any way.
Fig. 8 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. Wherein the memory 22 is configured to store a computer program that is loaded and executed by the processor 21 to implement the relevant steps of the code generation method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the present embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide an operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and the communication protocol to be followed is any communication protocol applicable to the technical solution of the present application, which is not specifically limited herein; the input/output interface 25 is used for acquiring external input data or outputting external output data, and the specific interface type thereof may be selected according to the specific application requirement, which is not limited herein.
The memory 22 may be a carrier for storing resources, such as a read-only memory, a random access memory, a magnetic disk, or an optical disk, and the resources stored thereon may include an operating system 221, a computer program 222, and the like, and the storage may be temporary storage or permanent storage.
The operating system 221 is used for managing and controlling various hardware devices on the electronic device 20 and computer programs 222, which may be Windows Server, netware, unix, linux, etc. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the code generation method performed by the electronic device 20 as disclosed in any of the previous embodiments.
Further, the embodiment of the application also discloses a storage medium, and the storage medium stores a computer program, and when the computer program is loaded and executed by a processor, the steps of the code generation method disclosed in any of the previous embodiments are realized.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing has described in detail the methods, apparatuses, devices and storage medium for generating codes according to the present invention, and specific examples are applied to illustrate the principles and embodiments of the present invention, and the above examples are only used to help understand the methods and core ideas of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present invention, the present description should not be construed as limiting the present invention in view of the above.

Claims (10)

1. A code generation method, comprising:
acquiring material information selected by a user and material configuration information corresponding to each material;
when the fact that the export button is clicked is detected, acquiring the material information through a code outputting service, and acquiring a corresponding target template based on the material information;
and generating a material source code based on the material information, the material configuration information and the target template, and generating an engineering source code based on the material source code.
2. The code generating method according to claim 1, wherein before the acquiring the material information selected by the user and the material configuration information corresponding to each material, further comprises:
Uploading current materials through a material management page in a management platform of the presentation layer, and generating a material code corresponding to each material;
performing preset checking operation on the current material, and packing the checked current material into corresponding ESModule, material template and configuration item through packing service;
storing the ESModule and the material template in an object storage OSS of a material library, and storing the configuration item in a monglodb of the material library.
3. The code generating method according to claim 2, wherein before the acquiring the material information selected by the user and the material configuration information corresponding to each material, further comprises:
acquiring all the materials in the material warehouse to generate a material area;
generating a visual editor based on the material area, the dragging area and the configuration area;
and generating a canvas based on the visual editor, the material renderer, the interface editor and the global configuration, so that the user can select the material information meeting the current requirement on the canvas and obtain the corresponding material configuration information after configuring the material information.
4. The code generating method according to claim 3, wherein the obtaining the material information selected by the user and the material configuration information corresponding to each material includes:
Acquiring the material information selected by the user, and acquiring a target material code corresponding to the material information through the material renderer when the fact that the user drags the material information from the material area to the dragging area is monitored;
and acquiring a material configuration item corresponding to the target material code from the configuration area by using the material renderer, and rendering the material configuration item to the dragging area so as to acquire the material configuration information corresponding to the target material code after the material configuration item is set by the configuration area by the user.
5. The code generating method according to claim 4, wherein when it is detected that the export button is clicked, the material information is acquired through an export service, and a corresponding target template is acquired based on the material information, comprising:
when the fact that the export button is clicked is detected, engineering configuration information corresponding to the material information is sent to the code outputting service through the canvas;
analyzing the engineering configuration information through the code outlet service to obtain interface configuration information, routing configuration information, page configuration information and global configuration information;
Splitting the page configuration information into a preset number of single page configuration information, and splitting each single page configuration information into page global configuration information and the material configuration information;
and acquiring the target template from the material library based on the target material code corresponding to the material configuration information.
6. The code generation method according to claim 5, wherein after parsing the engineering configuration information by the outbound service to obtain interface configuration information, routing configuration information, page configuration information, and global configuration information, further comprising:
acquiring a page global information source code based on the page global configuration information;
acquiring an interface source code based on the interface configuration information, acquiring a route source code based on the route configuration information, and acquiring a global configuration source code based on the global configuration information;
determining the route source code, the interface source code and the page global information source code as page source codes;
correspondingly, the generating the engineering source code based on the material source code comprises the following steps:
combining the material source codes into the page source codes to obtain combined page source codes;
And merging the merged page source codes into the global configuration source codes to obtain the engineering source codes.
7. The code generation method of any of claims 3 to 6, wherein after the canvas is generated based on the visualization editor, the materials renderer, the interface editor, and the global configuration, further comprising:
and converting the received standard swagger json interface file into a corresponding visual page through the interface editor, so that the user configures a data interface on the visual page displayed in the configuration area.
8. A code generating apparatus, comprising:
the information acquisition module is used for acquiring material information selected by a user and material configuration information corresponding to each material;
the template acquisition module is used for acquiring the material information through a code outputting service when detecting that the export button is clicked, and acquiring a corresponding target template based on the material information;
the material source code generation module is used for generating material source codes based on the material information, the material configuration information and the target template;
and the engineering source code generation module is used for generating engineering source codes based on the material source codes.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the code generation method of any of claims 1 to 7.
10. A computer-readable storage medium storing a computer program; wherein the computer program when executed by a processor implements the code generation method of any of claims 1 to 7.
CN202310146081.5A 2023-02-14 2023-02-14 Code generation method, device, equipment and storage medium Pending CN116069303A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310146081.5A CN116069303A (en) 2023-02-14 2023-02-14 Code generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310146081.5A CN116069303A (en) 2023-02-14 2023-02-14 Code generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116069303A true CN116069303A (en) 2023-05-05

Family

ID=86180091

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310146081.5A Pending CN116069303A (en) 2023-02-14 2023-02-14 Code generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116069303A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117289929A (en) * 2023-11-24 2023-12-26 浙江口碑网络技术有限公司 Plug-in frame, plug-in and data processing method and device and electronic equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117289929A (en) * 2023-11-24 2023-12-26 浙江口碑网络技术有限公司 Plug-in frame, plug-in and data processing method and device and electronic equipment
CN117289929B (en) * 2023-11-24 2024-03-19 浙江口碑网络技术有限公司 Plug-in frame, plug-in and data processing method and device and electronic equipment

Similar Documents

Publication Publication Date Title
US8417798B2 (en) Deploying artifacts for packaged software application in cloud computing environment
CN111241454B (en) Method, system and device for generating webpage codes
EP2151773B1 (en) Synchronous to asynchronous web page conversion
US8656346B2 (en) Converting command units into workflow activities
US10789052B2 (en) User interface (UI) design system mapping platform for automatically mapping design system components to a design document file from a design tool to generate a mapped specification
US20060212842A1 (en) Rich data-bound application
US20200384644A1 (en) Systems and Methods for Robotic Process Automation
CN113504908A (en) Business code generation method and device, electronic equipment and computer readable medium
Bünder Decoupling Language and Editor-The Impact of the Language Server Protocol on Textual Domain-Specific Languages.
US20120078809A1 (en) Integrating sub-processes in business process modeling notation processes
US20110022943A1 (en) Document object model (dom) application framework
US20240160410A1 (en) Application Development Platform, Micro-program Generation Method, and Device and Storage Medium
US20210334149A1 (en) Api adapter creation device, api adapter creation method, and api adapter creation program
US20180232216A1 (en) Systems and methods for executable content and executable content flow creation
CN111026634A (en) Interface automation test system, method, device and storage medium
CN117008923A (en) Code generation and compiling deployment method, platform and equipment based on AI large model
CN110674083A (en) Workflow migration method, device, equipment and computer readable storage medium
JP7280388B2 (en) Apparatus and method, equipment and medium for implementing a customized artificial intelligence production line
Snell et al. Microsoft Visual Studio 2012 Unleashed: Micro Visua Studi 2012 Unl_p2
CN116069303A (en) Code generation method, device, equipment and storage medium
CN114860218A (en) Low code development method and device
US20220308841A1 (en) Enabling custom software development by domain experts
CN111580804B (en) Method and device for developing software project
CN115469849B (en) Service processing system, method, electronic equipment and storage medium
Qi et al. An extension mechanism to verify, constrain and enhance geoprocessing workflows invocation

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