CN115577689A - Table component generation method, device, equipment and medium - Google Patents

Table component generation method, device, equipment and medium Download PDF

Info

Publication number
CN115577689A
CN115577689A CN202211175872.2A CN202211175872A CN115577689A CN 115577689 A CN115577689 A CN 115577689A CN 202211175872 A CN202211175872 A CN 202211175872A CN 115577689 A CN115577689 A CN 115577689A
Authority
CN
China
Prior art keywords
interface
data
target
component
processed
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
CN202211175872.2A
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.)
Daguan Data Chengdu Co ltd
Original Assignee
Daguan Data Chengdu 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 Daguan Data Chengdu Co ltd filed Critical Daguan Data Chengdu Co ltd
Priority to CN202211175872.2A priority Critical patent/CN115577689A/en
Publication of CN115577689A publication Critical patent/CN115577689A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/183Tabulation, i.e. one-dimensional positioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates

Abstract

The invention discloses a method, a device, equipment and a medium for generating a table component. The table component generation method comprises the following steps: converting the interface document to be processed into an interface information tree, and determining the interface data of the form to be processed by traversing the interface information tree; extracting table request interface key data in the table interface data to be processed, and determining template data to be injected according to the table request interface key data; injecting template data to be injected into a form template to obtain an initial form assembly; and if the table interface annotation data exists in the table interface data to be processed, generating a target table component according to the table interface annotation data and the initial table component. The technical scheme of the embodiment of the invention improves the development efficiency of the form component on the premise of facilitating data maintenance.

Description

Table component generation method, device, equipment and medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a medium for generating a table component.
Background
Currently, most software developers still write codes manually, and the traditional software development mode is generally low in efficiency and long in period, which often causes delay, cost exceeding plan or performance lower than expected of a large software project, and even fails in the middle, and these problems force software engineers to continuously explore efficient software development modes. Automatic code generation techniques have been developed that generate canonical computer-understandable source code by reading various documents, entities, or models in engineering design, according to certain domain rules. Automatic code generation techniques are still under constant development, and although there are still many deficiencies in automatic code generation techniques, in many aspects, automatic code generation techniques have a significant contribution to the perfection of software development and improve the efficiency of software development.
In the current front-end development work, particularly, a large amount of form display work exists in background application in development, but in the traditional form component writing work, a developer needs to manually input a form display method, data and a form header, and the work of the part is generally simple, repeated and tedious.
Although some similar code generators exist in the market, the code generator only generates a request interface document, namely, a code program which generates a request server data interface of a client, and the code generator cannot generate the request interface into a code program which conforms to a specification component in a targeted manner.
Disclosure of Invention
The invention provides a method, a device, equipment and a medium for generating a table component, which improve the development efficiency of the table component on the premise of facilitating data maintenance.
According to an aspect of the present invention, there is provided a table component generation method, including:
converting the interface document to be processed into an interface information tree, and determining the interface data of the table to be processed by traversing the interface information tree;
extracting table request interface key data in the table interface data to be processed, and determining template data to be injected according to the table request interface key data;
injecting template data to be injected into a form template to obtain an initial form assembly;
and if the table interface annotation data exists in the table interface data to be processed, generating a target table component according to the table interface annotation data and the initial table component.
According to another aspect of the present invention, there is provided a table component generation apparatus, including:
the to-be-processed form interface data determining module is used for converting the to-be-processed interface document into an interface information tree and determining the to-be-processed form interface data by traversing the interface information tree;
the template data to be injected determining module is used for extracting form request interface key data in the form interface data to be processed and determining the template data to be injected according to the form request interface key data;
the initial form component acquisition module is used for injecting the template data to be injected into the form template to obtain an initial form component;
and the target table component generation module is used for generating a target table component according to the table interface annotation data and the initial table component if the table interface annotation data exists in the table interface data to be processed.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to enable the at least one processor to perform a method of generating a form component according to any embodiment of the invention.
According to another aspect of the present invention, there is provided a computer-readable storage medium storing computer instructions for causing a processor to implement a method for generating a form component according to any one of the embodiments of the present invention when the computer instructions are executed.
According to the technical scheme, the interface document to be processed is converted into the interface information tree, the interface data of the table to be processed is determined by traversing the interface information tree, the key data of the table request interface in the interface data of the table to be processed is further extracted, the template data to be injected is determined according to the key data of the table request interface, the template data to be injected is injected into the table template, an initial table component is obtained, and if the table interface annotation data exists in the interface data of the table to be processed, a target table component is generated according to the table interface annotation data and the initial table component. In the scheme, the interface data of the form to be processed can be quickly positioned based on the interface information tree, the code file of the form interface, namely the initial form component, can be automatically generated by injecting the template data to be injected into the form template, and the initial form component is subjected to data supplement according to the form interface annotation data, so that the finally obtained target form component is convenient to call, i.e. a developer can quickly know the definition content of the target form component based on the form interface annotation data to complete the accurate call and maintenance of the component, the problem that the code program which meets the standard component cannot be generated by requesting the interface in a targeted manner through the prior art is solved, and the development efficiency of the form component is improved on the premise of convenient data maintenance.
It should be understood that the statements in this section are not intended to identify key or critical features of the embodiments of the present invention, nor are they intended to limit the scope of the invention. Other features of the present invention will become apparent from the following description.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a flowchart of a method for generating a table component according to an embodiment of the present invention;
fig. 2 is a flowchart of a method for generating a table component according to a second embodiment of the present invention;
FIG. 3 is a diagram of a visual interface definition document according to a second embodiment of the present invention;
FIG. 4 is a schematic diagram illustrating a display effect of a front-end item according to a second embodiment of the present invention;
FIG. 5 is a schematic diagram illustrating a display effect of another front-end item according to a second embodiment of the present invention;
fig. 6 is a schematic structural diagram of a table component generation apparatus according to a third embodiment of the present invention;
FIG. 7 shows a schematic diagram of an electronic device that may be used to implement an embodiment of the invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without making any creative effort based on the embodiments in the present invention, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It will be appreciated that the data referred to in this disclosure, including but not limited to the data itself, the acquisition or use of the data, should comply with the requirements of the applicable laws and regulations and related regulations.
Example one
Fig. 1 is a flowchart of a table component generation method according to an embodiment of the present invention, where this embodiment is applicable to a case where a table component is automatically generated based on table interface data, and the method may be executed by a table component generation apparatus, where the table component generation apparatus may be implemented in a form of hardware and/or software, and the table component generation apparatus may be configured in an electronic device. As shown in fig. 1, the method includes:
s110, converting the interface document to be processed into an interface information tree, and determining the interface data of the table to be processed by traversing the interface information tree.
The interface document to be processed may be an interface document acquired from any interface platform. The interface document to be processed comprises a table type interface document. The interface information tree may be a tree structure generated from the interface document to be processed. The interface data of the table to be processed can be the interface data of the table class in the interface document to be processed.
In the embodiment of the invention, the interface document to be processed can be obtained from any interface platform, so that the interface document to be processed is converted into the tree structure to obtain the interface information tree, and then the interface information tree is traversed to determine the interface data of the table to be processed included in the interface document to be processed.
And S120, extracting form request interface key data in the form interface data to be processed, and determining template data to be injected according to the form request interface key data.
The table request interface key data may be data used for generating a table component in the table interface data to be processed. The template data to be injected can be data which needs to be injected into the template engine and is determined according to the form request interface key data.
In the embodiment of the invention, the table interface data to be processed can be analyzed according to the data type required by the table component to be generated, the table request interface key data in the table interface data to be processed is extracted, and then the table request interface key data is subjected to data processing to generate the template data to be injected.
And S130, injecting the template data to be injected into the form template to obtain an initial form assembly.
The form template may be a template of a form type pre-stored in the template engine. The initial form component may be a form component generated according to the form template after the data of the template to be injected is injected into the form template.
In the embodiment of the invention, the obtained template data to be injected can be injected into the injection form template of the template engine, and then the form template after the data injection is encapsulated to obtain the initial form assembly.
And S140, if the table interface annotation data exists in the table interface data to be processed, generating a target table component according to the table interface annotation data and the initial table component.
The table interface annotation data may be annotation data for the table interface in the table interface data to be processed. The target form component may be a form component resulting from data supplementation of the initial form component based on the form interface annotation data.
In the embodiment of the present invention, after the initial form component is obtained, it may be determined whether form interface annotation data exists in the to-be-processed form interface data, and if the form interface annotation data exists in the to-be-processed form interface data, data supplement processing is performed on the initial form component based on the form interface annotation data, that is, the initial form component is annotated and supplemented according to the form interface annotation data, so as to obtain the target form component.
According to the technical scheme, the interface document to be processed is converted into the interface information tree, the interface data of the table to be processed is determined by traversing the interface information tree, the key data of the table request interface in the interface data of the table to be processed is further extracted, the template data to be injected is determined according to the key data of the table request interface, the template data to be injected is injected into the table template, an initial table component is obtained, and if the table interface annotation data exists in the interface data of the table to be processed, a target table component is generated according to the table interface annotation data and the initial table component. In the scheme, based on the interface information tree, the table interface data to be processed can be quickly positioned, the code file of the table interface, namely the initial table component, can be automatically generated by injecting the template data to be injected into the table template, and the initial table component is subjected to data supplement according to the table interface annotation data, so that the finally obtained target table component can be conveniently called, namely, a developer can quickly know the definition content of the target table component based on the table interface annotation data to complete accurate calling and maintenance of the component, the problem that a code program which meets the standard component cannot be generated by a request interface in a targeted manner through the prior art is solved, and the development efficiency of the table component is improved on the premise of facilitating data maintenance.
Example two
Fig. 2 is a flowchart of a table component generating method according to a second embodiment of the present invention, which is embodied based on the above embodiment and provides a specific optional implementation manner for converting a to-be-processed interface document into an interface information tree. The specific process of converting the interface document to be processed into the interface information tree comprises the following steps: analyzing and serializing the interface document to be processed to obtain interface document analysis serialized data; storing the interface document analysis serialized data, and acquiring swagger interface data; and performing deserialization processing and circular reference field processing on the swagger interface data to obtain an interface information tree. As shown in fig. 2, the method includes:
s210, analyzing and serializing the interface document to be processed to obtain interface document analyzing and serializing data.
The interface document analysis serialized data can be data obtained after the interface document to be processed is subjected to analysis serialized processing.
In the embodiment of the invention, the obtained interface document to be processed can be analyzed and serialized to obtain the interface document analysis serialized data.
S220, storing the interface document analysis serialized data, and acquiring swagger interface data.
Wherein the swagger interface data can be interface document parsing serialization data under the swagger framework.
In the embodiment of the invention, the interface document analysis serialized data can be stored in a local system, the persistent storage of the data is completed, and the interface document analysis serialized data, namely the swagger interface data, under the swagger framework stored in the local system is read.
And S230, performing deserialization processing and circular reference field processing on the swagger interface data to obtain an interface information tree, and determining the table interface data to be processed by traversing the interface information tree.
The cyclic reference field processing is used for processing a cyclic reference field existing in data obtained after the swagger interface data is subjected to deserialization processing, and the problem of cyclic reference of fields in JSON (JavaScript Object Notation) is solved.
In the embodiment of the invention, the swagger interface data can be firstly subjected to deserialization to obtain a deserialization result, whether a circular reference field exists in the deserialization result is further judged, if the circular reference field exists in the deserialization result, the circular reference field is subjected to circular reference field processing to obtain the interface information tree, and then the interface information tree is traversed to determine the table interface data to be processed in the interface document to be processed.
Optionally, the interface information of the linear structure of the flat layer suitable for the RESTful API (REST-style application program interface) interface specification may be converted into a JSON tree structure, that is, the processing result of the cyclic reference field of the linear structure of the flat layer of the RESTful API interface specification may be converted into an interface information tree of the JSON tree structure.
In an optional embodiment of the present invention, determining the to-be-processed form interface data by traversing the interface information tree may include: acquiring a form request interface specification; and determining the table interface data to be processed which meets the table request interface specification in the interface information tree by traversing the interface information tree.
The specification of the table request interface may be predefined, and is used to determine that the request interface is the specification of the table request interface. The form request interface specification may include an interface method for a GET request, at least two page set parameters, a return response result association field, and an entity display field. The page setting parameter may be used to set a page display format. The returned response result associated field may be a field associated with a response result returned upon invocation of the interface. The entity display field may be used for presentation of the header of the front end field.
In the embodiment of the invention, a table interface definition method and characteristics between a client and a server can be agreed, the agreed table interface definition method and characteristics are used as a table request interface specification, and an interface information tree is traversed according to the table request interface specification, namely, the interface information tree is traversed according to the table request interface specification agreed interface method for GET request, at least two pages of set parameters, a returned response result associated field and an entity display field, and table interface data to be processed, which meets the table request interface specification, in the interface information tree is obtained.
S240, extracting form request interface key data in the form interface data to be processed, and determining template data to be injected according to the form request interface key data.
In an optional embodiment of the present invention, extracting table request interface key data in the table interface data to be processed may include: extracting the form interface data of the current form interface according to the form interface data to be processed; determining a target request address, a target request parameter and a target title field of the current form interface according to form interface data of the current form interface; and taking the target request address, the target request parameter and the target header field in the current form interface as the form request interface key data of the current form interface.
The current form interface can be any one of the interfaces matched with the form interface data to be processed. The target request address may be an access address of the requested data of the current form interface. The target request parameters may be parameters stored at the target request address. The target title field may be an entity display field of the current form interface.
In the embodiment of the present invention, table interface data to be processed may be analyzed to determine table interface data of a current table interface, and a target request address, a target request parameter, and a target header field of the current table interface are further extracted from the table interface data of the current table interface, so that the target request address, the target request parameter, and the target header field in the current table interface are used as table request interface key data of the current table interface.
In an optional embodiment of the present invention, determining template data to be injected according to the form request interface key data may include: generating a target table component name and a target request interface name of the current table interface according to the target request address; generating a target request parameter type of the current form interface according to the request label and the target request address of the current form interface; generating a target table column according to the target title field; and taking the target table component name, the target request interface name, the target request parameter type and the target table column as template data to be injected, which is matched with the current table interface.
The target form component name may be a name of a component corresponding to the current form interface, which is determined according to the API address of the current form interface. The target request interface name may be the name of the current form interface generated from the target form component name. The target request parameter type may be the type of target request parameter required by the current form interface. The target table column may be the table column corresponding to the current table interface.
In the embodiment of the invention, the path parameters in the target request address can be divided into a plurality of path fragments, then the fragments are converted into large hump character strings and connected to obtain the name of a target table component, and get is added in front of the name of the target table component to obtain the name of a target request interface. According to an interface method in a form request interface specification, determining a request label of a current form interface from form interface data of the current form interface, so as to format the request label and a target request address of the current form interface respectively in a large hump format, splicing the request label and the target request address of the formatted current form interface to obtain a target request parameter type of the current form interface, generating target form columns according to target header fields, wherein the target header field of each form column of the target form columns is matched with a corresponding entity display field of the current form interface, and further, a target form component name, a target request interface name, a target request parameter type and a target form column are used as template data to be injected, wherein the template data are matched with the current form interface.
And S250, injecting the template data to be injected into the form template to obtain an initial form assembly.
And S260, if the table interface annotation data exists in the table interface data to be processed, generating a target table component according to the table interface annotation data and the initial table component.
In an optional embodiment of the present invention, if table interface annotation data exists in the table interface data to be processed, generating the target table component according to the table interface annotation data and the initial table component may include: if the form interface annotation data exists in the form interface file of the current form interface, generating a target form component of the current form interface according to the form interface annotation data matched with the current form interface and the initial form component matched with the current form interface; after generating the target form component according to the form interface annotation data and the initial form component, the method may further include: storing a target form component of a current form interface to a current target file; the file name of the current target file is the name of the target table component; a first subfile is created that holds the target form component type of the current form interface, and a second subfile that holds the component reference file.
Wherein the current target file may be a folder that holds the target form component of the current form interface. The target form component type may be used to characterize the type of the target form component. The first subfile may be a folder that stores the component type of the form component that matches the form interface data to be processed. The component reference file may be an export file that stores table components for reference to the table components. The second subfile may be a folder that stores component reference files.
In the embodiment of the present invention, it may be determined whether table interface annotation data exists in the table interface file of the current table interface, and then a target table component of the current table interface is generated according to the table interface annotation data matched with the current table interface and the initial table component matched with the current table interface, and the target table component of the current table interface is stored in the current target file with the file name being the name of the target table component. By analogy, the form components of other form interfaces corresponding to the form interface data to be processed can be respectively stored in the files with the corresponding form component names, and the folders for storing the form components are stored in one folder. Further, a first subfile is created that maintains the target form component type of the current form interface, and a second subfile that maintains the component reference file.
In an optional embodiment of the present invention, generating the target table column according to the target title field may include: acquiring a default rendering function when the type of the target title field is an indirect display field type; the target table column is rendered according to a default rendering function.
Wherein, the indirect display field type is a field type which cannot be directly displayed. The default rendering function may be a preset table rendering function for rendering a table column of a target title field of the indirect display field type.
In the embodiment of the invention, whether the type of the target title field is a direct display field type or an indirect display field type can be judged, if the type of the target title field is the indirect display field type, a default rendering function can be obtained, and then the target table column matched with the target title field of the indirect display field type is rendered by using the default rendering function.
In one specific example, the code program generation and application flow of the target form component is as follows:
step 1, a form interface definition method and characteristics between the client and the server are appointed, and whether the request interface is a form interface or not is conveniently judged.
And 2, downloading the interface document to be processed from the interface management platform, analyzing and storing the interface document to be processed into a local system for persistent storage of data.
And 3, reading swagger interface data of the local file, then performing deserialization, processing a cyclic reference field possibly contained in the deserialized data, and converting a processing result of the cyclic reference field of the flat-layer linear structure of the RESTful API specification into an interface information tree of a JSON tree structure.
And 4, traversing the interface information tree in the step 3 to capture all interface information, extracting the interface data of the table to be processed which accords with the interface specification of the table request, and storing the extracted interface data in the interface array to be processed. A request interface that conforms to the specification for a tabular request interface satisfies the following conditions:
1) The request interface method must be a GET request.
2) The request interface needs to have at least two Query parameters (page setting parameters), one for setting the page size and one for setting the current page.
3) The returned response result field must contain a total field which is a nonnegative integer and represents how many data results can be obtained by the request, and the field is used for the front-end page to judge the total paging number according to the paging size.
4) The returned response result must have a list or results field, the type must be an array of entities, and the stored entities are used for the presentation of the column field.
5) Each field in an entity requires a back-end engineer to mark a display field (entity display field) on the document for the header title presentation of the corresponding field at the front end.
And 5, extracting the table interface data of the current table interface from the interface array to be processed in the step 4, and analyzing the context information of the table interface data. And extracting information such as a target request address, target request parameters, table interface annotation data, a target title field and the like of the current table interface.
And 6, processing the data extracted in the step 5, wherein the processing flow is as follows:
1) Generating a target table component name according to the API address of the current table interface: the path parameters in the target request address are divided into a plurality of path fragments, then the fragments are converted into large hump character strings and connected to obtain the target table component name (if the target request address is/abc/bcd, the obtained target table component name is abcBcd).
2) The same method as 1), add get before the target table component name, get the target request interface name (e.g./abc/bcd gets getAbbcd).
3) And generating target table columns, wherein the title of each table column corresponds to the entity display field, and when the type of the target title field is a type which cannot be directly displayed (such as Object, array and the like) and data or data sets are collected, defining the rendering content of the table columns by providing a uniform default rendering function.
4) And respectively formatting the request label and the target request address of the current form interface carried by the request in a large hump format and then splicing the request label and the target request address to obtain the target request parameter type required by the current form interface.
And 7, acquiring a form template of the form component, injecting the data information (to-be-injected template data) acquired in the step 6 into the form template, and meanwhile, if a corresponding document annotation (form interface annotation data) is written in a document by the current form interface, adding the document annotation to the front of the component code, so that a front-end developer can conveniently understand the form function information, and then an available form component code can be acquired.
Step 8, saving the plurality of table code results generated in step 7 under the current tables folder, which specifically comprises the following steps: writing each table code into a target file named by the table component name in the step 5, creating an index.ts (second subfile) under the tables folder as all exports of all table component files, wherein all front-end developers want to reference the generated table components by referencing the index.ts file, and creating a type.ts (first subfile) under the tables folder to store type information defined inside all the table components, wherein the type information is used for providing code type check and code prompt after the front-end developers reference the components, so that the development efficiency of the front end is improved.
9. By introducing the form component generated in step 8, some configuration options can be optionally introduced when the form component is used, so that customized modification is performed on the display and data processing of the form component, or parameters are not introduced, data processing and display are performed on default configuration options in the configuration options (the default configuration options refer to configurations generated by corresponding relations between defined field attributes and field titles in the interface document to be processed), and the form component automatically requests data.
The data flow of the target table component generation method is as follows: firstly, acquiring a written complete interface document to be processed, storing the interface document to be processed to the local, further reading the local interface document, further judging whether the interface document is stored locally, if so, analyzing the interface document, converting the analyzed interface document into a JSON tree to obtain an interface information tree, and judging whether the interface information tree is a correct JSON tree. If the interface information tree is a correct JSON tree, traversing the interface information tree, counting the table interface requests which accord with the table request interface specification, if the table interface requests are larger than 0, generating template data to be injected, injecting the template data to be injected into the table template, generating a table component, and writing the table component into the local so as to output written information. If any of the following conditions exist: and the interface document is not stored locally, the interface information tree is an incorrect JSON tree, and the table interface request is less than 0, and then the method is ended.
All interfaces described in the document extracted after the document is analyzed are processed through the following interface processing flows: the method comprises the steps of obtaining form interface data, sequentially judging whether an interface method of a form interface is a GET request, whether two page setting parameters of paging and paging size exist, whether the two page setting parameters of the paging and the paging size exist or not, whether the two page setting parameters of the paging and the paging size exist in a returned response result or not, and determining that the form interface data to be processed meeting the form request interface specification exists in an interface information tree if the interface method is the GET request, the two page setting parameters of the paging and the paging size exist, the two page setting parameters of the page and the page size parameters are requested, and the total and the (results or the list) exist in the returned response result. If any condition is not met, determining that the interface information tree does not have the table interface data to be processed meeting the table request interface specification, obtaining a series of table interfaces after the interface processing flow is finished, converting the table interfaces into table component codes and writing the table component codes into files, and leading a front-end developer to introduce the table interface data into other code files. The content of the form template in the scheme can be modified according to the front-end architecture of different projects, so that the generated form assembly can be used for various different project scenes, and meanwhile, developers can achieve the purpose of improving the flexibility of the form assembly by modifying the content of the template due to the adoption of a form template filling method. The generated code can be used in the act project through a table template built in for the front project of the act frame. All the table code files generated by the generator contain a functional formula component, a data request method, a display method and a rendering method of the table are defined in the functional formula component, and the corresponding modes of the table title and the interface data are defined, so that the front-end table interface request data can be rendered on the front-end table according to the corresponding target title field.
Taking a certain user request interface module as an example, the definition of the visual interface definition document is shown in fig. 3, the display effect of the table component generated by the method on the read front-end item is shown in fig. 4, and fig. 5 shows the display effect of another front-end item, specifically adding the default column content of the table component.
According to the technical scheme, the interface document to be processed is converted into the interface information tree, the interface data of the table to be processed is determined by traversing the interface information tree, the key data of the table request interface in the interface data of the table to be processed is further extracted, the template data to be injected is determined according to the key data of the table request interface, the template data to be injected is injected into the table template, an initial table component is obtained, and if the table interface annotation data exists in the interface data of the table to be processed, a target table component is generated according to the table interface annotation data and the initial table component. In the scheme, based on the interface information tree, the table interface data to be processed can be quickly positioned, the code file of the table interface, namely the initial table component, can be automatically generated by injecting the template data to be injected into the table template, and the initial table component is subjected to data supplement according to the table interface annotation data, so that the finally obtained target table component can be conveniently called, namely, a developer can quickly know the definition content of the target table component based on the table interface annotation data to complete accurate calling and maintenance of the component, the problem that a code program which meets the standard component cannot be generated by a request interface in a targeted manner through the prior art is solved, and the development efficiency of the table component is improved on the premise of facilitating data maintenance.
EXAMPLE III
Fig. 6 is a schematic structural diagram of a table component generating apparatus according to a third embodiment of the present invention. As shown in fig. 6, the apparatus includes: a to-be-processed form interface data determination module 310, a to-be-injected template data determination module 320, an initial form component acquisition module 330, and a target form component generation module 340, wherein,
the to-be-processed form interface data determining module 310 is configured to convert the to-be-processed interface document into an interface information tree, and determine to-be-processed form interface data by traversing the interface information tree;
the template data to be injected determining module 320 is configured to extract form request interface key data in the form interface data to be processed, and determine template data to be injected according to the form request interface key data;
an initial form component obtaining module 330, configured to inject the template data to be injected into the form template to obtain an initial form component;
and the target table component generating module 340 is configured to generate a target table component according to the table interface annotation data and the initial table component if the table interface annotation data exists in the table interface data to be processed.
According to the technical scheme, the interface document to be processed is converted into the interface information tree, the interface data of the table to be processed is determined by traversing the interface information tree, the key data of the table request interface in the interface data of the table to be processed is further extracted, the template data to be injected is determined according to the key data of the table request interface, the template data to be injected is injected into the table template, an initial table component is obtained, and if the table interface annotation data exists in the interface data of the table to be processed, a target table component is generated according to the table interface annotation data and the initial table component. In the scheme, based on the interface information tree, the table interface data to be processed can be quickly positioned, the code file of the table interface, namely the initial table component, can be automatically generated by injecting the template data to be injected into the table template, and the initial table component is subjected to data supplement according to the table interface annotation data, so that the finally obtained target table component can be conveniently called, namely, a developer can quickly know the definition content of the target table component based on the table interface annotation data to complete accurate calling and maintenance of the component, the problem that a code program which meets the standard component cannot be generated by a request interface in a targeted manner through the prior art is solved, and the development efficiency of the table component is improved on the premise of facilitating data maintenance.
Optionally, the to-be-processed form interface data determining module 310 includes an interface information tree converting unit, configured to parse and serialize the to-be-processed interface document to obtain interface document parsed and serialized data; storing the interface document analysis serialized data, and acquiring swagger interface data; and performing deserialization processing and circular reference field processing on the swagger interface data to obtain the interface information tree.
Optionally, the to-be-processed form interface data determining module 310 includes a to-be-processed form interface data determining unit, configured to obtain the form request interface specification; determining the table interface data to be processed which meets the table request interface specification in the interface information tree by traversing the interface information tree; the form request interface specification comprises a GET request, at least two page setting parameters, a return response result association field and an entity display field by an interface method.
Optionally, the to-be-injected template data determining module 320 includes a form request interface key data determining unit, configured to extract form interface data of a current form interface according to the to-be-processed form interface data; determining a target request address, target request parameters and a target title field of the current form interface according to the form interface data of the current form interface; and taking the target request address, the target request parameter and the target title field in the current form interface as form request interface key data of the current form interface.
Optionally, the to-be-injected template data determining module 320 is configured to generate a target form component name and a target request interface name of the current form interface according to the target request address; generating a target request parameter type of the current form interface according to the request label of the current form interface and the target request address; generating a target table column according to the target title field; and taking the target table component name, the target request interface name, the target request parameter type and the target table column as template data to be injected, which is matched with the current table interface.
Optionally, the initial form component obtaining module 330 is configured to, if the form interface file of the current form interface has form interface annotation data, generate a target form component of the current form interface according to the form interface annotation data matched with the current form interface and the initial form component matched with the current form interface. The table component generating device further comprises a data storage module, which is used for saving the target table component of the current table interface to the current target file after generating the target table component according to the table interface annotation data and the initial table component; wherein, the file name of the current target file is the name of the target table component; a first subfile is created that holds the target form component type of the current form interface, and a second subfile that holds the component reference file.
Optionally, the to-be-injected template data determining module 320 is configured to obtain a default rendering function when the type of the target title field is an indirect display field type; and rendering the target table column according to the default rendering function.
The table component generation device provided by the embodiment of the invention can execute the table component generation method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example four
FIG. 7 shows a schematic diagram of an electronic device that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device may also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 7, the electronic device 10 includes at least one processor 11, and a memory communicatively connected to the at least one processor 11, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, and the like, wherein the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data necessary for the operation of the electronic apparatus 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to the bus 14.
A number of components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, or the like; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
Processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various dedicated Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, and so forth. The processor 11 performs the various methods and processes described above, such as the generation method of the form component.
In some embodiments, the method of generating a form component may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the above-described table component generation method may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the table component generation method by any other suitable means (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuitry, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), system on a chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs that are executable and/or interpretable on a programmable system including at least one programmable processor, which may be special or general purpose, receiving data and instructions from, and transmitting data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be performed. A computer program can execute entirely on a machine, partly on a machine, as a stand-alone software package partly on a machine and partly on a remote machine or entirely on a remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, 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 compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic, speech, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS service are overcome.
It should be understood that various forms of the flows shown above, reordering, adding or deleting steps, may be used. For example, the steps described in the present invention may be executed in parallel, sequentially, or in different orders, and are not limited herein as long as the desired result of the technical solution of the present invention can be achieved.
The above-described embodiments should not be construed as limiting the scope of the invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may be made in accordance with design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for generating a form component, comprising:
converting the interface document to be processed into an interface information tree, and determining the interface data of the table to be processed by traversing the interface information tree;
extracting form request interface key data in the form interface data to be processed, and determining template data to be injected according to the form request interface key data;
injecting the template data to be injected into a form template to obtain an initial form assembly;
and if the table interface annotation data exists in the table interface data to be processed, generating a target table component according to the table interface annotation data and the initial table component.
2. The method of claim 1, wherein converting the interface document to be processed into an interface information tree comprises:
analyzing and serializing the interface document to be processed to obtain interface document analysis serialized data;
storing the interface document analysis serialized data, and acquiring swagger interface data;
and performing deserialization processing and circular reference field processing on the swagger interface data to obtain the interface information tree.
3. The method of claim 2, wherein determining the form interface data to be processed by traversing the interface information tree comprises:
acquiring a form request interface specification;
determining the table interface data to be processed which meets the table request interface specification in the interface information tree by traversing the interface information tree;
the form request interface specification comprises an interface method, a GET request, at least two page setting parameters, a return response result association field and an entity display field.
4. The method of claim 1, wherein extracting form request interface key data in the form interface data to be processed comprises:
extracting the form interface data of the current form interface according to the form interface data to be processed;
determining a target request address, target request parameters and target title fields of the current form interface according to the form interface data of the current form interface;
and taking the target request address, the target request parameter and the target header field in the current form interface as the form request interface key data of the current form interface.
5. The method of claim 4, wherein determining template data to be injected based on the form request interface key data comprises:
generating a target table component name and a target request interface name of the current table interface according to the target request address;
generating a target request parameter type of the current form interface according to the request label of the current form interface and the target request address;
generating a target table column according to the target title field;
and taking the target table component name, the target request interface name, the target request parameter type and the target table column as template data to be injected, which is matched with the current table interface.
6. The method of claim 5, wherein if table interface annotation data exists in the to-be-processed table interface data, generating a target table component according to the table interface annotation data and the initial table component comprises:
if the form interface annotation data exists in the form interface file of the current form interface, generating a target form component of the current form interface according to the form interface annotation data matched with the current form interface and the initial form component matched with the current form interface;
after generating a target form component from the form interface annotation data and the initial form component, further comprising:
storing a target form component of the current form interface to a current target file; wherein, the file name of the current target file is the name of the target table component;
a first subfile is created that holds the target form component type of the current form interface, and a second subfile that holds the component reference file.
7. The method of claim 5, wherein generating a target table column from the target header field comprises:
acquiring a default rendering function when the type of the target title field is an indirect display field type;
and rendering the target table column according to the default rendering function.
8. A table component generation apparatus, comprising:
the interface data determining module of the table to be processed is used for converting the interface document to be processed into an interface information tree and determining the interface data of the table to be processed by traversing the interface information tree;
the template data to be injected determining module is used for extracting form request interface key data in the form interface data to be processed and determining the template data to be injected according to the form request interface key data;
the initial form component acquisition module is used for injecting the template data to be injected into the form template to obtain an initial form component;
and the target table component generating module is used for generating a target table component according to the table interface annotation data and the initial table component if the table interface annotation data exists in the table interface data to be processed.
9. An electronic device, characterized in that the electronic device comprises:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the method of generating a form assembly of any of claims 1-7.
10. A computer-readable storage medium storing computer instructions for causing a processor to perform a method of generating a form component according to any one of claims 1 to 7 when executed.
CN202211175872.2A 2022-09-26 2022-09-26 Table component generation method, device, equipment and medium Pending CN115577689A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211175872.2A CN115577689A (en) 2022-09-26 2022-09-26 Table component generation method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211175872.2A CN115577689A (en) 2022-09-26 2022-09-26 Table component generation method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN115577689A true CN115577689A (en) 2023-01-06

Family

ID=84582723

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211175872.2A Pending CN115577689A (en) 2022-09-26 2022-09-26 Table component generation method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN115577689A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117234513A (en) * 2023-11-15 2023-12-15 腾讯科技(深圳)有限公司 Page data file generation method and device, electronic equipment, medium and product

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117234513A (en) * 2023-11-15 2023-12-15 腾讯科技(深圳)有限公司 Page data file generation method and device, electronic equipment, medium and product
CN117234513B (en) * 2023-11-15 2024-03-08 腾讯科技(深圳)有限公司 Page data file generation method and device, electronic equipment, medium and product

Similar Documents

Publication Publication Date Title
CN115577689A (en) Table component generation method, device, equipment and medium
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN115469849B (en) Service processing system, method, electronic equipment and storage medium
CN115904240A (en) Data processing method and device, electronic equipment and storage medium
CN113138760B (en) Page generation method and device, electronic equipment and medium
CN115328898A (en) Data processing method and device, electronic equipment and medium
CN114880498A (en) Event information display method and device, equipment and medium
CN113779117A (en) Data monitoring method and device, storage medium and electronic equipment
CN117271840B (en) Data query method and device of graph database and electronic equipment
CN116382333B (en) Satellite instruction arranging method and device, electronic equipment and storage medium
CN117270838B (en) Method, device, equipment and medium for generating universal formula script
CN116755684B (en) OAS Schema generation method, device, equipment and medium
CN111338941B (en) Information processing method and device, electronic equipment and storage medium
CN115098405B (en) Software product evaluation method and device, electronic equipment and storage medium
CN113438428B (en) Method, apparatus, device and computer-readable storage medium for automated video generation
CN115981657A (en) Code generation method and device, electronic equipment and readable medium
CN113254826A (en) Dump file processing method and device
CN117632101A (en) Code file generation method and device, electronic equipment and storage medium
CN114780580A (en) SQL statement generation method, device, equipment, storage medium and product
CN116541417A (en) Batch data processing method, device, computer equipment and storage medium
CN114238132A (en) Detection method, detection device, electronic equipment and storage medium
CN117724981A (en) Test report generation method, device, equipment and storage medium
CN116051678A (en) Method, device and medium for drawing test data curve of distributed storage
CN116861922A (en) Webpage text processing method and device, electronic equipment and storage medium
CN114443035A (en) Code generation method for application program, code generator, electronic device, and medium

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