Data processing method, device, equipment and computer readable storage medium

文档序号:1936818 发布日期:2021-12-07 浏览:16次 中文

阅读说明:本技术 数据处理方法、装置、设备及计算机可读存储介质 (Data processing method, device, equipment and computer readable storage medium ) 是由 李东卫 杨洋 朱孝瑾 都业广 冯硕 于 2020-06-29 设计创作,主要内容包括:本发明实施例提供一种数据处理方法、装置、设备及计算机可读存储介质。该方法包括:在编译过程中,解析程序代码中的接口注解信息,得到接口信息;根据所述接口信息自动生成数据模型文件。本发明的方法,通过在编译过程中,解析程序代码中的接口注解信息,得到接口信息;根据所述接口信息自动生成数据模型文件,实现了接口信息及数据模型文件的自动生成,在接口发生变动时,重新编译即可及时地完成接口信息及数据模型文件的自动更新,提高了效率,并且克服了由于接口文档的更新不及时,且容易出现遗漏的情况,导致前端无法准确地获取到后台数据,从而导致前端页面出现无法访问、返回数据错误等异常的技术问题。(The embodiment of the invention provides a data processing method, a data processing device, data processing equipment and a computer readable storage medium. The method comprises the following steps: in the compiling process, interface annotation information in the program code is analyzed to obtain interface information; and automatically generating a data model file according to the interface information. In the method, interface annotation information in the program code is analyzed in the compiling process to obtain interface information; the data model file is automatically generated according to the interface information, automatic generation of the interface information and the data model file is achieved, when the interface changes, automatic updating of the interface information and the data model file can be timely completed through recompilation, efficiency is improved, and the technical problems that due to the fact that updating of an interface document is not timely and omission easily occurs, a front end cannot accurately acquire background data, and therefore the front end page cannot be accessed and data return errors and other exceptions occur are solved.)

1. A data processing method, comprising:

in the compiling process, interface annotation information in the program code is analyzed to obtain interface information;

and automatically generating a data model file according to the interface information.

2. The method of claim 1, after automatically generating the data model file according to the interface information, further comprising:

and automatically submitting the data model file to a preset code warehouse.

3. The method of claim 1 or 2, wherein automatically generating a data model file from the interface information comprises:

and automatically generating a data model file of the target interface corresponding to the specified operating system type according to the interface information, the target interface identifier and the specified operating system type.

4. The method of claim 3, wherein before automatically generating the data model file of the target interface corresponding to the specified operating system type according to the interface information, the target interface identifier and the specified operating system type, the method further comprises:

and receiving the target interface identifier and the specified operating system type sent by the front end, wherein the specified operating system type is input by a user through a front end page.

5. The method of claim 4, after automatically generating the data model file of the target interface corresponding to the specified operating system type according to the interface information, the target interface identifier and the specified operating system type, further comprising:

and submitting the data model file of the target interface corresponding to the specified operating system type to a specified code warehouse.

6. The method of claim 5, wherein prior to submitting the data model file of the target interface corresponding to the specified operating system type to a specified code repository, further comprising:

and receiving the address information of the specified code warehouse sent by the front end, wherein the address information of the specified code warehouse is input by a user through a front end page.

7. The method according to claim 1, wherein in the compiling process, after parsing the interface annotation information in the program code to obtain the interface information, further comprising:

and generating an interface document according to the interface information.

8. The method according to claim 1 or 7, wherein during the compiling process, after parsing the interface annotation information in the program code to obtain the interface information, the method further comprises:

and sending the interface information to a front end so as to display the interface information through a front end page.

9. The method of claim 1, wherein the interface annotation information comprises an ingress parameter annotation and an egress parameter annotation for an interface;

the analyzing the interface annotation information in the program code to obtain the interface information comprises:

scanning each class in the program code, and if the class contains an exit parameter annotation, storing the information of the exit parameter annotation on all member variables in the class into a first MAP set;

if the class is a Controller class, scanning whether each method in the class contains entry parameter annotation, and if at least one method in the class contains entry parameter annotation, storing the information of the entry parameter annotation of the at least one method in a first mapping MAP set.

10. The method according to claim 9, wherein the entry parameter annotation comprises a first attribute and a second attribute, the value of the first attribute is the name of the interface, and the value of the second attribute is the description information of each entry parameter of the interface;

the exit parameter annotation comprises a third attribute and a fourth attribute, the value of the third attribute is the name of the interface, the value of the fourth attribute is the description information of each exit parameter, and the number of the fourth attribute in the exit parameter annotation of the interface is consistent with the number of the exit parameters of the interface.

11. The method of claim 10, wherein if at least one method of the class includes an ingress parameter annotation, saving information of the ingress parameter annotation of the at least one method in the first MAP set comprises:

if at least one method in the category contains entry parameter annotations, taking the value of the first attribute of the entry parameter annotation of each method as a key, taking the value of the second attribute of the entry parameter annotation of the method as a value, and storing the value into the first MAP set.

12. The method of claim 10, wherein if the class includes an egress parameter annotation, saving information of the egress parameter annotation on all member variables in the class in the first MAP set comprises:

if the class contains the exit parameter annotations, the field name of each member variable in the class and the value of the fourth attribute of the corresponding exit parameter annotation are respectively used as key and value to form a key value pair, and the key value pairs corresponding to all the member variables in the class form a second MAP set; and taking the value of the third attribute of the exit parameter annotation as a key, taking the second MAP set as a value, and storing the value into the first MAP set.

13. The method of claim 12, further comprising:

