CN111581920A - Document conversion method, device, equipment and computer storage medium - Google Patents

Document conversion method, device, equipment and computer storage medium Download PDF

Info

Publication number
CN111581920A
CN111581920A CN202010399936.1A CN202010399936A CN111581920A CN 111581920 A CN111581920 A CN 111581920A CN 202010399936 A CN202010399936 A CN 202010399936A CN 111581920 A CN111581920 A CN 111581920A
Authority
CN
China
Prior art keywords
document
conversion
target
format
code
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
CN202010399936.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 CN202010399936.1A priority Critical patent/CN111581920A/en
Publication of CN111581920A publication Critical patent/CN111581920A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The invention relates to the technical field of financial technology (Fintech) and discloses a document conversion method, which comprises the following steps: receiving an input conversion instruction, and detecting whether the conversion instruction is a document conversion code instruction or not; if yes, determining a target template in a plurality of preset templates based on the document conversion code instruction, and inputting a target document corresponding to the document conversion code instruction into the target template; and carrying out format conversion on the target document according to the format rule in the target template so as to obtain a target code corresponding to the target document. The invention also discloses a document conversion device, equipment and a computer storage medium. The invention realizes the interconversion of the document and the code and reduces the maintenance cost of the document for developers.

Description

Document conversion method, device, equipment and computer storage medium
Technical Field
The invention relates to the technical field of financial technology (Fintech), in particular to a document conversion method, a device, equipment and a computer storage medium.
Background
With the development of computer technology, more and more technologies (big data, distributed, Blockchain, artificial intelligence, etc.) are applied to the financial field, and the traditional financial industry is gradually changing to financial technology (Fintech), but because of the requirements of security and real-time performance of the financial industry, higher requirements are also put forward on the document conversion technology. Currently, all open source document (such as Yapi or other) platforms can only provide traditional document functions, and have no function of bidirectional conversion or code generation of corresponding codes of the documents. In addition, in the open-source document platform, the development cost from documents to codes is high, and automatic document creation or updating cannot be realized, so that the maintenance cost of developers on the documents in the open-source document platform is high. Therefore, how to realize the interconversion between the document and the code and reduce the maintenance cost of the document becomes a technical problem to be solved urgently at present.
Disclosure of Invention
The invention mainly aims to provide a document conversion method, a document conversion device, document conversion equipment and a computer storage medium, and aims to solve the technical problems of how to realize the mutual conversion of documents and codes and reduce the maintenance cost of the documents.
In order to achieve the above object, the present invention provides a document conversion method, including the steps of:
receiving an input conversion instruction, and detecting whether the conversion instruction is a document conversion code instruction or not;
if yes, determining a target template in a plurality of preset templates based on the document conversion code instruction, and inputting a target document corresponding to the document conversion code instruction into the target template;
and carrying out format conversion on the target document according to the format rule in the target template so as to obtain a target code corresponding to the target document.
Optionally, the step of inputting the target document corresponding to the document conversion code instruction into the target template includes:
and determining a target document in a plurality of preset documents according to the document conversion code instruction, acquiring structured data of the target document, and inputting the structured data into the target template.
Optionally, the step of performing format conversion on the target document according to the format rule in the target template includes:
acquiring all variables of the target document, sequentially traversing all the variables, and determining the current document format of the currently traversed current variable;
and determining a current code format corresponding to the current document format according to a format rule in the target template, and converting the current document format into the current code format until all the variables are traversed.
Optionally, after the step of detecting whether the conversion instruction is a document conversion code instruction, the method includes:
if the conversion instruction is a code conversion document instruction, determining an initial code corresponding to the code conversion document instruction, and converting the initial code into an initial document according to a preset constraint rule.
Optionally, the step of converting the initial code into an initial document according to a preset constraint rule includes:
detecting whether format conversion data exists in the initial code;
if the initial document format exists, determining an initial document format according to the format conversion data, converting the format of the initial code into the initial document format according to a preset constraint rule, and determining an initial document based on the initial document format.
Optionally, the step of determining a target template among a plurality of preset templates based on the document transcoding instruction includes:
detecting whether the document conversion code instruction carries target template information or not;
and if so, determining the target template in a plurality of preset templates according to the target template information.
Optionally, the step of performing format conversion on the target document according to the format rule in the target template includes:
detecting whether the target document is subjected to format conversion according to a format rule in the target template;
if not, stopping format conversion of the target document, and outputting prompt information of unsuccessful conversion; and if so, carrying out format conversion on the target document according to the format rule in the target template.
Further, to achieve the above object, the present invention also provides a document conversion apparatus including:
the detection instruction is used for receiving an input conversion instruction and detecting whether the conversion instruction is a document conversion code instruction or not;
the input module is used for determining a target template in a plurality of preset templates based on the document conversion code instruction and inputting a target document corresponding to the document conversion code instruction into the target template if the target template is the preset template;
and the format conversion module is used for carrying out format conversion on the target document according to the format rule in the target template so as to obtain a target code corresponding to the target document.
Further, to achieve the above object, the present invention also provides a document conversion apparatus including: a memory, a processor and a document conversion program stored on the memory and executable on the processor, the document conversion program when executed by the processor implementing the steps of the document conversion method as described above.
In addition, to achieve the above object, the present invention also provides a computer storage medium having a document conversion program stored thereon, the document conversion program implementing the steps of the document conversion method as described above when executed by a processor.
The invention receives an input conversion instruction and detects whether the conversion instruction is a document conversion code instruction; if yes, determining a target template in a plurality of preset templates based on the document conversion code instruction, and inputting a target document corresponding to the document conversion code instruction into the target template; and carrying out format conversion on the target document according to the format rule in the target template so as to obtain a target code corresponding to the target document. When the conversion instruction is a document conversion code instruction, the target template is determined according to the document conversion code instruction, and the target document is input into the target template for format conversion so as to obtain the target code, so that the phenomenon that the document conversion code cannot be directly performed in a platform in the prior art is avoided, the document and the code can be converted mutually, and the maintenance cost of a developer on the document is reduced.
Drawings
FIG. 1 is a schematic diagram of a document transformation device in a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a first embodiment of a document conversion method according to the present invention;
FIG. 3 is a schematic diagram of an apparatus module of the document conversion apparatus according to the present invention;
FIG. 4 is a system flow diagram of document transformation code in the document transformation method of the present invention;
FIG. 5 is a flowchart illustrating a document conversion process 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.
As shown in fig. 1, fig. 1 is a schematic structural diagram of a document conversion device in a hardware operating environment according to an embodiment of the present invention.
The file conversion device of the embodiment of the invention can be a PC or a server device, and a Java virtual machine runs on the file conversion device.
As shown in fig. 1, the document conversion apparatus may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, a communication bus 1002. 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., 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 document conversion device architecture shown in FIG. 1 does not constitute a limitation of the device and may include more or fewer components than 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 an operating system, a network communication module, a user interface module, and a document conversion program.
In the document conversion device shown in fig. 1, the network interface 1004 is mainly used for connecting with a backend server and communicating with the backend server in data; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and the processor 1001 may be configured to call a document conversion program stored in the memory 1005 and perform operations in the document conversion method described below.
Based on the hardware structure, the embodiment of the document conversion method is provided.
Referring to fig. 2, fig. 2 is a flowchart illustrating a first embodiment of a document conversion method according to the present invention, the method including:
step S10, receiving the input conversion instruction, and detecting whether the conversion instruction is a document conversion code instruction;
in the embodiment, the method is mainly applied to format conversion of the document in the open-source document platform, namely converting the document into the code, or converting the code into the document. And YApi is mainly used for illustration in the present embodiment, but is not limited to this. YApi is a mainstream open source document platform, and can further integrate test-related functions around a series of core operations of a document. Including, but not limited to: and editing and displaying the interface document. As shown in the following figure, basic conventional HTTP (HyperText Transfer Protocol) interface parameters, such as Header/Body/Response core parameters, can be configured by clicking a button to create an interface. Fixed types of formatting parameters. The parameter type is also given to Object/String/Int (data type) standard types. Interface Mock, etc. As shown in the following figure, after the interface definition is completed, the developer can configure the basic request parameter to complete the Mock function, thereby implementing simple function verification of the interface. Automated test set or functional test set saving, etc. As shown in the following figure, when the interface is complete, the tester can prepare a functional test set or automated test cases, etc. In the embodiment, the code one-key generation of the interface document or the code-based one-key update capability can be realized on the basis of the open source item Yapi, that is, the document can be quickly converted into the code or the code can be converted into the document as long as the input conversion instruction is received. That is, in the present embodiment, when an input conversion instruction is received, it is necessary to first determine whether the conversion instruction is a document conversion code instruction or a code conversion document instruction. And executing different conversion operations according to different judgment results.
Step S20, if yes, determining a target template in a plurality of preset templates based on the document conversion code instruction, and inputting a target document corresponding to the document conversion code instruction into the target template;
when the conversion instruction is found to be the document conversion code instruction through judgment, whether the document conversion code instruction carries the target template information needs to be detected, namely, the operation of document conversion code is determined according to which template. And if the document conversion code instruction does not carry the target template information, stopping the document conversion code operation and outputting corresponding prompt information to inform a user that the conversion cannot be successful. However, if the document conversion code instruction carries the target template information, a target template matched with the target template information can be directly searched in a plurality of templates preset in Yapi, a target document to be subjected to document conversion is determined in Yapi according to the document conversion code instruction, and then structured data (such as json data) of the target document is input into the target template to perform format conversion.
And when the conversion instruction is found to be a code conversion document instruction through judgment, the structured json data of the document can be deduced reversely through the code, the Yapi standardized interface is transmitted to call the Yapi development interface to store the structured json data into the database, and the data required by document display is restored, so that the process of converting the code into the document is completed.
Step S30, performing format conversion on the target document according to the format rule in the target template to obtain a target code corresponding to the target document.
After the structured data of the target document is input into the target template, format conversion can be performed on the target document according to a format rule set in the target template in advance to obtain a target code corresponding to the target document. Analyzing json parameters of the target document according to the target template, realizing customized filling of java codes and obtaining the target codes. Under the principle of conforming to a Freemarker engine, customizing a request variable corresponding to a request parameter of a target document, a return variable corresponding to the return parameter, and replacing the corresponding variable by a Value corresponding to Key mapping through Key-Value form data carried by structured json data in the target document, wherein if a request code corresponding to the request variable is determined, the request variable is replaced by the request code; and determining a return code corresponding to the return variable, and replacing the return variable with the return code, thereby realizing the filled molding normalized java code, namely the target code. Wherein FreeMarker is a template engine: i.e. a generic tool that is based on templates and data to be changed and used to generate output text (HTML web pages, e-mails, configuration files, source code, etc.).
It should be noted that, when converting the target document into the target code, a Web frame is adopted, and the Web frame has Springboot (MVC/WebFlux), vert.x, etc., and the code level of these frames has format constraint specifications, such as Controller layer (Web entry route)/Service layer (Service processing layer)/Mapper & hierarchy layer (data access layer)/DTO & Entity layer (data model layer) etc., where Springboot MVC is standard, and Springboot WebFlux and vert.x, etc., have corresponding Handler layer (Web entry route), etc., and the frame code has a fixed outer layer writing method. For example, the Controller layer fixed code format is as follows, and the constraint to be followed is: must end with Controller; @ RequestMapping entails a standard request path; each request must indicate whether it is a GET request or a POST request; the specific parameters of the request are standardized and defined in the request parameters of the method; it must be stated with @ RestController that this is a standard Controller class, etc. Format constraints can be performed through the target template, determining stylistic constraints for the web framework.
And the data stored by the Yapi is specific structured data in a Json format, the document of the Yapi contains all definitions of a Web request, and the structured data corresponding to the definition data are stored in the MongoDB through the Json data. Namely, Yapi stores actual variable data in MongoDB; while the Web framework provides stylistic constraints for the corresponding written code. Therefore, the Java style code with a specific format can be generated by combining two parts of data, so that the function of automatically generating the code is realized, namely structured variable data + format constraint, namely structured code. Similarly, the structured Json data can be restored through a structured code-format constraint, namely structured variable data, the document data stored by the MongoDB is reversely pushed out, and the document code is restored according to the data.
In addition, in order to assist understanding of the technical principle of transcoding a document or transcoding a document in the present embodiment, the following description is made by way of example.
For example, as shown in FIG. 4, it includes developer, attendee, intellij IDEA (code to document plug-in), APIDESIGN-ENGINE (API document design management system ENGINE), MySQL (relational database management system), MongoDB (database), APIDESIGN-WEB (Yapi document design management system front end), APIDESIGN-CORE (Yapi document design management system back end). In Yapi, developers can write API documents and upload the documents through code-to-document plug-ins. And the attention user can download the document/code in Yapi, and when the document in Yapi is changed, the attention user can send a document change notice to the attention user. And when the document is converted into the code or the code is converted into the document, the API document or the code can be generated through the API document design management system engine. Therefore, when the conversion operation of the document is performed through the API document design management system engine, the grammar conversion, namely the format conversion, from the structured json data to the java code can be performed according to the generation rule of a Freemarker template (namely a target template) engine. In addition, when performing format conversion, as shown in fig. 5, in the Yapi platform, when a code request is generated, it is determined whether the code request carries template information, and if not, the process is terminated. If yes, whether the json is matched or not is detected, and if not, the process is terminated. If yes, determining a target document according to json, inputting the target document into a target template corresponding to the template information, detecting whether the target template successfully generates a corresponding code according to FreeMarker rules, and if yes, determining that the process is successful. If not, the flow is terminated.
In the embodiment, an input conversion instruction is received, and whether the conversion instruction is a document conversion code instruction is detected; if yes, determining a target template in a plurality of preset templates based on the document conversion code instruction, and inputting a target document corresponding to the document conversion code instruction into the target template; and carrying out format conversion on the target document according to the format rule in the target template so as to obtain a target code corresponding to the target document. When the conversion instruction is a document conversion code instruction, the target template is determined according to the document conversion code instruction, and the target document is input into the target template for format conversion so as to obtain the target code, so that the phenomenon that the document conversion code cannot be directly performed in a platform in the prior art is avoided, the document and the code can be converted mutually, and the maintenance cost of a developer on the document is reduced.
Further, based on the first embodiment of the document conversion method of the present invention, a second embodiment of the document conversion method of the present invention is proposed. This embodiment is a step S20 of the first embodiment of the present invention, and a refinement of the step of inputting the target document corresponding to the document conversion code instruction into the target template includes:
step a, determining a target document in a plurality of preset documents according to the document conversion code instruction, acquiring structured data of the target document, and inputting the structured data into the target template.
In this embodiment, when the document conversion code instruction is obtained, all documents (such as articles, news, lyrics, and the like) in the platform may be obtained first, and a target document to be converted is determined in the documents according to the document conversion code instruction. Since all documents in the platform are stored in the database as structured data, the structured data (such as json data) of the target temperature needs to be acquired, and then the structured data is input into the target template, so that the operation of inputting the target document into the target template is completed.
In the embodiment, the target document is determined according to the document conversion instruction, and the structured data of the target document is input into the target template for format conversion, so that the normal format conversion of the target document is ensured.
Further, the step of performing format conversion on the target document according to the format rule in the target template includes:
b, acquiring all variables of the target document, sequentially traversing all the variables, and determining the current document format of the currently traversed current variable;
in this embodiment, when the target document is converted, the API document design management system engine may control the target template to perform format conversion on the target document according to a preset format rule, that is, first obtain all variables of the target document, such as a request variable corresponding to a request parameter, return a return variable corresponding to the request parameter, determine Key-Value form data carried by structured data in the document, and replace the corresponding variable with a Value mapped by a corresponding Key. I.e., sequentially traversing each variable and determining the document format of the currently traversed current variable (i.e., the current document format).
And c, determining a current code format corresponding to the current document format according to a format rule in the target template, and converting the current document format into the current code format until all the variables are traversed.
And then, according to a format rule extracted and set from the target template, determining a code format (namely the current code format) corresponding to the current document format, namely determining a code value corresponding to the keyword, and then converting the current document format into the current code format until all variables are traversed, namely all variables are converted into codes, thereby summarizing to obtain the target code.
In the embodiment, all variables of the target document are traversed, and the current document format of the currently traversed current variable is converted into the current code format until all variables are traversed, so that the conversion of all variables of the target document is guaranteed.
Further, after the step of detecting whether the converting instruction is a document converting code instruction, the method comprises:
and d, if the conversion instruction is a code conversion document instruction, determining an initial code corresponding to the code conversion document instruction, and converting the initial code into an initial document according to a preset constraint rule.
In this embodiment, when it is determined that the conversion instruction is a code conversion instruction, it is necessary to determine, in the platform, the initial code corresponding to the code conversion instruction, that is, determine which piece of code needs to be converted into a document. And because the codes of different types of documents have different format constraints, the format constraint of the initial code, namely a preset constraint rule, needs to be determined, and then subtraction conversion is carried out to obtain a corresponding document, namely the initial document. I.e., structured code-format constraints, structured variable data.
In the embodiment, when the conversion instruction is determined to be the instruction for converting the code document, the initial code is determined first, and the initial code is converted into the initial document according to the constraint rule, so that the accuracy of converting the initial code into the initial document is guaranteed.
Further, the step of converting the initial code into an initial document according to a preset constraint rule includes:
step e, detecting whether format conversion data exists in the initial code;
in this embodiment, when converting the initial code into the initial document, it is necessary to detect whether a certain section of special code, i.e., format conversion data, exists in the initial code, and perform different operations according to different detection results. The format conversion data may be as follows:
@RequestMapping(value="/root/list")
public DeferredResult<ProjectDTO>listAll(String name){
return null;
}
and f, if the format conversion data exists, determining a target document format according to the format conversion data, converting the format of the initial code into the initial document format according to a preset constraint rule, and determining an initial document based on the initial document format.
When the format conversion data exists in the initial code after judgment, the target document format can be determined according to the format conversion data, for example, the key corresponding to the value is determined, and then the format of the initial code is converted into the initial document format according to a preset constraint rule, namely, structured json data. And calling the original open API of the Yapi platform to store the corresponding structured Json data into the MongoDB to finish standard data storage, and the original Yapi platform can be displayed. That is, the initial document is determined according to the initial document format, and is presented in the platform. However, if the format conversion data is not present in the initial code, a prompt message indicating that the document cannot be transcoded is output.
In this embodiment, when it is determined that format conversion data exists in the initial code, the format of the initial document is determined according to the format conversion data, the format of the initial code is converted into the format of the initial document, and the initial document is determined based on the format of the initial document, so that the accuracy of the acquired initial document is guaranteed.
Further, the step of determining a target template among a plurality of preset templates based on the document transcoding instruction includes:
step g, detecting whether the document conversion code instruction carries target template information;
in this embodiment, when the document transcoding instruction is obtained, it is further required to detect whether the document transcoding instruction carries target template information, and execute different operations according to different detection results.
And h, if so, determining a target template in a plurality of preset templates according to the target template information.
When the document conversion code instruction is judged to carry the target template information, the format constraint which needs to convert the target document into the target code can be determined, and the template matched with the target template information is obtained from a plurality of templates preset by the platform and is used as the target template. And if the document conversion code instruction does not carry the target template information, stopping the operation of the document conversion code.
In this embodiment, when it is determined that the document conversion code instruction carries the target template information, the target template is determined in the preset templates according to the target template information, so that the accuracy of the obtained target template is ensured.
Further, the step of performing format conversion on the target document according to the format rule in the target template includes:
step k, detecting whether the target document carries out format conversion according to the format rule in the target template;
in this embodiment, when converting the target code into the target document, it is necessary to detect whether the target document has format conversion according to the format rule in the target template in real time, and execute different operations according to different detection results.
Step m, if not, stopping format conversion of the target document, and outputting prompt information of unsuccessful conversion; and if so, carrying out format conversion on the target document according to the format rule in the target template.
And when the target document is judged to be subjected to format conversion according to the format rule in the target template, determining that the target document is subjected to conversion error, stopping the operation of converting the target code of the target document, and outputting prompt information of unsuccessful conversion. If the target document is subjected to format conversion according to the format rule in the target template, the format conversion of the target document is continued until the target document is successfully converted into the target code.
In the embodiment, when the target document is detected not to be subjected to format conversion according to the format rule in the target template, the format conversion of the target document is stopped, so that the phenomenon that the target document is converted wrongly is avoided.
It should be noted that, in this embodiment, in the process of converting the target document into the target code, json data of any interface document is obtained first, that is, structured data of the target document is obtained, for example:
Figure BDA0002488859100000111
Figure BDA0002488859100000121
then, customizing the structured code template, namely determining a target template, such as:
Figure BDA0002488859100000122
inputting the structured json data into a template, performing logic processing, and acquiring a final standardized code, namely a target code, such as:
@RequestMapping(value="/root/list")
public DeferredResult<ProjectDTO>listAll(String name){
return null;
}
in this embodiment, when a document is transcoded, a structured code needs to be converted into structured data, and if the following fields exist in the code:
@RequestMapping(value="/root/list")
public DeferredResult<ProjectDTO>listAll(String name){
return null;
}
the structured data can be deduced backwards from the constraint rules of the web as follows:
Figure BDA0002488859100000131
the present invention also provides a document conversion apparatus, referring to fig. 3, the document conversion apparatus comprising:
a detection instruction A10 for receiving an input conversion instruction and detecting whether the conversion instruction is a document conversion code instruction;
an input module a20, configured to determine, if yes, a target template among a plurality of preset templates based on the document transcoding instruction, and input a target document corresponding to the document transcoding instruction to the target template;
and the format conversion module a30 is configured to perform format conversion on the target document according to the format rule in the target template, so as to obtain a target code corresponding to the target document.
Optionally, the input module a20 is further configured to:
and determining a target document in a plurality of preset documents according to the document conversion code instruction, acquiring structured data of the target document, and inputting the structured data into the target template.
Optionally, the format conversion module a30 is further configured to:
acquiring all variables of the target document, sequentially traversing all the variables, and determining the current document format of the currently traversed current variable;
and determining a current code format corresponding to the current document format according to a format rule in the target template, and converting the current document format into the current code format until all the variables are traversed.
Optionally, the detection instruction a10 is further configured to:
if the conversion instruction is a code conversion document instruction, determining an initial code corresponding to the code conversion document instruction, and converting the initial code into an initial document according to a preset constraint rule.
Optionally, the detection instruction a10 is further configured to:
detecting whether format conversion data exists in the initial code;
if the initial document format exists, determining an initial document format according to the format conversion data, converting the format of the initial code into the initial document format according to a preset constraint rule, and determining an initial document based on the initial document format.
Optionally, the input module a20 is further configured to:
detecting whether the document conversion code instruction carries target template information or not;
and if so, determining the target template in a plurality of preset templates according to the target template information.
Optionally, the format conversion module a30 is further configured to:
detecting whether the target document is subjected to format conversion according to a format rule in the target template;
if not, stopping format conversion of the target document, and outputting prompt information of unsuccessful conversion; and if so, carrying out format conversion on the target document according to the format rule in the target template.
The method executed by each program unit can refer to each embodiment of the document conversion method of the present invention, and is not described herein again.
The invention also provides a computer storage medium.
The computer storage medium of the present invention has stored thereon a document conversion program which, when executed by a processor, implements the steps of the document conversion method as described above.
The method implemented when the document conversion program running on the processor is executed may refer to each embodiment of the document conversion method of the present invention, and details are not described here.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
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 document conversion method, characterized by comprising the steps of:
receiving an input conversion instruction, and detecting whether the conversion instruction is a document conversion code instruction or not;
if yes, determining a target template in a plurality of preset templates based on the document conversion code instruction, and inputting a target document corresponding to the document conversion code instruction into the target template;
and carrying out format conversion on the target document according to the format rule in the target template so as to obtain a target code corresponding to the target document.
2. The document conversion method according to claim 1, wherein the step of inputting the target document corresponding to the document conversion code instruction into the target template includes:
and determining a target document in a plurality of preset documents according to the document conversion code instruction, acquiring structured data of the target document, and inputting the structured data into the target template.
3. The document conversion method according to claim 1, wherein the step of format-converting the target document according to the format rule in the target template includes:
acquiring all variables of the target document, sequentially traversing all the variables, and determining the current document format of the currently traversed current variable;
and determining a current code format corresponding to the current document format according to a format rule in the target template, and converting the current document format into the current code format until all the variables are traversed.
4. The document conversion method of claim 1, wherein said step of detecting whether said conversion instruction is a document conversion code instruction is followed by:
if the conversion instruction is a code conversion document instruction, determining an initial code corresponding to the code conversion document instruction, and converting the initial code into an initial document according to a preset constraint rule.
5. The document conversion method according to claim 4, wherein the step of converting the initial code into the initial document according to a preset constraint rule comprises:
detecting whether format conversion data exists in the initial code;
if the initial document format exists, determining an initial document format according to the format conversion data, converting the format of the initial code into the initial document format according to a preset constraint rule, and determining an initial document based on the initial document format.
6. The document conversion method according to claim 1, wherein the step of determining a target template among a plurality of templates preset based on the document conversion code instruction comprises:
detecting whether the document conversion code instruction carries target template information or not;
and if so, determining the target template in a plurality of preset templates according to the target template information.
7. The document conversion method according to any one of claims 1 to 6, wherein the step of format-converting the target document according to the format rule in the target template includes:
detecting whether the target document is subjected to format conversion according to a format rule in the target template;
if not, stopping format conversion of the target document, and outputting prompt information of unsuccessful conversion; and if so, carrying out format conversion on the target document according to the format rule in the target template.
8. A document conversion apparatus, characterized by comprising:
the detection instruction is used for receiving an input conversion instruction and detecting whether the conversion instruction is a document conversion code instruction or not;
the input module is used for determining a target template in a plurality of preset templates based on the document conversion code instruction and inputting a target document corresponding to the document conversion code instruction into the target template if the target template is the preset template;
and the format conversion module is used for carrying out format conversion on the target document according to the format rule in the target template so as to obtain a target code corresponding to the target document.
9. A document conversion apparatus, characterized by comprising: memory, a processor and a document conversion program stored on the memory and executable on the processor, the document conversion program when executed by the processor implementing the steps of the document conversion method according to any one of claims 1 to 7.
10. A computer storage medium, characterized in that the computer storage medium has stored thereon a document conversion program which, when executed by a processor, implements the steps of the document conversion method according to any one of claims 1 to 7.
CN202010399936.1A 2020-05-12 2020-05-12 Document conversion method, device, equipment and computer storage medium Pending CN111581920A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010399936.1A CN111581920A (en) 2020-05-12 2020-05-12 Document conversion method, device, equipment and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010399936.1A CN111581920A (en) 2020-05-12 2020-05-12 Document conversion method, device, equipment and computer storage medium

