Model-to-code conversion method, device, electronic device, and storage medium
By dragging and selecting controls, service modules and entity modules, the preset template database is used to generate a logical code structure and convert it into executable code, which solves the problem of low development efficiency in the existing technology and realizes efficient component development.
Patent Information
- Application Number
- CN202210545314.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-19
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2042-05-19
AI Technical Summary
In the existing technology, each component needs to be manually coded during the software development process, resulting in low development efficiency.
By dragging and selecting controls, service modules, and entity modules, a preset template database is used to generate a logical code structure, which is then converted into executable code based on the code language type, including the use of business tables and code databases to optimize data storage and search.
The efficiency of component development is improved, and technicians can generate runnable code with simple operations, reducing the workload of manual coding.
Smart Images

Figure CN115048089B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more particularly, to a model-to-code conversion method, device, electronic device, and storage medium. Background Art
[0002] As the IT industry continues to evolve, the complexity of software development is also increasing. For example, when developing a webpage, a page consists of multiple components. Each component is composed of controls, multiple service modules, and multiple entity modules. Each component also contains the complete processing logic between controls, multiple service modules, and multiple entity modules. This means that each component must be developed separately, resulting in low development efficiency. Summary of the Invention
[0003] In order to solve the above technical problems, the present application provides a model-to-code conversion method, device, electronic device and storage medium.
[0004] In a first aspect of the present application, a method for converting a model to code is provided. The method comprises:
[0005] Obtain the code language type to be generated and pre-configured controls, service modules, and entity modules, where the service modules are used to execute processing logic and the entity modules are a collection of data required for the execution of the processing logic;
[0006] According to the control, service module and entity module, the corresponding control template, service template and entity template are retrieved from the preset template database;
[0007] According to the corresponding relationship between the control, service module and entity module, the control template, service template and entity template are configured to generate a logical code structure;
[0008] According to the code language type, the logical code structure and the preset model code conversion rules, the logical code structure is converted into an executable code.
[0009] Optionally, the model code conversion rules include:
[0010] Creating a business table, wherein the business table is used to store the data in the entity module or the address of the data in the database;
[0011] According to the code language type, a code language package corresponding to the code language type is screened in a code database, wherein the code language package includes an executable code unit corresponding to each control template and service template;
[0012] According to the control templates and service templates contained in the logical code structure, the corresponding executable code units are called respectively;
[0013] According to the corresponding relationship among the control template, the service template and the entity template in the logical code structure, the executable code unit is configured to generate the executable code, and the executable code is associated with the business table.
[0014] Optionally, the business table is used to store the data in the entity module or the address of the data in the database, including:
[0015] The entity module is composed of multiple data packets, among which,
[0016] Data packets with a storage size smaller than the preset value are stored in the service table;
[0017] The data packet whose storage size is larger than the preset value is stored in the database, and the storage address of the data packet in the database is stored in the service table.
[0018] Optionally, if there are multiple code language types, the following steps are executed in a loop:
[0019] Converting the logical code structure into executable code according to the code language type, the logical code structure, and preset model code conversion rules;
[0020] Until all executable codes of the acquired code language types are generated.
[0021] Optionally, before generating the executable code, the method further includes establishing a blank table in a database, wherein the blank table is used to store the executable code.
[0022] Optionally, after storing the executable code in the blank table, configure the page properties and encapsulate it.
[0023] Optionally, configure controls, service modules, and entity modules as follows:
[0024] Push multiple optional controls;
[0025] Get the selected control and push multiple optional service modules that match the selected control;
[0026] Get the selected service module and push multiple entity modules that match the selected service module;
[0027] The selected entity module is obtained, and according to the corresponding relationship between the selected control, the selected service module and the selected entity module, the control, the service module and the entity module are configured.
[0028] This application discloses a model-to-code conversion method that automatically generates executable code after the configuration of controls, service modules, and entity modules is completed. Based on the required code language type and the configured controls, service modules, and entity modules, the method automatically generates executable code based on preset model-to-code conversion rules. This application changes the previous situation where technicians had to manually write code for each component. Technicians can now generate the required executable code through simple operations such as dragging, dropping, and selecting, greatly improving the efficiency of component development.
[0029] In a second aspect of the present application, a model-to-code conversion device is provided. The device comprises:
[0030] An acquisition module, configured to acquire the code language type to be generated and pre-configured controls, service modules, and entity modules. The service modules are used to execute processing logic, and the entity modules are a collection of data required for the execution of the processing logic.
[0031] A calling module, used to call corresponding control templates, service templates and entity templates from a preset template database according to the control, service module and entity module;
[0032] A generation module, configured to configure the control template, service template and entity template to generate a logical code structure according to the corresponding relationship between the control, service module and entity module;
[0033] The conversion module is used to convert the logical code structure into executable code according to the code language type, logical code structure and preset model code conversion rules.
[0034] In a third aspect of the present application, an electronic device is provided, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor implements the above method when executing the program.
[0035] In a fourth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method according to the first aspect of the present application is implemented.
[0036] It should be understood that the contents described in the Summary of the Invention are not intended to limit the key or important features of the embodiments of the present application, nor are they intended to limit the scope of the present application. Other features of the present application will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The above and other features, advantages and aspects of the embodiments of the present application will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, wherein:
[0038] Figure 1 A flow chart of a model-to-code conversion method according to an embodiment of the present application is shown;
[0039] Figure 2 A block diagram of a model-to-code conversion device according to an embodiment of the present application is shown;
[0040] Figure 3 A schematic diagram of the structure of a terminal device or server suitable for implementing an embodiment of the present application is shown. DETAILED DESCRIPTION
[0041] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0042] In the present application, a model-to-code conversion method is disclosed, which is applied to a visual development system. In the visual development system, the present application splits the visual components into controls, service modules and entity modules. When configuring a new page, you can select the required controls in the toolbar by dragging, selecting, etc. After selecting the controls, the optional service modules corresponding to the controls are displayed in the toolbar. After selecting the service modules, the entity modules corresponding to the service modules are displayed in the toolbar. After selecting the entity modules, you can select the required code language type. The present application can automatically generate executable code based on the preset model code conversion rules according to the required code language type and the configured space, service modules and entity modules. The present application has changed the situation in which each component required technicians to write code manually. The technicians only need to generate the required executable code through simple operations such as dragging, selecting, etc., which greatly improves the efficiency of component development.
[0043] Figure 1 A flow chart of a model-to-code conversion method according to an embodiment of the present application is shown. The method is executed by an electronic device.
[0044] Step S100: Obtain the code language type to be generated and pre-configured controls, service modules, and entity modules. The service module is used to execute processing logic, and the entity module is a collection of data required for the execution of the processing logic.
[0045] The configuration of a page is usually composed of multiple visual components. A visual component consists of controls, service modules and entity modules. A control may be associated with one or more service modules, and a service module may be associated with one or more entity modules. For the sake of ease of description, this application takes the conversion of a visual component into executable code as an example.
[0046] Among them, the control can be, for example, an edit box, a drop-down menu, a button, etc.; the service module can execute processing logic, and in this application, it can be understood as the smallest logical processing unit; when executing processing logic, data and parameters are usually used, and the entity module is a collection of data required for the execution of the processing logic of the service module, and these data are stored in the database.
[0047] In an embodiment of the present application, the method of configuring controls, service modules and entity modules can be: pushing multiple optional controls; obtaining a selected control and pushing multiple optional service modules that match the selected control; obtaining a selected service module and pushing multiple entity modules that match the selected service module; obtaining a selected entity module and configuring the controls, service modules and entity modules based on the correspondence between the selected control, the selected service module and the selected entity module.
[0048] Optional controls, optional service modules and optional entity modules can all be pushed to the terminal. The technician selects the required controls, service modules and entity modules on the terminal by dragging, clicking, etc. After the server obtains these selected controls, service modules and entity modules, it completes the preliminary configuration of the controls, service modules and entity modules.
[0049] Step S200: According to the control, service module and entity module, the corresponding control template, service template and entity template are retrieved from a preset template database.
[0050] There can be multiple types of controls, service modules, and entity modules. A pre-set template database stores control templates corresponding to each control, service templates corresponding to each service module, and entity templates corresponding to each entity module. For example, each control is associated with its corresponding control template. Once a control is identified, the corresponding control template can be retrieved based on the associated information. The same method is used for retrieving service templates and entity templates.
[0051] In the embodiment of the present application, the control template, service template and entity template can all be logic codes in XML format rather than an executable code language.
[0052] Step S300: According to the corresponding relationship between the control, service module and entity module, the control template, service template and entity template are configured to generate a logical code structure.
[0053] Controls, service modules and entity modules are interrelated and have corresponding relationships. Accordingly, when configuring control templates, service templates and entity templates, they are also associated with each other based on the corresponding relationships between them to generate a logical code structure. The logical code structure here is also a logical code in XML format.
[0054] Step S400: Convert the logical code structure into executable code according to the code language type, logical code structure and preset model code conversion rules.
[0055] In an embodiment of the present application, the model code conversion rules may include:
[0056] Step S410: Create a business table, where the business table is used to store the data in the entity module or the address of the data in the database.
[0057] Since the data in the entity module are all stored in the database, and the amount of data in the database is huge, there will inevitably be a defect of low retrieval efficiency when retrieving data. Therefore, this application creates a business table, pulls the data required for execution processing from the database and stores it in the business table, reducing the workload of searching for data during code execution and improving search efficiency.
[0058] The entity module includes multiple data packets, usually one data packet is used to provide data support for one service module, or multiple data packets provide data support for one service module. In some special cases, it is inevitable that the storage size of a single data packet is too large, and such a data packet is not convenient to store in the business table. Therefore, data packets with a storage size smaller than a preset value can be stored in the business table, and data packets with a storage size larger than the preset value can be stored in the database. For data packets with a storage size larger than the preset value, the business table stores the storage address of the data packet in the database. In this way, when retrieving data, the data can be searched in the database according to the address in the business table, which reduces the storage pressure of the business table and also improves the efficiency of searching for data.
[0059] Step S420: Filter a code language package corresponding to the code language type in a code database according to the code language type, wherein the code language package includes an executable code unit corresponding to each control template and service template.
[0060] In this field, there are many types of languages that can run code. Therefore, the code database of this application stores code data packages of various code language types to meet the needs of technicians for different code language types. The code in each code data package is stored in the form of runnable code units, and the code data package includes runnable code units corresponding to each control template and service template.
[0061] According to the acquired code language type, the corresponding code data package can be filtered out in the code database for subsequent code retrieval.
[0062] Step S430: According to the control template and service template included in the logical code structure, the corresponding executable code units are respectively retrieved.
[0063] It can be seen that the logical code structure includes a control template and a service template. The association relationship between the control template, the service template and the executable code unit can be preset. Therefore, based on the control template and the service template, the executable code unit corresponding to the control template and the executable code unit corresponding to the service template can be called respectively.
[0064] Step S440: According to the correspondence between the control template, the service template and the entity template in the logical code structure, the executable code unit is configured to generate the executable code, and the executable code is associated with the business table.
[0065] After obtaining multiple executable code units, the executable code can be obtained by associating the multiple executable code units according to the corresponding relationship between the control template, service template and entity template in the logical code structure.
[0066] Furthermore, based on the correspondence between the service template and the entity template, the location and content of the data to be retrieved in the executable code can be determined, and the executable code can be associated with the business table. Specifically, the executable code can be associated with an identification field in the business table. This way, when the code is executed, data can be retrieved from the business table.
[0067] In this embodiment, if multiple code language types are obtained, step S400 is performed multiple times until executable codes of all obtained code language types are generated.
[0068] In the embodiment of the present application, before generating the executable code, a blank table can be created in the database, and the generated executable code can be stored in the blank table. It should be noted that one blank table should store one page of executable code. If there are multiple code language types, one blank table is configured for each language type.
[0069] Finally, after storing the executable code in a blank table, configure the page properties and encapsulate it, and a new page is configured.
[0070] It should be noted that for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all optional embodiments, and the actions and modules involved are not necessarily required by this application.
[0071] The above is an introduction to the method embodiment. The following is a device embodiment to further illustrate the solution described in this application.
[0072] Figure 2 A block diagram of a model-to-code conversion device according to an embodiment of the present application is shown. The device includes:
[0073] An acquisition module, configured to acquire the code language type to be generated and pre-configured controls, service modules, and entity modules. The service modules are used to execute processing logic, and the entity modules are a collection of data required for the execution of the processing logic.
[0074] A calling module, used to call corresponding control templates, service templates and entity templates from a preset template database according to the control, service module and entity module;
[0075] A generation module, configured to configure the control template, service template and entity template to generate a logical code structure according to the corresponding relationship between the control, service module and entity module;
[0076] The conversion module is used to convert the logical code structure into executable code according to the code language type, logical code structure and preset model code conversion rules.
[0077] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the described module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0078] Figure 3 A schematic structural diagram of an electronic device suitable for implementing the embodiments of the present application is shown.
[0079] like Figure 3As shown, the electronic device includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 302 or a program loaded from a storage portion 308 into a random access memory (RAM) 303. Various programs and data required for the operation of the system 300 are also stored in the RAM 303. The CPU 301, ROM 302, and RAM 303 are connected to each other via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0080] The following components are connected to the I / O interface 305: an input section 306 including a keyboard, a mouse, and the like; an output section 307 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 308 including a hard disk; and a communication section 309 including a network interface card such as a LAN card or a modem. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as needed. Removable media 311, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 310 as needed, so that computer programs read therefrom can be installed into the storage section 308 as needed.
[0081] In particular, according to the embodiment of the present application, the above reference flow chart Figure 1 The described process can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product comprising a computer program carried on a machine-readable medium, the computer program comprising program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 309 and / or installed from a removable medium 311. When the computer program is executed by the central processing unit (CPU) 301, the above-mentioned functions defined in the system of the present application are performed.
[0082] It should be noted that the computer-readable medium shown in this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. The computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this application, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical fiber cable, RF, or any suitable combination thereof.
[0083] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the aforementioned module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified function or operation, or can be implemented by a combination of dedicated hardware and computer instructions.
[0084] The units or modules involved in the embodiments described in the present application can be implemented by software or by hardware. The units or modules described can also be set in a processor. For example, they can be described as: a processor includes an acquisition module, a call module, a generation module and a conversion module. Among them, the names of these units or modules do not constitute a limitation of the unit or module itself under certain circumstances. For example, the call module can also be described as "a module for calling corresponding control templates, service templates and entity templates from a preset template database based on the control, service module and entity module."
[0085] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or may exist independently and not be incorporated into the electronic device. The computer-readable storage medium stores one or more programs, which are used by one or more processors to perform a model-to-code conversion described in the present application.
[0086] The above description is merely a preferred embodiment of the present application and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of application involved in this application is not limited to the technical solutions formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the aforementioned application concept. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions applied for in this application.
Claims
1. A model-to-code conversion method, characterized in that: include: Obtaining the code language type to be generated and pre-configured controls, service modules, and entity modules, wherein the service modules are used to execute processing logic, and the entity modules are a collection of data required for the execution of the processing logic. The controls, service modules, and entity modules constitute components; The method of pre-configuring controls, service modules, and entity modules is as follows: pushing multiple optional controls; obtaining a selected control and pushing multiple optional service modules that match the selected control; obtaining a selected service module and pushing multiple entity modules that match the selected service module; obtaining a selected entity module and configuring the control, service module, and entity module according to the corresponding relationship between the selected control, the selected service module, and the selected entity module; According to the control, service module and entity module, the corresponding control template, service template and entity template are retrieved from the preset template database; According to the corresponding relationship between the control, service module and entity module, the control template, service template and entity template are configured to generate a logical code structure of the component; According to the code language type, the logical code structure and the preset model code conversion rules, the logical code structure is converted into the executable code of the component; The model code conversion rule includes: creating a business table, the business table is used to store the data in the entity module or store the address of the data in the database; The business table is used to store the data in the entity module or store the address of the data in the database, including: the entity module is composed of multiple data packets, among which, the data packets with a storage size smaller than a preset value are stored in the business table; the data packets with a storage size larger than the preset value are stored in the database, and the business table stores the storage address of the data packet in the database.
2. A model-to-code conversion method according to claim 1, characterized in that: The model code conversion rules also include: According to the code language type, a code language package corresponding to the code language type is screened in a code database, wherein the code language package includes an executable code unit corresponding to each control template and service template; According to the control templates and service templates contained in the logical code structure, the corresponding executable code units are called respectively; According to the corresponding relationship among the control template, the service template and the entity template in the logical code structure, the executable code unit is configured to generate the executable code, and the executable code is associated with the business table.
3. The method for converting a model to code according to claim 1, wherein: If there are multiple code language types, the following steps are executed in a loop: Converting the logical code structure into executable code according to the code language type, the logical code structure, and preset model code conversion rules; Until all executable codes of the acquired code language types are generated.
4. A model-to-code conversion method according to claim 3, characterized in that: The method further includes establishing a blank table in a database before generating the executable code, wherein the blank table is used to store the executable code.
5. The method for converting a model to code according to claim 1, wherein: After storing the executable code in a blank table, configure the page properties and package it.
6. A model-to-code conversion device, characterized in that: include: An acquisition module (201) is used to acquire the code language type to be generated and pre-configured controls, service modules, and entity modules, wherein the service module is used to execute processing logic, and the entity module is a collection of data required for the execution of the processing logic. The controls, service modules, and entity modules constitute components, and the manner of pre-configuring the controls, service modules, and entity modules is as follows: pushing multiple optional controls, acquiring a selected control, and pushing multiple optional service modules that match the selected control, acquiring a selected service module, and pushing multiple entity modules that match the selected service module, acquiring a selected entity module, and configuring the controls, service modules, and entity modules according to the corresponding relationship between the selected control, the selected service module, and the selected entity module; A calling module (202) is used to call corresponding control templates, service templates and entity templates from a preset template database according to the control, service module and entity module; A generation module (203) configured to configure the control template, service template and entity template according to the corresponding relationship between the control, service module and entity module to generate a logical code structure of the component; A conversion module (204) is used to convert the logical code structure into an executable code of the component according to the code language type, the logical code structure and a preset model code conversion rule, wherein the model code conversion rule includes creating a business table, the business table is used to store the data in the entity module or the address of the data in the database, the entity module is composed of a plurality of data packets, wherein the data packets with a storage size smaller than a preset value are stored in the business table, and the data packets with a storage size larger than the preset value are stored in the database, and the business table stores the storage address of the data packet in the database.
7. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the program, the method according to any one of claims 1 to 5 is implemented.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
User interface generation method and device
CN106598556A
Cross-platform APP construction method, device and system and medium
CN113778405A