CN114201179A - Code conversion method and device of interface document, terminal equipment and storage medium - Google Patents

Code conversion method and device of interface document, terminal equipment and storage medium Download PDF

Info

Publication number
CN114201179A
CN114201179A CN202111547504.1A CN202111547504A CN114201179A CN 114201179 A CN114201179 A CN 114201179A CN 202111547504 A CN202111547504 A CN 202111547504A CN 114201179 A CN114201179 A CN 114201179A
Authority
CN
China
Prior art keywords
code
code conversion
document
interface
interface document
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111547504.1A
Other languages
Chinese (zh)
Inventor
曾凯瑶
黄叶飞
高银川
于亚军
吕定刚
李婷
陈显彬
张全康
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN202111547504.1A priority Critical patent/CN114201179A/en
Publication of CN114201179A publication Critical patent/CN114201179A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/51Source to source
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/38Creation or generation of source code for implementing user interfaces

Abstract

The invention relates to the technical field of financial science and technology, and discloses a code conversion method and device of an interface document, terminal equipment and a computer storage medium. The code conversion method of the interface document receives code conversion configuration parameters based on a preset code conversion functional plug-in, wherein the code conversion functional plug-in is developed and generated based on an integrated development environment in advance; acquiring document information of an interface document from an interface document platform of the system according to the code conversion configuration parameters, and determining a code template according to the code conversion configuration parameters; and according to the document content of the interface document, the document information and the code template, performing code conversion operation to obtain a code file which is required to be introduced into the target project. The invention realizes the direct butt joint of the interface document platform on the system project, and uses the developed functional plug-in to directly convert the interface document to generate the code without repeatedly switching back and forth between the code generating platform and the development project to copy and paste the data.

Description