Publications (1)

Publication Number Publication Date
CN111581920A true CN111581920A (en) 2020-08-25

Family

ID=72120822

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010399936.1A Pending CN111581920A (en) 2020-05-12 2020-05-12 Document conversion method, device, equipment and computer storage medium

Country Status (1)

Country Link
CN (1) CN111581920A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112306498A (en) * 2020-11-13 2021-02-02 用友网络科技股份有限公司 Code generation method, ERP system and readable storage medium
CN112463261A (en) * 2020-11-20 2021-03-09 北京达佳互联信息技术有限公司 Interface calling method and device
CN112540862A (en) * 2020-12-23 2021-03-23 东莞市盟大塑化科技有限公司 Interface document data generation method, device, equipment and storage medium
CN113992765A (en) * 2021-12-28 2022-01-28 北京南天信息工程有限公司 Financial message conversion method and system based on Freemarker template engine
CN114629807A (en) * 2020-12-11 2022-06-14 中国移动通信集团湖南有限公司 Work order processing method, device and equipment
CN117034900A (en) * 2023-09-27 2023-11-10 厦门星纵数字科技有限公司 Automatic generation method of API (application program interface) code file, terminal equipment and storage medium

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112306498A (en) * 2020-11-13 2021-02-02 用友网络科技股份有限公司 Code generation method, ERP system and readable storage medium
CN112463261A (en) * 2020-11-20 2021-03-09 北京达佳互联信息技术有限公司 Interface calling method and device
CN114629807A (en) * 2020-12-11 2022-06-14 中国移动通信集团湖南有限公司 Work order processing method, device and equipment
CN112540862A (en) * 2020-12-23 2021-03-23 东莞市盟大塑化科技有限公司 Interface document data generation method, device, equipment and storage medium
CN113992765A (en) * 2021-12-28 2022-01-28 北京南天信息工程有限公司 Financial message conversion method and system based on Freemarker template engine
CN117034900A (en) * 2023-09-27 2023-11-10 厦门星纵数字科技有限公司 Automatic generation method of API (application program interface) code file, terminal equipment and storage medium
CN117034900B (en) * 2023-09-27 2023-12-26 厦门星纵数字科技有限公司 Automatic generation method of API (application program interface) code file, terminal equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111581920A (en) Document conversion method, device, equipment and computer storage medium
CN107608889B (en) Method and system for automatically generating test script
US10558434B2 (en) Rule-based automatic class generation from a JSON message
US20180011780A1 (en) Web application test script generation to test software functionality
US11269694B2 (en) Automated API code generation
US9594802B2 (en) Graphical modeling of database query statements
CN108984155B (en) Data processing flow setting method and device
US11531914B2 (en) Artificial intelligence (AI) based automatic rule generation
CN108762743A (en) Data table operation code generation method and device
CN111026670B (en) Test case generation method, test case generation device and storage medium
CN113238740B (en) Code generation method, code generation device, storage medium and electronic device
CN111694547A (en) Automatic coding data processing application design tool based on data state change
US20200150937A1 (en) Advanced machine learning interfaces
JP2018514878A (en) A computer-implemented method for displaying software-type applications based on design specifications
CN110941427A (en) Code generation method and code generator
CN114138244A (en) Method and device for automatically generating model files, storage medium and electronic equipment
KR102226463B1 (en) UI/UX solution providing server linked with process automation program, process automation method using the same, and computer program executing the same
CN111309317A (en) Code automation method and device for realizing data visualization
CN115599386A (en) Code generation method, device, equipment and storage medium
CN114510262A (en) Interface request parameter verification method and device
US20100275183A1 (en) Source code auditor with a customized rules builder
CN116541020A (en) Code generation method, device, equipment, medium and product based on field model
CN111506305A (en) Tool kit generation method and device, computer equipment and readable storage medium
US11876756B2 (en) Graph-based natural language generation for conversational systems
CN114063868A (en) AI (Artificial intelligence) dragging modeling system and method, computer equipment and application

Legal Events

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