and if the class contains member variables of the preset data type, storing information of the exit parameter annotation of the definition class corresponding to the member variables of the preset data type into the first MAP set in a recursive mode, wherein the first MAP set contains nested model information.

14. The method of claim 13, further comprising:

and if the interface information contains the nesting model information, generating a data model file containing the nesting model by adopting a recursive mode according to the interface information.

15. A data processing apparatus, comprising:

the annotation analysis module is used for analyzing the interface annotation information in the program code in the compiling process to obtain interface information;

and the information processing module is used for automatically generating a data model file according to the interface information.

16. A data processing apparatus, characterized by comprising:

a processor, a memory, and a computer program stored on the memory and executable on the processor;

wherein the processor, when executing the computer program, implements the method of any of claims 1 to 14.

17. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 14.

Technical Field

The present invention relates to the field of computer technologies, and in particular, to a data processing method, apparatus, device, and computer readable storage medium.

Background

In the existing software development process, a front-end developer needs to obtain background data through an interface program written by a back-end developer, and front-end and back-end butt joint is completed.

Currently, a back-end developer usually records information of an interface into an interface document manually, and performs a certain description on a background interface. The front-end developer analyzes the returned data and puts the analyzed returned data into use by checking the json format of the interface returned data in the interface document, and the interface document needs to be referred in the use process.

If the interface changes, a back-end developer needs to manually modify the interface document and informs all front-end related personnel to modify the corresponding data model, and due to the fact that the back-end developer is heavy in task, the interface document is often not updated timely, omission easily occurs, the front end cannot accurately acquire background data, and therefore the front-end page is abnormal in the aspects of incapability of accessing, data return error and the like.

Disclosure of Invention

Embodiments of the present invention provide a data processing method, an apparatus, a device, and a computer-readable storage medium, which are used to solve the problems in the prior art that a back-end developer needs to manually write and modify an interface document, a front-end developer manually generates a data model according to the interface document, the interface document is not updated timely, and omission easily occurs, so that the front-end cannot accurately obtain background data, and abnormalities such as incapability of accessing a front-end page and data return error occur.

In one aspect, an embodiment of the present invention provides a data processing method, including:

in the compiling process, interface annotation information in the program code is analyzed to obtain interface information;

and automatically generating a data model file according to the interface information.

In one possible design, after the automatically generating the data model file according to the interface information, the method further includes:

and automatically submitting the data model file to a preset code warehouse.

In one possible design, the automatically generating the data model file according to the interface information includes:

and automatically generating a data model file of the target interface corresponding to the specified operating system type according to the interface information, the target interface identifier and the specified operating system type.

In a possible design, before automatically generating, according to the interface information, the target interface identifier, and the specified operating system type, the data model file of the target interface corresponding to the specified operating system type, the method further includes:

and receiving the target interface identifier and the specified operating system type sent by the front end, wherein the specified operating system type is input by a user through a front end page.

In a possible design, after automatically generating a data model file of a target interface corresponding to a specified operating system type according to the interface information, a target interface identifier, and the specified operating system type, the method further includes:

and submitting the data model file of the target interface corresponding to the specified operating system type to a specified code warehouse.

In one possible design, before submitting the data model file of the target interface corresponding to the specified operating system type to a specified code repository, the method further includes:

and receiving the address information of the specified code warehouse sent by the front end, wherein the address information of the specified code warehouse is input by a user through a front end page.

In a possible design, after parsing the interface annotation information in the program code during the compiling process to obtain the interface information, the method further includes:

and generating an interface document according to the interface information.

In one possible design, in the compiling process, after parsing the interface annotation information in the program code to obtain the interface information, the method further includes:

and sending the interface information to a front end so as to display the interface information through a front end page.

In one possible design, the interface annotation information includes an entry parameter annotation and an exit parameter annotation of the interface; the analyzing the interface annotation information in the program code to obtain the interface information comprises:

scanning each class in the program code, and if the class contains an exit parameter annotation, storing the information of the exit parameter annotation on all member variables in the class into a first MAP set;

if the class is a Controller class, scanning whether each method in the class contains entry parameter annotation, and if at least one method in the class contains entry parameter annotation, storing the information of the entry parameter annotation of the at least one method in a first mapping MAP set.

In one possible design, the entry parameter annotation includes a first attribute and a second attribute, the value of the first attribute is the name of the interface, and the value of the second attribute is description information of each entry parameter of the interface; the exit parameter annotation comprises a third attribute and a fourth attribute, the value of the third attribute is the name of the interface, the value of the fourth attribute is the description information of each exit parameter, and the number of the fourth attribute in the exit parameter annotation of the interface is consistent with the number of the exit parameters of the interface.

In one possible design, if at least one method of the class includes an entry parameter annotation, saving information of the entry parameter annotation of the at least one method in the first MAP set includes:

if at least one method in the category contains entry parameter annotations, taking the value of the first attribute of the entry parameter annotation of each method as a key, taking the value of the second attribute of the entry parameter annotation of the method as a value, and storing the value into the first MAP set.

In one possible design, if the class includes an exit parameter annotation, saving information of the exit parameter annotation on all member variables in the class in the first MAP set includes:

if the class contains the exit parameter annotations, the field name of each member variable in the class and the value of the fourth attribute of the corresponding exit parameter annotation are respectively used as key and value to form a key value pair, and the key value pairs corresponding to all the member variables in the class form a second MAP set; and taking the value of the third attribute of the exit parameter annotation as a key, taking the second MAP set as a value, and storing the value into the first MAP set.

In one possible design, the method further includes:

and if the class contains member variables of the preset data type, storing information of the exit parameter annotation of the definition class corresponding to the member variables of the preset data type into the first MAP set in a recursive mode, wherein the first MAP set contains nested model information.

In one possible design, the method further includes:

and if the interface information contains the nesting model information, generating a data model file containing the nesting model by adopting a recursive mode according to the interface information.

In another aspect, an embodiment of the present invention provides a data processing apparatus, including:

the annotation analysis module is used for analyzing the interface annotation information in the program code in the compiling process to obtain interface information;

and the information processing module is used for automatically generating a data model file according to the interface information.

In one possible design, the apparatus further includes:

and the sending module is used for automatically submitting the data model file to a preset code warehouse.

In one possible design, the information processing module is further configured to:

and automatically generating a data model file of the target interface corresponding to the specified operating system type according to the interface information, the target interface identifier and the specified operating system type.

In one possible design, the apparatus further includes:

and the receiving module is used for receiving the target interface identifier and the specified operating system type sent by the front end, wherein the specified operating system type is input by a user through a front end page.

In one possible design, the sending module is further configured to:

and submitting the data model file of the target interface corresponding to the specified operating system type to a specified code warehouse.

In one possible design, the receiving module is further configured to:

and receiving the address information of the specified code warehouse sent by the front end, wherein the address information of the specified code warehouse is input by a user through a front end page.

In one possible design, the information processing module is further configured to:

and generating an interface document according to the interface information.

In one possible design, the sending module is further configured to:

and sending the interface information to a front end so as to display the interface information through a front end page.

In one possible design, the interface annotation information includes an entry parameter annotation and an exit parameter annotation of the interface; the annotation parsing module is further configured to:

scanning each class in the program code, and if the class contains an exit parameter annotation, storing the information of the exit parameter annotation on all member variables in the class into a first MAP set; if the class is a Controller class, scanning whether each method in the class contains entry parameter annotation, and if at least one method in the class contains entry parameter annotation, storing the information of the entry parameter annotation of the at least one method in a first mapping MAP set.

In one possible design, the entry parameter annotation includes a first attribute and a second attribute, the value of the first attribute is the name of the interface, and the value of the second attribute is description information of each entry parameter of the interface; the exit parameter annotation comprises a third attribute and a fourth attribute, the value of the third attribute is the name of the interface, the value of the fourth attribute is the description information of each exit parameter, and the number of the fourth attribute in the exit parameter annotation of the interface is consistent with the number of the exit parameters of the interface.

In one possible design, the annotation parsing module is further configured to:

if at least one method in the category contains entry parameter annotations, taking the value of the first attribute of the entry parameter annotation of each method as a key, taking the value of the second attribute of the entry parameter annotation of the method as a value, and storing the value into the first MAP set.

In one possible design, the annotation parsing module is further configured to:

if the class contains the exit parameter annotations, the field name of each member variable in the class and the value of the fourth attribute of the corresponding exit parameter annotation are respectively used as key and value to form a key value pair, and the key value pairs corresponding to all the member variables in the class form a second MAP set; and taking the value of the third attribute of the exit parameter annotation as a key, taking the second MAP set as a value, and storing the value into the first MAP set.

In one possible design, the annotation parsing module is further configured to:

and if the class contains member variables of the preset data type, storing information of the exit parameter annotation of the definition class corresponding to the member variables of the preset data type into the first MAP set in a recursive mode, wherein the first MAP set contains nested model information.

In one possible design, the information processing module is further configured to:

and if the interface information contains the nesting model information, generating a data model file containing the nesting model by adopting a recursive mode according to the interface information.

In another aspect, an embodiment of the present invention provides a data processing apparatus, including:

a processor, a memory, and a computer program stored on the memory and executable on the processor;

wherein the processor implements the data processing method when running the computer program.

In another aspect, an embodiment of the present invention provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the data transmission method described above.

The data processing method, the device, the equipment and the computer readable storage medium provided by the embodiment of the invention have the following advantages or beneficial effects: analyzing interface annotation information in the program code in the compiling process to obtain interface information; the data model file is automatically generated according to the interface information, automatic generation of the interface information and the data model file is achieved, when the interface changes, automatic updating of the interface information and the data model file can be timely completed through recompilation, efficiency is improved, and the technical problems that due to the fact that updating of an interface document is not timely and omission easily occurs, a front end cannot accurately acquire background data, and therefore the front end page cannot be accessed and data return errors and other exceptions occur are solved.

Drawings

FIG. 1 is a schematic diagram of a software development platform system architecture according to an embodiment of the present invention;

FIG. 2 is a flowchart of a data processing method according to an embodiment of the present invention;

FIG. 3 is a flowchart of a data processing method according to a second embodiment of the present invention;

FIG. 4 is a diagram illustrating entry parameter annotation provided in a second embodiment of the present invention;

FIG. 5 is a schematic diagram of an exit parameter annotation provided in the second embodiment of the present invention;

FIG. 6 is a schematic overall flowchart of parsing annotations according to the second embodiment of the present invention;

fig. 7 is a schematic diagram of an interface information display interface according to a second embodiment of the present invention;

fig. 8 is a schematic structural diagram of a data processing apparatus according to a third embodiment of the present invention;

fig. 9 is a schematic structural diagram of a data processing apparatus according to a fourth embodiment of the present invention;

fig. 10 is a schematic structural diagram of a data processing apparatus according to a fifth embodiment of the present invention.

With the above figures, certain embodiments of the invention have been illustrated and described in more detail below. The drawings and the description are not intended to limit the scope of the inventive concept in any way, but rather to illustrate it by those skilled in the art with reference to specific embodiments.

Detailed Description

Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.

The terms to which the present invention relates will be explained first:

json format: json is a lightweight data exchange format.

vo (value object): is a business object in java and survives in a business layer.

git: the system is an open-source distributed version control system and is used for processing large or small items agilely and efficiently.

And annotating: the java annotation is also called java annotation, and is an annotation mechanism introduced by jdk 5.0.

bootstrap: the front-end framework is introduced by Twitter, is brief and flexible, and enables web development to be faster.

shell script: the shell is a program written in c language, which is a bridge for users to use Linux, and receives user commands and then calls corresponding application programs.

Furthermore, the terms "first," "second," "third," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicit to a number of indicated technical features. In the description of the following examples, "plurality" means two or more unless specifically limited otherwise.

The data processing method provided by the embodiment of the invention can be applied to the software development platform system architecture schematic diagram shown in fig. 1. As shown in fig. 1, the system architecture includes a data acquisition module, a client model module, an interface document presentation module, and a client code repository.

The data acquisition module is located at a server side in the system, a back-end developer adds a self-defined interface annotation to a request method and a returned data VO class in a coding stage, and the back end automatically analyzes the interface annotation to obtain interface information and stores the interface information in a compiling stage, so that the acquisition function of data information required by an interface document is realized.

The interface document display module is used for displaying interface information acquired by the back end through a front end display interface and providing an interactive interface with a front end user so that the user submits the information to the back end through the front end interface.

The client model module is located at a server side in the system and used for automatically generating a data model file required by a client user according to the interface information, wherein the data model file can be a model file required by the iOS and the android terminal. Illustratively, the user may select an interface through the front-end interface to generate the data model file, enter a name of the data model file to be generated, enter address information of the code repository to which the generated data model file is submitted, and so forth.

The client code library provides a function of automatically submitting the generated data model file to a git code warehouse, and is convenient for front-end clerks to directly use.

The data processing method provided by the embodiment of the invention can automatically analyze the interface annotation information in the code to obtain the interface information in the compiling process, automatically generate the data model file, and automatically submit the data model file to the code warehouse, once the interface changes, a back-end developer only needs to modify the annotation of the interface, the interface information can be automatically updated, the data model file can be regenerated and automatically updated to the code warehouse during compiling, the communication cost of front-end and back-end personnel is reduced, the efficiency is improved, and the technical problems that the front end cannot accurately acquire background data, the front-end page cannot access and returns data errors and the like due to the fact that the interface file is not updated timely and omission easily occurs are solved.

The following describes the technical solutions of the present invention and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present invention will be described below with reference to the accompanying drawings.

Fig. 2 is a flowchart of a data processing method according to an embodiment of the present invention. The embodiment of the invention provides a data processing method aiming at the problems that in the prior art, a back-end developer needs to manually write and modify an interface document, a front-end developer manually generates a data model according to the interface document, the interface document is not updated timely, omission easily occurs, the front end cannot accurately acquire background data, and abnormity such as incapability of accessing and data return error occurs on a front-end page. The method in the embodiment is applied to server-side equipment of a software development platform background. As shown in fig. 2, the method comprises the following specific steps:

and step S101, in the compiling process, analyzing the interface annotation information in the program code to obtain the interface information.

Wherein the interface annotation information comprises an entry parameter annotation and an exit parameter annotation.

In this embodiment, a back-end developer adds a custom annotation to the request method and the returned data VO at the encoding stage, thereby completing the writing of interface annotation information.

In the compiling stage, the server-side equipment can automatically analyze the interface annotation information in the program code to obtain the required interface information in the interface document.

The interface information at least comprises entrance parameter information and exit parameter information, and the entrance parameter information at least comprises an interface name and description information of entrance parameters. The egress parameter information includes at least an interface name and description information of the egress parameter.

And S102, automatically generating a data model file according to the interface information.

In this embodiment, after the interface information is analyzed, a data model file is generated by calling a shell script according to the interface information.

For example, common operating system types include IOS and Android, and for different operating system types, the server device may call different shell scripts to generate data model files applied to the different operating system types.

Optionally, if the user specifies that the operating system type is IOS, a shell script applicable to IOS is called to generate a data model file applicable to IOS.

Optionally, if the user specifies that the operating system type is Android, calling a shell script applicable to the Android to generate a data model file applicable to the Android.

Optionally, if the user does not specify the operating system type, the shell script applicable to the IOS and the shell script applicable to the Android may be respectively called, and data model files applicable to the IOS and the Android may be respectively generated.

In the embodiment of the invention, the interface annotation information in the program code is analyzed in the compiling process to obtain the interface information; the method has the advantages that the data model file is automatically generated according to the interface information, automatic generation of the interface information and the data model file is realized, when the interface changes, automatic updating of the interface information and the data model file can be timely completed by recompiling, efficiency is improved, and the technical problems that due to the fact that updating of the interface file is not timely and omission easily occurs, the front end cannot accurately acquire background data, and therefore the front end page cannot be accessed and data return errors and other exceptions occur are solved.

Fig. 3 is a flowchart of a data processing method according to a second embodiment of the present invention. On the basis of the first embodiment, in this embodiment, automatically generating the data model file according to the interface information includes: and automatically generating a data model file of the target interface corresponding to the specified operating system type according to the interface information, the target interface identifier and the specified operating system type. Further, after automatically generating the data model file according to the interface information, the method further includes: and automatically submitting the data model file to a preset code warehouse. As shown in fig. 3, the method comprises the following specific steps:

step S201, in the compiling process, the interface annotation information in the program code is analyzed to obtain the interface information.

Wherein the interface annotation information comprises an entry parameter annotation and an exit parameter annotation of the interface.

The entry parameter annotation comprises a first attribute and a second attribute, wherein the value of the first attribute is the name of the interface, and the value of the second attribute is the description information of each entry parameter of the interface.

Illustratively, an entry parameter annotation may be represented by "DocReqValue", a first attribute of the entry parameter annotation may be represented by name, a value of the first attribute is an interface name, a second attribute may be represented by value, a value of the second attribute includes description information of each entry parameter, description information of different parameters is divided by a semicolon, and an order of the description information is consistent with an order of the entry parameters. In addition, in this embodiment, the entry parameter annotation and the identifier used by the first attribute and the second attribute thereof are not specifically limited.

For example, as shown in fig. 4, in the program code, there are two entry parameters, pin and uuid, in the request function getShopList, an entry parameter annotation "@ DocReqValue" is added to the request function getShopList, a value of the first attribute name is an interface name "interface for obtaining a list of interest", a value of the second attribute value includes description information of the pin and uuid divided by a semicolon, description information of the entry parameter pin is "gateway automatic acquisition after login", and description information of the entry parameter uuid is "must pass" (note: machine unique code-android is uuid, ios is openid) ".

In this embodiment, the exit parameter annotation includes a third attribute and a fourth attribute, where a value of the third attribute is an interface name, and a value of the fourth attribute is description information of each exit parameter, and the number of the fourth attribute in the exit parameter annotation of the interface is consistent with the number of the exit parameters of the interface.

Illustratively, the "DocValue" may be used to represent the exit parameter annotation, the third attribute of the exit parameter annotation may be represented by name, the value of the third attribute is the interface name, the fourth attribute may be represented by key, and the value of the fourth attribute includes the description information of the exit parameter. For an interface with multiple egress parameters, each egress parameter may correspond to a key. In addition, in this embodiment, the exit parameter annotation and the identifier used by the third attribute and the fourth attribute thereof are not specifically limited.

For example, as shown in fig. 5, in the program code, an exit argument "@ DocValue" is added to the data VO class shopresponseto, a value of the third attribute name is an interface name "interface for acquiring a list of interest", fourth attributes are annotated on member variables "allclosed", "havefoulled" and "shopNum", respectively, and values of corresponding fourth attribute keys are "false: not all attention is paid to true: full attention "," number of concerned stores ", and" total number of backing stores ".

It should be noted that the interface name in the exit parameter annotation of a certain data VO class and the entry parameter annotation of the request method corresponding to the data VO class should be consistent, that is, the first attribute name of the exit parameter annotation of the data VO class is consistent with the third attribute name of the entry parameter annotation of the request method corresponding to the data VO class.

As a possible implementation manner, in order to implement automatic parsing of the annotation, the overall flow of parsing the annotation is shown in fig. 6, and may include the following steps:

and step S1, scanning the custom annotation.

By registering the rule of the self-defining annotation of the annotation class, the self-defining scanning class is used for scanning which positions in the code are added with the self-defining annotation.

And step S2, adding the custom annotation into the spining container.

And adding the annotation class into a spring container by extending an ImportBeanDefinitionRegistrar interface to prepare for subsequent annotation parsing.

And step S3, the bean post-processing method analyzes the annotation.

The annotations are parsed in a bean post-processing method by extending the BeanPostprocessor interface.

And step S4, interface information is saved.

And analyzing the annotation by a bean post-processing method to obtain the interface information required by the interface document and storing the interface information.

As a possible implementation manner, the process of parsing annotations by the bean post-processing method in step 3 may be specifically implemented by the following processing of steps S2011-S2013:

step S2011, scanning each class in the program code, and performing the following processing on the currently scanned class:

step S2012, determine whether the class includes an exit parameter annotation.

If the class contains the exit parameter annotation, the exit parameter annotation in the class is analyzed by executing the step S2013 to obtain the corresponding exit parameter information.

If the class does not contain the exit parameter annotation, step S2014 is executed to continue parsing the entry parameter annotation in the class to obtain the entry parameter information in the class.

For example, based on the example of the export parameter annotation shown in fig. 5, whether the class contains the export parameter annotation may be determined by determining whether an identifier "@ DocValue" of the export parameter annotation is added to the class, and if the identifier "@ DocValue" is added to the class, it may be determined that the class contains the export parameter annotation; if "@ DocValue" is not added to the class, it may be determined that the class does not contain an export parameter annotation. For the example in FIG. 5, the data VO class ShopResponseVO is added with the exit argument "@ DocValue", and it may be determined that the data VO class ShopResponseVO contains the exit argument.

And S2013, if the class contains the exit parameter annotations, storing the information of the exit parameter annotations on all the member variables in the class into the first MAP set.

Specifically, if the class includes the exit parameter annotations, the field name of each member variable in the class and the value of the fourth attribute of the corresponding exit parameter annotation are respectively used as a key and a value to form a key value pair by traversing each member variable in the class, and the key value pairs corresponding to all the member variables in the class form a second MAP set; and taking the value of the third attribute of the exit parameter annotation as a key, taking the second MAP set as a value, and storing the value into the first MAP set.

For example, based on the example of the export parameter annotation shown in fig. 5, annotation information is added to 3 member variables in the data VO class shoppponsevo, and by traversing each member variable, the field name of each member variable in the shoppponsevo class and the value of the fourth attribute of the corresponding export parameter annotation are respectively used as a key and value formation key-value pair, so that the second MAP set includes the following 3 key-value pairs: key ═ allfallen ", value ═ false: not all attention is paid to true: has been fully concerned "; key ═ havefoulowed ", value ═ number of stores of interest"; key "shopNum", value "total number of bottompool stores". And taking the value of the third attribute of the exit parameter annotation, namely 'acquiring the attention list interface' as a key, taking the second MAP set as a value, and storing the second MAP set into the first MAP set.

Illustratively, when traversing each member variable in the class, if an annotation is added to the member variable, the field name of the member variable and the value of the fourth attribute of the corresponding exit parameter annotation may be respectively used as a key and a value to constitute a key-value pair; if no annotation is added to the member variable, the field name and the field type of the member variable can be used as key and value respectively to form a key-value pair; the key-value pairs corresponding to all member variables in the class form a second MAP set.

For example, based on the example of the exit parameter annotation shown in fig. 5, a total of 4 member variables in the data VO class shoppponsevo, where annotation information is added to 3 member variables, and a second MAP set is obtained by traversing each member variable, and includes the following 4 key-value pairs: key ═ shopList ", value ═ List < ShopInfo >"; key ═ allfallen ", value ═ false: not all attention is paid to true: has been fully concerned "; key ═ havefoulowed ", value ═ number of stores of interest"; key "shopNum", value "total number of bottompool stores".

Further, if the class contains member variables of the preset data type, information of an exit parameter annotation of the definition class corresponding to the member variables of the preset data type is stored in the first MAP set in a recursive mode, and the first MAP set contains nested model information.

The preset data type at least comprises a normal form, an array and a mapping MAP.

For example, taking the class including the normal form member variable as an example, the processing of the above steps S2012 to S2013 is recursively performed on the normal form class defining the normal form member variable, so as to store the exit parameter information of the normal form class in the first MAP set. Further, if the default data type is included in the normal type, the process of the above steps S2012-2013 is recursively performed on the defined type defining the default data type to store the exit parameter information of the defined type into the first MAP set.

And step S2014, judging whether the class contains a Controller annotation.

Wherein, the Controller annotation is the self-contained annotation in the spring frame.

If the class contains the Controller annotation, the class is indicated as the Controller class, the class may contain the entry parameter annotation, and step S2015 is continuously executed to parse the entry parameter annotation in the class.

If the class does not contain a Controller annotation, indicating that it is not possible to contain an entry parameter annotation in that class, then the scan continues for the next class.

Step S2015, determine whether the method in the class includes entry parameter annotation.

If at least one method in the class contains an entry parameter annotation, the entry parameter annotation is parsed by performing step S2016.

If all methods in the class do not contain entry parameter annotations, the scan continues for the next class.

For example, based on the example of the entry parameter annotation shown in fig. 4, whether the method contains the entry parameter annotation may be determined by determining whether the method in the class is added with an identifier "@ DocReqValue" of the entry parameter annotation, and if the method is added with "@ DocReqValue", it may be determined that the method contains the entry parameter annotation; if "@ DocReqValue" is not added to the method, it may be determined that the method does not contain an export parameter annotation. For the example in fig. 4, the request function getShopList is augmented with an entry argument "@ DocValue" and may be determined to contain an exit argument.

Step S2016, if at least one method in the class includes an entry parameter annotation, storing information of the entry parameter annotation of the at least one method in the first MAP set.

Specifically, if a plurality of methods in the class contain entry parameter annotations, for each method in the class containing entry parameter annotations, the value of the first attribute of the entry parameter annotations of the method is taken as a key, the value of the second attribute of the entry parameter annotations of the method is taken as a value, and the value is stored in the first MAP set.

For example, based on the example of the entry parameter annotation shown in fig. 4, an entry parameter annotation "@ DocValue" is added to the request function getShopList, the value "get attention list interface" of the first attribute of the entry parameter annotation of the method is used as a key, and the value "sign-in gateway of the second attribute of the entry parameter annotation of the method is automatically obtained; and (note: machine unique code-as uuid and ios as openudid) is value, and the value is stored in the first MAP set.

In this embodiment, the parsing of the exit parameter annotation and the entry parameter annotation can be realized by one-time scanning. Analyzing the exit parameter annotation through the steps S2012-S2013 to obtain exit parameter information; the parsing of the entry parameter annotation can be realized through the steps S2014-S2016 to obtain entry parameter information.

It should be noted that, when each class is scanned, the example is described by taking the example of parsing the exit parameter annotation in the class first and then parsing the entry parameter annotation in the class later; in other embodiments of this embodiment, the entry parameter annotations in the class may be parsed first, and then the exit parameter annotations may be parsed; or the parsing of the entry parameter annotation and the exit parameter annotation may be performed in parallel, and this embodiment is not limited in this embodiment.

In addition, the parsing process for the entry parameter annotation and the parsing process for the exit parameter annotation may be two independent processes, one of the processes may be implemented by one-pass scanning, and the other process may be implemented by the second-pass scanning, which is not specifically limited in this embodiment.

In this embodiment, the interface entry parameter and the interface exit parameter may define a unique interface name in a unified manner, and after the analysis is completed, the information of the interface is recorded completely by the unique interface name, so that all the information required by the interface document is obtained.

