CN117667089A - Front-end form generation method and device, storage medium and electronic equipment - Google Patents
Front-end form generation method and device, storage medium and electronic equipment Download PDFInfo
- Publication number
- CN117667089A CN117667089A CN202311560864.4A CN202311560864A CN117667089A CN 117667089 A CN117667089 A CN 117667089A CN 202311560864 A CN202311560864 A CN 202311560864A CN 117667089 A CN117667089 A CN 117667089A
- Authority
- CN
- China
- Prior art keywords
- data
- verification
- page
- target file
- server
- 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
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/30—Creation or generation of source code
- G06F8/38—Creation or generation of source code for implementing user interfaces
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/75—Structural analysis for program understanding
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Stored Programmes (AREA)
Abstract
本发明公开了一种前端表单生成方法、装置、存储介质及电子设备。其中,该方法包括:对后端服务器中预定类的目标文件进行解析,得到预定类的数据信息和后端验证注解;基于数据信息,确定用于在前端页面获取输入的表单数据的表单项目,其中,前端页面与后端服务器为分离架构,分离架构为前端页面的功能部署与后端服务器的功能部署相互解耦;对后端验证注解进行转换,确定用于在前端页面对表单数据进行验证的表单验证规则;基于表单验证规则和表单项目,在前端页面生成前端表单,其中,前端表单与目标文件之间存在映射关系,目标文件用于对提交至后端服务器的前端表单进行处理。本发明解决了相关技术中存在前后端数据转换效率不理想的技术问题。
The invention discloses a front-end form generation method, device, storage medium and electronic equipment. Among them, the method includes: parsing the target file of the predetermined class in the back-end server to obtain the data information of the predetermined class and the back-end verification annotation; based on the data information, determining the form item used to obtain the input form data on the front-end page, Among them, the front-end page and the back-end server have a separated architecture. The separated architecture means that the functional deployment of the front-end page and the functional deployment of the back-end server are decoupled from each other; the back-end verification annotations are converted and used to verify the form data on the front-end page. Form validation rules; based on the form validation rules and form items, a front-end form is generated on the front-end page. There is a mapping relationship between the front-end form and the target file, and the target file is used to process the front-end form submitted to the back-end server. The invention solves the technical problem of unsatisfactory front-end and back-end data conversion efficiency in related technologies.
Description
技术领域Technical field
本发明涉及前后端开发领域,数据传输领域,以及验证技术领域,具体而言,涉及一种前端表单生成方法、装置、存储介质及电子设备。The present invention relates to the field of front-end and back-end development, the field of data transmission, and the field of verification technology. Specifically, it relates to a front-end form generation method, device, storage medium, and electronic equipment.
背景技术Background technique
目前,在Web(网页)应用程序开发中,前后端分离架构应用广泛,前端和后端之间需要频繁地进行数据交互,为了实现数据传输的高效性和一致性,常常使用数据传输对象来在不同层之间传递数据,数据传输对象通常包含多个字段以及验证注解,用于描述数据的结构和验证规则。然而,由于前端和后端的代码语言和验证规则差异,通常需要手动创建前端表单项和验证规则,存在重复性工作和潜在的错误,相关技术中但还没有出现广泛应用的自动化解决方案,数据转换和验证方法对于复杂的数据传输对象结构和验证规则,可能效率较低,而且容易出错。Currently, in the development of Web (webpage) applications, the front-end and back-end separation architecture is widely used. Frequent data interaction is required between the front-end and the back-end. In order to achieve the efficiency and consistency of data transmission, data transfer objects are often used to Data is transferred between different layers. Data transfer objects usually contain multiple fields and validation annotations to describe the structure and validation rules of the data. However, due to the differences in code languages and validation rules between the front-end and back-end, it is usually necessary to manually create front-end form items and validation rules, which results in repetitive work and potential errors. There is no widely used automated solution in related technologies. Data conversion and validation methods may be less efficient and error-prone for complex data transfer object structures and validation rules.
针对上述的问题,目前尚未提出有效的解决方案。In response to the above problems, no effective solution has yet been proposed.
发明内容Contents of the invention
本发明实施例提供了一种前端表单生成方法、装置、存储介质及电子设备,以至少解决相关技术中存在前后端数据转换效率不理想的技术问题。Embodiments of the present invention provide a front-end form generation method, device, storage medium and electronic equipment to at least solve the technical problem of unsatisfactory front-end and back-end data conversion efficiency in related technologies.
根据本发明实施例的一个方面,提供了一种前端表单生成方法,包括:对后端服务器中预定类的目标文件进行解析,得到所述预定类的数据信息和后端验证注解;基于所述数据信息,确定用于在前端页面获取输入的表单数据的表单项目,其中,所述前端页面与所述后端服务器为分离架构,所述分离架构为所述前端页面的功能部署与所述后端服务器的功能部署相互解耦;对所述后端验证注解进行转换,确定用于在所述前端页面对所述表单数据进行验证的表单验证规则;基于所述表单验证规则和所述表单项目,在所述前端页面生成前端表单,其中,所述前端表单与所述目标文件之间存在映射关系,所述目标文件用于对提交至所述后端服务器的所述前端表单进行处理。According to one aspect of an embodiment of the present invention, a front-end form generation method is provided, including: parsing a target file of a predetermined class in a back-end server to obtain data information of the predetermined class and back-end verification annotations; based on the Data information, determine the form items used to obtain the input form data on the front-end page, wherein the front-end page and the back-end server have a separated architecture, and the separated architecture is the functional deployment of the front-end page and the back-end server. The functional deployment of the end server is decoupled from each other; the back-end verification annotations are converted to determine the form verification rules used to verify the form data on the front-end page; based on the form verification rules and the form items , generate a front-end form on the front-end page, where there is a mapping relationship between the front-end form and the target file, and the target file is used to process the front-end form submitted to the back-end server.
可选地,所述对所述后端验证注解进行转换,确定在所述前端页面的表单验证规则,包括:获取前端调用映射配置;基于所述前端调用映射配置指示对所述后端验证注解进行转换,确定所述后端验证注解对应的前端调用方法;基于所述前端调用方法,生成所述表单验证规则。Optionally, converting the back-end verification annotations and determining the form verification rules on the front-end page includes: obtaining the front-end call mapping configuration; and converting the back-end verification annotations based on the front-end call mapping configuration instructions. Perform conversion to determine the front-end calling method corresponding to the back-end verification annotation; and generate the form verification rules based on the front-end calling method.
可选地,所述基于所述数据信息,确定用于在前端页面获取输入的表单数据的表单项目,包括:确定所述数据信息的数据类型;确定所述数据类型对应的输入框,得到所述表单项目。Optionally, based on the data information, determining the form items used to obtain the input form data on the front-end page includes: determining the data type of the data information; determining the input box corresponding to the data type, and obtaining the Describe form items.
可选地,所述基于所述表单验证规则和所述表单项目,在所述前端页面生成前端表单,包括:获取前端模板样式和前端接口;基于所述表单验证规则和所述表单项目,采用所述前端模板样式生成所述前端表单,其中,所述前端表单通过所述前端接口提交至所述后端服务器。Optionally, generating a front-end form on the front-end page based on the form validation rules and the form items includes: obtaining a front-end template style and a front-end interface; based on the form validation rules and the form items, using The front-end template style generates the front-end form, wherein the front-end form is submitted to the back-end server through the front-end interface.
可选地,所述对后端服务器中预定类的目标文件进行解析,得到所述预定类的数据信息和后端验证注解,包括:对所述后端服务器中的所述目标文件的源代码进行解析,得到所述目标文件中所述预定类的变量名,关键字,运算符;将所述变量名,所述关键字,以及所述运算符作为节点,生成抽象语法树;对所述抽象语法树进行遍历,得到所述数据信息和所述后端验证注解。Optionally, parsing the target file of the predetermined class in the back-end server to obtain the data information and back-end verification annotations of the predetermined class includes: parsing the source code of the target file in the back-end server Perform analysis to obtain the variable names, keywords, and operators of the predetermined class in the target file; use the variable names, keywords, and operators as nodes to generate an abstract syntax tree; The abstract syntax tree is traversed to obtain the data information and the back-end verification annotations.
可选地,在所述基于所述表单验证规则和所述表单项目,在所述前端页面生成前端表单之后,由所述前端页面执行以下处理:获取在所述表单项目中输入的所述表单数据;在所述表单数据通过所述表单验证规则校验的情况下,将所述前端表单提交至所述后端服务器。Optionally, after the front-end page generates a front-end form based on the form validation rule and the form item, the front-end page performs the following processing: obtain the form input in the form item Data; if the form data is verified by the form validation rule, submit the front-end form to the back-end server.
可选地,所述前端页面设置有自定义配置接口,所述基于所述表单验证规则和所述表单项目,在所述前端页面生成前端表单,包括:基于所述表单验证规则和所述表单项目,生成初始表单;通过所述自定义配置接口,对所述初始表单进行调整,得到所述前端表单。Optionally, the front-end page is provided with a custom configuration interface, and generating a front-end form on the front-end page based on the form verification rules and the form items includes: based on the form verification rules and the form Project, generate an initial form; adjust the initial form through the custom configuration interface to obtain the front-end form.
根据本发明实施例的另一方面,提供了一种前端表单生成装置,包括:解析模块,用于对后端服务器中预定类的目标文件进行解析,得到所述预定类的数据信息和后端验证注解;项目确定模块,用于基于所述数据信息,确定用于在前端页面获取输入的表单数据的表单项目,其中,所述前端页面与所述后端服务器为分离架构,所述分离架构为所述前端页面的功能部署与所述后端服务器的功能部署相互解耦;规则确定模块,用于对所述后端验证注解进行转换,确定用于在所述前端页面对所述表单数据进行验证的表单验证规则;表单生成模块,用于基于所述表单验证规则和所述表单项目,在所述前端页面生成前端表单,其中,所述前端表单与所述目标文件之间存在映射关系,所述目标文件用于对提交至所述后端服务器的所述前端表单进行处理。According to another aspect of the embodiment of the present invention, a front-end form generation device is provided, including: a parsing module for parsing a target file of a predetermined class in a back-end server to obtain the data information of the predetermined class and the back-end Verification annotation; an item determination module, configured to determine the form item used to obtain the input form data on the front-end page based on the data information, wherein the front-end page and the back-end server have a separate architecture, and the separate architecture Decoupling the functional deployment of the front-end page from the functional deployment of the back-end server; a rule determination module for converting the back-end verification annotations and determining the form data for the front-end page Form verification rules for verification; a form generation module for generating a front-end form on the front-end page based on the form verification rule and the form item, wherein there is a mapping relationship between the front-end form and the target file , the target file is used to process the front-end form submitted to the back-end server.
根据本发明实施例的另一方面,提供了一种非易失性存储介质,所述非易失性存储介质存储有多条指令,所述指令适于由处理器加载并执行任意一项所述的前端表单生成方法。According to another aspect of the embodiment of the present invention, a non-volatile storage medium is provided. The non-volatile storage medium stores a plurality of instructions, and the instructions are suitable for loading and executing any one of the instructions by a processor. The front-end form generation method described above.
根据本发明实施例的另一方面,提供了一种电子设备,包括:一个或多个处理器和存储器,所述存储器用于存储一个或多个程序,其中,当所述一个或多个程序被所述一个或多个处理器执行时,使得所述一个或多个处理器实现任意一项所述的前端表单生成方法。According to another aspect of an embodiment of the present invention, an electronic device is provided, including: one or more processors and a memory, the memory being used to store one or more programs, wherein when the one or more programs When executed by the one or more processors, the one or more processors are caused to implement any one of the front-end form generation methods described above.
在本发明实施例中,通过对后端服务器中预定类的目标文件进行解析,得到所述预定类的数据信息和后端验证注解;基于所述数据信息,确定用于在前端页面获取输入的表单数据的表单项目,其中,所述前端页面与所述后端服务器为分离架构,所述分离架构为所述前端页面的功能部署与所述后端服务器的功能部署相互解耦;对所述后端验证注解进行转换,确定用于在所述前端页面对所述表单数据进行验证的表单验证规则;基于所述表单验证规则和所述表单项目,在所述前端页面生成前端表单,其中,所述前端表单与所述目标文件之间存在映射关系,所述目标文件用于对提交至所述后端服务器的所述前端表单进行处理。达到了后端处理到前端表单的自动化转换的目的,实现了提高前后端数据转换效率不理想的技术效果,进而解决了相关技术中存在前后端数据转换效率不理想的技术问题。In the embodiment of the present invention, by parsing the target file of the predetermined class in the back-end server, the data information of the predetermined class and the back-end verification annotation are obtained; based on the data information, the method used to obtain input on the front-end page is determined. Form items of form data, wherein the front-end page and the back-end server have a separated architecture, and the separated architecture is that the functional deployment of the front-end page and the functional deployment of the back-end server are decoupled from each other; The back-end verification annotations are converted to determine the form verification rules used to verify the form data on the front-end page; based on the form verification rules and the form items, a front-end form is generated on the front-end page, wherein, There is a mapping relationship between the front-end form and the target file, and the target file is used to process the front-end form submitted to the back-end server. The purpose of automatic conversion from back-end processing to front-end forms is achieved, and the technical effect of improving the unsatisfactory front-end and back-end data conversion efficiency is achieved, thereby solving the technical problem of unsatisfactory front-end and back-end data conversion efficiency existing in related technologies.
附图说明Description of drawings
此处所说明的附图用来提供对本发明的进一步理解,构成本申请的一部分,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The drawings described here are used to provide a further understanding of the present invention and constitute a part of this application. The illustrative embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the attached picture:
图1是根据本发明实施例提供的一种可选的前端表单生成方法的流程图;Figure 1 is a flow chart of an optional front-end form generation method provided according to an embodiment of the present invention;
图2是根据本发明实施例提供的一种可选的前端表单生成方法的示意流程图;Figure 2 is a schematic flow chart of an optional front-end form generation method provided according to an embodiment of the present invention;
图3是根据本发明实施例提供的一种可选的前端表单生成装置的示意图。Figure 3 is a schematic diagram of an optional front-end form generation device provided according to an embodiment of the present invention.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only These are some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts should fall within the scope of protection of the present invention.
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances so that the embodiments of the invention described herein are capable of being practiced in sequences other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, e.g., a process, method, system, product, or apparatus that encompasses a series of steps or units and need not be limited to those explicitly listed. Those steps or elements may instead include other steps or elements not expressly listed or inherent to the process, method, product or apparatus.
为了便于描述,以下对本申请实施例涉及的部分名词或术语进行说明:For the convenience of description, some nouns or terms involved in the embodiments of this application are described below:
Data Transfer Object(DTO,数据传输对象),用于在应用程序内部或不同系统之间传输数据,通常用于将数据从一个层传递到另一个层,DTO文件通常是用于描述数据传输对象的Java类文件或其他编程语言中的文件,有助于解耦数据模型和业务逻辑,提高系统的灵活性和可维护性。Data Transfer Object (DTO, Data Transfer Object) is used to transfer data within an application or between different systems. It is usually used to transfer data from one layer to another. DTO files are usually used to describe data transfer objects. Java class files or files in other programming languages help decouple data models and business logic, improving the flexibility and maintainability of the system.
AST(Abstract Syntax Tree,抽象语法树),是一种树形数据结构,通过对源代码进行解析和分析来构建。在AST中每个节点代表源代码中的一个语法单元,例如表达式、语句、函数、类等。AST (Abstract Syntax Tree) is a tree-shaped data structure that is constructed by parsing and analyzing source code. Each node in AST represents a syntax unit in the source code, such as expression, statement, function, class, etc.
前端指的是应用程序的用户界面部分,包括用户与应用程序进行交互的界面和逻辑。前端的作用是展示数据、与用户进行交互并向用户呈现用户界面,提供用户友好的使用体验。The front end refers to the user interface part of the application, including the interface and logic for users to interact with the application. The role of the front-end is to display data, interact with users, and present the user interface to users to provide a user-friendly experience.
后端指的是应用程序的服务器端部分,负责处理业务逻辑、数据存储和与前端的通信。后端的作用是处理业务逻辑、数据存储和与前端的通信,确保应用程序的正常运行并提供相应的功能。Backend refers to the server-side part of the application that handles business logic, data storage, and communication with the frontend. The role of the backend is to handle business logic, data storage and communication with the frontend, ensuring the normal operation of the application and providing corresponding functions.
前后端分离架构是一种软件架构模式,其中前端和后端分别独立开发、部署和维护,前后端分离架构的主要特点是,前后端之间可以存在数据交互,通过网络传输数据,而不是直接耦合在一起。前后端功能解耦可以提高开发效率、降低系统复杂度,并且可以实现前后端并行开发和部署。The front-end and back-end separation architecture is a software architecture model in which the front-end and back-end are developed, deployed and maintained independently. The main feature of the front-end and front-end separation architecture is that there can be data interaction between the front and back ends, and data is transmitted through the network instead of directly coupled together. Decoupling front-end and back-end functions can improve development efficiency, reduce system complexity, and enable parallel development and deployment of front-end and back-end.
相关技术中,手动创建或是借助部分组件、框架,创建前端表单项目和验证规则容易出现错误,导致数据交互不准确或不完成,影响系统的稳定性和可靠性。前后端之间的代码语言差异,也导致了维护困到,一旦后端数据结构发生变化,前端页面中的表单也需要对应修改,增加了维护成本和风险。并且频繁的数据交互和手动创建前端表单项目和验证规则降低了开发效率,可扩展性也较差。In related technologies, errors are prone to occur when creating front-end form items and validation rules manually or with the help of some components and frameworks, resulting in inaccurate or incomplete data interaction and affecting the stability and reliability of the system. The code language differences between the front-end and back-end also lead to maintenance difficulties. Once the back-end data structure changes, the forms in the front-end page also need to be modified accordingly, increasing maintenance costs and risks. Moreover, frequent data interaction and manual creation of front-end form items and validation rules reduce development efficiency and have poor scalability.
针对上述问题,本发明实施例提供了一种前端表单生成的方法实施例,需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。In response to the above problems, embodiments of the present invention provide a method embodiment for generating a front-end form. It should be noted that the steps shown in the flow chart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart diagrams, in some cases the steps shown or described may be performed in a different order than herein.
图1是根据本发明实施例的前端表单生成方法的流程图,如图1所示,可选执行主体为用于前后端转换的软件组件,该方法包括如下步骤:Figure 1 is a flow chart of a front-end form generation method according to an embodiment of the present invention. As shown in Figure 1, the optional execution subject is a software component for front-end and back-end conversion. The method includes the following steps:
步骤S102,对后端服务器中预定类的目标文件进行解析,得到预定类的数据信息和后端验证注解;Step S102, parse the target file of the predetermined class in the back-end server to obtain the data information of the predetermined class and the back-end verification annotation;
可以理解,对后端服务器中预定类的目标文件进行解析,预定类可以为Java中的DTO类文件进行词法分析,基于源代码进行分解,可以得到预定类的数据信息和后端验证注解。通过上述处理,可以将后端服务器中目标文件需要执行的数据处理进行提取,可以用于后续在前端页面中生成前端表单。It can be understood that by parsing the target file of the predetermined class in the back-end server, the predetermined class can be lexically analyzed for the DTO class file in Java, and decomposed based on the source code, the data information and back-end verification annotations of the predetermined class can be obtained. Through the above processing, the data processing that needs to be performed on the target file in the back-end server can be extracted, which can be used to subsequently generate a front-end form in the front-end page.
在一种可选的实施例中,对后端服务器中预定类的目标文件进行解析,得到预定类的数据信息和后端验证注解,包括:对后端服务器中的目标文件的源代码进行解析,得到目标文件中预定类的变量名,关键字,运算符;将变量名,关键字,以及运算符作为节点,生成抽象语法树;对抽象语法树进行遍历,得到数据信息和后端验证注解。In an optional embodiment, parsing the target file of the predetermined class in the back-end server to obtain the data information of the predetermined class and the back-end verification annotations includes: parsing the source code of the target file in the back-end server. , get the variable names, keywords, and operators of the predetermined class in the target file; use the variable names, keywords, and operators as nodes to generate an abstract syntax tree; traverse the abstract syntax tree to obtain data information and back-end verification annotations. .
可以理解,预定类可以为Java的DTO类,对目标文件进行词法分析,将源代码分解成标记(tokens),如DTO类的关键字、标识符、运算符等。将变量名,关键字,以及运算符作为节点,生成抽象语法树,来表示源代码的结构和层次。对抽象语法树进行遍历,得到数据信息和后端验证注解。It can be understood that the predetermined class can be Java's DTO class, perform lexical analysis on the target file, and decompose the source code into tokens, such as keywords, identifiers, operators, etc. of the DTO class. Using variable names, keywords, and operators as nodes, an abstract syntax tree is generated to represent the structure and hierarchy of the source code. Traverse the abstract syntax tree to obtain data information and back-end verification annotations.
需要说明的是,上述后端验证注解可能来自于人工标注,也可能是由代码分析工具自动添加的,后端验证注解包含了代码的一些额外信息,如变量的数据类型,方法的返回值等。上述后端验证注解可以为预定注解格式。It should be noted that the above backend verification annotations may come from manual annotations, or may be automatically added by code analysis tools. The backend verification annotations contain some additional information about the code, such as the data type of variables, return values of methods, etc. . The above-mentioned backend verification annotations may be in a predetermined annotation format.
可选地,遍历抽象语法树的方式可以有多种方式,通过遍历获取源代码的特定信息,遍历可以是深度优先搜索,或是广度优先搜索。上述深度优先搜索会尽可能深的搜索树的分支,这一过程一直进行到发现从源节点可达的所有节点为止。如果还存在未发现的节点,则选择其中一个作为源节点并重复上述过程,整个进程反复进行指导抽象语法树中所有节点都被访问为止。广度优先搜索会先访问更接近抽象语法树中根节点,然后访问所有相邻的节点,继而对这些相邻节点的相邻节点进行访问。Optionally, there are many ways to traverse the abstract syntax tree. Specific information of the source code is obtained through traversal. The traversal can be a depth-first search or a breadth-first search. The depth-first search described above searches the branches of the tree as deep as possible until all nodes reachable from the source node are found. If there are still undiscovered nodes, select one of them as the source node and repeat the above process. The entire process is repeated until all nodes in the abstract syntax tree are visited. Breadth-first search will first visit the node closer to the root of the abstract syntax tree, then visit all adjacent nodes, and then visit the adjacent nodes of these adjacent nodes.
可选地,上述DTO类的关键字、标识符、运算符可以为多种,例如,关键字可以为用于定义类的访问权限,以及用于定义类的类型和实现接口等关键字。标识符可以为指用于表示类、属性、方法等的名称,通常是由字母、数字、下划线符号组成的字符串。运算符可以为赋值运算符,加减乘除运算符等用于对类的属性进行赋值和计算的运算符。除此之外,DTO类还可能包括用于表示数据类型、方法声明、注解等的关键字、标识符和运算符。Optionally, the keywords, identifiers, and operators of the above DTO class can be of multiple types. For example, the keywords can be keywords used to define the access rights of the class, and keywords used to define the type and implementation interface of the class. An identifier can refer to a name used to represent a class, property, method, etc., usually a string composed of letters, numbers, and underscore symbols. Operators can be assignment operators, addition, subtraction, multiplication and division operators, etc. that are used to assign and calculate attributes of a class. In addition, DTO classes may also include keywords, identifiers and operators used to represent data types, method declarations, annotations, etc.
步骤S104,基于数据信息,确定用于在前端页面获取输入的表单数据的表单项目,其中,前端页面与后端服务器为分离架构,分离架构为前端页面的功能部署与后端服务器的功能部署相互解耦;Step S104, based on the data information, determine the form items used to obtain the input form data on the front-end page, where the front-end page and the back-end server have a separated architecture, and the separated architecture is that the functional deployment of the front-end page and the functional deployment of the back-end server are mutually exclusive. decoupling;
可以理解,前端页面和后端服务器为分离架构,为前端页面的功能部署与后端服务器的功能部署相互解耦。前端页面和后端服务器的功能解耦后,可以分别独立进行开发和维护,不会相互影响。这样可以更灵活地更新和修改页面和服务器的功能,而不会因为一个部分的变动影响到另一个部分。因而更容易地进行扩展和升级。新的功能可以独立添加到前端页面或者后端服务器,进而更好地适应不同的平台和设备。基于后端服务器中解析出的数据信息,可以确定用于在前端页面中获取输入的表单数据的表单项目。It can be understood that the front-end page and the back-end server have separate architectures, which decouples the functional deployment of the front-end page from the functional deployment of the back-end server. After the functions of the front-end page and back-end server are decoupled, they can be developed and maintained independently without affecting each other. This allows for more flexibility in updating and modifying page and server functionality without affecting changes in one part to another. This makes it easier to expand and upgrade. New features can be added independently to front-end pages or back-end servers to better adapt to different platforms and devices. Based on the data information parsed in the back-end server, the form items used to obtain the input form data in the front-end page can be determined.
可选地,上述表单项目可以为Vue表单项目,是用来收集用户输入数据的组件,这些表单项目可以被绑定到Vue实例的数据属性上,从而实现数据的双向绑定。Vue表单项也可以包含验证规则,用来确保用户输入的数据符合要求。Vue(视图)是用于构建用户界面和单页面应用程序。Optionally, the above form items can be Vue form items, which are components used to collect user input data. These form items can be bound to the data attributes of the Vue instance, thereby realizing two-way binding of data. Vue form items can also contain validation rules to ensure that the data entered by the user meets the requirements. Vue (view) is used to build user interfaces and single-page applications.
在一种可选的实施例中,基于数据信息,确定用于在前端页面获取输入的表单数据的表单项目,包括:确定数据信息的数据类型;确定数据类型对应的输入框,得到表单项目。In an optional embodiment, based on the data information, determining the form items used to obtain the input form data on the front-end page includes: determining the data type of the data information; determining the input box corresponding to the data type to obtain the form items.
可以理解,按照数据信息中的DOT类型,可以确定出数据信息的数据类型,可以确定出数据类型对应的输入框,得到表单项目。It can be understood that according to the DOT type in the data information, the data type of the data information can be determined, the input box corresponding to the data type can be determined, and the form items can be obtained.
可选地,在数据信息指示为字符串类型的情况下,生成文本输入框作为表单项目,在数据信息指示为整型的情况下,生成数字输入框作为表单项目,在数据信息指示为日期类型的情况下,生成日期输入框作为表单项目,在数据信息指示为枚举类型的情况下,生成下拉框作为表单项目,在数据信息指示为布尔型的情况下,生成复选框作为表单项目。Optionally, when the data information is indicated as a string type, a text input box is generated as a form item; when the data information is indicated as an integer, a numeric input box is generated as a form item; when the data information is indicated as a date type In the case of , a date input box is generated as a form item, when the data information indicates an enumeration type, a drop-down box is generated as a form item, and when the data information indicates a Boolean type, a check box is generated as a form item.
步骤S106,对后端验证注解进行转换,确定用于在前端页面对表单数据进行验证的表单验证规则;Step S106, convert the back-end verification annotations and determine the form verification rules used to verify the form data on the front-end page;
可以理解,对后端验证注解进行转换,可以确定出用于在前端页面对表单数据进行验证的表单验证规则。在前端表单提交至后端服务器之前,是会按照表单验证规则对表单数据在前端页面进行验证,之后才能执行向后端服务器的提交。It can be understood that by converting the back-end validation annotations, the form validation rules used to validate the form data on the front-end page can be determined. Before the front-end form is submitted to the back-end server, the form data will be verified on the front-end page according to the form validation rules, and then the submission to the back-end server can be performed.
在一种可选的实施例中,对后端验证注解进行转换,确定在前端页面的表单验证规则,包括:获取前端调用映射配置;基于前端调用映射配置指示对后端验证注解进行转换,确定后端验证注解对应的前端调用方法;基于前端调用方法,生成表单验证规则。In an optional embodiment, converting the back-end verification annotations and determining the form verification rules on the front-end page includes: obtaining the front-end call mapping configuration; converting the back-end verification annotations based on the front-end call mapping configuration instructions and determining The front-end calling method corresponding to the back-end verification annotation; based on the front-end calling method, form validation rules are generated.
可以理解,前端调用映射配置中的内容,包括将后端验证注解与前端调用方法对应的转换映射。基于转换后端验证注解后得到的前端调用方法,可以生成表单验证规则。It can be understood that the content in the front-end call mapping configuration includes the conversion mapping corresponding to the back-end verification annotation and the front-end calling method. Based on the front-end calling method obtained after converting the back-end validation annotations, form validation rules can be generated.
可选地,后端验证注解可以为DTO类中提取到的Hibernate验证注解,如@NotNull、@Max(value)、@Min(value)、message等。Hibernate验证注解是一组用在Java对象上数据验证的注解,用于在应用程序中对实体类的字段进行验证。@NotNull用于确保字段不为空(null),如果该字段为null,则会引发验证错误。@Max(value)用于指定字段的最大值,如果该数据字段的值超过此最大值,则会引发验证错误。@Min(value)用于指定字段的最小值,如果该数据字段的值超过此最小值,则会引发验证错误。Message表示该属性用于指定验证失败时的错误消息,当字段不符合验证规则是,将显示message中的消息。Optionally, the backend verification annotations can be Hibernate verification annotations extracted from the DTO class, such as @NotNull, @Max(value), @Min(value), message, etc. Hibernate validation annotations are a set of annotations used for data validation on Java objects, used to validate fields of entity classes in applications. @NotNull is used to ensure that the field is not empty (null), if the field is null, a validation error will be thrown. @Max(value) is used to specify the maximum value of the field. If the value of the data field exceeds this maximum value, a validation error will be thrown. @Min(value) is used to specify the minimum value of the field. If the value of the data field exceeds this minimum value, a validation error will be thrown. Message indicates that this property is used to specify the error message when validation fails. When the field does not meet the validation rules, the message in message will be displayed.
可选地,按照前端调用映射配置,将@NotNull转换为调用必填项验证方法,@Max(value)转换为调用最大值验证方法,将message转为调用报错信息方法。Optionally, according to the front-end call mapping configuration, @NotNull is converted into calling the required item verification method, @Max(value) is converted into calling the maximum value verification method, and message is converted into calling the error message method.
步骤S108,基于表单验证规则和表单项目,在前端页面生成前端表单,其中,前端表单与目标文件之间存在映射关系,目标文件用于对提交至后端服务器的前端表单进行处理。Step S108: Based on the form validation rules and form items, a front-end form is generated on the front-end page. There is a mapping relationship between the front-end form and the target file. The target file is used to process the front-end form submitted to the back-end server.
可以理解,利用上述得到的表单验证规则和表单项目,在前端页面生成前端表单。前端表单和目标文件之间存在映射关系,在经过前端表单验证后,前端表单会被提交至后端服务器中,后端服务器中目标文件用于对提交来的前端表单进行处理。It can be understood that the front-end form is generated on the front-end page using the form validation rules and form items obtained above. There is a mapping relationship between the front-end form and the target file. After the front-end form is verified, the front-end form will be submitted to the back-end server. The target file in the back-end server is used to process the submitted front-end form.
在一种可选的实施例中,基于表单验证规则和表单项目,在前端页面生成前端表单,包括:获取前端模板样式和前端接口;基于表单验证规则和表单项目,采用前端模板样式生成前端表单,其中,前端表单通过前端接口提交至后端服务器。In an optional embodiment, based on the form validation rules and form items, generating a front-end form on the front-end page includes: obtaining the front-end template style and front-end interface; based on the form validation rules and form items, using the front-end template style to generate the front-end form , where the front-end form is submitted to the back-end server through the front-end interface.
可以理解,前端模板样式和前端接口是预先配置的,采用前端模板样式生成前端表单,前端表单通过前端接口提交至后端服务器。It can be understood that the front-end template style and front-end interface are pre-configured, the front-end template style is used to generate the front-end form, and the front-end form is submitted to the back-end server through the front-end interface.
可选地,上述前端表单可以多种,例如:Vue或React单页面文件。Vue和React都可以创建单页面应用程序(SPA),而单页面文件则是用来构建这些应用程序的一种技术。在Vue中,单页面文件通常以“.vue”扩展名结尾,包含了HTML、CSS和JavaScript代码,以及组件相关的逻辑。而React的单页面文件通常以“.js”或“.jsx”文件,React单页面文件支持组件化开发,将一个页面拆分成多个组件,每个组件有自己的状态和行为,使得代码复用性和可维护都得到了很大提升。Optionally, the above front-end forms can be of multiple types, such as Vue or React single-page files. Both Vue and React can create single page applications (SPA), and single page files are a technology used to build these applications. In Vue, single-page files usually end with the ".vue" extension and contain HTML, CSS and JavaScript code, as well as component-related logic. React's single-page files are usually ".js" or ".jsx" files. React single-page files support component development, splitting a page into multiple components. Each component has its own status and behavior, making the code Reusability and maintainability have been greatly improved.
在一种可选的实施例中,在基于表单验证规则和表单项目,在前端页面生成前端表单之后,由前端页面执行以下处理:获取在表单项目中输入的表单数据;在表单数据通过表单验证规则校验的情况下,将前端表单提交至后端服务器。In an optional embodiment, after the front-end form is generated on the front-end page based on the form validation rules and form items, the front-end page performs the following processing: obtain the form data entered in the form item; after the form data passes the form validation In the case of rule verification, the front-end form is submitted to the back-end server.
可以理解,上述执行主体为前端页面,前端页面一般为展示数据、与用户进行交互并向用户呈现用户界面,可以获取输入到表单项目中的表单数据。如果表单数据通过表单验证规则校验后,前端表单会被提交至后端服务器进行处理。It can be understood that the above-mentioned execution subject is the front-end page. The front-end page generally displays data, interacts with the user, and presents the user interface to the user, and can obtain the form data input into the form item. If the form data passes the form validation rules, the front-end form will be submitted to the back-end server for processing.
在一种可选的实施例中,前端页面设置有自定义配置接口,基于表单验证规则和表单项目,在前端页面生成前端表单,包括:基于表单验证规则和表单项目,生成初始表单;通过自定义配置接口,对初始表单进行调整,得到前端表单。In an optional embodiment, the front-end page is provided with a custom configuration interface, and based on the form validation rules and form items, a front-end form is generated on the front-end page, including: generating an initial form based on the form validation rules and form items; Define the configuration interface, adjust the initial form, and obtain the front-end form.
可以理解,前端页面上可以设置有自定义配置接口,可以将自动化生成的表单验证规则和表单项目,作为初始表单。设置的自定义配置接口可以对自动设置的初始表单进行自定义配置,以满足不同项目的需求。在通过自定义配置接口,对初始表单进行调整后,可以得到调整好的前端表单。It is understandable that a custom configuration interface can be set up on the front-end page, and the automatically generated form validation rules and form items can be used as the initial form. The set custom configuration interface can customize the automatically set initial form to meet the needs of different projects. After adjusting the initial form through the custom configuration interface, you can get the adjusted front-end form.
通过上述步骤S102,对后端服务器中预定类的目标文件进行解析,得到预定类的数据信息和后端验证注解;步骤S104,基于数据信息,确定用于在前端页面获取输入的表单数据的表单项目,其中,前端页面与后端服务器为分离架构,分离架构为前端页面的功能部署与后端服务器的功能部署相互解耦;步骤S106,对后端验证注解进行转换,确定用于在前端页面对表单数据进行验证的表单验证规则;步骤S108,基于表单验证规则和表单项目,在前端页面生成前端表单,其中,前端表单与目标文件之间存在映射关系,目标文件用于对提交至后端服务器的前端表单进行处理。可以实现后端处理到前端表单的自动化转换的目的,实现了提高前后端数据转换效率不理想的技术效果,进而解决了相关技术中存在前后端数据转换效率不理想的技术问题。Through the above-mentioned step S102, the target file of the predetermined class in the back-end server is parsed to obtain the data information of the predetermined class and the back-end verification annotation; step S104, based on the data information, determine the form used to obtain the input form data on the front-end page project, in which the front-end page and the back-end server have a separated architecture, and the separated architecture is that the functional deployment of the front-end page and the functional deployment of the back-end server are decoupled from each other; step S106, convert the back-end verification annotations and determine them for use in the front-end page Form validation rules for validating form data; step S108, based on the form validation rules and form items, generate a front-end form on the front-end page, where there is a mapping relationship between the front-end form and the target file, and the target file is used to submit to the back-end The server's front-end form is processed. It can achieve the purpose of automatic conversion from back-end processing to front-end forms, achieve the technical effect of improving the unsatisfactory front-end and back-end data conversion efficiency, and thereby solve the technical problem of unsatisfactory front-end and back-end data conversion efficiency existing in related technologies.
基于上述实施例和可选实施例,本发明提出一种可选实施方式,如图2所示具体为以下步骤:Based on the above embodiments and optional embodiments, the present invention proposes an optional implementation, as shown in Figure 2, which specifically includes the following steps:
步骤S1,对后端服务器中DOT类的目标文件进行词法分析,基于目标文件的源代码进行分解生成标记(tokens),如关键字、标识符、运算符等作为数据信息。基于上述数据信息进行语法分析,关键字、标识符、运算符作为节点,生成抽象语法树,来表示源代码的结构和层次。Step S1: Perform lexical analysis on the target file of the DOT class in the back-end server, and decompose it to generate tokens based on the source code of the target file, such as keywords, identifiers, operators, etc. as data information. Based on the above data information, syntax analysis is performed, and keywords, identifiers, and operators are used as nodes to generate an abstract syntax tree to represent the structure and hierarchy of the source code.
步骤S2,在抽象语法树(AST)上进行遍历和分析,识别并提取出Java DTO类的结构、字段类型和字段名称作为数据信息。Step S2: Traverse and analyze the abstract syntax tree (AST) to identify and extract the structure, field type and field name of the Java DTO class as data information.
步骤S3,根据DTO类的数据信息,生成表单项目用于表格的列表项目展示使用。Step S3: Based on the data information of the DTO class, form items are generated for display and use as list items of the table.
步骤S4,根据数据信息的数据类型,将其转换为对应的Vue表单项目,如文本输入框、数字输入框、时间输入框、下拉框、复选框等。Step S4: According to the data type of the data information, convert it into corresponding Vue form items, such as text input box, number input box, time input box, drop-down box, check box, etc.
步骤S5,DOT类的目标文件还可以解析出后端验证注解,后端验证注解可以为Hibernate验证注解,提取Hibernate验证注解可以有多种,如@NotNull、@Max(value)、@Min(value)、message等。Step S5, the target file of the DOT class can also parse out the back-end verification annotations. The back-end verification annotations can be Hibernate verification annotations. There can be many types of Hibernate verification annotations extracted, such as @NotNull, @Max(value), @Min(value ), message, etc.
步骤S6,根据提取的Hibernate验证注解,生成对应的Vue表单验证规则,例如将@NotNull转换为调用必填项验证方法,@Max(value)转换为调用最大值验证方法,将message转为调用报错信息方法。Step S6: Generate corresponding Vue form validation rules based on the extracted Hibernate validation annotations. For example, convert @NotNull to call the required item verification method, @Max(value) to call the maximum value verification method, and convert message to call the error reporting method. information method.
步骤S7,根据转换后的Vue表单项目和Vue表单验证规则,生成Vue单页面文件。Step S7: Generate a Vue single page file based on the converted Vue form item and Vue form validation rules.
由上述可选实施方式至少实现以下效果:相比传统的手动创建前端表单项和验证规则的方法,本具体实施方式利用抽象语法树(AST)实现自动化转换,无需逐个创建Vue或React表单项目和验证规则,只需将目标文件作为输入,即可自动生成前端表单,从而加快开发速度,节省时间成本,并且也可以保持数据一致性。通过抽象语法树技术,并将其直接转换为对应的前端表单。保了前后端数据模型的一致性,避免了因手动转换造成的潜在错误,提高了前后端数据交互的准确性和稳定性。通过结合AST技术和前端表单项的自动生成,显著提高了软件开发的效率和质量。相较于传统的手动转换方式,在数据一致性和错误减少方面具有明显优势,能够更专注于业务逻辑而非繁琐的表单和验证规则编写,加速了表单开发效率。The above optional implementation methods achieve at least the following effects: Compared with the traditional method of manually creating front-end form items and validation rules, this specific implementation method uses abstract syntax trees (AST) to achieve automated conversion, without the need to create Vue or React form items and verification rules one by one. For validation rules, you only need to take the target file as input to automatically generate a front-end form, thereby speeding up development, saving time and costs, and maintaining data consistency. Through abstract syntax tree technology, it is directly converted into the corresponding front-end form. It ensures the consistency of the front-end and back-end data models, avoids potential errors caused by manual conversion, and improves the accuracy and stability of front-end and back-end data interaction. By combining AST technology with the automatic generation of front-end form items, the efficiency and quality of software development are significantly improved. Compared with the traditional manual conversion method, it has obvious advantages in data consistency and error reduction. It can focus more on business logic rather than tedious writing of forms and validation rules, speeding up the efficiency of form development.
需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and, although a logical sequence is shown in the flowchart, in some cases, The steps shown or described may be performed in a different order than here.
在本实施例中还提供了一种前端表单生成装置,该装置用于实现上述实施例及优选实施方式,已经进行过说明的不再赘述。如以下所使用的,术语“模块”“装置”可以实现预定功能的软件和/或硬件的组合。尽管以下实施例所描述的装置较佳地以软件来实现,但是硬件,或者软件和硬件的组合的实现也是可能并被构想的。This embodiment also provides a front-end form generation device, which is used to implement the above-mentioned embodiments and preferred implementations. What has already been described will not be described again. As used below, the terms "module" and "device" may be a combination of software and/or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
根据本发明实施例,还提供了一种用于实施前端表单生成方法的装置实施例,图3是根据本发明实施例的一种前端表单生成装置的示意图,如图3所示,上述前端表单生成装置,包括:解析模块302,项目确定模块304,规则确定模块306,表单生成模块308,下面对该装置进行说明。According to an embodiment of the present invention, an embodiment of a device for implementing a front-end form generation method is also provided. Figure 3 is a schematic diagram of a front-end form generation device according to an embodiment of the present invention. As shown in Figure 3, the above-mentioned front-end form The generation device includes: an analysis module 302, an item determination module 304, a rule determination module 306, and a form generation module 308. This device will be described below.
解析模块302,用于对后端服务器中预定类的目标文件进行解析,得到预定类的数据信息和后端验证注解;The parsing module 302 is used to parse the target file of the predetermined class in the back-end server to obtain the data information of the predetermined class and the back-end verification annotations;
项目确定模块304,与解析模块302连接,用于基于数据信息,确定用于在前端页面获取输入的表单数据的表单项目,其中,前端页面与后端服务器为分离架构,分离架构为前端页面的功能部署与后端服务器的功能部署相互解耦;The item determination module 304 is connected to the parsing module 302 and is used to determine the form items used to obtain the input form data on the front-end page based on the data information, wherein the front-end page and the back-end server have a separate architecture, and the separation architecture is the front-end page. Function deployment is decoupled from that of the back-end server;
规则确定模块306,与项目确定模块304连接,用于对后端验证注解进行转换,确定用于在前端页面对表单数据进行验证的表单验证规则;The rule determination module 306 is connected to the project determination module 304 and is used to convert the back-end verification annotations and determine the form verification rules used to verify the form data on the front-end page;
表单生成模块308,与规则确定模块306连接,用于基于表单验证规则和表单项目,在前端页面生成前端表单,其中,前端表单与目标文件之间存在映射关系,目标文件用于对提交至后端服务器的前端表单进行处理。The form generation module 308 is connected to the rule determination module 306 and is used to generate a front-end form on the front-end page based on the form verification rules and form items. There is a mapping relationship between the front-end form and the target file, and the target file is used to submit to the back-end page. The front-end form of the end server is processed.
本发明实施例提供的一种前端表单生成装置中,通过解析模块302,用于对后端服务器中预定类的目标文件进行解析,得到预定类的数据信息和后端验证注解;项目确定模块304,与解析模块302连接,用于基于数据信息,确定用于在前端页面获取输入的表单数据的表单项目,其中,前端页面与后端服务器为分离架构,分离架构为前端页面的功能部署与后端服务器的功能部署相互解耦;规则确定模块306,与项目确定模块304连接,用于对后端验证注解进行转换,确定用于在前端页面对表单数据进行验证的表单验证规则;表单生成模块308,与规则确定模块306连接,用于基于表单验证规则和表单项目,在前端页面生成前端表单,其中,前端表单与目标文件之间存在映射关系,目标文件用于对提交至后端服务器的前端表单进行处理。达到了后端处理到前端表单的自动化转换的目的,实现了提高前后端数据转换效率不理想的技术效果,进而解决了相关技术中存在前后端数据转换效率不理想的技术问题。In a front-end form generation device provided by an embodiment of the present invention, the parsing module 302 is used to parse the target file of a predetermined class in the back-end server to obtain the data information of the predetermined class and the back-end verification annotations; the project determination module 304 , connected to the parsing module 302, used to determine the form items used to obtain the input form data on the front-end page based on the data information, where the front-end page and the back-end server are separated architectures, and the separated architecture is the function deployment of the front-end page and the back-end server. The functional deployment of the end server is decoupled from each other; the rule determination module 306 is connected to the project determination module 304, and is used to convert the back-end verification annotations and determine the form verification rules used to verify the form data on the front-end page; the form generation module 308, connected to the rule determination module 306, used to generate a front-end form on the front-end page based on the form validation rules and form items, where there is a mapping relationship between the front-end form and the target file, and the target file is used to process the data submitted to the back-end server. Front-end forms are processed. The purpose of automatic conversion from back-end processing to front-end forms is achieved, and the technical effect of improving the unsatisfactory front-end and back-end data conversion efficiency is achieved, thereby solving the technical problem of unsatisfactory front-end and back-end data conversion efficiency existing in related technologies.
作为一种可选的实施例,本发明实施例提供的前端表单生成装置,该规则确定模块包括:第一获取模块,用于获取前端调用映射配置;注解转换模块,用于基于前端调用映射配置指示对后端验证注解进行转换,确定后端验证注解对应的前端调用方法;规则生成模块,用于基于前端调用方法,生成表单验证规则。As an optional embodiment, in the front-end form generation device provided by the embodiment of the present invention, the rule determination module includes: a first acquisition module, used to obtain the front-end call mapping configuration; an annotation conversion module, used to call the mapping configuration based on the front-end Instructs to convert the back-end verification annotations and determines the front-end calling method corresponding to the back-end verification annotations; the rule generation module is used to generate form verification rules based on the front-end calling methods.
作为一种可选的实施例,该项目确定模块包括:第一确定模块,用于确定数据信息的数据类型;第二确定模块,用于确定数据类型对应的输入框,得到表单项目。As an optional embodiment, the item determination module includes: a first determination module, used to determine the data type of the data information; a second determination module, used to determine the input box corresponding to the data type to obtain the form item.
作为一种可选的实施例,该表单生成模块包括:第二获取模块,用于获取前端模板样式和前端接口;生成处理模块,用于基于表单验证规则和表单项目,采用前端模板样式生成前端表单,其中,前端表单通过前端接口提交至后端服务器。As an optional embodiment, the form generation module includes: a second acquisition module, used to obtain the front-end template style and front-end interface; a generation processing module, used to generate the front-end using the front-end template style based on the form verification rules and form items. Form, where the front-end form is submitted to the back-end server through the front-end interface.
作为一种可选的实施例,该解析模块包括:第一解析模块,用于对后端服务器中的目标文件的源代码进行解析,得到目标文件中预定类的变量名,关键字,运算符;抽象语法树生成模块,用于将变量名,关键字,以及运算符作为节点,生成抽象语法树;遍历模块,用于对抽象语法树进行遍历,得到数据信息和后端验证注解。As an optional embodiment, the parsing module includes: a first parsing module, used to parse the source code of the target file in the back-end server to obtain the variable names, keywords, and operators of the predetermined class in the target file. ; The abstract syntax tree generation module is used to generate abstract syntax trees using variable names, keywords, and operators as nodes; the traversal module is used to traverse the abstract syntax tree to obtain data information and back-end verification annotations.
作为一种可选的实施例,该表单生成模块包括:第三获取模块,用于获取在表单项目中输入的表单数据;提交模块,用于在表单数据通过表单验证规则校验的情况下,将前端表单提交至后端服务器。As an optional embodiment, the form generation module includes: a third acquisition module, used to acquire the form data entered in the form item; a submission module, used to submit the form data when the form data passes the form verification rule verification. Submit the front-end form to the back-end server.
作为一种可选的实施例,该表单生成模块包括:初始生成模块,用于基于表单验证规则和表单项目,生成初始表单;自定义配置模块,用于通过自定义配置接口,对初始表单进行调整,得到前端表单。As an optional embodiment, the form generation module includes: an initial generation module, used to generate an initial form based on the form validation rules and form items; a custom configuration module, used to configure the initial form through a custom configuration interface Adjust to get the front-end form.
需要说明的是,上述各个模块是可以通过软件或硬件来实现的,例如,对于后者,可以通过以下方式实现:上述各个模块可以位于同一处理器中;或者,上述各个模块以任意组合的方式位于不同的处理器中。It should be noted that each of the above modules can be implemented through software or hardware. For example, the latter can be implemented in the following ways: the above modules can be located in the same processor; or the above modules can be implemented in any combination. Located in different processors.
此处需要说明的是,上述解析模块302,项目确定模块304,规则确定模块306,表单生成模块308对应于实施例中的步骤S102至步骤S108,上述模块与对应的步骤所实现的实例和应用场景相同,但不限于上述实施例所公开的内容。需要说明的是,上述模块作为装置的一部分可以运行在计算机终端中。It should be noted here that the above-mentioned parsing module 302, project determination module 304, rule determination module 306, and form generation module 308 correspond to steps S102 to S108 in the embodiment. The examples and applications implemented by the above-mentioned modules and the corresponding steps are The scenarios are the same, but are not limited to the content disclosed in the above embodiments. It should be noted that the above module can run in a computer terminal as part of the device.
需要说明的是,本实施例的可选或优选实施方式可以参见实施例中的相关描述,此处不再赘述。It should be noted that for optional or preferred implementation modes of this embodiment, reference can be made to the relevant descriptions in the embodiments, and details will not be described again here.
上述前端表单生成装置还可以包括处理器和存储器,解析模块302,项目确定模块304,规则确定模块306,表单生成模块308等均作为程序单元存储在存储器中,由处理器执行存储在存储器中的上述程序单元来实现相应的功能。The above-mentioned front-end form generation device may also include a processor and a memory. The parsing module 302, the item determination module 304, the rule determination module 306, the form generation module 308, etc. are all stored in the memory as program units, and the processor executes the programs stored in the memory. The above program units are used to implement the corresponding functions.
处理器中包含内核,由内核去存储器中调取相应的程序单元。内核可以设置一个或以上。存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM),存储器包括至少一个存储芯片。The processor contains a core, which retrieves the corresponding program unit from the memory. The kernel can set one or more. Memory may include non-permanent memory in computer-readable media, random access memory (RAM) and/or non-volatile memory, such as read-only memory (ROM) or flash memory (flash RAM). The memory includes at least one memory chip.
本发明实施例提供了一种非易失性存储介质,其上存储有程序,该程序被处理器执行时实现前端表单生成方法。Embodiments of the present invention provide a non-volatile storage medium on which a program is stored. When the program is executed by a processor, a front-end form generation method is implemented.
本发明实施例提供了一种电子设备,该电子设备包括处理器、存储器及存储在存储器上并可在处理器上运行的程序,处理器执行程序时实现以下步骤:对后端服务器中预定类的目标文件进行解析,得到预定类的数据信息和后端验证注解;基于数据信息,确定用于在前端页面获取输入的表单数据的表单项目,其中,前端页面与后端服务器为分离架构,分离架构为前端页面的功能部署与后端服务器的功能部署相互解耦;对后端验证注解进行转换,确定用于在前端页面对表单数据进行验证的表单验证规则;基于表单验证规则和表单项目,在前端页面生成前端表单,其中,前端表单与目标文件之间存在映射关系,目标文件用于对提交至后端服务器的前端表单进行处理。本文中的设备可以是服务器、PC等。An embodiment of the present invention provides an electronic device. The electronic device includes a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it implements the following steps: The target file is parsed to obtain the data information of the predetermined class and the back-end verification annotations; based on the data information, the form items used to obtain the input form data on the front-end page are determined. Among them, the front-end page and the back-end server are separated architectures. The architecture is that the functional deployment of the front-end page and the functional deployment of the back-end server are decoupled from each other; the back-end validation annotations are converted to determine the form validation rules used to validate the form data on the front-end page; based on the form validation rules and form items, A front-end form is generated on the front-end page, where there is a mapping relationship between the front-end form and the target file, and the target file is used to process the front-end form submitted to the back-end server. The devices in this article can be servers, PCs, etc.
本发明还提供了一种计算机程序产品,当在数据处理设备上执行时,适于执行初始化有如下方法步骤的程序:对后端服务器中预定类的目标文件进行解析,得到预定类的数据信息和后端验证注解;基于数据信息,确定用于在前端页面获取输入的表单数据的表单项目,其中,前端页面与后端服务器为分离架构,分离架构为前端页面的功能部署与后端服务器的功能部署相互解耦;对后端验证注解进行转换,确定用于在前端页面对表单数据进行验证的表单验证规则;基于表单验证规则和表单项目,在前端页面生成前端表单,其中,前端表单与目标文件之间存在映射关系,目标文件用于对提交至后端服务器的前端表单进行处理。The present invention also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program initialized with the following method steps: parsing the target file of a predetermined class in the back-end server to obtain data information of the predetermined class and back-end validation annotations; based on the data information, determine the form items used to obtain the input form data on the front-end page. Among them, the front-end page and the back-end server are separated architectures, and the separated architecture is the function deployment of the front-end page and the back-end server. Function deployment is decoupled from each other; the back-end validation annotations are converted to determine the form validation rules used to validate the form data on the front-end page; based on the form validation rules and form items, a front-end form is generated on the front-end page, in which the front-end form and There is a mapping relationship between target files, and the target files are used to process front-end forms submitted to the back-end server.
可选地,上述计算机程序产品还适用于执行初始化有如下方法步骤的程序:获取前端调用映射配置;基于前端调用映射配置指示对后端验证注解进行转换,确定后端验证注解对应的前端调用方法;基于前端调用方法,生成表单验证规则。Optionally, the above computer program product is also applicable to a program that performs the following initialization steps: obtains the front-end call mapping configuration; converts the back-end verification annotations based on the front-end call mapping configuration instructions, and determines the front-end calling method corresponding to the back-end verification annotations. ; Generate form validation rules based on the front-end calling method.
可选地,上述计算机程序产品还适用于执行初始化有如下方法步骤的程序:确定数据信息的数据类型;确定数据类型对应的输入框,得到表单项目。Optionally, the above-mentioned computer program product is also suitable for executing a program initialized with the following method steps: determining the data type of the data information; determining the input box corresponding to the data type, and obtaining the form items.
可选地,上述计算机程序产品还适用于执行初始化有如下方法步骤的程序:获取前端模板样式和前端接口;基于表单验证规则和表单项目,采用前端模板样式生成前端表单,其中,前端表单通过前端接口提交至后端服务器。Optionally, the above computer program product is also applicable to a program that performs the following initialization steps: obtain the front-end template style and front-end interface; based on the form validation rules and form items, use the front-end template style to generate the front-end form, wherein the front-end form passes through the front-end The interface is submitted to the backend server.
可选地,上述计算机程序产品还适用于执行初始化有如下方法步骤的程序:对后端服务器中的目标文件的源代码进行解析,得到目标文件中预定类的变量名,关键字,运算符;将变量名,关键字,以及运算符作为节点,生成抽象语法树;对抽象语法树进行遍历,得到数据信息和后端验证注解。Optionally, the above computer program product is also suitable for executing a program that has the following steps for initialization: parsing the source code of the target file in the back-end server to obtain the variable names, keywords, and operators of the predetermined class in the target file; Use variable names, keywords, and operators as nodes to generate an abstract syntax tree; traverse the abstract syntax tree to obtain data information and back-end verification annotations.
可选地,上述计算机程序产品还适用于执行初始化有如下方法步骤的程序:获取在表单项目中输入的表单数据;在表单数据通过表单验证规则校验的情况下,将前端表单提交至后端服务器。Optionally, the above-mentioned computer program product is also applicable to a program that performs the following initialization steps: obtaining the form data entered in the form item; and submitting the front-end form to the back-end when the form data is verified by the form validation rules. server.
可选地,上述计算机程序产品还适用于执行初始化有如下方法步骤的程序:基于表单验证规则和表单项目,生成初始表单;通过自定义配置接口,对初始表单进行调整,得到前端表单。Optionally, the above computer program product is also applicable to a program that performs the following initialization steps: generate an initial form based on form validation rules and form items; adjust the initial form through a custom configuration interface to obtain a front-end form.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each process and/or block in the flowchart illustrations and/or block diagrams, and combinations of processes and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device produce a use A device for realizing the functions specified in one process or multiple processes of the flowchart and/or one block or multiple blocks of the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that causes a computer or other programmable data processing apparatus to operate in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction means, the instructions The device implements the functions specified in a process or processes of the flowchart and/or a block or blocks of the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions may also be loaded onto a computer or other programmable data processing device, causing a series of operating steps to be performed on the computer or other programmable device to produce computer-implemented processing, thereby executing on the computer or other programmable device. Instructions provide steps for implementing the functions specified in a process or processes of a flowchart diagram and/or a block or blocks of a block diagram.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。存储器是计算机可读介质的示例。Memory may include non-volatile memory in computer-readable media, random access memory (RAM), and/or non-volatile memory in the form of read-only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes both persistent and non-volatile, removable and non-removable media that can be implemented by any method or technology for storage of information. Information may be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), and read-only memory. (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, Magnetic tape cassettes, tape disk storage or other magnetic storage devices or any other non-transmission medium can be used to store information that can be accessed by a computing device. As defined in this article, computer-readable media does not include transitory media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "comprises," "comprises," or any other variation thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements not only includes those elements, but also includes Other elements are not expressly listed or are inherent to the process, method, article or equipment. Without further limitation, an element qualified by the statement "comprises a..." does not exclude the presence of additional identical elements in the process, method, good, or device that includes the element.
本领域技术人员应明白,本发明的实施例可提供为方法、系统或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems or computer program products. Thus, the invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
以上仅为本发明的实施例而已,并不用于限制本发明。对于本领域技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本发明的权利要求范围之内。The above are only examples of the present invention and are not intended to limit the present invention. Various modifications and variations will occur to the present invention to those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention shall be included in the scope of the claims of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311560864.4A CN117667089A (en) | 2023-11-21 | 2023-11-21 | Front-end form generation method and device, storage medium and electronic equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311560864.4A CN117667089A (en) | 2023-11-21 | 2023-11-21 | Front-end form generation method and device, storage medium and electronic equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117667089A true CN117667089A (en) | 2024-03-08 |
Family
ID=90072514
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311560864.4A Pending CN117667089A (en) | 2023-11-21 | 2023-11-21 | Front-end form generation method and device, storage medium and electronic equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117667089A (en) |
-
2023
- 2023-11-21 CN CN202311560864.4A patent/CN117667089A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10592319B2 (en) | API notebook tool | |
US11561772B2 (en) | Low-code development platform | |
US9483260B1 (en) | Documentation generation for web APIs based on byte code analysis | |
EP3502896B1 (en) | Generation of an adapters configuration user interface using a data structure | |
US8082144B1 (en) | Tax calculation explanation generator | |
CN110968325B (en) | Applet conversion method and device | |
CN110806863A (en) | Interface document generation method and device, electronic equipment and storage medium | |
US10558434B2 (en) | Rule-based automatic class generation from a JSON message | |
CN104156313B (en) | Method for automatically generating Web service testing case | |
JP5197688B2 (en) | Integrated environment generator | |
US20090254881A1 (en) | Code generation techniques for administrative tasks | |
CN104461531B (en) | A kind of implementation method of reporting system SQL | |
US20150261507A1 (en) | Validating sql queries in a report | |
US10572278B2 (en) | Smart controls for user interface design and implementation | |
US10691434B2 (en) | System and method for converting a first programming language application to a second programming language application | |
CN117112060A (en) | Component library construction method, device, electronic equipment and storage medium | |
CN116755669A (en) | Low code development method and tool based on DSL language operation model | |
CN116028028B (en) | Request function generation method, device, equipment and storage medium | |
US9244706B2 (en) | Command line shell command generation based on schema | |
US10606569B2 (en) | Declarative configuration elements | |
CN112287266B (en) | A web page configuration processing method and its device, equipment and storage medium | |
CN111399842A (en) | Code compiling method and device | |
CN117667089A (en) | Front-end form generation method and device, storage medium and electronic equipment | |
Petukhova | Sitecore JavaScript Services Framework Comparison | |
Le Zou et al. | On synchronizing with web service evolution |
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 |