Code conversion method and device of interface document, terminal equipment and storage medium
Technical Field
The present invention relates to the field of financial technology (Fintech) technologies, and in particular, to a code conversion method and apparatus for an interface document, a terminal device, and a computer storage medium.
Background
With the development of computer technology, more and more technologies are applied in the financial field, and the traditional financial industry is gradually changing to financial technology, but higher requirements are also put forward on the technologies due to the requirements of the financial industry on safety, instantaneity, stability and the like.
Currently, enterprises typically use an interface document platform to translate interface documents of various systems into code for maintenance on the various interface documents. However, in the existing code conversion method based on the interface document platform, a worker who develops the system needs to manually copy the code data generated based on the conversion document in different business projects of the system, and particularly when a plurality of categories of code data need to be generated, the worker needs to repeatedly copy and paste the data between an intermediate platform for converting the document to generate the code and a project development tool.
In summary, in the process of converting the system interface document into the code file for maintenance, the worker who develops the system needs to perform the data copying and pasting operation frequently and repeatedly, and the process is complicated and error is easily caused, so that the efficiency of the overall development or operation and maintenance of the system is seriously affected.
Disclosure of Invention
The invention mainly aims to provide a code conversion method, a code conversion device, terminal equipment and a computer storage medium for an interface document, and aims to solve the technical problems that in the existing code conversion mode for the interface document, a worker needs to frequently and repeatedly execute copy and paste operations, the process is complicated, and errors are easy to make.
In order to achieve the above object, the present invention provides a code conversion method for an interface document, including the steps of:
receiving code conversion configuration parameters based on a preset code conversion functional plug-in, wherein the code conversion functional plug-in is developed and generated in advance based on an integrated development environment;
acquiring document information of an interface document from an interface document platform of the system according to the code conversion configuration parameters, and determining a code template according to the code conversion configuration parameters;
and according to the document content of the interface document, the document information and the code template, performing code conversion operation to obtain a code file which is required to be introduced into the target project.
In addition, to achieve the above object, the present invention also provides a code conversion apparatus for an interface document, including:
the parameter configuration module is used for receiving code conversion configuration parameters based on a preset code conversion functional plug-in, wherein the code conversion functional plug-in is developed and generated in advance based on an integrated development environment;
the acquisition module is used for acquiring document information of the interface document from an interface document platform of the system according to the code conversion configuration parameters and determining a code template according to the code conversion configuration parameters;
and the code conversion module is used for carrying out code conversion operation according to the document content of the interface document, the document information and the code template to obtain a code file which is required to be introduced into the target project.
Wherein, each functional module of the code conversion device of the interface document of the invention realizes the steps of the code conversion method of the interface document when in operation.
In addition, to achieve the above object, the present invention also provides a terminal device, including: a memory, a processor and a code conversion program of an interface document stored on the memory and executable on the processor, the code conversion program of the interface document implementing the steps of the code conversion method of the interface document as described above when executed by the processor.
Further, to achieve the above object, the present invention also provides a computer storage medium having stored thereon a code conversion program of an interface document, which when executed by a processor, implements the steps of the code conversion method of the interface document as described above.
Furthermore, to achieve the above object, the present invention also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the code conversion method of the interface document as described above.
The invention provides a code conversion method, a code conversion device, terminal equipment, a computer storage medium and a computer program product of an interface document, wherein the code conversion method of the interface document receives code conversion configuration parameters based on a preset code conversion functional plug-in, and the code conversion functional plug-in is developed and generated based on an integrated development environment in advance; acquiring document information of an interface document from an interface document platform of the system according to the code conversion configuration parameters, and determining a code template according to the code conversion configuration parameters; and according to the document content of the interface document, the document information and the code template, performing code conversion operation to obtain a code file which is required to be introduced into the target project.
In the process of converting the interface document of the system into the code file for introduction, the code conversion function plug-in generated based on the integrated environment development in advance is used for receiving the code conversion configuration parameters, then the document information is obtained from the interface document platform of the system according to the received code conversion configuration parameters, the code template is determined according to the code conversion configuration parameters, and finally, the code conversion operation is carried out according to the document information and the code template to directly obtain the code file required to be introduced by the target project.
Compared with the traditional mode of converting the code of the interface document, the invention receives the configuration parameters through the pre-developed code conversion functional plug-in, and then directly performs the code conversion operation according to the parameters to directly obtain the code file required to be introduced by the target project in the system, thus realizing the direct butt joint of the interface document platform on the project to be developed of the system, and directly converting and generating the code aiming at the interface document by using the developed functional plug-in.
Drawings
Fig. 1 is a schematic device structure diagram of a hardware operating environment of a terminal device according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a method for transcoding an interface document according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an application flow of generating codes based on interface operations of a code conversion function plug-in according to an embodiment of the code conversion method for an interface document of the present invention;
FIG. 4 is a schematic diagram of an interactive interface involved in an embodiment of the method for transcoding an interface document according to the present invention;
FIG. 5 is a diagram illustrating an application scenario involved in an embodiment of the method for transcoding an interface document according to the present invention;
FIG. 6 is a schematic diagram illustrating another application flow of generating code according to an embodiment of the code conversion method of the interface document of the present invention;
FIG. 7 is a flowchart illustrating an application of processing an interface document according to an embodiment of the method for transcoding an interface document of the present invention;
FIG. 8 is a functional block diagram of an embodiment of a code conversion apparatus for interface documents according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic device structure diagram of a terminal device hardware operating environment according to an embodiment of the present invention.
The terminal device in the embodiment of the present invention may be a terminal device used by a worker to develop a system project or perform operation and maintenance on a system service project, and the terminal device may be a PC (Personal Computer), a smart phone, a tablet Computer, a portable Computer, a server, and the like.
As shown in fig. 1, the terminal device may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., a Wi-Fi interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the terminal device configuration shown in fig. 1 is not intended to be limiting of the terminal device and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer storage medium, may include therein a code conversion program of an operating system, a network communication module, a user interface module, and an interface document.
In the terminal shown in fig. 1, the network interface 1004 is mainly used for connecting to a backend server and performing data communication with the backend server; the user interface 1003 is mainly used for connecting a client and performing data communication with the client; and the processor 1001 may be configured to call a code conversion program of the interface document stored in the memory 1005 and perform the following embodiments of a code conversion method of the interface document.
Based on the above hardware structure, embodiments of the code conversion method of the interface document of the present invention are provided.
It should be noted that, an interface document platform is usually used by an enterprise to convert interface documents of various systems into codes for maintenance of the various interface documents. However, in the existing code conversion method based on the interface document platform, a worker who develops the system needs to manually copy the code data generated based on the conversion document in different business projects of the system, and particularly when a plurality of categories of code data need to be generated, the worker needs to repeatedly copy and paste the data between an intermediate platform for converting the document to generate the code and a project development tool.
In summary, in the process of converting the system interface document into the code file for maintenance, the worker who develops the system needs to perform the data copying and pasting operation frequently and repeatedly, and the process is complicated and error is easily caused, so that the efficiency of the overall development or operation and maintenance of the system is seriously affected.
Aiming at the phenomenon, the invention provides a code conversion method of an interface document, aiming at solving the technical problems that the existing code conversion method of the interface document needs workers to frequently and repeatedly execute copy and paste operations, the process is complicated and errors are easy to make.
Referring to fig. 2, fig. 2 is a flowchart illustrating a code conversion method of an interface document according to a first embodiment of the present invention.
In this embodiment, the code conversion method of the interface document of the present invention is applied to the terminal device described above, and includes:
step S10, receiving code conversion configuration parameters based on a preset code conversion function plug-in, wherein the code conversion function plug-in is developed and generated based on an integrated development environment in advance;
in the process of carrying out code conversion on the interface document, the terminal equipment receives code conversion configuration parameters required by the code conversion operation on the interface document based on a code conversion function plug-in developed and generated in advance based on an integrated development environment.
It should be noted that, in the present embodiment, the integrated development environment is any application that is mature to provide a program development environment. And the terminal equipment develops and generates a code conversion functional plug-in which can be directly operated in each target project to be developed or operated and maintained of the system in advance based on the integrated development environment so as to automatically convert and generate the code file to be introduced in the target project.
Further, in this embodiment, the code conversion method of the interface document of the present invention may further include:
step A, developing a newly-built development project based on an integrated development environment, providing a user interface through various interface development plug-ins in a preset software development kit, receiving program information based on the user interface, and performing code conversion on the received program information to generate an initial code conversion functional plug-in;
before starting to automatically perform code conversion operation on an interface document so as to generate a code file required to be introduced into a target project, a terminal device develops a newly-built development project based on an operation integrated development environment in advance, and then provides a user interface for development workers through various interface development plug-ins in a preset software development toolkit, so that various program information filled by the development workers is received based on the user interface, and the received program information is subjected to code conversion to generate an initial code conversion functional plug-in.
It should be noted that, in this embodiment, the Software Development Kit is a Software Development Kit (SDK) for Software Development, and the Software Development Kit carries various Interface Development plug-ins, and the Interface Development plug-ins all provide, to Development staff or other users, a User Interface (UI) Interface for specifically applying the Software Development Kit SDK to perform Software Development, and the Software Development Kit has a function of automatically performing code conversion.
Specifically, for example, the terminal device may specifically generate an initial code conversion function plug-in based on an Integrated Development Environment (Development IDE under jetbridge flag), i.e., an Integrated Development Environment (IDE is fully called, i.e., an Integrated Development Environment in chinese), which runs a mature Integrated Development Environment, and is an application program used by Development workers to provide a program Development Environment.
And B, debugging the initial code conversion functional plug-in, and packaging to obtain the code conversion functional plug-in after the debugging is stable.
After the terminal equipment generates the initialization code conversion function plug-in, the terminal equipment further adjusts the initialization code conversion function plug-in, so that after the initialization code conversion function plug-in is adjusted stably and correctly, the debugged initialization code conversion function plug-in is packaged and determined to be the code conversion function plug-in for the terminal equipment to generate a code file in the subsequent application of code conversion operation.
Specifically, for example, after generating an initial code conversion function plug-in based on the above process, the terminal device debugs the initial code conversion function plug-in by running a gradle runIde (a specific development test tool in the integrated development environment) until the initial code conversion function plug-in runs stably and correctly, and further runs a gradle buildPlugin (a data packing tool in the integrated development environment) to package and build a plug-in installation package for generating a subsequent code conversion function plug-in specifically for performing a code conversion operation with respect to the initial code conversion function plug-in which runs stably after debugging. In this way, after the terminal device installs the plug-in installation package into the currently integrated development environment, IntelliJ IDEA, the code conversion function plug-in can be used based on the operation of the development worker.
Further, in this embodiment, the step S10 may include:
step S101, detecting a code conversion instruction initiated aiming at a target project, wherein the target project is a project needing to introduce codes in a system;
the method comprises the steps that during the process that development workers develop projects or operate and maintain a system, the terminal equipment continuously detects code conversion instructions triggered by the development workers who actively select target projects needing codes to be introduced.
Specifically, for example, referring to the application flow shown in fig. 3 and the interactive interface shown in fig. 4, in the process of running the integrated development environment IntelliJ IDEA, the terminal device outputs a project user graphical interface containing the project to be developed or the project to be operated and maintained by the system to the development staff of the system, so that the development staff can select a target project to be developed or operated and maintained by introducing a code based on the user graphical interface, and click an instruction control indicating "generate code …" to initiate a code conversion instruction for the selected target project, and the terminal device detects the code conversion instruction.
And S102, operating the code conversion function plug-in to output a visual function interface, and receiving code conversion configuration parameters for generating a code file under the target project according to the visual function interface.
The method comprises the steps that after a code conversion instruction initiated aiming at a target project is detected, the terminal equipment runs an installed code conversion function plug-in used for performing code conversion operation immediately, so that a visual function interface is output to development workers, and then code conversion configuration parameters used for generating a code file under the target project are received by the workers actively based on the visual function interface.
Specifically, for example, referring to the application flow shown in fig. 3 and the interactive interface shown in fig. 4, after detecting a transcoding instruction initiated by a development worker for an autonomously selected target project, the terminal device runs a previously installed transcoding function plug-in to pop up a "generate code" dialog box to the development worker. In this way, the development worker can autonomously perform configuration operations such as selecting one or more document interfaces and corresponding code templates for generating codes and inputting the prefix of the class name through the dialog box, so that the terminal device can determine the platform interface information, the code templates, the prefix of the code category and the like selected by the development worker based on the configuration operations as the code conversion configuration parameters for generating the code file under the target item autonomously selected by the development worker.
It should be noted that, in this embodiment, please refer to the application flow shown in fig. 3 and the interactive interface shown in fig. 4, after the terminal device receives two basic transcoding configuration parameters, i.e., platform interface information and a code template, by performing a configuration operation of selecting a document interface and a corresponding code template based on a development worker, a "prefix" dialog box is further popped up to the development worker for the development worker to perform a configuration operation of inputting a class name prefix to define a file name of a code file to be generated, so that the terminal device further receives the transcoding configuration parameter, i.e., a prefix of a code category.
In addition, in this embodiment, in the process of running the integrated development environment, the terminal device starts the code conversion functional plug-in to output the visualized functional interfaces such as the "generate code" dialog box and the "prefix" dialog box to the development worker, which are all configured and generated by the development worker through autonomously selecting the interface provided by the SDK based on the design requirement of the actual application in the process of obtaining the code conversion functional plug-in based on the development and debugging. Based on this, it should be understood that, in any other feasible implementation manner, based on different design requirements of the actual application, the terminal device provides the visual function interface to the development worker based on running the code conversion function plug-in, which may of course include any different interface content, and the code conversion method of the interface document of the present invention is not limited to the specific interface content of the visual function interface.
Step S20, obtaining the document information of the interface document from the interface document platform of the system according to the code conversion configuration parameter, and determining a code template according to the code conversion configuration parameter;
it should be noted that, in this embodiment, the interface document platform of the system is used to centrally store and/or manage each interface document, and the development workers or system users of the interface document system communicate with each other to perform transcoding to generate document data of the system project referenceable code file.
After receiving the code conversion configuration parameters required by the code conversion operation of the current interface document based on the code conversion function plug-in, the terminal equipment further acquires the document information which is selected by development workers and needs to be converted into the code file for introduction from an interface document platform of the system according to the code conversion configuration parameters, and determines the code template which needs to be called currently to perform the code conversion operation from a preset code template library according to the code conversion configuration parameters.
Further, in this embodiment, the transcoding configuration parameters include: platform interface information; in the step S20, the step of "obtaining the document information of the interface document from the interface document platform of the system according to the transcoding configuration parameter" may include:
step S201, according to the platform interface information in the code conversion configuration parameters, calling an application program interface corresponding to an interface document platform of a system, wherein the number of the application program interfaces is greater than or equal to one;
when the terminal equipment acquires the document information from the interface document platform of the system according to the received code conversion configuration parameters, the terminal equipment firstly converts the platform interface information in the configuration parameters according to the code and directly calls the corresponding application program interface on the interface document platform of the system.
It should be noted that, in this embodiment, because the terminal device outputs the visual function interface to the development staff based on the code conversion function plug-in, and when the development staff performs the configuration operation of selecting the document interface based on the visual function interface, the development staff may simultaneously select a plurality of interfaces under one interface classification, information such as the identifiers of a plurality of document interfaces may be included in the platform interface information received by the terminal device based on the configuration operation, and therefore, when the terminal device calls the application program interfaces on the interface document platform based on the platform interface information, the terminal device may simultaneously call the application program interfaces corresponding to the identifiers of the plurality of document interfaces.
Step S202, obtaining the document information of the interface document to be code-converted from the application program interface.
It should be noted that, in the present embodiment, the document information of the interface document includes, but is not limited to: the interface url (Uniform Resource Locator) of the document, the HTTP (Hyper Text Transfer Protocol) method, the header, the field name of the request/return parameter, and the remark.
The terminal equipment directly calls application program interfaces corresponding to interface document platforms of one or more systems based on platform interface information in the code conversion configuration parameters, and then further obtains document information such as an interface url, an http method, a header, a field name of a request/return parameter, remarks and the like of the interface document needing code conversion at present from the called application program interfaces.
Further, in this embodiment, the terminal device performs a configuration operation of selecting a corresponding code template based on a developer, so as to receive a code conversion configuration parameter of the code template, and store the received code conversion configuration parameter in a preset code template library, where the code template library is built in the terminal device or externally connected to the terminal device and is specially used for storing the code template, and the code template library calls the code template based on a template engine such as Freemarker.
In the step S20, the step of "determining a code template according to the code conversion configuration parameter" may include:
step S203, determining a code template for code conversion operation from the code template library according to the code conversion configuration parameters;
the terminal equipment determines a code template according to the received code conversion configuration parameters, and determines the code template which is autonomously selected by a development worker to execute the configuration operation of selecting the code template and is currently used for executing the code conversion operation according to the code conversion configuration parameters directly in a code template library for storing the code template.
It should be noted that, in this embodiment, the terminal device generates different codes according to the content of the interface document and the code template autonomously selected by the development worker, by using an open API provided by the interface document Platform as a connection in combination with a freemaker template engine, based on a code conversion functional plug-in developed by the IntelliJ Platform plug SDK in advance.
In addition, in the present embodiment, the preset code templates in the code template library include, but are not limited to: DTO (Data Transfer Object) template, contller (controller) template, and Service (business logic Service entry) template.
Further, in a possible embodiment, the code conversion method of the interface document of the present invention may further include:
and step C, editing and/or newly building a code template according to a preset code conversion function plug-in, and storing the code template in the code template library.
The terminal device can also run the code conversion function plug-in to output the visual function interface to the development staff so that the development staff can execute the operation of editing and/or newly building a code template based on the interface, and the terminal device directly stores the code template edited and/or newly built by the development staff in a built-in or external code template library so as to be called by a template engine at any time.
Specifically, for example, referring to the application flow shown in fig. 3, in the process of operating the integrated development environment IntelliJ IDEA, the terminal device outputs a graphical user interface including a project to be developed or to be operated and maintained by the system to a development worker of the system, so that the development worker can enter the code template library based on the graphical user interface, select an editing operation for modifying or deleting an existing code template in the code template library, or select to newly create a new code template in the code template library, and the terminal device directly stores the edited code template or the newly created code template in the code template library based on the editing or newly created operation. Therefore, when a subsequent development worker autonomously selects a corresponding code template through the 'code generation' dialog box, the subsequent development worker can directly enter the code template library to select a code template for code conversion on the target project currently to generate a code file which needs to be introduced into the target project from the code template library.
Please refer to the application scenario shown in fig. 5 in this embodiment. One item of an interface document platform of the system can have a plurality of classifications, and a plurality of interface documents are arranged under each classification, so if a development worker selects one interface classification and a plurality of interfaces in a UI interface (a 'code generation' dialog box) output by a terminal device running a code conversion function plug-in, and further selects a controller template as a code template for currently carrying out a code conversion operation, the terminal device finally generates a plurality of code files based on the code template, namely, a code file with a plurality of methods of the controller class and a plurality of DTO classes of the code files, wherein the number of the DTO class code files depends on the number of objects for requesting and returning document information of parameters in the interface document.
And step S30, according to the document content of the interface document, the document information and the code template, code conversion operation is carried out to obtain a code file which is required to be introduced by the target project.
After the terminal device obtains the document information according to the received code conversion configuration parameters and determines the code template currently used for code conversion operation according to the code conversion configuration parameters, the terminal device further generates a code file required to be introduced into the target project under the target project selected by the development staff according to the document information and the code template and the code category prefix in the code conversion configuration parameters.
Further, in this embodiment, the transcoding configuration parameters include: the prefix of the code category, the code conversion method of the interface document of the invention, can also include:
step D, establishing a file name of a code file which is required to be introduced into the target project according to the code conversion configuration parameters;
when the received code conversion configuration parameters include prefixes of code categories generated by configuration operation of inputting the prefix of the class name executed by development workers, the terminal equipment further creates file names of code files required to be introduced for code conversion operation under the current target item according to the code conversion configuration parameters, namely the prefixes of the code categories.
Further, in this embodiment, step D may include:
step D1, extracting the prefix of the code category from the code conversion configuration parameter;
and D2, splicing according to the prefixes of the code categories to create and obtain the file name of the code file which needs to be introduced into the target project.
When the received code conversion configuration parameters comprise prefixes of code categories generated by configuration operation of input class name prefixes executed by development workers, the prefixes are immediately extracted by the terminal equipment, and then splicing is carried out based on the prefixes, so that file names of code files required to be introduced for code conversion operation under the current target item are created.
Specifically, for example, it is assumed that the terminal device runs a code conversion function plug-in which has been installed in advance to pop up a "generate code" dialog box to the development worker, so that the development worker performs a configuration operation of selecting a document interface through the dialog box, the generated configuration parameters are two document interfaces under one document classification, and after the terminal device also pops up a "prefix" dialog box to the development worker by running the code conversion function plug-in, the development worker performs a configuration operation of inputting a class prefix based on the dialog box, and the prefix of the input class is User, that is, the code conversion configuration parameter of the prefix of the code class received by the terminal device is "User". Therefore, the terminal device, based on the extracted prefix User, splices the prefix User and the prefix Update and Update of the DTO to obtain file names of several code files generated under the current target item, which are respectively User controller, queryrequesttto, QueryResponseDTO, UpdateRequestDTO and updateresponsetto.
Further, in the present embodiment, the transcoding operation is: the package name, user information, and/or document information is converted into parameters in the code template.
The step S30 may include:
step S301, analyzing the target project to obtain a package name, and acquiring user information of a code introduction object;
step S302, converting the document content, the document information, the user information, and the package name into the code template to obtain a code file that needs to be introduced into the target project.
The method comprises the steps that when a terminal device runs a code conversion function plug-in an integrated development environment and generates a target project selected by a development worker to be introduced into a code file by combining a template engine with received code conversion configuration parameters, the terminal device firstly analyzes the target project selected by the development worker to obtain a package name and obtains user information when the current development worker is used as a code introduction object needing to introduce the code file into the target project, and then the terminal device replaces document information, the user information, the package name and document content of an interface document which are obtained from an interface document platform according to the code conversion configuration parameters into a code template selected by the development worker together, so that the template engine directly outputs the code file generated by conversion under the current target project.
Specifically, for example, referring to the application flow shown in fig. 6, when the terminal device runs a code conversion function plug-in to perform a code conversion operation in conjunction with a template engine that calls a code template to generate a code file, the terminal device obtains document content and document information of an interface document from an interface document platform of the system according to platform interface information in code conversion configuration parameters, obtains a package name by parsing a target directory selected by a developer performing a configuration operation based on a visual function interface, obtains user information of a code introduction object, i.e., a system developer git account or a user name of a user of the operating system, and obtains a file name (illustration class name) by splicing prefixes of code categories in the code conversion configuration parameters, further parses the document content of the interface document into a template engine, Freemarker, parameters in the currently called code template, and scanning the package name of the class of the code required to be introduced into the current target project, and then, replacing the document content, the document information, the user information and the file name into the code template by the terminal equipment to directly generate the code file.
After that, the terminal device may execute a refresh operation on the current target project by running the current integrated development environment once, that is, may determine that the code file generated based on the above process conversion has been introduced under the current target project, and then, the terminal device ends the whole current code conversion operation process.
Note that, in this embodiment, please refer to an application flow when processing is performed on the content of the interface document as shown in fig. 7. Because there may be many objects in a http request/return parameter in the document content, and one object needs to generate a DTO class code file, in the process of converting the document content of the interface document into the parameter in the code template, when the request/return parameter in the document content is converted into the DTO class, the terminal device first converts the comment and name in the document content into the DTO class parameter comment and parameter name, then first judges whether the parameter name of the document content is in the hump format, if not, converts into the hump format and adds @ jsoproperty comment (a kind comment) for unification, then detects whether the parameter type of the document content is a basic type — array, thereby recursively processing the array object and generating an DTO object file of an internal class or an external class for the parameter of the basic type of array, for a parameter of a basic type which is not an array, when the type of the parameter is an object type, namely an object, the object is processed recursively, an dto object file of an inner class or an outer class is generated, and finally, the generated dto object file is returned as a document content processing result.
In the embodiment, in the process of performing code conversion on an interface document by using a terminal device, a code conversion configuration parameter required by the current code conversion operation on the interface document is received on the basis of a code conversion function plug-in which is developed and generated in advance based on an integrated development environment; after receiving code conversion configuration parameters required by code conversion operation aiming at an interface document at present based on a code conversion functional plug-in, the terminal equipment further acquires document information which is selected by development workers and needs to be converted into a code file for introduction from an interface document platform of the system according to the code conversion configuration parameters, and determines a code template which needs to be called at present for code conversion operation from a preset code template library according to the code conversion configuration parameters; after the terminal device obtains the document information according to the received code conversion configuration parameters and determines the code template currently used for code conversion operation according to the code conversion configuration parameters, the terminal device further generates a code file required to be introduced into the target project under the target project selected by the development staff according to the document information and the code template and the code category prefix in the code conversion configuration parameters.
Compared with the traditional mode of converting the code of the interface document, the invention receives the configuration parameters through the pre-developed code conversion functional plug-in, and then directly performs the code conversion operation according to the parameters to directly obtain the code file required to be introduced by the target project in the system, thus realizing the direct butt joint of the interface document platform on the project to be developed of the system, and directly converting and generating the code aiming at the interface document by using the developed functional plug-in.
In addition, the project information of the developer customized by the development staff can be provided by providing a visual function interface for the development staff, and is also directly written into the finally generated code file as the configuration parameter, so that the codes can be directly used under the target project without secondary processing of the converted codes by the development staff, and the overall efficiency of code conversion is further improved.
Furthermore, the invention also provides a code conversion device of the interface document. Referring to fig. 8, fig. 8 is a functional module diagram of an embodiment of a code conversion apparatus of an interface document according to the present invention. As shown in fig. 8, the code conversion apparatus of the interface document of the present invention includes:
the parameter configuration module 10 is configured to receive a code conversion configuration parameter based on a preset code conversion functional plug-in, where the code conversion functional plug-in is developed and generated in advance based on an integrated development environment;
the obtaining module 20 is configured to obtain document information of an interface document from an interface document platform of the system according to the code conversion configuration parameter, and determine a code template according to the code conversion configuration parameter;
and the code conversion module 30 is configured to perform a code conversion operation according to the document content of the interface document, the document information, and the code template to obtain a code file that needs to be introduced into the target project.
Further, the code conversion apparatus of the interface document of the present invention further includes:
the system comprises a plug-in development module, a plug-in conversion module and a plug-in conversion module, wherein the plug-in development module is used for developing a newly-built development project based on an integrated development environment, providing a user interface through various interface development plug-ins in a preset software development kit, receiving program information based on the user interface, and performing code conversion on the received program information to generate an initial code conversion functional plug-in; and debugging the initial code conversion function plug-in, and packaging to obtain the code conversion function plug-in after the debugging is stable.
Further, the parameter configuration module 10 includes:
the system comprises a detection unit, a code conversion unit and a control unit, wherein the detection unit is used for detecting a code conversion instruction initiated aiming at a target project, and the target project is a project needing to introduce codes in the system;
and the receiving unit is used for operating the code conversion function plug-in to output a visual function interface and receiving code conversion configuration parameters for generating a code file under the target project according to the visual function interface.
Further, the transcoding configuration parameters include: platform interface information; an acquisition module 20, comprising:
the interface calling unit is used for calling an application program interface corresponding to an interface document platform of the system according to the platform interface information in the code conversion configuration parameters, wherein the number of the application program interfaces is greater than or equal to one;
and the acquisition unit is used for acquiring the document information of the interface document to be subjected to code conversion from the application program interface.
Further, the code template is stored in a preset code template library; the obtaining module 20 is further configured to determine, according to the code conversion configuration parameter, a code template for performing a code conversion operation from the code template library;
the code conversion device of the interface document of the invention also comprises:
and the template editing module is used for editing and/or newly creating a code template according to a preset code conversion function plug-in and storing the code template in the code template library.
Further, the transcoding operation is to: replacing the package name, the user information, the document content and the document information into a code template; a transcoding module 30, comprising:
the package name analyzing unit is used for analyzing the target project to obtain a package name and acquiring user information of the code introduction object;
and the conversion unit is used for converting the document content, the document information, the user information and the package name into the code template to obtain a code file which needs to be introduced into the target project.
Further, the transcoding configuration parameters include: the prefix of the code category, the code conversion device of the interface document of the invention, also include:
the creating module is used for creating a file name of a code file which needs to be introduced into the target project according to the code conversion configuration parameters;
a creation module comprising:
an extracting unit, configured to extract a prefix of the code category from the code conversion configuration parameter;
and the splicing unit is used for splicing according to the prefixes of the code categories to create and obtain the file name of the code file required to be introduced into the target project.
The function implementation of each module in the code conversion device of the interface document corresponds to each step in the code conversion method embodiment of the interface document, and the function and implementation process are not described in detail herein.
The present invention also provides a computer storage medium having stored thereon a code conversion program of an interface document, which when executed by a processor, implements the steps of the code conversion method of the interface document as described in any one of the above embodiments.
The specific embodiment of the computer storage medium of the present invention is basically the same as the embodiments of the code conversion method of the interface document, and is not described herein again.
The invention also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the method for transcoding an interface document as described in any one of the above embodiments.
The specific embodiment of the computer program product of the present invention is substantially the same as the embodiments of the code conversion method of the interface document, and is not described herein again.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A code conversion method for an interface document, the code conversion method for the interface document comprising the steps of:
receiving code conversion configuration parameters based on a preset code conversion functional plug-in, wherein the code conversion functional plug-in is developed and generated in advance based on an integrated development environment;
acquiring document information of an interface document from an interface document platform of the system according to the code conversion configuration parameters, and determining a code template according to the code conversion configuration parameters;
and according to the document content of the interface document, the document information and the code template, performing code conversion operation to obtain a code file which is required to be introduced into the target project.
2. The method of transcoding an interface document of claim 1, wherein the method further comprises:
developing a new development project based on an integrated development environment, providing a user interface through various interface development plug-ins in a preset software development kit, receiving program information based on the user interface, and performing code conversion on the received program information to generate an initial code conversion functional plug-in;
and debugging the initial code conversion functional plug-in, and packaging to obtain the code conversion functional plug-in after the debugging is stable.
3. The method for transcoding an interface document according to claim 1, wherein the step of receiving transcoding configuration parameters based on a preset transcoding function plug-in comprises:
detecting a code conversion instruction initiated aiming at a target project, wherein the target project is a project needing to introduce codes in a system;
and operating the code conversion function plug-in to output a visual function interface, and receiving code conversion configuration parameters for generating a code file under the target project according to the visual function interface.
4. The transcoding method of the interface document of claim 1, wherein the transcoding configuration parameters comprise: platform interface information;
the step of obtaining the document information of the interface document from the interface document platform of the system according to the code conversion configuration parameters comprises the following steps:
according to the platform interface information in the code conversion configuration parameters, calling an application program interface corresponding to an interface document platform of the system, wherein the number of the application program interfaces is greater than or equal to one;
and acquiring document information of the interface document to be subjected to code conversion from the application program interface.
5. The code conversion method of an interface document according to claim 1, wherein the code template is stored in a preset code template library;
the step of determining a code template according to the code conversion configuration parameters includes:
determining a code template for code conversion operation from the code template library according to the code conversion configuration parameters;
the method further comprises the following steps:
and editing and/or creating a code template according to a preset code conversion function plug-in, and storing the code template in the code template library.
6. The method of transcoding an interface document of claim 1, wherein the transcoding operation is to: replacing the package name, the user information, the document content and the document information into a code template;
the step of performing code conversion operation according to the document content of the interface document, the document information and the code template to obtain a code file to be introduced into the target project includes:
analyzing the target project to obtain a package name, and acquiring user information of the code introduction object;
and converting the document content, the document information, the user information and the package name into the code template to obtain a code file which needs to be introduced into the target project.
7. The method for transcoding of an interface document according to any of claims 1 to 6, wherein the transcoding configuration parameters comprise: a prefix of a code category, the method further comprising:
establishing a file name of a code file which needs to be introduced into the target project according to the code conversion configuration parameters;
the step of creating the file name of the code file which is required to be introduced into the target project according to the code conversion configuration parameters comprises the following steps:
extracting prefixes of the code categories from the code conversion configuration parameters;
and splicing according to the prefixes of the code categories to create and obtain the file name of the code file required to be introduced into the target project.
8. A code conversion apparatus for an interface document, characterized in that the code conversion apparatus for an interface document comprises:
the parameter configuration module is used for receiving code conversion configuration parameters based on a preset code conversion functional plug-in, wherein the code conversion functional plug-in is developed and generated in advance based on an integrated development environment;
the acquisition module is used for acquiring document information of the interface document from an interface document platform of the system according to the code conversion configuration parameters and determining a code template according to the code conversion configuration parameters;
and the code conversion module is used for carrying out code conversion operation according to the document content of the interface document, the document information and the code template to obtain a code file which is required to be introduced into the target project.
9. A terminal device, characterized in that the terminal device comprises: memory, a processor and a code translation program of an interface document stored on the memory and executable on the processor, the code translation program of the interface document implementing the steps of the code translation method of the interface document according to any one of claims 1 to 7 when executed by the processor.
10. A computer storage medium, characterized in that the computer storage medium has stored thereon a code conversion program of an interface document, which when executed by a processor implements the steps of the code conversion method of the interface document according to any one of claims 1 to 7.
CN202111547504.1A 2021-12-16 2021-12-16 Code conversion method and device of interface document, terminal equipment and storage medium Pending CN114201179A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111547504.1A CN114201179A (en) 2021-12-16 2021-12-16 Code conversion method and device of interface document, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111547504.1A CN114201179A (en) 2021-12-16 2021-12-16 Code conversion method and device of interface document, terminal equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114201179A true CN114201179A (en) 2022-03-18