Step S202, receiving a target interface identifier sent by the front end and an appointed operating system type, wherein the appointed operating system type is input by a user through a front end page.

The target interface is at least one interface which is specified by a user and is required to generate the data model file, and the specified operation type is an operating system type which is specified by the user and is suitable for generating the data model file. The specified operating system type may be IOS or Android.

In this embodiment, a user may input a name of a data model file to be generated and an application operating system type on an interactive interface displayed at a front end, submit the name and the application operating system type to a background server, name the data model file by the user, and specify the operating system type of the data model file.

Illustratively, the user selects, via the front-end page, the interface that wants to generate the corresponding data model file as the target interface, specifies the operating system type to which the data model file to be generated applies,

step S203, according to the interface information, the target interface identification and the appointed operation system type, a data model file of the target interface corresponding to the appointed operation system type is automatically generated.

After the server receives the target interface identification and the appointed operating system type sent by the front end, the data model file which is appointed by the user and named by the user can be automatically generated through the step, so that the method is more flexible and better in user experience.

Specifically, a data model file interface provided by a background server and used for generating a client is called, the data model file to be generated is judged to be iOS or Android, and different shell scripts are called according to different operating system types.

In addition, in this embodiment, if some classes include member variables of the preset data type, information of the exit parameter annotation of the definition class corresponding to the member variables of the preset data type is stored in the first MAP set in a recursive manner. Then, the first MAP set includes nesting model information, that is, the parsed interface information includes nesting model information.

In this step, if the interface information includes the nested model information, a data model file including the nested model is generated in a recursive manner according to the interface information.

Illustratively, in order to generate a data model file containing a nested model, a plurality of model classes are generated at both ends of iOS and Android, and a corresponding shell script is generated by adopting a recursive analysis method. Meanwhile, for the iOS platform, codes required for processing and analyzing the nested model are added by default when the shell script is generated.

The embodiment can analyze a multi-nested data model by using a recursion mode, generate the script language suitable for different operating system platforms by using the recursion method when generating the data model file, and associate the data model file with the code warehouse, thereby achieving the purpose of simplifying the development of front-end personnel.

And step S204, receiving the address information of the specified code warehouse sent by the front end, wherein the address information of the specified code warehouse is input by the user through the front end page.

In this embodiment, the user may input address information of the code warehouse stored in the generated data model file on the interactive interface displayed at the front end. For example, the specified code repository may be a git repository.

And step S205, submitting the data model file of the target interface corresponding to the specified operating system type to a specified code warehouse.

And the server receives the address information of the specified code warehouse sent by the front end, and submits the generated data model file to the specified code warehouse according to the address information of the specified code warehouse, so that a user can conveniently obtain the data model file.

And step S206, generating an interface document according to the interface information.

In this embodiment, after the interface information is obtained, the interface document may be generated according to the interface information and a preset format of the interface document, so that the automatic generation of the interface document may be completed, and time consumed for writing the interface document may be reduced.

Optionally, the generated interface document may be displayed through a front-end interface.

And step S207, sending the interface information to the front end so as to display the interface information through the front end page.

In this embodiment, after the interface information is obtained, the interface information may also be displayed through the front-end interface, so that the user may view the interface information.

Illustratively, the interface information can be displayed through an interface information display interface of the front end. As shown in fig. 7, different interface information can be displayed by the selection of the user, and an operation area for the user to switch and select different interfaces and an operation area for the user to specify the type of the operating system of the data model file to be generated are provided in the interface information display interface.

Optionally, the interface information presentation interface of the front end may be written by javaScript, and the front end style is implemented by bootstrap.

Optionally, as shown in fig. 7, the present embodiment may also display the code of the interface on the interface information display interface, and support conversion of different languages. For example, Objective-C and java code conversion may be supported.

In the embodiment of the invention, the interface annotation information in the program code is analyzed in the compiling process to obtain the interface information; the data model file is automatically generated according to the interface information, automatic generation of the interface information and the data model file is achieved, when the interface changes, automatic updating of the interface information and the data model file can be timely completed only by changing values in annotations and recompiling, the data model file is associated with a code warehouse, a front-end person only needs to pull codes and does not need to care about generation of the data model file, working hours for writing an interface document by a rear-end developer and a working flow for generating the data model file by the front-end developer are greatly simplified, communication cost of the front-end developer and the rear-end developer is reduced, and efficiency is greatly improved.

Fig. 8 is a schematic structural diagram of a data processing apparatus according to a third embodiment of the present invention. The data processing device provided by the embodiment of the invention can execute the processing flow provided by the embodiment of the data processing method. As shown in fig. 8, the data processing apparatus 30 includes: an annotation parsing module 301 and an information processing module 302.

Specifically, the annotation parsing module 301 is configured to parse the interface annotation information in the program code to obtain the interface information during the compiling process.

The information processing module 302 is used for automatically generating a data model file according to the interface information.

The apparatus provided in the embodiment of the present invention may be specifically configured to execute the method embodiment provided in the first embodiment, and specific functions are not described herein again.

In the embodiment of the invention, the interface annotation information in the program code is analyzed in the compiling process to obtain the interface information; the method has the advantages that the data model file is automatically generated according to the interface information, automatic generation of the interface information and the data model file is realized, when the interface changes, automatic updating of the interface information and the data model file can be timely completed by recompiling, efficiency is improved, and the technical problems that due to the fact that updating of the interface file is not timely and omission easily occurs, the front end cannot accurately acquire background data, and therefore the front end page cannot be accessed and data return errors and other exceptions occur are solved.

