CN110175022B - Method and device for automatically generating POJO class, storage medium and computer equipment - Google Patents

Method and device for automatically generating POJO class, storage medium and computer equipment Download PDF

Info

Publication number
CN110175022B
CN110175022B CN201910340983.6A CN201910340983A CN110175022B CN 110175022 B CN110175022 B CN 110175022B CN 201910340983 A CN201910340983 A CN 201910340983A CN 110175022 B CN110175022 B CN 110175022B
Authority
CN
China
Prior art keywords
field
information
interface
attribute
newly added
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.)
Active
Application number
CN201910340983.6A
Other languages
Chinese (zh)
Other versions
CN110175022A (en
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen 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 Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201910340983.6A priority Critical patent/CN110175022B/en
Publication of CN110175022A publication Critical patent/CN110175022A/en
Priority to PCT/CN2019/117595 priority patent/WO2020215680A1/en
Application granted granted Critical
Publication of CN110175022B publication Critical patent/CN110175022B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Abstract

The invention provides a method and a device for automatically generating POJO classes, a storage medium and computer equipment, wherein the method comprises the following steps: creating a target interface document, wherein newly added interface information is filled in the target interface document; defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document; and scanning the newly added interface information in the target interface document and the attribute corresponding to the POJO class to generate the POJO class. According to the method, POJO class does not need to be manually written according to the newly added interface information of the target interface document, and the efficiency of interface development is improved.

Description

Method and device for automatically generating POJO class, storage medium and computer equipment
Technical Field
The invention relates to the technical field of interface codes, in particular to a method and a device for automatically generating POJO classes, a storage medium and computer equipment.
Background
In the system project development process, the project is generally divided into a plurality of sub-projects, each of which is developed separately. After the sub-projects are developed, a plurality of sub-projects are connected through interfaces. How to define an interface and how to write an interface document, developers of sub-items that need interfacing agree together.
In general, the interaction among sub-projects in the system is mostly realized by excel interface documents. When updating the document content of the interface, the POJO class is written in the code corresponding to the interface. When the number of newly added fields is excessive, the writing of POJO is relatively troublesome, and partial fields are easy to miss.
Disclosure of Invention
The invention provides a method and a device for automatically generating POJO classes, a storage medium and computer equipment, which are used for automatically generating the POJO classes based on interface information of an interface document, so that the efficiency of interface development is improved.
The invention provides the following scheme:
a method for automatically generating POJO classes based on interface documents, comprising: creating a target interface document, wherein newly added interface information is filled in the target interface document; defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document; and scanning the newly added interface information in the target interface document and the attribute corresponding to the POJO class to generate the POJO class.
In one embodiment, the target interface document comprises an interface document of an excel sheet; the newly added interface information comprises field information of a newly added interface; defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document, wherein the attribute comprises the following steps: defining different annotation attributes corresponding to different fields in the POJO class in field information of the newly added interface in an interface document of the excel table; the step of scanning the newly added interface information in the target interface document and the corresponding attribute in the POJO class to generate the POJO class includes: and scanning field information of the newly added interface in the interface document of the excel form and the annotation attribute of each field in the field information, and generating the POJO class according to the field information and the annotation attribute of each field.
In one embodiment, the field information further includes data information corresponding to each field; defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document, and further comprising: defining data type attributes corresponding to each field in the field information of the newly added interface in the interface document of the excel table; the scanning the field information of the newly added interface in the interface document of the excel table and the annotation attribute of each field in the field information, generating the POJO class according to the field information and the annotation attribute of each field, including: scanning field information of the newly added interface in the interface document of the excel form, and the annotation attribute of each field in the field information and the data type attribute of the data information corresponding to each field, and generating the POJO class according to the field information, the annotation attribute of each field and the data type attribute of the data information corresponding to each field.
In one embodiment, the field information further includes a field value corresponding to each field; defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document, and further comprising: defining a field value attribute of the corresponding field value of each field in the POJO class according to the data type attribute of the data information corresponding to each field in an interface document of the excel table; the scanning the field information of the newly added interface in the interface document of the excel table, and the comment attribute of each field in the field information and the data type attribute of the data information corresponding to each field, generating the POJO class according to the field information, the comment attribute of each field and the data type attribute of the data information corresponding to each field, includes: scanning field information of the newly added interface in the interface document of the excel form, the annotation attribute of each field in the field information, the data type attribute of the data information corresponding to each field, and the field value attribute of the field value corresponding to each field, and generating the POJO class according to the field information, the annotation attribute of each field, the data type attribute of the data information corresponding to each field, and the field value attribute of the field value corresponding to each field.
In one embodiment, the newly added interface information includes a class name of the POJO class generated according to the newly added interface, and a field value of an interface field, a digital type of the field and a field length; defining the attribute of the new interface information corresponding to the POJO class in the target interface document, scanning the new interface information in the target interface document and the attribute corresponding to the POJO class, and generating the POJO class, including: defining a name attribute of the class name corresponding to the POJO class in the target interface document, and defining a numerical value attribute of the interface field of which the field value corresponds to the POJO class, a numerical value type attribute of the field of which the numerical type corresponds to the POJO class and a length value attribute of the field of which the length corresponds to the POJO class; scanning the class name and the name attribute in the target interface document, and generating the POJO class by a field value and the numerical value attribute of the interface field, a digital type and the numerical value type attribute of the field, and a field length and the length value attribute of the field.
In one embodiment, the newly added interface information includes parallel incoming parameter information and parameter returning information in the newly added interface; defining the attribute of the new interface information corresponding to the POJO class in the target interface document, scanning the new interface information in the target interface document and the attribute corresponding to the POJO class, and generating the POJO class, including: defining class name attributes of the input parameter information corresponding to the POJO class in the target interface document, filling the class name attributes in a previous row of the input parameter information in the target interface document, scanning the input parameter information in the target interface document and the class name attributes corresponding to the POJO class, and generating a first POJO class; and according to the property of the back-reference information, defining Map attribute or List attribute of the back-reference information corresponding to the POJO class in the target interface document, scanning the back-reference information in the target interface document and the Map attribute or List attribute corresponding to the POJO class, and generating a second POJO class.
In one embodiment, the creating the target interface document includes: when confirming that an object code of a newly added interface receives an instruction for generating an interface document, acquiring a code annotation in the object code; reading the newly added interface information from the code annotation; classifying the newly added interface information to obtain newly added interface information of a plurality of categories and association relations among the newly added interface information of each category; filling the newly added interface information of each category into an interface document according to the newly added interface information of the plurality of categories and the association relation between the newly added interface information of each category so as to obtain the target interface document.
An apparatus for automatically generating POJO classes based on interface documents, comprising: the creation module creates a target interface document, wherein newly added interface information is filled in the target interface document; the definition module is used for defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document; and the generating module is used for scanning the newly added interface information in the target interface document and the attribute corresponding to the POJO class to generate the POJO class.
A storage medium having a computer program stored thereon; the computer program is adapted to be loaded by a processor and to perform the method of automatically generating POJO classes based on interface documents as described in any of the embodiments above.
A computer apparatus, comprising: one or more processors; a memory; one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications configured to perform the method of automatically generating POJO classes based on interface documents according to any of the embodiments described above.
According to the method for automatically generating the POJO class based on the interface document, the target interface document is created, the newly added interface information is filled in the target interface document, and the attribute of the newly added interface information in the POJO class is defined. Because the attribute of the newly added interface information in the corresponding POJO class is defined in the target interface document, when the corresponding POJO class is generated according to the target interface document, the newly added interface information in the target interface document and the attribute of the newly added interface information in the POJO class can be directly scanned, so that the corresponding POJO class can be automatically generated. Therefore, POJO class does not need to be manually written according to the newly added interface information of the target interface document, and the efficiency of interface development is improved.
Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Drawings
The foregoing and/or additional aspects and advantages of the invention will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, in which:
FIG. 1 is a flow chart of a method for automatically generating POJO classes based on interface documents according to one embodiment of the present invention;
FIG. 2 is a flow chart of a part of a method for automatically generating POJO class based on an interface document according to an embodiment of the present invention;
FIG. 3 is a partial flow chart of a method for automatically generating POJO classes based on an interface document according to another embodiment of the present invention;
FIG. 4 is a partial flow chart of a method for automatically generating POJO classes based on an interface document according to another embodiment of the present invention;
FIG. 5 is a block diagram illustrating an exemplary embodiment of an apparatus for automatically generating POJO classes based on interface documents according to the present invention;
fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present invention.
Detailed Description
Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are illustrative only and are not to be construed as limiting the invention.
It will be understood by those within the art that, unless expressly stated otherwise, the singular forms "a," "an," "the," and "the" are intended to include the plural forms as well, and that "first," "second," and "the" are used herein merely to distinguish one and the same technical feature and do not limit the order, quantity, etc. of that technical feature. It will be further understood that the terms "comprises" and/or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It will be understood by those skilled in the art that all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs unless defined otherwise. It will be further understood that terms, such as those defined in commonly used dictionaries, should be interpreted as having a meaning that is consistent with their meaning in the context of the prior art and will not be interpreted in an idealized or overly formal sense unless expressly so defined herein.
The invention provides a method for automatically generating POJO class based on an interface document, which can automatically generate the corresponding POJO class in a java format according to the interface document when a developer writes codes based on the interface document, and does not need the developer to manually write the codes of the POJO class, thereby improving the development efficiency. In order to better describe the method for automatically generating POJO classes according to the present invention, the following explanation will be given for the relevant background knowledge of the method:
the software program interface is an interface for interaction between a software component or an application service and the outside. It is similar to a black box, inputs information while outputting information, and logic control is performed inside the box to determine and output information according to the input information. In order to better realize the interfacing of system interaction, a developer writes an interface document based on the implementation function of the interface so as to develop and encode based on the interface document. The contents of the interface document typically contain an interface specification, an interface request mode (e.g., GET/POST/RETRIEVE/UPDATE requests, etc.), a description of the interface address called, request parameters, and return parameters. When writing codes based on the interface document, corresponding POJO classes are required to be written according to part of interface information in the interface document for code operation. For example, the request parameters and the return parameters in the interface document are respectively written into POJO classes corresponding to the request parameters and the return parameters. In a general development process, a developer writes the interface information in the interface document into a corresponding POJO class.
The invention provides a method for automatically generating POJO class based on interface document. In one embodiment, as shown in fig. 1, the method for automatically generating the POJO class based on the interface document includes the following steps:
s100, creating a target interface document, wherein newly added interface information is filled in the target interface document.
In this embodiment, the system may create the target interface document based on the interface information of the newly added interface. And the target interface document is filled with newly added interface information of the newly added interface. The newly added interface information is information for characterizing the interface function of the newly created interface. For example, a database interface is added. The database interface is used for providing a connection path for connecting the database to the outside. The data information in the database can be read through the database interface or sent to the database for storage by the database. At this time, the newly added interface information of the newly added database interface includes information defining a transmission protocol, a data transmission format, and the like of data input and output.
In one embodiment, as shown in fig. 2, step S100 includes:
s101, when the object code of the newly added interface is confirmed to receive an instruction for generating an interface document, code annotation in the object code is acquired.
S103, reading the newly added interface information from the code annotation.
S105, classifying the newly added interface information to obtain newly added interface information of a plurality of categories and association relations among the newly added interface information of each category.
S107, filling the newly added interface information of each category into an interface document according to the newly added interface information of the plurality of categories and the association relation between the newly added interface information of each category so as to obtain the target interface document.
In this embodiment, the system automatically creates the target interface document. And when the target interface file is the target code of the newly added interface and receives a corresponding instruction, the corresponding newly added interface information is obtained by reading the code annotation of the target code. The newly added interface information is further classified into class a, class B and class C. And the A, B and C types have association relation, and the newly added interface information is automatically added into the interface document according to the association relation, so that the target interface document is obtained. In the automatically generated target interface document, the newly added interface information is obtained by analyzing and reading according to the code annotation, and the attribute of the newly added interface information corresponding to the POJO class is not included. Therefore, only newly added interface information is filled in the created target interface document.
S200, defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document.
In this embodiment, the system performs interface development according to the target interface document, and at this time, newly added interface information in the target interface document needs to be written into a corresponding java object in the form of a POJO class, and finally, the function of the newly added interface is implemented by running the code of the java object. Here, the attribute of the newly added interface information when converting to the POJO class is defined in the target interface document. Specifically, the newly added interface information defined by the target interface document contains a certain value, and the value attribute of the value in the POJO class can be integer int, integer long or double-precision floating point double and the like. The newly added interface information defined by the target interface document contains characters, and the character attribute of the characters in the POJO class is char type.
S300, scanning the newly added interface information in the target interface document and the attribute corresponding to the POJO class to generate the POJO class.
In this embodiment, after the new interface information is filled in the target interface document and the attribute of each new interface information in the corresponding POJO class is defined, each new interface information and the attribute in the corresponding POJO class in the document may be directly scanned, the information type of each new interface information is analyzed, and the basic writing model of the POJO class is determined according to the type. Further, according to the attribute in the POJO class of the newly added interface information, the java code of the newly added interface information is written in the corresponding basic writing model of the POJO class, so that the POJO class is generated.
In an embodiment, the target interface document comprises an interface document of an excel sheet; the newly added interface information includes field information of the newly added interface. As shown in fig. 3, step S200 includes:
s210, defining different fields in the field information of the newly added interface in the interface document of the excel table to correspond to different annotation attributes in the POJO class.
Step S300 at this time includes:
s310, scanning field information of the newly added interface in the interface document of the excel form and the annotation attribute of each field in the field information, and generating the POJO class according to the field information and the annotation attribute of each field.
The interaction of a general system adopts an interface document of an excel table. In this embodiment, the newly added interface uses the interface document of the excel form to write the newly added interface information. The newly added interface information contains field information of a plurality of newly added interfaces. When the field information is written into the corresponding POJO class, different annotation descriptions are often performed on different field information. And filling the annotation attribute of each field in the field information into an interface document of an excel table, and associating the field with the annotation attribute so that the annotation attribute corresponding to the field can be read out simultaneously when the interface document of the excel table is scanned, and further, the POJO class is generated according to each field of the field information and the annotation attribute of each field.
Further, the field information also contains data information corresponding to each field. At this time, step S200 further includes: and defining the data type attribute corresponding to each field in the field information of the newly added interface in the interface document of the excel table. Step S310 includes: scanning field information of the newly added interface in the interface document of the excel form, and the annotation attribute of each field in the field information and the data type attribute of the data information corresponding to each field, and generating the POJO class according to the field information, the annotation attribute of each field and the data type attribute of the data information corresponding to each field.
Specifically, each field contains data information. The interface document of the excel form is filled with a plurality of data information, and each data information is defined with a corresponding data type attribute in the POJO class. Such as an int attribute, a long attribute, or a double attribute, etc. And defining a corresponding data type attribute in each piece of digital information of the interface document of the excel form, so that after the interface document of the excel form is scanned, the POJO class can be generated according to field information in the document, the annotation attribute of each field and the data type attribute of the data information corresponding to each field.
In one implementation of this embodiment, the field information further includes a field value corresponding to each field. At this time, step S200 further includes: and defining a field value attribute of which the field value corresponds to in the POJO class according to the data type attribute of the data information corresponding to each field in the interface document of the excel table. The scanning the field information of the newly added interface in the interface document of the excel table, and the comment attribute of each field in the field information and the data type attribute of the data information corresponding to each field, generating the POJO class according to the field information, the comment attribute of each field and the data type attribute of the data information corresponding to each field, includes: scanning field information of the newly added interface in the interface document of the excel form, the annotation attribute of each field in the field information, the data type attribute of the data information corresponding to each field, and the field value attribute of the field value corresponding to each field, and generating the POJO class according to the field information, the annotation attribute of each field, the data type attribute of the data information corresponding to each field, and the field value attribute of the field value corresponding to each field.
Specifically, each field in the field information also corresponds to a field value, and each field value has a corresponding field value attribute in the POJO class. The field value attribute of the corresponding field value in the POJO class is defined according to the data type attribute of the data information corresponding to each field. For example, assuming that in the interface document of the excel table, a field value corresponding to a field is 1 and a data type attribute of data information corresponding to the field is an int attribute, the field value attribute is defined as int 1 in the interface document of the excel table. If the data type attribute of the data information corresponding to the field is a double attribute, defining the field value attribute as double 1 in the interface document of the excel form. Therefore, the POJO class can be generated according to the field information in the interface document of the excel table, the annotation attribute of each field, the data type attribute of the data information corresponding to each field, and the field value attribute of the field value corresponding to each field.
In a specific implementation process, different java files are generated by scanning data in an interface document of an excel form, wherein fields with data types of a database in the interface document of the excel form need to be converted into corresponding data types in the java, different fields are used for filling in different notes, and finally a field value is defined.
According to the method for automatically generating the POJO class based on the interface document, the target interface document is created, the newly added interface information is filled in the target interface document, and the attribute of the newly added interface information in the POJO class is defined. Because the attribute of the newly added interface information in the corresponding POJO class is defined in the target interface document, when the corresponding POJO class is generated according to the target interface document, the newly added interface information in the target interface document and the attribute of the newly added interface information in the POJO class can be directly scanned, so that the corresponding POJO class can be automatically generated. Therefore, POJO class does not need to be manually written according to the newly added interface information of the target interface document, and the efficiency of interface development is improved.
In a specific embodiment, the new interface information includes a class name of the POJO class generated according to the new interface, and a field value of an interface field, a number type of the field, and a field length. As shown in fig. 4, step S200 includes:
s201, defining a name attribute of the class name corresponding to the POJO class in the target interface document, and defining a numerical value attribute of the interface field value corresponding to the POJO class, a numerical value type attribute of the field corresponding to the numerical value type attribute in the POJO class and a length value attribute of the field length corresponding to the POJO class.
Step S300, including:
s301, scanning the class name and the name attribute in the target interface document, and generating the POJO class by the field value and the numerical value attribute of the interface field, the digital type and the numerical value type attribute of the field and the field length and the length value attribute of the field.
Specifically, POJO class name applyNoInfo, field key value applyNo, data type and length varchar2 are defined in the target interface document (10). The field describes the information of the application number, whether Y is filled in or not, remark the application number and the like. The POJO class generated by scanning the target interface document is as follows:
in an embodiment, the newly added interface information includes parallel incoming parameter information and return parameter information in the newly added interface. Defining the attribute of the new interface information corresponding to the POJO class in the target interface document, scanning the new interface information in the target interface document and the attribute corresponding to the POJO class, and generating the POJO class, including: defining class name attributes of the input parameter information corresponding to the POJO class in the target interface document, filling the class name attributes in a previous row of the input parameter information in the target interface document, scanning the input parameter information in the target interface document and the class name attributes corresponding to the POJO class, and generating a first POJO class; and according to the property of the back-reference information, defining Map attribute or List attribute of the back-reference information corresponding to the POJO class in the target interface document, scanning the back-reference information in the target interface document and the Map attribute or List attribute corresponding to the POJO class, and generating a second POJO class.
In a specific implementation, a standard excel form template is created for filling in the newly added interfaces or fields. By identifying the corresponding table field, for example, the name of the class can be input in the previous row of the parameter input in the merging row, and a POJO class is generated after the table is scanned. And for the back-up parameters, corresponding POJO classes are generated according to each Map or List defined by the back-up parameters. The table template can also confirm the entry, the return and each item of the return through the provided font color or the combination line number or defining an identifier.
The invention also provides a device for automatically generating POJO class based on the interface document. In one embodiment, as shown in fig. 5, the apparatus for automatically generating the POJO class based on the interface document includes a creation module 10, a definition module 20, and a generation module 30.
The creation module 10 creates a target interface document in which newly added interface information is filled. In this embodiment, the system may create the target interface document based on the interface information of the newly added interface. And the target interface document is filled with newly added interface information of the newly added interface. The newly added interface information is information for characterizing the interface function of the newly created interface. For example, a database interface is added. The database interface is used for providing a connection path for connecting the database to the outside. The data information in the database can be read through the database interface or sent to the database for storage by the database. At this time, the newly added interface information of the newly added database interface includes information defining a transmission protocol, a data transmission format, and the like of data input and output.
The definition module 20 is configured to define, in the target interface document, an attribute of the new interface information corresponding to the POJO class. In this embodiment, the system performs interface development according to the target interface document, and at this time, newly added interface information in the target interface document needs to be written into a corresponding java object in the form of a POJO class, and finally, the function of the newly added interface is implemented by running the code of the java object. Here, the attribute of the newly added interface information when converting to the POJO class is defined in the target interface document. Specifically, the newly added interface information defined by the target interface document contains a certain value, and the value attribute of the value in the POJO class can be integer int, integer long or double-precision floating point double and the like. The newly added interface information defined by the target interface document contains characters, and the character attribute of the characters in the POJO class is char type.
The generating module 30 is configured to scan the newly added interface information in the target interface document and the attribute corresponding to the POJO class, and generate the POJO class. In this embodiment, after the new interface information is filled in the target interface document and the attribute of each new interface information in the corresponding POJO class is defined, each new interface information and the attribute in the corresponding POJO class in the document may be directly scanned, the information type of each new interface information is analyzed, and the basic writing model of the POJO class is determined according to the type. Further, according to the attribute in the POJO class of the newly added interface information, the java code of the newly added interface information is written in the corresponding basic writing model of the POJO class, so that the POJO class is generated.
In other embodiments, each module in the device for automatically generating the POJO class based on the interface document provided by the present invention is further configured to execute the method for automatically generating the POJO class based on the interface document according to the present invention, and the operations executed corresponding to each step are not described in detail herein.
The invention also provides a storage medium. The storage medium has a computer program stored thereon; the method for automatically generating POJO class based on the interface document according to any one of the embodiments is realized when the computer program is executed by a processor. The storage medium may be a memory. Such as internal memory or external memory, or both. The internal memory may include read-only memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), flash memory, or random access memory. The external memory may include a hard disk, floppy disk, ZIP disk, U-disk, tape, etc. The storage media disclosed herein include, but are not limited to, these types of memory. The memory disclosed herein is by way of example only and not by way of limitation.
The invention also provides computer equipment. A computer device comprising: one or more processors; a memory; one or more applications. Wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications configured to perform the method of automatically generating POJO classes based on interface documents of any of the embodiments described above.
Fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the invention. The computer device in this embodiment may be a server, a personal computer, or a network device. As shown in fig. 6, the apparatus includes a processor 603, a memory 605, an input unit 607, a display unit 609, and the like. Those skilled in the art will appreciate that the device architecture shown in fig. 6 does not constitute a limitation of all devices, and may include more or fewer components than shown, or may combine certain components. The memory 605 may be used to store an application 601 and various functional modules, and the processor 603 runs the application 601 stored in the memory 605 to perform various functional applications of the device and data processing. The memory may be internal memory or external memory, or include both internal memory and external memory. The internal memory may include read-only memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), flash memory, or random access memory. The external memory may include a hard disk, floppy disk, ZIP disk, U-disk, tape, etc. The disclosed memory includes, but is not limited to, these types of memory. The memory disclosed herein is by way of example only and not by way of limitation.
The input unit 607 is for receiving input of a signal and receiving keywords input by a user. The input unit 607 may include a touch panel and other input devices. The touch panel may collect touch operations on or near the user (e.g., the user's operation on or near the touch panel using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a preset program; other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., play control keys, switch keys, etc.), a trackball, mouse, joystick, etc. The display unit 609 may be used to display information input by a user or information provided to the user and various menus of the computer device. The display unit 609 may take the form of a liquid crystal display, an organic light emitting diode, or the like. The processor 603 is a control center of the computer device, connects various parts of the entire computer using various interfaces and lines, performs various functions and processes data by running or executing software programs and/or modules stored in the memory 605, and invoking data stored in the memory.
In one embodiment, the device includes one or more processors 603, and one or more memories 605, one or more applications 601. Wherein the one or more application programs 601 are stored in the memory 605 and configured to be executed by the one or more processors 603, the one or more application programs 601 configured to perform the method of automatically generating POJO classes based on interface documents described in the above embodiments.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing module, or each unit may exist alone physically, or two or more units may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated modules may also be stored in a computer readable storage medium if implemented in the form of software functional modules and sold or used as a stand-alone product.
Those of ordinary skill in the art will appreciate that all or a portion of the steps implementing the above embodiments may be implemented by hardware, or may be implemented by a program to instruct related hardware, where the program may be stored in a computer readable storage medium, and the storage medium may include a memory, a magnetic disk, an optical disk, or the like.
The foregoing is only a partial embodiment of the present invention, and it should be noted that it will be apparent to those skilled in the art that modifications and adaptations can be made without departing from the principles of the present invention, and such modifications and adaptations are intended to be comprehended within the scope of the present invention.
It should be understood that each functional unit in the embodiments of the present invention may be integrated in one processing module, or each unit may exist alone physically, or two or more units may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules.
The foregoing is only a partial embodiment of the present invention, and it should be noted that it will be apparent to those skilled in the art that modifications and adaptations can be made without departing from the principles of the present invention, and such modifications and adaptations are intended to be comprehended within the scope of the present invention.

Claims (6)

1. A method for automatically generating POJO classes based on interface documents, comprising:
creating a target interface document filled with newly added interface information, comprising: when confirming that an object code of a newly added interface receives an instruction for generating an interface document, acquiring a code annotation in the object code; reading the newly added interface information from the code annotation; classifying the newly added interface information to obtain newly added interface information of a plurality of categories and association relations among the newly added interface information of each category; filling the newly added interface information of each category into an interface document according to the newly added interface information of the plurality of categories and the association relation between the newly added interface information of each category so as to obtain the target interface document;
Defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document, scanning the newly added interface information in the target interface document and the attribute corresponding to the POJO class, and generating the POJO class;
if the target interface document comprises an interface document of an excel table, and the newly added interface information comprises field information of a newly added interface, different fields in the field information of the newly added interface are defined in the interface document of the excel table to correspond to different annotation attributes in a POJO class; scanning field information of the newly added interface in the interface document of the excel form and the annotation attribute of each field in the field information, and generating the POJO class according to the field information and the annotation attribute of each field;
if the newly added interface information comprises a class name of the POJO class generated according to the newly added interface, a field value of an interface field, a digital type of the field and a field length, defining a name attribute of the class name corresponding to the POJO class in the target interface document, a numerical value attribute of the interface field corresponding to the POJO class, a numerical value type attribute of the field corresponding to the numerical value type attribute of the POJO class and a length value attribute of the field length corresponding to the POJO class in the target interface document; scanning the class name and the name attribute thereof in the target interface document, and generating the POJO class by a field value and the numerical value attribute thereof of the interface field, a digital type and the numerical value type attribute thereof of the field, and a length and the length value attribute thereof;
If the newly added interface information comprises parallel input parameter information and return parameter information in the newly added interface, defining class name attributes of the input parameter information in POJO classes in the target interface document, filling the class name attributes in a previous row of the input parameter information in the target interface document, scanning the input parameter information in the target interface document and the class name attributes in the POJO classes, and generating a first POJO class; and according to the property of the back-reference information, defining Map attribute or List attribute of the back-reference information corresponding to the POJO class in the target interface document, scanning the back-reference information in the target interface document and the Map attribute or List attribute corresponding to the POJO class, and generating a second POJO class.
2. The method of claim 1, wherein the field information further comprises data information corresponding to each field; defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document, and further comprising: defining data type attributes corresponding to each field in the field information of the newly added interface in the interface document of the excel table;
The scanning the field information of the newly added interface in the interface document of the excel table and the annotation attribute of each field in the field information, generating the POJO class according to the field information and the annotation attribute of each field, including:
scanning field information of the newly added interface in the interface document of the excel form, and the annotation attribute of each field in the field information and the data type attribute of the data information corresponding to each field, and generating the POJO class according to the field information, the annotation attribute of each field and the data type attribute of the data information corresponding to each field.
3. The method of claim 2, wherein the field information further comprises a field value corresponding to each field; defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document, and further comprising: defining a field value attribute of the corresponding field value of each field in the POJO class according to the data type attribute of the data information corresponding to each field in an interface document of the excel table;
The scanning the field information of the newly added interface in the interface document of the excel table, and the comment attribute of each field in the field information and the data type attribute of the data information corresponding to each field, generating the POJO class according to the field information, the comment attribute of each field and the data type attribute of the data information corresponding to each field, includes:
scanning field information of the newly added interface in the interface document of the excel form, the annotation attribute of each field in the field information, the data type attribute of the data information corresponding to each field, and the field value attribute of the field value corresponding to each field, and generating the POJO class according to the field information, the annotation attribute of each field, the data type attribute of the data information corresponding to each field, and the field value attribute of the field value corresponding to each field.
4. An apparatus for automatically generating POJO class based on interface document, comprising:
the creation module creates a target interface document filled with newly added interface information, comprising: when confirming that an object code of a newly added interface receives an instruction for generating an interface document, acquiring a code annotation in the object code; reading the newly added interface information from the code annotation; classifying the newly added interface information to obtain newly added interface information of a plurality of categories and association relations among the newly added interface information of each category; filling the newly added interface information of each category into an interface document according to the newly added interface information of the plurality of categories and the association relation between the newly added interface information of each category so as to obtain the target interface document;
The definition module is used for defining the attribute of the newly added interface information corresponding to the POJO class in the target interface document, and the generation module is used for scanning the newly added interface information in the target interface document and the attribute corresponding to the POJO class to generate the POJO class;
if the target interface document includes an interface document of an excel table, and the newly added interface information includes field information of a newly added interface, the definition module is further configured to define, in the interface document of the excel table, different annotation attributes corresponding to different fields in the field information of the newly added interface in a POJO class; the generating module is further configured to scan field information of the newly added interface in the interface document of the excel table, and the annotation attribute of each field in the field information, and generate the POJO class according to the field information and the annotation attribute of each field;
if the newly added interface information includes a class name of the POJO class generated according to the newly added interface, and a field value of an interface field, a digital type of the field and a field length, the definition module is further configured to define, in the target interface document, a name attribute of the class name corresponding to the POJO class, and a numerical attribute of the field value of the interface field corresponding to the POJO class, a numerical type attribute of the field digital type corresponding to the POJO class, and a length value attribute of the field length corresponding to the POJO class; the generating module is further configured to scan the class name and the name attribute thereof in the target interface document, and a field value and the numerical value attribute thereof of the interface field, a digital type and the numerical value type attribute thereof of the field, and a field length and the length value attribute thereof, to generate the POJO class;
If the newly added interface information comprises parallel input parameter information and parallel return parameter information in the newly added interface, the definition module is further configured to define a class name attribute of the input parameter information corresponding to a POJO class in the target interface document, fill the class name attribute in a previous line of the input parameter information in the target interface document, and the generation module is further configured to scan the input parameter information in the target interface document and the class name attribute corresponding to the POJO class, so as to generate a first POJO class; the definition module is further configured to define, according to the property of the back-reference information, a Map attribute or a List attribute of the back-reference information corresponding to the POJO class in the target interface document, and the generation module is further configured to scan the back-reference information in the target interface document and the Map attribute or the List attribute corresponding to the POJO class, and generate a second POJO class.
5. A storage medium having a computer program stored thereon; the computer program is adapted to be loaded by a processor and to perform the method of automatically generating POJO classes based on interface documents as claimed in any of the preceding claims 1 to 3.
6. A computer device, comprising:
One or more processors;
a memory;
one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, the one or more applications configured to perform the method of automatically generating POJO classes based on interface documents according to any one of claims 1 to 3.
CN201910340983.6A 2019-04-25 2019-04-25 Method and device for automatically generating POJO class, storage medium and computer equipment Active CN110175022B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910340983.6A CN110175022B (en) 2019-04-25 2019-04-25 Method and device for automatically generating POJO class, storage medium and computer equipment
PCT/CN2019/117595 WO2020215680A1 (en) 2019-04-25 2019-11-12 Method and apparatus for automatically generating pojo class, and storage medium and computer device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910340983.6A CN110175022B (en) 2019-04-25 2019-04-25 Method and device for automatically generating POJO class, storage medium and computer equipment

Publications (2)

Publication Number Publication Date
CN110175022A CN110175022A (en) 2019-08-27
CN110175022B true CN110175022B (en) 2023-10-13

Family

ID=67690085

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910340983.6A Active CN110175022B (en) 2019-04-25 2019-04-25 Method and device for automatically generating POJO class, storage medium and computer equipment

Country Status (2)

Country Link
CN (1) CN110175022B (en)
WO (1) WO2020215680A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110175022B (en) * 2019-04-25 2023-10-13 平安科技(深圳)有限公司 Method and device for automatically generating POJO class, storage medium and computer equipment
CN110633076B (en) * 2019-09-16 2021-05-04 杭州趣链科技有限公司 Method for automatically generating identity intelligent contract Java client program

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103383645A (en) * 2013-07-29 2013-11-06 北京邮电大学 Code generation method and system
US8856642B1 (en) * 2013-07-22 2014-10-07 Recommind, Inc. Information extraction and annotation systems and methods for documents
JP2015052875A (en) * 2013-09-06 2015-03-19 日本電信電話株式会社 Software component generation apparatus, software component generation method, and management system
CN108268253A (en) * 2017-05-05 2018-07-10 平安科技(深圳)有限公司 Interface code generation method and terminal device
CN108874924A (en) * 2018-05-31 2018-11-23 康键信息技术(深圳)有限公司 Creation method, device and the computer readable storage medium of search service
CN109298861A (en) * 2018-10-19 2019-02-01 中国银行股份有限公司 A kind of method and device automatically generating file according to interface document
CN109375922A (en) * 2018-09-26 2019-02-22 深圳壹账通智能科技有限公司 A kind of automatic generation method and terminal device of interface document
CN109634607A (en) * 2018-12-13 2019-04-16 泰康保险集团股份有限公司 A kind of method and device of Code automatic build

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473045A (en) * 2013-08-27 2013-12-25 广州华多网络科技有限公司 Method and device for generating interface documents
CN107463376A (en) * 2017-07-21 2017-12-12 珠海牛角科技有限公司 The method and device for automatically generating back end interface document based on Javadoc
US10839011B2 (en) * 2018-04-18 2020-11-17 International Business Machines Corporation Application programing interface document generator
CN109032663A (en) * 2018-07-09 2018-12-18 深圳市小牛在线互联网信息咨询有限公司 Generation method, device, computer equipment and the storage medium of interface document
CN110175022B (en) * 2019-04-25 2023-10-13 平安科技(深圳)有限公司 Method and device for automatically generating POJO class, storage medium and computer equipment

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8856642B1 (en) * 2013-07-22 2014-10-07 Recommind, Inc. Information extraction and annotation systems and methods for documents
CN103383645A (en) * 2013-07-29 2013-11-06 北京邮电大学 Code generation method and system
JP2015052875A (en) * 2013-09-06 2015-03-19 日本電信電話株式会社 Software component generation apparatus, software component generation method, and management system
CN108268253A (en) * 2017-05-05 2018-07-10 平安科技(深圳)有限公司 Interface code generation method and terminal device
CN108874924A (en) * 2018-05-31 2018-11-23 康键信息技术(深圳)有限公司 Creation method, device and the computer readable storage medium of search service
CN109375922A (en) * 2018-09-26 2019-02-22 深圳壹账通智能科技有限公司 A kind of automatic generation method and terminal device of interface document
CN109298861A (en) * 2018-10-19 2019-02-01 中国银行股份有限公司 A kind of method and device automatically generating file according to interface document
CN109634607A (en) * 2018-12-13 2019-04-16 泰康保险集团股份有限公司 A kind of method and device of Code automatic build

Also Published As

Publication number Publication date
CN110175022A (en) 2019-08-27
WO2020215680A1 (en) 2020-10-29

Similar Documents

Publication Publication Date Title
Hoffmann et al. Requirements for requirements management tools
US10699067B2 (en) Form design and data input in which a server provides a repository of form templates that are distributed to multiple form filing client systems
KR101224813B1 (en) Relationship modeling
US8745581B2 (en) Method and system for selectively copying portions of a document contents in a computing system (smart copy and paste
JP5087261B2 (en) Data element naming system and method
CN106874244B (en) Method for constructing automatic document generation model based on work sequence
US9411798B1 (en) Methods and apparatus for reusing report design components and templates
KR101114189B1 (en) Label system-translation of text and multi-language support at runtime and design
US20060136433A1 (en) File formats, methods, and computer program products for representing workbooks
CN1609764A (en) System and method for providing context to an input method
CN103778107A (en) Method and platform for quickly and dynamically generating form based on EXCEL
Chillón et al. A model-driven approach to generate schemas for object-document mappers
CN104881275A (en) Electronic spreadsheet generating method and device
US10699112B1 (en) Identification of key segments in document images
CN106648569B (en) Target serialization realization method and device
Demuth et al. Supporting the co-evolution of metamodels and constraints through incremental constraint management
Langer et al. From UML profiles to EMF profiles and beyond
CN110175022B (en) Method and device for automatically generating POJO class, storage medium and computer equipment
CN111753140A (en) XML file parsing method and related equipment
CN102460381A (en) Software extension analysis
Schippers et al. Leveraging UML profiles to generate plugins from visual model transformations
MXPA03004411A (en) System and method for defining and using subclasses declaratively within markup.
US20060004836A1 (en) Dynamic forms generation
US11977473B2 (en) Providing a pseudo language for manipulating complex variables of an orchestration flow
CN113687827B (en) Data list generation method, device and equipment based on widget and storage 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
GR01 Patent grant
GR01 Patent grant