Disclosure of Invention
In order to solve the above technical problems, the present invention provides a method and an apparatus for converting an interface document into a data model file, which can be used to convert an interface document into a data model file, and does not require a user to write the data model file according to the interface document, and when the interface document has more fields and excessive hierarchies, it does not require a lot of labor and time costs, and simultaneously reduces the error rate.
The invention provides the following technical scheme:
in one aspect, an embodiment of the present invention provides a method for converting an interface document into a data model file, including the following steps:
receiving data information in an interface document input by a user, wherein the data information comprises first-layer data information, and the first-layer data information comprises first-layer attribute name information, first-layer attribute type information, first-layer attribute annotation information and first-layer method implementation information;
receiving a file name of a first-layer data model file input by a user, and calling out a corresponding first-layer data model file frame according to the file name of the first-layer data model file, wherein the first-layer data model file frame comprises a first-layer declaration file frame and a first-layer implementation file frame, the first-layer declaration file frame comprises an attribute frame of the first-layer declaration file, and the first-layer implementation file frame comprises a method implementation frame of the first-layer implementation file;
responding to a first-layer conversion operation of a user, respectively putting the first-layer attribute name information, the first-layer attribute type information and the first-layer attribute annotation information into an attribute frame of the first-layer declaration file, and putting the first-layer method implementation information into a method implementation frame of the first-layer implementation file;
and responding to the generation operation of a user, generating a first layer declaration file from the first layer declaration file framework, and generating a first layer implementation file from the first layer implementation file framework.
On the other hand, an embodiment of the present invention further provides an apparatus for converting an interface document into a data model file, including:
the receiving module is used for receiving data information in an interface document input by a user, wherein the data information comprises first-layer data information, and the first-layer data information comprises first-layer attribute name information, first-layer attribute type information, first-layer attribute annotation information and first-layer method implementation information;
the system comprises a calling-out module, a calling-out module and a calling-out module, wherein the calling-out module is used for receiving a file name of a first-layer data model file input by a user and calling out a corresponding first-layer data model file frame according to the file name of the first-layer data model file, the first-layer data model file frame comprises a first-layer declaration file frame and a first-layer implementation file frame, the first-layer declaration file frame comprises an attribute frame of the first-layer declaration file, and the first-layer implementation file frame comprises a method implementation frame of the first-layer implementation file;
the input module is used for responding to a first-layer conversion operation of a user, respectively inputting the first-layer attribute name information, the first-layer attribute type information and the first-layer attribute annotation information into an attribute frame of the first-layer declaration file, and inputting the first-layer method implementation information into a method implementation frame of the first-layer implementation file;
and the generating module is used for responding to the generating operation of the user, generating the first layer declaration file framework into a first layer declaration file, and generating the first layer realization file framework into a first layer realization file.
According to the method for converting the interface document into the data model file, disclosed by the embodiment of the invention, a user does not need to write the data model file according to the interface document, the data model file frame is written in advance, when the interface document is required to be converted into the data model file, the corresponding data model file frame is called out according to the selection operation of the user, the data information in the interface document is put into the corresponding position of the data model file frame, and then the frame is converted into the required file. Therefore, when the interface document has more fields and excessive levels, a large amount of labor and time cost is not required to be consumed, and meanwhile, the error rate is reduced.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The steps of the embodiments of the present invention illustrated in the flowchart of the figures may be performed in a computer system, such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
The terms "first" and "second" in the embodiments of the present invention are used to distinguish some features, which are set for convenience of understanding and are not limited in other aspects.
A method of converting an interface document into a data model file as shown in fig. 1, comprising the steps of:
s101: receiving data information in an interface document input by a user, wherein the data information comprises first-layer data information, and the first-layer data information comprises first-layer attribute name information, first-layer attribute type information, first-layer attribute annotation information and first-layer method implementation information.
The interface document can have a plurality of layers of data information, the data information of each layer can have different fields, each field is corresponding to attribute information and method implementation information, and the attribute information generally comprises attribute name information, attribute type information, attribute annotation information and the like. The attribute type information includes a character string type, a number type, an array type, and the like.
The data information in the interface document input by the user can be received by setting a text input box, and when the user needs to input the data information in the interface document, the user can jump to the corresponding text input box.
S102: the method comprises the steps of receiving a file name of a first-layer data model file input by a user, calling a corresponding first-layer data model file frame according to the file name of the first-layer data model file, wherein the first-layer data model file frame comprises a first-layer declaration file frame and a first-layer implementation file frame, the first-layer declaration file frame comprises an attribute frame of the first-layer declaration file, and the first-layer implementation file frame comprises a method implementation frame of the first-layer implementation file.
The first layer data model file frame is a file frame which is edited in advance before calling out. The first-layer declaration file framework generally comprises annotation information of the first-layer declaration file, header information imported by the first-layer declaration file, declaration class information of the first-layer declaration file, property boxes of the first-layer declaration file, and end flag information of the first-layer declaration file. The first-layer implementation file framework generally comprises annotation information of the first-layer implementation file, a name of a declaration file to be imported and a method implementation box of the first-layer implementation file. The attribute box of the first-layer declaration file may include a position box of first-layer attribute name information, a position box of first-layer attribute type information, a position box of first-layer attribute comment information, and the like. The method implementation frame of the first layer implementation file may include a location frame of the first layer method implementation information, and the like.
After the user inputs the data information in the interface document, the file name of the corresponding data model file can be directly input or selected in another input box, and then the corresponding first-layer data model file frame is called.
S103: and responding to the first-layer conversion operation of a user, respectively putting the first-layer attribute name information, the first-layer attribute type information and the first-layer attribute annotation information into an attribute frame of the first-layer declaration file, and putting the first-layer method implementation information into a method implementation frame of the first-layer implementation file.
After the user inputs the data information in the interface document and the file name of the data model file, the user can directly operate the conversion button to perform conversion operation. The first layer attribute name information, the first layer attribute type information and the first layer attribute annotation information are respectively put into the attribute frame of the first layer declaration file, and the first layer attribute name information may be put into a position frame of the first layer attribute name information in the attribute frame of the first layer declaration file, the first layer attribute type information may be put into a position frame of the first layer attribute type information in the attribute frame of the first layer declaration file, and the first layer attribute annotation information may be put into a position frame of the first layer attribute annotation information in the attribute frame of the first layer declaration file; the step of putting the first layer method implementation information into the method implementation frame of the first layer implementation file may be to put the first layer method implementation information into a position frame of the first layer method implementation information in the method implementation frame of the first layer implementation file.
S104: and responding to the generation operation of a user, generating a first layer declaration file from the first layer declaration file framework, and generating a first layer implementation file from the first layer implementation file framework.
After the conversion operation, the user may select a generation button, so as to generate the first layer declaration file from the first layer declaration file framework and generate the first layer implementation file from the first layer implementation file framework. At this time, the first-layer declaration file frame is a file frame in which the first-layer attribute name information, the first-layer attribute type information, and the first-layer attribute comment information are placed, and at this time, the first-layer implementation file frame is a file frame in which the first-layer method implementation information has been placed, so that the generated first-layer declaration file includes the first-layer attribute name information, the first-layer attribute type information, and the first-layer attribute comment information, and the generated first-layer implementation file includes the first-layer method implementation information.
According to the method for converting the interface document into the data model file, a user does not need to write the data model file according to the interface document, the data model file frame is written in advance, when the interface document is required to be converted into the data model file, the corresponding data model file frame is called out according to the selection operation of the user, data information in the interface document is put into the corresponding position of the data model file frame, and then the frame is converted into the required file. Therefore, when the interface document has more fields and excessive levels, a large amount of labor and time cost is not required to be consumed, and the error rate is reduced.
Based on the method for converting the interface document into the data model file shown in fig. 1, the method further includes:
and receiving the file name of the first-layer data model file input by the user, and simultaneously receiving the storage path of the first-layer data model file input by the user.
The storage path of the first-layer data model file may be a storage path selected and input by a user or a default storage path.
Based on the method for converting an interface document into a data model file shown in fig. 1, as shown in fig. 2, after the placing the first-layer attribute name information, the first-layer attribute type information, and the first-layer attribute annotation information into the attribute box of the first-layer declaration file and the first-layer method implementation information into the method implementation box of the first-layer implementation file, the method further includes:
s201: and judging whether the data information in the interface document has second layer data information, wherein the second layer data information comprises second layer attribute name information, second layer attribute type information, second layer attribute annotation information and second layer method implementation information.
The data information in the interface document has several layers, which are determined according to the specific content in the interface document. For example, the following interface documents:
the interface document comprises two layers of data information. The first layer data information includes three fields of information: the data information of type a, the data information of type b and the data information of type c; the second layer data information includes nine field information: data information of a0 type, data information of a1 type, data information of a2 type, data information of b0 type, data information of b1 type, data information of b2 type, data information of c0 type, data information of c1 type, data information of c2 type.
S202: and if the data information in the interface document has second-layer data information, judging whether a user needs to generate a second-layer data model file according to the selection of the user.
S203: if the user selects to generate the second layer data model file, receiving the file name of the second layer data model file input by the user, and calling out a corresponding second layer data model file frame according to the file name of the second layer data model file, wherein the second layer data model file frame comprises a second layer declaration file frame and a second layer realization file frame, the second layer declaration file frame comprises an attribute frame of the second layer declaration file, and the second layer realization file frame comprises a method realization frame of the second layer realization file.
If the user selects to generate the second layer data model file, the user can jump to another interface, so that the user can input or select the file name of the corresponding data model file, and then call out the corresponding second layer data model file frame.
The second layer data model file frame is a file frame which is edited in advance before being called. The second layer declaration file framework generally includes annotation information of the second layer declaration file, header file information of the second layer declaration file import, declaration class information of the second layer declaration file, property boxes of the second layer declaration file, and end flag information of the second layer declaration file. The second-layer implementation file framework generally comprises annotation information of the second-layer implementation file, a name of a declaration file to be imported and a method implementation box of the second-layer implementation file. The attribute box of the second layer declaration file may include a location box of second layer attribute name information, a location box of second layer attribute type information, a location box of second layer attribute comment information, and the like. The method implementation frame of the second layer implementation file may include a location frame of second layer method implementation information, and the like.
S204: and responding to a second layer conversion operation of a user, respectively putting the second layer attribute name information, the second layer attribute type information and the second layer attribute annotation information into an attribute frame of the second layer declaration file, and putting the second layer method implementation information into a method implementation frame of the second layer implementation file.
After the user inputs the file name of the second layer data model file, the user can directly operate the conversion button to perform conversion operation. The second layer attribute name information, the second layer attribute type information and the second layer attribute annotation information are respectively put into the attribute frame of the second layer declaration file, and may be that the second layer attribute name information is put into a position frame of the second layer attribute name information in the attribute frame of the second layer declaration file, the second layer attribute type information is put into a position frame of the second layer attribute type information in the attribute frame of the second layer declaration file, and the second layer attribute annotation information is put into a position frame of the second layer attribute annotation information in the attribute frame of the second layer declaration file; the step of putting the second layer method implementation information into the method implementation frame of the second layer implementation file may be to put the second layer method implementation information into a position frame of the second layer method implementation information in the method implementation frame of the second layer implementation file.
In the method for converting the interface document into the data model file according to the embodiment of the present invention, not only the first layer of data information in the interface document can be converted into the corresponding data model file, but also the second layer of data information can be converted into the corresponding data model file according to the user's requirement, and of course, if there is the third layer of data information, the fourth layer of data information, and the like, the data information of different layers can be converted into different data model files according to the method.
Based on the method for converting the interface document into the data model file shown in fig. 1 and 2, in response to the generation operation of the user, the second layer declaration file framework is further generated into a second layer declaration file, and the second layer implementation file framework is generated into a second layer implementation file.
The method for converting an interface document into a data model file based on fig. 1, wherein after the first-layer attribute name information, the first-layer attribute type information, and the first-layer attribute annotation information are respectively put into an attribute box of the first-layer declaration file and put into a method implementation box of the first-layer implementation file, and before responding to a generating operation of a user, the method further includes:
s301: displaying the first layer declaration file frame and the first layer realization file frame;
s302: and responding to the modification operation of the user on the first layer declaration file frame and the first layer implementation file frame, and modifying and storing the first layer declaration file frame and the first layer implementation file frame.
Before generating the declaration file and the implementation file, the user can modify the first-layer declaration file frame and the first-layer implementation file frame according to the requirement of the user.
The apparatus for converting an interface document into a data model file as shown in fig. 3 comprises:
the receiving module is used for receiving data information in an interface document input by a user, wherein the data information comprises first-layer data information, and the first-layer data information comprises first-layer attribute name information, first-layer attribute type information, first-layer attribute annotation information and first-layer method implementation information;
the system comprises a calling-out module, a calling-out module and a calling-out module, wherein the calling-out module is used for receiving a file name of a first-layer data model file input by a user and calling out a corresponding first-layer data model file frame according to the file name of the first-layer data model file, the first-layer data model file frame comprises a first-layer declaration file frame and a first-layer implementation file frame, the first-layer declaration file frame comprises an attribute frame of the first-layer declaration file, and the first-layer implementation file frame comprises a method implementation frame of the first-layer implementation file;
the input module is used for responding to a first-layer conversion operation of a user, respectively inputting the first-layer attribute name information, the first-layer attribute type information and the first-layer attribute annotation information into an attribute frame of the first-layer declaration file, and inputting the first-layer method implementation information into a method implementation frame of the first-layer implementation file;
and the generating module is used for responding to the generating operation of the user, generating a first layer declaration file from the first layer declaration file frame, and generating a first layer realization file from the first layer realization file frame.
The device for converting the interface document into the data model file of the embodiment of the invention can be used for realizing the method shown in fig. 1, and does not need a user to write the data model file according to the interface document, wherein the data model file frame is written in advance, when the interface document needs to be converted into the data model file, the corresponding data model file frame is called out according to the selection operation of the user, the data information in the interface document is put into the corresponding position of the data model file frame, and then the frame is converted into the required file. Therefore, when the interface document has more fields and excessive levels, a large amount of labor and time cost is not required to be consumed, and meanwhile, the error rate is reduced.
The device for converting the interface document into the data model file is based on the device shown in FIG. 3, wherein:
and the calling-out module is also used for receiving the file name of the first-layer data model file input by the user and simultaneously receiving the storage path of the first-layer data model file input by the user.
Based on the apparatus for converting the interface document into the data model file shown in fig. 3, as shown in fig. 4, it further includes:
a first judging module, configured to respectively put the first layer attribute name information, the first layer attribute type information, and the first layer attribute annotation information into an attribute box of the first layer declaration file and put the first layer method implementation information into a method implementation box of the first layer implementation file, and then judge whether data information in the interface document has second layer data information, where the second layer data information includes second layer attribute name information, second layer attribute type information, second layer attribute annotation information, and second layer method implementation information;
the second judgment module is used for judging whether a user needs to generate a second layer data model file according to the selection of the user if the data information in the interface document has second layer data information;
the calling-out module is further used for receiving a file name of the second layer data model file input by a user and calling out a corresponding second layer data model file frame according to the file name of the second layer data model file if the user selects to generate the second layer data model file, wherein the second layer data model file frame comprises a second layer declaration file frame and a second layer implementation file frame, the second layer declaration file frame comprises an attribute frame of the second layer declaration file, and the second layer implementation file frame comprises a method implementation frame of the second layer implementation file;
and the input module is further used for responding to a second layer conversion operation of a user, respectively inputting the second layer attribute name information, the second layer attribute type information and the second layer attribute annotation information into an attribute frame of the second layer declaration file, and inputting the second layer method implementation information into a method implementation frame of the second layer implementation file.
The apparatus for converting an interface document into a data model file as shown in fig. 4, wherein the generating module is further configured to respond to a generating operation of a user, generate a second layer declaration file from the second layer declaration file framework, and generate a second layer implementation file from the second layer implementation file framework.
Based on the apparatus for converting the interface document into the data model file shown in fig. 3, as shown in fig. 5, it further includes:
the display module is used for respectively putting the first layer attribute name information, the first layer attribute type information and the first layer attribute annotation information into an attribute frame of the first layer declaration file, putting the first layer method implementation information into a method implementation frame of the first layer implementation file, and displaying the first layer declaration file frame and the first layer implementation file frame before responding to the generation operation of a user;
and the modification module is used for responding to the modification operation of the first layer declaration file frame and the first layer realization file frame by a user, and modifying and storing the first layer declaration file frame and the first layer realization file frame.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present invention may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a terminal device (which may be a mobile phone, a personal computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
Those skilled in the art can understand that the modules in the devices in the embodiments can be distributed in the devices in the embodiments according to the description of the embodiments, and the modules can be located in one or more devices different from the embodiments with corresponding changes. The modules of the above embodiments may be integrated into one body, or may be separately deployed; the sub-modules can be combined into one module, or can be further split into a plurality of sub-modules.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and improvements can be made without departing from the principle of the present invention, and such modifications and improvements should also be considered within the scope of the present invention.