Fig. 9 is a schematic structural diagram of a data processing apparatus according to a fourth embodiment of the present invention. In addition to the third embodiment, in the present embodiment, as shown in fig. 9, the data processing apparatus 30 further includes: a sending module 303. The sending module 303 is configured to automatically submit the data model file to a preset code repository.

In one possible design, information processing module 302 is further configured to:

and automatically generating a data model file of the target interface corresponding to the specified operating system type according to the interface information, the target interface identifier and the specified operating system type.

In one possible design, as shown in fig. 9, the data processing apparatus 30 further includes: a receiving module 304. The receiving module 304 is configured to:

and receiving a target interface identifier and a specified operating system type sent by the front end, wherein the specified operating system type is input by a user through a front end page.

In one possible design, the sending module 303 is further configured to:

and submitting the data model file of the target interface corresponding to the specified operating system type to a specified code warehouse.

In one possible design, the receiving module 304 is further configured to:

and receiving address information of the designated code warehouse sent by the front end, wherein the address information of the designated code warehouse is input by a user through a front end page.

In one possible design, information processing module 302 is further configured to:

and generating an interface document according to the interface information.

In one possible design, the sending module 303 is further configured to:

the interface information is sent to the front end to display the interface information through the front end page.

In one possible design, the interface annotation information includes an entry parameter annotation and an exit parameter annotation for the interface; the annotation parsing module 301 is further configured to:

scanning each class in the program code, and if the class contains an exit parameter annotation, storing the information of the exit parameter annotation on all member variables in the class into a first MAP set; if the class is a Controller class, scanning whether each method in the class contains entry parameter annotation, and if at least one method in the class contains entry parameter annotation, storing the information of the entry parameter annotation of the at least one method in the first mapping MAP set.

In one possible design, the entry parameter annotation includes a first attribute and a second attribute, the value of the first attribute is the name of the interface, and the value of the second attribute is the description information of each entry parameter of the interface; the exit parameter annotation includes a third attribute and a fourth attribute, the value of the third attribute is the name of the interface, the value of the fourth attribute is the description information of each exit parameter, and the number of the fourth attribute in the exit parameter annotation of the interface is consistent with the number of the exit parameters of the interface.

In one possible design, the annotation parsing module 301 is further configured to:

if at least one method in the class contains the entry parameter annotation, the value of the first attribute of the entry parameter annotation of each method is used as a key, the value of the second attribute of the entry parameter annotation of the method is used as a value, and the value is stored in the first MAP set.

In one possible design, the annotation parsing module 301 is further configured to:

if the class contains the exit parameter annotations, the field name of each member variable in the class and the value of the fourth attribute of the corresponding exit parameter annotation are respectively used as key and value to form a key value pair, and the key value pairs corresponding to all the member variables in the class form a second MAP set; and taking the value of the third attribute of the exit parameter annotation as a key, taking the second MAP set as a value, and storing the value into the first MAP set.

In one possible design, the annotation parsing module 301 is further configured to:

and if the class contains member variables of the preset data type, storing the information of the exit parameter annotation of the definition class corresponding to the member variables of the preset data type into a first MAP set in a recursive mode, wherein the first MAP set contains nesting model information.

In one possible design, information processing module 302 is further configured to:

and if the interface information contains the nesting model information, generating a data model file containing the nesting model by adopting a recursive mode according to the interface information.

In one possible design, the predetermined data types include at least a normal form, an array, and a MAP.

The apparatus provided in the embodiment of the present invention may be specifically configured to execute the method embodiment provided in the second embodiment, and specific functions are not described herein again.

In the embodiment of the invention, the interface annotation information in the program code is analyzed in the compiling process to obtain the interface information; the data model file is automatically generated according to the interface information, automatic generation of the interface information and the data model file is achieved, when the interface changes, automatic updating of the interface information and the data model file can be timely completed only by changing values in annotations and recompiling, the data model file is associated with a code warehouse, a front-end person only needs to pull codes and does not need to care about generation of the data model file, working hours for writing an interface document by a rear-end developer and a working flow for generating the data model file by the front-end developer are greatly simplified, communication cost of the front-end developer and the rear-end developer is reduced, and efficiency is greatly improved.

Fig. 10 is a schematic structural diagram of a data processing apparatus according to a fifth embodiment of the present invention. As shown in fig. 10, the data processing apparatus 100 includes: a processor 1001, a memory 1002, and computer programs stored on the memory 1002 and executable on the processor 1001.

When the processor 1001 runs the computer program, the data processing method provided by any one of the above method embodiments is implemented.

In the embodiment of the invention, the interface annotation information in the program code is analyzed in the compiling process to obtain the interface information; the method has the advantages that the data model file is automatically generated according to the interface information, automatic generation of the interface information and the data model file is realized, when the interface changes, automatic updating of the interface information and the data model file can be timely completed by recompiling, efficiency is improved, and the technical problems that due to the fact that updating of the interface file is not timely and omission easily occurs, the front end cannot accurately acquire background data, and therefore the front end page cannot be accessed and data return errors and other exceptions occur are solved.

In addition, an embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the data processing method provided in any of the above method embodiments.

In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.

Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.

The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.

It is obvious to those skilled in the art that, for convenience and simplicity of description, the foregoing division of the functional modules is merely used as an example, and in practical applications, the above function distribution may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to perform all or part of the above described functions. For the specific working process of the device described above, reference may be made to the corresponding process in the foregoing method embodiment, which is not described herein again.

Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.

It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

22页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种文件生成方法、装置、设备及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!