A method, device, electronic device and storage medium for generating view layer code
By analyzing the model layer code and configuration files, the view layer code is generated based on the mapping relationship between data types and functional components, which solves the problem of high development cost of view layer in middle and backend applications, realizes the automatic generation of view layer code, and reduces the development cost .
Patent Information
- Application Number
- CN202010955800.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-11
- Publication Date
- 2025-01-17
- Estimated Expiration
- 2040-09-11
AI Technical Summary
In the model layer development and view layer development of middle and backend applications, code needs to be written separately, resulting in high development costs.
By obtaining the code and configuration files of the model layer, analyzing the model layer code and configuration files, generating view layer codes based on the mapping relationship between pre-set data types and functional components, and directly automatically generating view layer codes.
Reduces the development cost of view layers, and automatically generates view layer code through model layer code, saving development time and cost.
Smart Images

Figure CN112181410B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a view layer code generation method, device, electronic device and storage medium. Background Art
[0002] The front-end business development of mid- and back-end applications such as management systems generally includes model layer development and view layer development. The process of model layer development is: using state management tools to organize data into models that meet business needs; and providing specific methods for external calls to change data. The process of view layer development is: using front-end frameworks and component libraries to develop the view layer. It mainly includes two types of tasks: writing the user interaction interface of the application and writing the user interaction logic of the application.
[0003] In the related art, when developing the model layer and the view layer, codes need to be written separately, which leads to high development costs. Summary of the invention
[0004] In order to solve the technical problem in the related art that when developing the model layer and the view layer, codes need to be written separately, resulting in high development costs, the embodiments of the present application provide a view layer code generation method, device, electronic device and storage medium.
[0005] In a first aspect, an embodiment of the present application provides a method for generating view layer code, the method comprising:
[0006] Obtaining a model layer code of a model layer and a configuration file of the model layer, wherein the configuration file stores a view template and a functional block of a view layer corresponding to the model layer;
[0007] Analyze the model layer code to obtain the model data included in the model layer code, and analyze the configuration file to obtain the view template and functional block of the view layer corresponding to the model layer;
[0008] Determine the functional component corresponding to the data type of the model data according to a preset mapping relationship between the data type and the functional component;
[0009] Generate view layer code according to the view template and function block stored in the configuration file, and the function component.
[0010] Optionally, the analyzing the model layer code to obtain the model data included in the model layer code includes:
[0011] Analyze the multiple parameter data included in the model layer code to obtain variable names and data types of the multiple parameter data;
[0012] The variable names and data types of the plurality of parameter data are generated into a data structure in a predetermined format.
[0013] Optionally, before determining the functional component corresponding to the data type of the model data according to the preset mapping relationship between the data type and the functional component, the method further includes:
[0014] Obtaining annotation data corresponding to each data type in the model layer, wherein the annotation data corresponding to each data type is used to annotate the functional component corresponding to the data type;
[0015] The annotation data corresponding to each data type is analyzed to obtain the functional components corresponding to each data type.
[0016] Optionally, when the coding language used by the model layer code is a preset language;
[0017] The analyzing of the plurality of parameter data included in the model layer code to obtain the variable names and data types of the plurality of parameter data includes:
[0018] Analyzing the plurality of parameter data included in the model layer code by using a first language analysis tool corresponding to the preset language to obtain variable names and data types of the plurality of parameter data;
[0019] Accordingly, the annotation data corresponding to each data type is analyzed to obtain the functional components corresponding to each data type, including:
[0020] The annotation data corresponding to each data type is analyzed by a second language analysis tool corresponding to the preset language to obtain a functional component corresponding to each data type.
[0021] In a second aspect, an embodiment of the present application provides a view layer code generation device, the device comprising:
[0022] A code and file acquisition module, used to acquire the model layer code of the model layer and the configuration file of the model layer, wherein the configuration file stores the view template and function block of the view layer corresponding to the model layer;
[0023] A code and file analysis module, used to analyze the model layer code to obtain the model data included in the model layer code, and to analyze the configuration file to obtain the view template and functional block of the view layer corresponding to the model layer;
[0024] A function component determination module, used to determine the function component corresponding to the data type of the model data according to a preset mapping relationship between the data type and the function component;
[0025] The view layer code generation module is used to generate view layer code according to the view template and functional blocks stored in the configuration file, and the functional components.
[0026] Optionally, the code and file analysis module includes:
[0027] A parameter data analysis unit, used to analyze a plurality of parameter data included in the model layer code to obtain variable names and data types of the plurality of parameter data;
[0028] The data structure generating unit is used to generate a data structure of a predetermined format from the variable names and data types of the plurality of parameter data.
[0029] Optionally, the device further comprises:
[0030] An annotation data acquisition module is used to acquire annotation data corresponding to each data type in the model layer before the functional component determination module determines the functional component corresponding to the data type of the model data according to the mapping relationship between the preset data type and the functional component, wherein the annotation data corresponding to each data type is used to annotate the functional component corresponding to the data type;
[0031] The annotation data analysis module is used to analyze the annotation data corresponding to each data type to obtain the functional components corresponding to each data type.
[0032] Optionally, when the coding language used by the model layer code is a preset language;
[0033] The parameter data analysis unit is specifically used for:
[0034] Analyzing the plurality of parameter data included in the model layer code by using a first language analysis tool corresponding to the preset language to obtain variable names and data types of the plurality of parameter data;
[0035] Accordingly, the annotation data analysis module is specifically used for:
[0036] The annotation data corresponding to each data type is analyzed by a second language analysis tool corresponding to the preset language to obtain a functional component corresponding to each data type.
[0037] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the view layer code generation method described in the first aspect when executing the program.
[0038] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the view layer code generation method described in the first aspect are implemented.
[0039] The technical solution provided by the embodiment of the present application obtains the model layer code of the model layer and the configuration file of the model layer, wherein the configuration file stores the view template and the functional block of the view layer corresponding to the model layer; analyzes the model layer code to obtain the model data included in the model layer code, and analyzes the configuration file to obtain the view template and the functional block of the view layer corresponding to the model layer; determines the functional component corresponding to the data type of the model data according to the mapping relationship between the preset data type and the functional component; generates the view layer code according to the view template and the functional block stored in the configuration file, and the functional component.
[0040] It can be seen that through the technical solution provided in the embodiment of the present application, by configuring and storing the view templates and configuration files of the view layer corresponding to the model layer, and the functional components corresponding to the data types of the model data included in the model layer code according to the mapping relationship between the pre-set data types and functional components, the view layer code can be automatically generated, that is, the view layer code can be automatically generated directly from the model layer code, thereby reducing the development cost of the view layer. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 It is a flowchart of the steps of a method for generating view layer code provided by an embodiment of the present application;
[0042] Figure 2 It is a schematic diagram of the overall process of the technical solution provided in the embodiment of the present application.
[0043] Figure 3 It is a structural block diagram of a view layer code generation device provided in an embodiment of the present application;
[0044] Figure 4 It is a structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0046] The front-end business development of mid- and back-end applications such as management systems generally includes two parts: model layer development and view layer development.
[0047] The model layer development process is roughly as follows: use state management tools such as Redux, Mobx, and Vuex to organize data into models that meet business needs; and provide specific methods for external calls to change data, such as changing data based on user operations, obtaining data through interfaces, etc.
[0048] The specific process of view layer development can be: using front-end frameworks such as React and Vue and component libraries such as AntD and Element to develop the view layer. View layer development mainly includes two types of tasks: writing the user interaction interface of the application and writing the user interaction logic of the application.
[0049] In the related art, when developing the model layer and the view layer, codes need to be written separately, which leads to high development costs.
[0050] In the process of implementing this application, the inventors have at least discovered that the front-end parts of most mid- and back-end applications have the following characteristics:
[0051] First, the structures of a large number of page views are consistent or very similar. For example, a large number of page views have a form at the top and a table or chart at the bottom.
[0052] Second, it follows a fixed interaction mode with users. For example, the fixed interaction mode of data query. Specifically, the operation process of data query is basically that the user operates the form, clicks a button or presses Enter to submit, and the query results are returned and displayed in a table below. The table may also have an operation area for users to edit or jump to other pages.
[0053] Although the page view structure is consistent, the content of each page is different. For example, the input items in the form are different, and different fields in the table require different processing. Similarly, although the interaction mode is fixed, the corresponding methods of interaction are different, and the parameters and return results of the methods are also different. These all need to be processed by coding.
[0054] However, these differences are all related to the data structure and open methods in the model layer. Therefore, by clarifying the mapping relationship, adding certain restrictions to the model layer code writing, summarizing the same page structure and interaction mode, the view layer code can be automatically generated from the model layer code, thus saving the development cost of the view layer.
[0055] To this end, embodiments of the present application provide a view layer code generation method, device, electronic device and storage medium.
[0056] In the first aspect, a view layer code generation method provided in an embodiment of the present application is first described in detail.
[0057] It should be noted that the executor of the view layer code generation method provided in the embodiment of the present application may be a view layer code generation device, which may run in an electronic device, which may be a terminal or a server, etc. The embodiment of the present application does not specifically limit the electronic device.
[0058] like Figure 1 As shown, a method for generating view layer code provided in an embodiment of the present application may specifically include the following steps:
[0059] S110, obtaining the model layer code and the configuration file of the model layer.
[0060] The configuration file stores the view templates and functional blocks of the view layer corresponding to the model layer.
[0061] In the front-end business development of mid- and back-end applications, the model layer code of the model layer has been written, so the model layer code of the model layer can be directly obtained.
[0062] Specifically, the view templates and functional blocks of the view layer can be summarized based on the view structure and interaction mode of a large number of pages in the mid- and back-end applications.
[0063] In addition, modules that handle specific functions, such as obtaining user input information, displaying tables, displaying charts, modal boxes, etc., can be called functional blocks.
[0064] The function blocks are assembled in a fixed form and displayed in the form of a page, which can be called a view template. For example, the view module can be a default view template that displays the function blocks from top to bottom, a tab-type template that displays different content blocks by clicking on the tab, or a step view template that displays the content blocks in sequence according to the steps, etc. The present application embodiment does not specifically limit the view template.
[0065] In order to automatically generate view layer code according to the model layer code in the subsequent steps, it is necessary to configure the configuration file for the model layer in advance, that is, it is necessary to configure the view template and functional blocks of the view layer corresponding to the model layer.
[0066] For example, because different technology stacks have different structures, the method used for searching can be simply called search(), and the data used to display the results can be called list. The page view structure and interaction mode are as follows: a form is displayed in the upper part of the page, and submitting the form triggers search(), which changes the list after returning the result. Changes in the list drive the table rendering in the lower part of the page to display the list data. In the configuration file, the view templates of the view layer corresponding to the model layer can be stored as follows: the default template displayed from top to bottom; the functional blocks are: the first part is the form functional block, and the second part is the table functional block.
[0067] S120, analyzing the model layer code to obtain the model data included in the model layer code, and analyzing the configuration file to obtain the view template and function block of the view layer corresponding to the model layer.
[0068] Specifically, after obtaining the model layer code of the model layer, the model layer code may be analyzed to obtain the model data included in the model layer code.
[0069] In one implementation, analyzing the model layer code to obtain the model data included in the model layer code may include the following steps, namely step a1 and step a2:
[0070] Step a1, analyzing multiple parameter data included in the model layer code to obtain variable names and data types of the multiple parameter data.
[0071] Step a2, generating a data structure of a predetermined format by using the variable names and data types of the plurality of parameter data.
[0072] In this implementation, since the model layer code usually includes multiple parameter data, for example, it may include param1, param2, param3, param4 and param5, the multiple parameter data included in the model layer code may be analyzed to obtain the variable names and data types of the multiple parameter data. The data type may be a string, a Boolean, an enumeration value, an enumeration value array, a string or a number, a time, etc.
[0073] After obtaining the variable names and data types of multiple parameter data included in the model layer code, they can be sorted into a reasonable data structure according to the needs of automatically generating the view layer code, and a certain query interface can be provided.
[0074] Furthermore, after obtaining the configuration file of the model layer, in order to automatically generate the view layer code in the subsequent steps, the configuration file can also be analyzed to obtain the view template and functional blocks of the view layer corresponding to the model layer.
[0075] S130, determining the functional component corresponding to the data type of the model data according to a preset mapping relationship between the data type and the functional component.
[0076] Specifically, in order to automatically generate view layer code, it is necessary to clarify a more detailed mapping relationship between the model layer and the view layer. Therefore, after obtaining the model data included in the model layer code, the functional component corresponding to the data type of the model data can be determined according to the pre-set mapping relationship between the data type and the functional component.
[0077] For example, you need to determine the mapping between search() parameters and form items, and the mapping between list element data and table cell display.
[0078] In actual applications, this can be achieved through data types supplemented by a small amount of annotation data. For example, when the data type is a Boolean value, the corresponding form item component can be Switch; when the data type is an enumeration value, the corresponding form item component is Radio; when the data type is an array of enumeration values, the corresponding form item component is Checkbox; some data types are strings or numbers, and users need to select through a drop-down list. In this case, annotations are needed to assist in processing, such as the link tag of JSDoc, which is associated with the corresponding option data or the method of obtaining the option array, such as {@link store.selectvalues}. When the data type is time, the corresponding form item component is DatePicker.
[0079] In one embodiment, before determining the functional component corresponding to the data type of the model data according to the preset mapping relationship between the data type and the functional component, the view layer code generation method may further include the following steps, namely step b1 and step b2:
[0080] Step b1, obtaining annotation data corresponding to each data type in the model layer, wherein the annotation data corresponding to each data type is used to annotate the functional component corresponding to the data type;
[0081] Step b2: Analyze the annotation data corresponding to each data type to obtain the functional components corresponding to each data type.
[0082] In this embodiment, when encoding the model layer code, annotation data can be marked for each data type in the model layer. Therefore, the annotation data corresponding to each data type can be obtained, and the annotation data can be analyzed to obtain the functional components corresponding to each data type.
[0083] S140, generating view layer code according to the view templates and functional blocks and functional components stored in the configuration file.
[0084] Specifically, after analyzing the configuration file to obtain the view template and functional blocks of the view layer corresponding to the model layer, and determining the functional components required to generate the view layer based on the functional components corresponding to the data type of the model data, the view layer code can be automatically generated based on the obtained view template, functional blocks, and functional components, thereby automatically generating the view layer.
[0085] The technical solution provided by the embodiment of the present application obtains the model layer code of the model layer and the configuration file of the model layer, wherein the configuration file stores the view template and the functional block of the view layer corresponding to the model layer; analyzes the model layer code to obtain the model data included in the model layer code, and analyzes the configuration file to obtain the view template and the functional block of the view layer corresponding to the model layer; determines the functional component corresponding to the data type of the model data according to the mapping relationship between the preset data type and the functional component; generates the view layer code according to the view template and the functional block stored in the configuration file, and the functional component.
[0086] It can be seen that through the technical solution provided in the embodiment of the present application, by configuring and storing the view templates and configuration files of the view layer corresponding to the model layer, and the functional components corresponding to the data types of the model data included in the model layer code according to the mapping relationship between the pre-set data types and functional components, the view layer code can be automatically generated, that is, the view layer code can be automatically generated directly from the model layer code, thereby reducing the development cost of the view layer.
[0087] Based on the above embodiment, in one implementation, when the coding language used by the model layer code is a preset language;
[0088] Analyzing multiple parameter data included in the model layer code to obtain variable names and data types of the multiple parameter data may include the following steps:
[0089] Analyzing the plurality of parameter data included in the model layer code by using a first language analysis tool corresponding to a preset language to obtain variable names and data types of the plurality of parameter data;
[0090] Accordingly, analyzing the annotation data corresponding to each data type to obtain the functional components corresponding to each data type may include the following steps:
[0091] The annotation data corresponding to each data type is analyzed by a second language analysis tool corresponding to the preset language to obtain the functional components corresponding to each data type.
[0092] In this embodiment, when the coding language used for the model layer code is Typescript, the rich language analysis tools provided by Typescript can be used to analyze the multiple parameter data included in the model layer code; and TADoc can be used to analyze the annotation data corresponding to each data type to obtain the functional components corresponding to each data type.
[0093] When the coding language used in the model layer code is Javascript, JSDoc and Esprima can be used to analyze the multiple parameter data included in the model layer code; and JSDoc can be used to analyze the annotation data corresponding to each data type to obtain the functional components corresponding to each data type.
[0094] It can be seen that, through the technical solution provided by this embodiment, the multiple parameter data included in the model layer code and the annotation data corresponding to each data type can be accurately analyzed.
[0095] In order to describe the solution clearly, the overall process of the technical solution of the embodiment of the present application will be described in detail below. Figure 2 shown.
[0096] The first step is business project preparation. Specifically, obtain the configuration file of the model layer and the model layer code of the model layer.
[0097] The second step is model layer analysis. Specifically, the model layer code is analyzed to obtain the model data included in the model layer code, and the configuration file is analyzed to obtain the view template and functional blocks of the view layer corresponding to the model layer;
[0098] The third step is view layer analysis. Specifically, in a material library that stores a pre-set mapping relationship between data types and functional components, the functional component corresponding to the data type of the model data is searched.
[0099] The fourth step is to generate the view layer code. The view layer code is automatically generated based on the view template and functional blocks of the view layer obtained in the second step, and the functional components obtained in the third step.
[0100] It can be seen that through the technical solution provided in the embodiment of the present application, by configuring and storing the view templates and configuration files of the view layer corresponding to the model layer, and the functional components corresponding to the data types of the model data included in the model layer code according to the mapping relationship between the pre-set data types and functional components, the view layer code can be automatically generated, that is, the view layer code can be automatically generated directly from the model layer code, thereby reducing the development cost of the view layer.
[0101] It should be noted that, for the 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 the present application is not limited by the order of the actions described, because according to the present 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 the specification are all optional embodiments, and the actions involved are not necessarily required by the present application.
[0102] In a second aspect, the present application embodiment provides a view layer code generation device, such as Figure 3 As shown, the device comprises:
[0103] A code and file acquisition module 310 is used to acquire the model layer code of the model layer and the configuration file of the model layer, wherein the configuration file stores the view template and function block of the view layer corresponding to the model layer;
[0104] The code and file analysis module 320 is used to analyze the model layer code to obtain the model data included in the model layer code, and to analyze the configuration file to obtain the view template and functional block of the view layer corresponding to the model layer;
[0105] A function component determination module 330, configured to determine the function component corresponding to the data type of the model data according to a preset mapping relationship between the data type and the function component;
[0106] The view layer code generation module 340 is used to generate view layer code according to the view template and functional blocks stored in the configuration file, as well as the functional components.
[0107] The technical solution provided by the embodiment of the present application obtains the model layer code of the model layer and the configuration file of the model layer, wherein the configuration file stores the view template and the functional block of the view layer corresponding to the model layer; analyzes the model layer code to obtain the model data included in the model layer code, and analyzes the configuration file to obtain the view template and the functional block of the view layer corresponding to the model layer; determines the functional component corresponding to the data type of the model data according to the mapping relationship between the preset data type and the functional component; generates the view layer code according to the view template and the functional block stored in the configuration file, and the functional component.
[0108] It can be seen that through the technical solution provided in the embodiment of the present application, by configuring and storing the view templates and configuration files of the view layer corresponding to the model layer, and the functional components corresponding to the data types of the model data included in the model layer code according to the mapping relationship between the pre-set data types and functional components, the view layer code can be automatically generated, that is, the view layer code can be automatically generated directly from the model layer code, thereby reducing the development cost of the view layer.
[0109] Optionally, the code and file analysis module includes:
[0110] A parameter data analysis unit, used to analyze a plurality of parameter data included in the model layer code to obtain variable names and data types of the plurality of parameter data;
[0111] The data structure generating unit is used to generate a data structure of a predetermined format from the variable names and data types of the plurality of parameter data.
[0112] Optionally, the device further comprises:
[0113] An annotation data acquisition module is used to acquire annotation data corresponding to each data type in the model layer before the functional component determination module determines the functional component corresponding to the data type of the model data according to the mapping relationship between the preset data type and the functional component, wherein the annotation data corresponding to each data type is used to annotate the functional component corresponding to the data type;
[0114] The annotation data analysis module is used to analyze the annotation data corresponding to each data type to obtain the functional components corresponding to each data type.
[0115] Optionally, when the coding language used by the model layer code is a preset language;
[0116] The parameter data analysis unit is specifically used for:
[0117] Analyzing the plurality of parameter data included in the model layer code by using a first language analysis tool corresponding to the preset language to obtain variable names and data types of the plurality of parameter data;
[0118] Accordingly, the annotation data analysis module is specifically used for:
[0119] The annotation data corresponding to each data type is analyzed by a second language analysis tool corresponding to the preset language to obtain a functional component corresponding to each data type.
[0120] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0121] In a third aspect, an embodiment of the present application provides an electronic device, such as Figure 4 As shown, it includes a memory 410, a processor 420, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of the view layer code generation method described in the first aspect are implemented.
[0122] The technical solution provided by the embodiment of the present application obtains the model layer code of the model layer and the configuration file of the model layer, wherein the configuration file stores the view template and the functional block of the view layer corresponding to the model layer; analyzes the model layer code to obtain the model data included in the model layer code, and analyzes the configuration file to obtain the view template and the functional block of the view layer corresponding to the model layer; determines the functional component corresponding to the data type of the model data according to the mapping relationship between the preset data type and the functional component; generates the view layer code according to the view template and the functional block stored in the configuration file, and the functional component.
[0123] It can be seen that through the technical solution provided in the embodiment of the present application, by configuring and storing the view templates and configuration files of the view layer corresponding to the model layer, and the functional components corresponding to the data types of the model data included in the model layer code according to the mapping relationship between the pre-set data types and functional components, the view layer code can be automatically generated, that is, the view layer code can be automatically generated directly from the model layer code, thereby reducing the development cost of the view layer.
[0124] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the view layer code generation method described in the first aspect are implemented.
[0125] The technical solution provided by the embodiment of the present application obtains the model layer code of the model layer and the configuration file of the model layer, wherein the configuration file stores the view template and the functional block of the view layer corresponding to the model layer; analyzes the model layer code to obtain the model data included in the model layer code, and analyzes the configuration file to obtain the view template and the functional block of the view layer corresponding to the model layer; determines the functional component corresponding to the data type of the model data according to the mapping relationship between the preset data type and the functional component; generates the view layer code according to the view template and the functional block stored in the configuration file, and the functional component.
[0126] It can be seen that through the technical solution provided in the embodiment of the present application, by configuring and storing the view templates and configuration files of the view layer corresponding to the model layer, and the functional components corresponding to the data types of the model data included in the model layer code according to the mapping relationship between the pre-set data types and functional components, the view layer code can be automatically generated, that is, the view layer code can be automatically generated directly from the model layer code, thereby reducing the development cost of the view layer.
[0127] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0128] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, devices, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0129] The present application is described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0130] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0131] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0132] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0133] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0134] The above is a detailed introduction to a view layer code generation method, device, electronic device and storage medium provided by the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for generating view layer code, characterized in that: The method comprises: Obtaining a model layer code of a model layer and a configuration file of the model layer, wherein the configuration file stores a view template and a functional block of a view layer corresponding to the model layer; Analyze the model layer code to obtain the model data included in the model layer code, and analyze the configuration file to obtain the view template and functional block of the view layer corresponding to the model layer; Determine the functional component corresponding to the data type of the model data according to a preset mapping relationship between the data type and the functional component; Generate view layer code according to the view template and function block stored in the configuration file and the function component; The model layer code is analyzed to obtain the model data included in the model layer code, including: Analyze the multiple parameter data included in the model layer code to obtain variable names and data types of the multiple parameter data; Generate a data structure of a predetermined format from the variable names and data types of the plurality of parameter data; Before determining the functional component corresponding to the data type of the model data according to the preset mapping relationship between the data type and the functional component, the method further includes: Obtaining annotation data corresponding to each data type in the model layer, wherein the annotation data corresponding to each data type is used to annotate the functional component corresponding to the data type; Analyze the annotation data corresponding to each data type to obtain the functional components corresponding to each data type; When the coding language used by the model layer code is a preset language; The analyzing of the plurality of parameter data included in the model layer code to obtain the variable names and data types of the plurality of parameter data includes: Analyzing the plurality of parameter data included in the model layer code by using a first language analysis tool corresponding to the preset language to obtain variable names and data types of the plurality of parameter data; Accordingly, the annotation data corresponding to each data type is analyzed to obtain the functional components corresponding to each data type, including: The annotation data corresponding to each data type is analyzed by a second language analysis tool corresponding to the preset language to obtain a functional component corresponding to each data type.
2. A view layer code generation device, characterized in that: The device comprises: A code and file acquisition module, used to acquire the model layer code of the model layer and the configuration file of the model layer, wherein the configuration file stores the view template and function block of the view layer corresponding to the model layer; A code and file analysis module, used to analyze the model layer code to obtain the model data included in the model layer code, and to analyze the configuration file to obtain the view template and functional block of the view layer corresponding to the model layer; A function component determination module, used to determine the function component corresponding to the data type of the model data according to a preset mapping relationship between the data type and the function component; A view layer code generation module, used to generate view layer code according to the view template and functional blocks stored in the configuration file, and the functional components; The code and file analysis module includes: A parameter data analysis unit, used to analyze a plurality of parameter data included in the model layer code to obtain variable names and data types of the plurality of parameter data; A data structure generating unit, used for generating a data structure of a predetermined format from the variable names and data types of the plurality of parameter data; The device also includes: An annotation data acquisition module is used to acquire annotation data corresponding to each data type in the model layer before the functional component determination module determines the functional component corresponding to the data type of the model data according to the mapping relationship between the preset data type and the functional component, wherein the annotation data corresponding to each data type is used to annotate the functional component corresponding to the data type; An annotation data analysis module, used to analyze the annotation data corresponding to each data type to obtain a functional component corresponding to each data type; When the coding language used by the model layer code is a preset language; The parameter data analysis unit is specifically used for: Analyzing the plurality of parameter data included in the model layer code by using a first language analysis tool corresponding to the preset language to obtain variable names and data types of the plurality of parameter data; Accordingly, the annotation data analysis module is specifically used for: The annotation data corresponding to each data type is analyzed by a second language analysis tool corresponding to the preset language to obtain a functional component corresponding to each data type.
3. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the view layer code generation method as claimed in claim 1 are implemented.
4. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the view layer code generation method as claimed in claim 1 are implemented.
Citation Information
Patent Citations
Automatic generation method and device of user interface (UI)
CN104731589A
User interface generation method and device
CN106598556A