Family

ID=80654779

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111547504.1A Pending CN114201179A (en) 2021-12-16 2021-12-16 Code conversion method and device of interface document, terminal equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114201179A (en)

Similar Documents

Publication Publication Date Title
US10169031B2 (en) Program code library searching and selection in a networked computing environment
US8091071B2 (en) Method and system for template-based code generation
US9448770B2 (en) Source code editor
CN105718289B (en) Component relation establishing method and equipment
CN106547527B (en) JavaScript file construction method and device
US20100146492A1 (en) Translation of programming code
US9672032B2 (en) Mobile enabled application
CN113971110A (en) Interface testing method, device, equipment and computer readable storage medium
CN110895471A (en) Installation package generation method, device, medium and electronic equipment
CN112398809B (en) Protocol rule conversion method, device, computer equipment and storage medium
US20180275957A1 (en) Assistive technology for code generation using voice and virtual reality
CN113268245A (en) Code analysis method, device and storage medium
CN113127361A (en) Application program development method and device, electronic equipment and storage medium
CN115658237A (en) Container application automatic deployment method, device, apparatus, equipment and medium
US10353700B1 (en) Code base sharing between standalone and web-based versions of an application via an emulated network communication channel
CN113138768A (en) Application package generation method and device, electronic equipment and readable storage medium
US10606569B2 (en) Declarative configuration elements
WO2023083071A1 (en) View interaction method and apparatus, electronic device, and computer readable medium
CN114201179A (en) Code conversion method and device of interface document, terminal equipment and storage medium
CN112015384A (en) Interface mapping method and device
CN111427770B (en) Resource testing method and related equipment
CN111240693A (en) Real-time data processing method, device, equipment and storage medium
CN113032004A (en) Method, apparatus and program product for managing development jobs in a development environment
CN107070964B (en) Remote communication packaging method and system based on heterogeneous environment
CN110716746B (en) Method and device for converting RN style code into applet style code

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination