Method and system for directly generating back-end code package from form image
By identifying hand-drawn form images to generate data model definition files and dynamically generate back-end code packages, the problem of low development efficiency of form functions in the existing technology is solved, efficient and flexible back-end code generation is achieved, and development efficiency and code readability are improved.
Patent Information
- Application Number
- CN202510411467.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-02
- Publication Date
- 2025-07-22
AI Technical Summary
In the existing technology, form function development efficiency is low, and low-code generation tools cannot generate back-end code with strong readability, cannot improve the efficiency of developers, and lack flexibility and scalability.
The hand-drawn form image is identified through OCR technology, a data model definition file is generated, and a back-end code package is dynamically generated based on the file, including modifying the configuration file and dynamically populating the field name, and generating highly readable and editable back-end code.
Improves software development efficiency, and development engineers can directly generate back-end source code through pictures, saving repetitive work, and the generated code is highly consistent, readable and editable.
Smart Images

Figure CN120353460A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to computer communication technologies, and particularly to a method and system for directly generating a backend code package from a form image. Background Art
[0002] Currently, in various management systems, a large number of form functions need to be developed. The development of form functions mainly involves product designers drawing prototype diagrams, UI designers producing high-fidelity prototype diagrams, and developers developing through manual programming such as HTML and Java. This results in repetitive workload, time-consuming, and unskilled work. At the same time, in the industry, low-code is used as a tool platform for rapid development of forms. The applications generated by low-code cannot generate readable source code, do not have the characteristics of secondary editing and in-depth customization, cannot generate highly readable backend code, and cannot be used as a tool for developers to improve development efficiency. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide a method and system for directly generating a backend code package from a form image, which can effectively improve the development efficiency in the software development process and has flexibility and scalability.
[0004] A method for directly generating a backend code package from a form image in the present invention includes: Obtaining a form image based on a hand-drawn form design diagram; Identifying the form image and performing structured processing to parse and generate a data model definition file; Generating a backend code package according to the data model definition file.
[0005] Further, the step of obtaining a form image based on a hand-drawn form design diagram includes: Taking a photo of the hand-drawn form design diagram through a terminal device to obtain a form image.
[0006] Further, the step of identifying the form image and performing structured processing to parse and generate a data model definition file includes: Invoking the server OCR interface, identifying the key form elements in the image through OCR technology, and extracting them as a structured data file; Reading the structured data file through a code generator tool, sequentially and cyclically obtaining the key data elements of the form, and identifying the data elements as fields of the information input type; Extracting the data type of the field, invoking the Chinese-to-English translation interface, converting the Chinese text in the field into an English database field name, and retrieving the data type of the field through the field type library on the server side; Generating a database definition file according to the identified fields and the identified data types; Generate a database generation file through a database definition file for the generation and initialization of the database.
[0007] Furthermore, generating a backend code package according to the data model definition file includes: Modify the configuration file of the code generator tool, and name each backend code service of the form in the configuration file; Dynamically obtain the schema template file of the backend code, and dynamically modify the output code file name according to the naming in the configuration file; Read the database definition file, dynamically fill the field names in each backend code file, and generate a backend code package.
[0008] Furthermore, the key elements of the form at least include buttons, input boxes, and text.
[0009] A system for directly generating a backend code package from a form image in the present invention includes: An image acquisition application and device for obtaining a form image based on a hand-drawn form design drawing; A data file parsing tool for identifying the form image and performing structured processing, and parsing and generating a data model definition file; And a code generation plugin for generating a backend code package according to the data model definition file.
[0010] Furthermore, the image acquisition application and device are specifically used for: taking a photo of the hand-drawn form design drawing through a terminal device to obtain a form image.
[0011] Furthermore, the data file parsing tool is specifically used for: Call the server OCR interface, identify the key elements of the form in the image through OCR technology, and extract them as a structured data file; Read the structured data file through the code generator tool, sequentially loop to obtain the key data elements of the form, and identify the data elements as fields of the information input type; Extract the data type of the field, call the Chinese translation interface, convert the Chinese text in the field to an English database field name, and retrieve the data type of the field through the field type library on the server side; Generate a database definition file according to the identified fields and data types; Generate a database generation file through the database definition file for the generation and initialization of the database.
[0012] Furthermore, the code generation plugin is specifically used for: Modify the configuration file of the code generator tool, and name each backend code service of the form in the configuration file; Dynamically obtain the schema template file of the backend code, and dynamically modify the name of the output code file according to the naming in the configuration file; Read the database definition file, dynamically fill in the field names in each backend code file, and generate a backend code package.
[0013] Furthermore, the key form elements at least include buttons, input boxes, and text.
[0014] The beneficial effects of the present invention are as follows: The present invention can effectively improve the development efficiency in the software development process. Development engineers can directly generate backend source code from pictures, saving a large amount of repetitive work; and it has flexibility and scalability: The program code package generated based on pictures has a high degree of consistency with the code structure of conventional programming and has high readability and editability. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to make the objectives, technical solutions, and beneficial effects of the present invention clearer, the present invention provides the following drawings for description: Figure 1 It is a schematic flow diagram of the present invention; Figure 2 It is a detailed schematic flow diagram of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0016] The technical solutions of the present invention will be described in detail below with reference to the drawings and embodiments.
[0017] Embodiment 1 As Figure 1 - Figure 2 shown, a method for directly generating a backend code package from a form image in this embodiment includes the following steps: S1. Based on the hand-drawn form design drawing, obtain the form image.
[0018] In this step, specifically, the hand-drawn form design drawing is photographed by a terminal device to obtain the form image. That is: First, the product engineer or business personnel draw the form design drawing by hand to describe the key business information through the form design drawing. Then, the development engineer takes a photo through a scanning device or a mobile phone APP to obtain the form image.
[0019] S2. Identify the form image and perform structured processing, and parse and generate a data model definition file. Specifically, it includes: S201, calling the server OCR interface, using OCR (Optical Character Recognition) technology to identify key elements of the form in the image, and extracting them into a structured data file; wherein the key elements of the form include at least buttons, input boxes, and text. The extraction result is similar to: [{type: input, text: name}, {type: button, text: registration}].
[0020] S202, read the structured data file through the code generator tool, loop through the key data elements of the form in sequence, and identify the data elements as fields of information input types such as input, textarea, option, etc.
[0021] S203, extract the data type of the field, call the Chinese translation interface, convert the Chinese text in the field into the English database field name, and retrieve the data type of the field through the field type library on the server; for example, the database field name of 'name' is name; if the translation fails, it is replaced by pinyin; then the field type is retrieved through the field type library built by the server (the library is based on daily maintenance), for example: the field text is the name, and the field type is locked as string after the search; if the search fails, it is processed as the general type String.
[0022] S204: Generate a database definition file according to the identified fields and the identified data types.
[0023] S205. Generate a database generation file xx.Sql through the database definition file for generating and initializing the database.
[0024] S3. Generate a backend code package based on the data model definition file. Specifically includes: S301. Modify the configuration file of the code generator tool. In the configuration file, name each backend code service of the form; for example, modify it to register.
[0025] S302. Dynamically obtain the schema template file of the backend code, which includes xxxControoler, xxxService, xxxDAO, and xxx.Xml respectively; according to the naming in the configuration file, dynamically modify the output code file name: registerController.java, registerService.java, registerDAO.java, register.Xml.
[0026] S303. Read the database definition file, dynamically fill in the field names in each backend code file, and generate a backend code package. After downloading the backend code package, it has high readability and editability.
[0027] In summary, the above method can effectively improve the development efficiency in the software development process. Development engineers can directly generate backend source code from pictures, saving a lot of repetitive work; and it has flexibility and scalability: the program code package generated based on pictures has a high degree of consistency with the code structure of regular programming and has high readability and editability.
[0028] Embodiment 2 A system for directly generating a backend code package from a form image in this embodiment includes: An image acquisition application and device for obtaining a form image based on a hand-drawn form design diagram; A data file parsing tool for identifying the form image and performing structured processing, and parsing and generating a data model definition file; And a code generation plugin for generating a backend code package according to the data model definition file.
[0029] In this embodiment, the image acquisition application and device are specifically used for: taking a photo of the hand-drawn form design diagram through a terminal device to obtain a form image.
[0030] In this embodiment, the data file parsing tool is specifically used for: Calling the server OCR interface, identifying the key form elements in the image through OCR technology, and extracting them as a structured data file; Reading the structured data file through a code generator tool, sequentially and circularly obtaining the key data elements of the form, and identifying the data elements as fields of the information input type; Extracting the data type of the field, calling the Chinese translation interface, converting the Chinese text in the field into an English database field name, and retrieving the data type of the field through the field type library on the server side; Generating a database definition file according to the identified fields and the identified data types; Generating a database generation file through the database definition file for the generation and initialization of the database.
[0031] In this embodiment, the code generation plugin is specifically used for: Modifying the configuration file of the code generator tool, and naming each backend code service of the form in the configuration file; Dynamically obtaining the schema template file of the backend code, and dynamically modifying the output code file name according to the naming in the configuration file; Read the database definition file, dynamically fill in the field names in each backend code file, and generate the backend code package.
[0032] In this embodiment, the form key elements at least include buttons, input boxes, and texts.
[0033] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the spirit and scope of the technical solutions of the present invention, and they should all be covered within the scope of the claims of the present invention.
Claims
1. A method for directly generating a back-end code package from a form image, characterized in that, including: Based on the hand-drawn form design drawing, obtain the form image; Identify the form image and perform structured processing, and parse and generate a data model definition file; Generate a backend code package according to the data model definition file.
2. The method for directly generating a backend code package from a form image according to claim 1, wherein The obtaining the form image based on the hand-drawn form design drawing includes: Take a photo of the hand-drawn form design drawing through a terminal device to obtain the form image.
3. The method for directly generating a back-end code package from a form image according to claim 1, wherein The identifying the form image and performing structured processing, and parsing and generating a data model definition file includes: Call the server OCR interface, identify the key form elements in the image through OCR technology, and extract them as a structured data file; Read the structured data file through a code generator tool, sequentially loop to obtain the key form data elements, and identify the data elements as fields of the information input type; Extract the data type of the field, call the Chinese translation interface, convert the Chinese text in the field into an English database field name, and retrieve the data type of the field through the field type library on the server side; Generate a database definition file according to the identified fields and the identified data types; Generate a database generation file through the database definition file for the generation and initialization of the database.
4. The method for directly generating a backend code package from a form image according to claim 3, characterized in that, The generating a backend code package according to the data model definition file includes: Modify the configuration file of the code generator tool, and name each backend code service of the form in the configuration file; Dynamically obtain the schema template file of the backend code, and dynamically modify the output code file name according to the naming in the configuration file; Read the database definition file, dynamically fill in the field names in each backend code file, and generate a backend code package.
5. The method for directly generating a backend code package from a form image according to claim 3, wherein: The key form elements at least include buttons, input boxes, and texts.
6. A system for directly generating a back-end code package from a form image, characterized in that, including: An image acquisition application and device for obtaining a form image based on a hand-drawn form design drawing; A data file parsing tool for identifying the form image and performing structured processing, and parsing and generating a data model definition file; And a code generation plugin for generating a backend code package according to the data model definition file.
7. The system for directly generating a backend code package from a form image according to claim 6, wherein The image acquisition application and device is specifically used for: taking a photo of the hand-drawn form design drawing through a terminal device to obtain the form image.
8. The method for directly generating a backend code package from a form image according to claim 6, characterized in that, The data file parsing tool is specifically used for: Call the server OCR interface, identify the key form elements in the image through OCR technology, and extract them as a structured data file; Read the structured data file through a code generator tool, sequentially loop to obtain the key form data elements, and identify the data elements as fields of the information input type; Extract the data type of the field, call the Chinese translation interface, convert the Chinese text in the field into an English database field name, and retrieve the data type of the field through the field type library on the server side; Generate a database definition file according to the identified fields and the identified data types; Generate a database generation file through the database definition file for the generation and initialization of the database.
9. The system for directly generating a backend code package from a form image according to claim 8, wherein The code generation plugin is specifically used for: Modify the configuration file of the code generator tool, and name each backend code service of the form in the configuration file; Dynamically obtain the schema template file of the backend code, and dynamically modify the output code file name according to the naming in the configuration file; Read the database definition file, dynamically fill in the field names in each back-end code file, and generate the back-end code package.
10. The system for directly generating a back-end code package from a form image according to claim 8, characterized in that: The key form elements at least include buttons, input boxes, and text.