CN109614102A - Code automatic generation method, device, electronic equipment and storage medium - Google Patents

Code automatic generation method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN109614102A
CN109614102A CN201811180729.6A CN201811180729A CN109614102A CN 109614102 A CN109614102 A CN 109614102A CN 201811180729 A CN201811180729 A CN 201811180729A CN 109614102 A CN109614102 A CN 109614102A
Authority
CN
China
Prior art keywords
code
service interface
class
url
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
CN201811180729.6A
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.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Priority to CN201811180729.6A priority Critical patent/CN109614102A/en
Publication of CN109614102A publication Critical patent/CN109614102A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/447Target code generation

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

A kind of code automatic generation method, which comprises receive Code automatic build request;According to the Code automatic build request service interface document;URL, interface description, required parameter and response body are parsed from the service interface document;The data responded in body are converted into Json format, the dictionary type data in the Json formatted data after conversion are mapped as class;According to the URL, interface description, the required parameter, the class and preset network request template generation network request code.The present invention also provides a kind of code automatically generating device, electronic equipment and storage medium, it can be used for developing auxiliary automatic code generating.

Description

Code automatic generation method, device, electronic equipment and storage medium
Technical field
The present invention relates to mobile internet technical fields, and in particular to a kind of code automatic generation method, device, electronics are set Standby and storage medium.
Background technique
Currently, common client code generation method is to write completion client-side interface manually by developer to correspond to Code.In client code generation method, developer is needed to carry out largely duplicate write to each client-side interface Work is not only easy error, reduces the accuracy rate of code, and increase the generation time of code, reduce the life of code At efficiency.
Summary of the invention
In view of the foregoing, it is necessary to propose a kind of code automatic generation method, device, electronic equipment and storage medium, It can be used for developing auxiliary automatic code generating.
The first aspect of the present invention provides a kind of code automatic generation method, which comprises
Receive Code automatic build request;
According to the Code automatic build request service interface document;
URL, interface description, required parameter and response body are parsed from the service interface document;
The data responded in body are converted into Json format, by the dictionary type data in the Json formatted data after conversion It is mapped as class;
According to the URL, interface description, the required parameter, the class and preset network request template generation Network request code.
Further, the service interface document is the service interface document or word format of the html format of webpage Service interface document.
Further, URL, interface description, required parameter and response body are parsed from the service interface document includes:
When the service interface document is html format, using document object come in the service interface document All data access, obtain URL in the service interface document, interface description, required parameter and response body;
When the service interface document is word format, using java poi, java2word or jacob to described Interface document is parsed to obtain the URL in the service interface document, interface description, required parameter and response body.
Further, the dictionary type data in the Json formatted data after conversion are mapped as class includes:
Json formatted data after traversing the conversion determines the dictionary type in the Json formatted data after the conversion Data;
The dictionary type data are mapped as class.
Further, the preset network request template includes for describing the code of request function, for describing to ask Ask the code, the code for describing request path and the code for describing class of parameter.
Further, according to the URL, interface description, the required parameter, the class and preset network request Template generation network request code includes:
The code for being used to describe request path in the preset network request template is replaced with into the URL, by institute It states the code for describing request function in preset network request template and replaces with the interface description, it will be described preset The code for describing required parameter in network request template replaces with the required parameter, by the preset network request The code for describing class in template replaces with the class.
Further, the method also includes:
According to the network request code building client.
The second aspect of the present invention provides a kind of code automatically generating device, and described device includes:
Receiving module, for receiving Code automatic build request;
Document obtains module, for according to the Code automatic build request service interface document;
Parsing module, for parsing URL, interface description, required parameter and response body from the service interface document;
Mapping block will be in the Json formatted data after conversion for the data responded in body to be converted to Json format Dictionary type data be mapped as class;
Generation module, for according to the URL, interface description, the required parameter, the class and preset network Request template generation network request code.
The third aspect of the present invention provides a kind of electronic equipment, and the electronic equipment includes processor and memory, described Processor realizes that code described in any one as above is automatic when being used to execute at least one instruction stored in the memory Generation method.
The fourth aspect of the present invention provides a kind of computer readable storage medium, the computer-readable recording medium storage There is at least one instruction, at least one described instruction is executed by processor to realize that code described in any one as above is given birth to automatically At method.
Code automatic generation method, device, electronic equipment and storage medium of the invention, by according to the service interface Response body in document automatically generates corresponding class, is joined according to the URL in the service interface document, interface description, request Several, the described class and preset network request template automatic generating network request code, to realize the mistake of automatic code generating Journey carries out each client-side interface without developer to write work, avoids the standard of the code caused by manual compiling The true reduction of rate and the reduction of code building efficiency.
Detailed description of the invention
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technical description to be briefly described, it should be apparent that, the accompanying drawings in the following description is only this The embodiment of invention for those of ordinary skill in the art without creative efforts, can also basis The attached drawing of offer obtains other attached drawings.
Fig. 1 is the flow chart for the code automatic generation method that the embodiment of the present invention one provides.
Fig. 2 is the functional block diagram of code automatically generating device provided by Embodiment 2 of the present invention.
Fig. 3 is the schematic diagram for the electronic equipment that the embodiment of the present invention three provides.
The present invention that the following detailed description will be further explained with reference to the above drawings.
Specific embodiment
To better understand the objects, features and advantages of the present invention, with reference to the accompanying drawing and specific real Applying example, the present invention will be described in detail.It should be noted that in the absence of conflict, the embodiment of the present invention and embodiment In feature can be combined with each other.
In the following description, numerous specific details are set forth in order to facilitate a full understanding of the present invention, described embodiment is only It is only a part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, ordinary skill Personnel's every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
Unless otherwise defined, all technical and scientific terms used herein and belong to technical field of the invention The normally understood meaning of technical staff is identical.Term as used herein in the specification of the present invention is intended merely to description tool The purpose of the embodiment of body, it is not intended that in the limitation present invention.
Embodiment one
Fig. 1 is the schematic flow diagram for the code automatic generation method that the embodiment of the present invention one provides.According to different requirements, The sequence of step can change in the flow chart, and certain steps can be omitted.The method is applied in electronic equipment, the electricity Sub- equipment can be any electronic product, for example, personal computer, tablet computer, smart phone, personal digital assistant (Personal Digital Assistant, PDA) etc..As shown in Figure 1, the code automatic generation method may include following Step:
Step 11, Code automatic build request is received.
Code automatic build request request generated when being user's operation user interface.The Code automatic build The request automatically generated behind the address that can input in the user interface service interface document for user is requested, includes in the request The address of service interface document.Alternatively, the Code automatic build request can input in the user interface service interface for user It is automatically generated after the network address of document, includes the network address of service interface document in the request.Alternatively, the Code automatic build is asked It asks and is clicked virtually after can inputting in the user interface the address of service interface document or the network address of service interface document for user The request that the operation of frame automatically generates includes address or the net of service interface document of service interface document in the request Location.
Step 12, according to the Code automatic build request service interface document.
When including the address of service interface document in Code automatic build request, according to the Code automatic build Request service interface document is to obtain the service interface document from local according to the address of the service interface document.When When including the network address of service interface document in the Code automatic build request, taken according to the Code automatic build request Interface document be engaged in obtain the service interface document from network according to the network address of the service interface document.The service interface Document can be HTML (Hyper Text Mark-up Language, hypertext markup language or the HyperText Markup of webpage Language) format service interface document, or the service interface document etc. for word format.The network has been locally stored The service interface document of the html format of the webpage or the service interface document of the Word format.The service interface text Client-side interface is described in shelves.URL (Uniform Resource is defined in the service interface document Locator, uniform resource locator), interface description, required parameter and the response information such as body.The URL is internet subscript The address of quasi- resource, each file on internet have a unique URL, the URL be used to point out file path and Access mode.The URL can be, such as: http://www.abc.com.cn/user/info.The interface description can be example Such as: obtaining user information.The required parameter can be, such as: User.The response body can be, such as:
Step 13, URL, interface description, required parameter and response body are parsed from the service interface document.
When the service interface document is html format, URL is parsed from the service interface document, interface is retouched State, required parameter and response body include: to utilize for example, Document object etc., to all in the service interface document Data access, and obtain URL, interface description, required parameter and response body in the service interface document.
When the service interface document is Word format, URL is parsed from the service interface document, interface is retouched It states, required parameter and response body include: to utilize for example, java poi, java2word or jacob etc., to the service Interface document is parsed to obtain URL, interface description, required parameter and response body.
Step 14, the data responded in body are converted into Json format, by the dictionary in the Json formatted data after conversion Categorical data is mapped as class.
The Json is a kind of data interaction format.Json formatted data after the conversion may include number, character string, One or more types in array and dictionary etc..The number is an individually number, such as " 33 ".The character string is One individual character string, such as " Beijing ".The array is in juxtaposition by several relevant data according to certain sequence, example Such as " Beijing ", " Shanghai ".The dictionary includes title and value corresponding with the title, such as " capital ": " Beijing ".It is described to incite somebody to action Data in response body, which are converted to Json format, to be, such as the response body in above-mentioned example is converted to following Json format Data:
It includes: after traversing the conversion that dictionary type data in Json formatted data after conversion, which are mapped as class, Json formatted data determines the dictionary type data in the Json formatted data after the conversion, and the dictionary type data are reflected It penetrates as class.The class includes data member and member function.The data member corresponds to the attribute of class, and the attribute of the class is corresponding The title of dictionary.The member function is used to operate every attribute of class.Such as: there are words in the Json formatted data after conversion Dictionary type data UserInfo is mapped as UserInfo class by allusion quotation categorical data UserInfo.The category of the UserInfo class Property be " ID " and " name ", the data member be " ID " and " name ", the member function be " getID " and " getname ".
Step 15, according to the URL, interface description, the required parameter, the class and preset network request mould Plate generates network request code.
The preset network request template is the program code that user writes in advance.The preset network request template Are as follows:
Wherein, described/* ##Description##*/it is in the preset network request template for describing request function The code of energy, the ##Path## are in the preset network request template for describing the code of required parameter, the ## URL## is for describing the code of request path in the preset network request template, and the ##Class## is described default Network request template in for describing the code of class.
It is described according to the URL, interface description, the required parameter, the class and preset network request template Generating network request code includes: that the ##URL## in the preset network request template is replaced with the URL, will be described ##Description## in preset network request template replaces with the interface description, by the preset network request ##Path## in template replaces with the required parameter, and the ##Class## in the preset network request template is replaced For the class, to generate the network request code.For example, when according to the URL " http://www.abc.com.cn/ User/info ", the interface description " obtaining user information ", the required parameter " User ", the class " UserInfo " and institute When stating preset network request template generation network request code, the ##URL## in the preset network request template is replaced It is changed to http://www.abc.com.cn/user/info, by the ## in the preset network request template Description## replaces with acquisition user information, and the ##Path## in the preset network request template is replaced with ##Class## in the preset network request template is replaced with UserInfo.class, the network request of generation by User Code are as follows:
Wherein, the UserInfo.class includes the data member and the member function.To which this method is not necessarily to Developer's hand-coding, can be realized automatic code generating.
Further, in order to automatically generate client, the method also includes:
According to the network request code building client.
It is described according to the network request code building client include by the network request code on-the-flier compiler generate The client executing code, that is, generate the client.
This method is by automatically generating corresponding class according to the response body in the service interface document, according to the clothes URL, interface description, required parameter, the class and preset network request template automatic generating network in business interface document are asked Code is sought, to realize the process of automatic code generating, each client-side interface is carried out without developer to write work, Avoid the reduction of code accuracy rate and the reduction of code building efficiency caused by manual compiling.
Embodiment two
Fig. 2 is the functional block diagram of code automatically generating device provided by Embodiment 2 of the present invention.In some embodiments, The code automatically generating device 20 is run in electronic equipment.The electronic equipment can be any electronic product, example Such as, personal computer, tablet computer, smart phone, personal digital assistant (Personal Digital Assistant, PDA) Deng.The code automatically generating device 20 may include multiple functional modules as composed by program code segments.The code is certainly The program code of each program segment in dynamic generating means 20 can store in memory, and be held by least one processor Row, to execute automatic code generating.
In the present embodiment, function of the code automatically generating device 20 according to performed by it can be divided into multiple Functional module.The functional module may include: receiving module 21, document acquisition module 22, parsing module 23, mapping block 24 And code generation module 25.The so-called module of the present invention refers to that one kind can be performed by least one processor and can be complete At the series of computation machine program segment of fixed function, storage is in memory.
The receiving module 21, for receiving Code automatic build request.
Code automatic build request request generated when being user's operation user interface.The Code automatic build The request automatically generated behind the address that can input in the user interface service interface document for user is requested, includes in the request The address of service interface document.Alternatively, the Code automatic build request can input in the user interface service interface for user It is automatically generated after the network address of document, includes the network address of service interface document in the request.Alternatively, the Code automatic build is asked It asks and is clicked virtually after can inputting in the user interface the address of service interface document or the network address of service interface document for user The request that the operation of frame automatically generates includes address or the net of service interface document of service interface document in the request Location.
The document obtains module 22, for according to the Code automatic build request service interface document.
When including the address of service interface document in Code automatic build request, according to the Code automatic build Request service interface document is to obtain the service interface document from local according to the address of the service interface document.When When including the network address of service interface document in the Code automatic build request, taken according to the Code automatic build request Interface document be engaged in obtain the service interface document from network according to the network address of the service interface document.The service interface Document can be HTML (Hyper Text Mark-up Language, hypertext markup language or the HyperText Markup of webpage Language) format service interface document, or the service interface document etc. for word format.The network has been locally stored The service interface document of the html format of the webpage or the service interface document of the Word format.The service interface text Client-side interface is described in shelves.URL (Uniform Resource is defined in the service interface document Locator, uniform resource locator), interface description, required parameter and the response information such as body.The URL is internet subscript The address of quasi- resource, each file on internet have a unique URL, the URL be used to point out file path and Access mode.The URL can be, such as: http://www.abc.com.cn/user/info.The interface description can be example Such as: obtaining user information.The required parameter can be, such as: User.The response body can be, such as:
The parsing module 23, for parsed from the service interface document URL, interface description, required parameter and Respond body.
When the service interface document is html format, URL is parsed from the service interface document, interface is retouched State, required parameter and response body include: to utilize for example, Document object etc., to all in the service interface document Data access, and obtain URL, interface description, required parameter and response body in the service interface document.
When the service interface document is Word format, URL is parsed from the service interface document, interface is retouched It states, required parameter and response body include: to utilize for example, java poi, java2word or jacob etc., to the service Interface document is parsed to obtain URL, interface description, required parameter and response body.
The mapping block 24, for the data responded in body to be converted to Json format, by the Json format after conversion Dictionary type data in data are mapped as class.
The Json is a kind of data interaction format.Json formatted data after the conversion may include number, character string, One or more types in array and dictionary etc..The number is an individually number, such as " 33 ".The character string is One individual character string, such as " Beijing ".The array is in juxtaposition by several relevant data according to certain sequence, example Such as " Beijing ", " Shanghai ".The dictionary includes title and value corresponding with the title, such as " capital ": " Beijing ".It is described to incite somebody to action Data in response body, which are converted to Json format, to be, such as the response body in above-mentioned example is converted to following Json format Data:
It includes: after traversing the conversion that dictionary type data in Json formatted data after conversion, which are mapped as class, Json formatted data determines the dictionary type data in the Json formatted data after the conversion, and the dictionary type data are reflected It penetrates as class.The class includes data member and member function.The data member corresponds to the attribute of class, and the attribute of the class is corresponding The title of dictionary.The member function is used to operate every attribute of class.Such as: there are words in the Json formatted data after conversion Dictionary type data UserInfo is mapped as UserInfo class by allusion quotation categorical data UserInfo.The category of the UserInfo class Property be " ID " and " name ", the data member be " ID " and " name ", the member function be " getID " and " getname ".
The code generation module 25, for according to the URL, interface description, the required parameter, the class and Preset network request template generation network request code.
The preset network request template is the program code that user writes in advance.The preset network request template Are as follows:
Wherein, described/* ##Description##*/it is in the preset network request template for describing request function The code of energy, the ##Path## are in the preset network request template for describing the code of required parameter, the ## URL## is for describing the code of request path in the preset network request template, and the ##Class## is described default Network request template in for describing the code of class.
It is described according to the URL, interface description, the required parameter, the class and preset network request template Generating network request code includes: that the ##URL## in the preset network request template is replaced with the URL, will be described ##Description## in preset network request template replaces with the interface description, by the preset network request ##Path## in template replaces with the required parameter, and the ##Class## in the preset network request template is replaced For the class, to generate the network request code.For example, when according to the URL " http://www.abc.com.cn/ User/info ", the interface description " obtaining user information ", the required parameter " User ", the class " UserInfo " and institute When stating preset network request template generation network request code, the ##URL## in the preset network request template is replaced It is changed to http://www.abc.com.cn/user/info, by the ## in the preset network request template Description## replaces with acquisition user information, and the ##Path## in the preset network request template is replaced with ##Class## in the preset network request template is replaced with UserInfo.class, the network request of generation by User Code are as follows:
Wherein, the UserInfo.class includes the data member and the member function.To which this method is not necessarily to Developer's hand-coding, can be realized automatic code generating.
Further, in order to automatically generate client, described device further includes client generation module 26.The client Generation module 26, for according to the network request code building client.
It is described according to the network request code building client include by the network request code on-the-flier compiler generate The client executing code, that is, generate the client.
The present apparatus is by automatically generating corresponding class according to the response body in the service interface document, according to the clothes URL, interface description, required parameter, the class and preset network request template automatic generating network in business interface document are asked Code is sought, to realize the process of automatic code generating, each client-side interface is carried out without developer to write work, Avoid the reduction of code accuracy rate and the reduction of code building efficiency caused by manual compiling.
The above-mentioned integrated unit realized in the form of software function module, can store and computer-readable deposit at one In storage media.Above-mentioned software function module is stored in a storage medium, including some instructions are with so that an electronics is set Standby or processor (processor) executes the part of each embodiment the method for the present invention.
Embodiment three
Fig. 3 is the schematic diagram for the electronic equipment that the embodiment of the present invention three provides.
The electronic equipment 3 includes: computer readable storage medium 31, at least one processor 32 and is stored in described In memory 31 and the computer program 33 that can be run at least one described processor 32.At least one described processor 32 The step in above-mentioned code automatic generation method embodiment is realized when executing the computer program 33.Alternatively, described at least one A processor 32 realizes the function of each module in above-mentioned code automatically generating device embodiment when executing the computer program 33 Energy.
Illustratively, the computer program 33 can be divided into one or more module/units, it is one or Multiple module/units are stored in the memory 31, and are executed by least one described processor 32, to complete this hair It is bright.One or more of module/units can be the series of computation machine program instruction section that can complete specific function, this refers to Enable section for describing implementation procedure of the computer program 33 in the electronic equipment 3.For example, the computer program 33 Module shown in Fig. 2 can be divided into, each module concrete function is referring to embodiment two.
The electronic equipment 3 can be any electronic product, for example, personal computer, tablet computer, intelligent hand Machine, personal digital assistant (Personal Digital Assistant, PDA) etc..It will be understood by those skilled in the art that described Schematic diagram 3 is only the example of electronic equipment 3, does not constitute the restriction to electronic equipment 3, may include more or more than illustrating Few component perhaps combines certain components or different components, such as the electronic equipment 3 can also include input and output Equipment, network access equipment, bus etc..
At least one described processor 32 can be central processing unit (Central Processing Unit, CPU), It can also be other general processors, digital signal processor (Digital Signal Processor, DSP), dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), ready-made programmable gate array (Field- Programmable Gate Array, FPGA) either other programmable logic device, discrete gate or transistor logic, Discrete hardware components etc..The processor 32 can be microprocessor or the processor 32 is also possible to any conventional processor Deng the processor 32 is the control centre of the electronic equipment 3, utilizes various interfaces and the entire electronic equipment 3 of connection Various pieces.
The memory 31 can be used for storing the computer program 33 and/or module/unit, and the processor 32 passes through Operation executes the computer program and/or module/unit being stored in the memory 31, and calls and be stored in memory Data in 31 realize the various functions of the electronic equipment 3.The memory 31 can mainly include storing program area and storage Data field, wherein storing program area can application program needed for storage program area, at least one function (for example sound plays Function, image player function etc.) etc.;Storage data area, which can be stored, uses created data (such as sound according to electronic equipment 3 Frequency evidence, phone directory etc.) etc..In addition, memory 31 may include high-speed random access memory, it can also include non-volatile Memory, such as hard disk, memory, plug-in type hard disk, intelligent memory card (Smart Media Card, SMC), secure digital (Secure Digital, SD) card, flash card (Flash Card), at least one disk memory, flush memory device or other Volatile solid-state part.
If the integrated module/unit of the electronic equipment 3 is realized in the form of SFU software functional unit and as independent Product when selling or using, can store in a computer readable storage medium.Based on this understanding, the present invention is real All or part of the process in existing above-described embodiment method, can also instruct relevant hardware come complete by computer program At the computer program can be stored in a computer readable storage medium, which is being executed by processor When, it can be achieved that the step of above-mentioned each embodiment of the method.Wherein, the computer program includes computer program code, described Computer program code can be source code form, object identification code form, executable file or certain intermediate forms etc..The meter Calculation machine readable medium may include: can carry the computer program code any entity or device, recording medium, USB flash disk, Mobile hard disk, magnetic disk, CD, computer storage, read-only memory (ROM, Read-Only Memory), random access memory Device (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium etc..It needs to illustrate It is that the content that the computer-readable medium includes can be fitted according to the requirement made laws in jurisdiction with patent practice When increase and decrease, such as in certain jurisdictions, according to legislation and patent practice, computer-readable medium does not include electric carrier wave letter Number and telecommunication signal.
In several embodiments provided by the present invention, it should be understood that disclosed electronic equipment and method, Ke Yitong Other modes are crossed to realize.For example, electronic equipment embodiment described above is only schematical, for example, the unit Division, only a kind of logical function partition, there may be another division manner in actual implementation.
It, can also be in addition, each functional unit in each embodiment of the present invention can integrate in same treatment unit It is that each unit physically exists alone, can also be integrated in same unit with two or more units.Above-mentioned integrated list Member both can take the form of hardware realization, can also realize in the form of hardware adds software function module.
It is obvious to a person skilled in the art that invention is not limited to the details of the above exemplary embodiments, Er Qie In the case where without departing substantially from spirit or essential attributes of the invention, the present invention can be realized in other specific forms.Therefore, no matter From the point of view of which point, the present embodiments are to be considered as illustrative and not restrictive, and the scope of the present invention is by appended power Benefit requires rather than above description limits, it is intended that all by what is fallen within the meaning and scope of the equivalent elements of the claims Variation is included in the present invention.Any reference signs in the claims should not be construed as limiting the involved claims.This Outside, it is clear that one word of " comprising " is not excluded for other units or, odd number is not excluded for plural number.The multiple units stated in system claims Or device can also be implemented through software or hardware by a unit or device.
Finally it should be noted that the above examples are only used to illustrate the technical scheme of the present invention and are not limiting, although reference Preferred embodiment describes the invention in detail, those skilled in the art should understand that, it can be to of the invention Technical solution is modified or equivalent replacement, without departing from the spirit of the technical scheme of the invention range.

Claims (10)

1. a kind of code automatic generation method, which is characterized in that the described method includes:
Receive Code automatic build request;
According to the Code automatic build request service interface document;
URL, interface description, required parameter and response body are parsed from the service interface document;
The data responded in body are converted into Json format, the dictionary type data in the Json formatted data after conversion are mapped For class;
According to the URL, interface description, the required parameter, the class and preset network request template generation network Request code.
2. the method as described in claim 1, it is characterised in that:
The service interface document is the service interface document of the html format of webpage or the service interface document of word format.
3. method according to claim 2, it is characterised in that: parse URL from the service interface document, interface is retouched It states, required parameter and response body include:
When the service interface document is html format, using document object come to the institute in the service interface document There are data to access, obtains URL, interface description, required parameter and response body in the service interface document;
When the service interface document is word format, using java poi, java2word or jacob to the interface Document is parsed to obtain the URL in the service interface document, interface description, required parameter and response body.
4. the method as described in claim 1, which is characterized in that by the dictionary type data in the Json formatted data after conversion Being mapped as class includes:
Json formatted data after traversing the conversion determines the dictionary type data in the Json formatted data after the conversion;
The dictionary type data are mapped as class.
5. the method as described in claim 1, it is characterised in that: the preset network request template includes for describing request The code of function, the code for describing required parameter, the code for describing request path and the code for describing class.
6. method as claimed in claim 5, which is characterized in that according to the URL, interface description, the required parameter, The class and preset network request template generation network request code include:
The code for being used to describe request path in the preset network request template is replaced with into the URL, it will be described pre- If network request template in the code for describing request function replace with the interface description, by the preset network The code for describing required parameter in please seeking template replaces with the required parameter, by the preset network request template In the code for describing class replace with the class.
7. the method as described in claim 1, which is characterized in that the method also includes:
According to the network request code building client.
8. a kind of code automatically generating device, which is characterized in that described device includes:
Receiving module, for receiving Code automatic build request;
Document obtains module, for according to the Code automatic build request service interface document;
Parsing module, for parsing URL, interface description, required parameter and response body from the service interface document;
Mapping block, for the data responded in body to be converted to Json format, by the word in the Json formatted data after conversion Allusion quotation categorical data is mapped as class;
Generation module, for according to the URL, interface description, the required parameter, the class and preset network request Template generation network request code.
9. a kind of electronic equipment, which is characterized in that the electronic equipment includes processor and memory, and the processor is for holding Realize that code as claimed in any of claims 1 to 7 in one of claims is automatic when at least one instruction stored in the row memory Generation method.
10. a kind of computer readable storage medium, which is characterized in that the computer-readable recording medium storage has at least one Instruction, at least one described instruction are executed by processor to realize that code as claimed in any of claims 1 to 7 in one of claims is automatic Generation method.
CN201811180729.6A 2018-10-09 2018-10-09 Code automatic generation method, device, electronic equipment and storage medium Pending CN109614102A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811180729.6A CN109614102A (en) 2018-10-09 2018-10-09 Code automatic generation method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811180729.6A CN109614102A (en) 2018-10-09 2018-10-09 Code automatic generation method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN109614102A true CN109614102A (en) 2019-04-12

Family

ID=66001775

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811180729.6A Pending CN109614102A (en) 2018-10-09 2018-10-09 Code automatic generation method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN109614102A (en)

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110099122A (en) * 2019-05-07 2019-08-06 北京字节跳动网络技术有限公司 Method and apparatus for sending network request
CN110262783A (en) * 2019-05-22 2019-09-20 深圳华科云动力科技有限公司 A kind of interface creation method, device and terminal device
CN110297633A (en) * 2019-06-28 2019-10-01 百度在线网络技术(北京)有限公司 Code conversion method, device, equipment and storage medium
CN110597503A (en) * 2019-09-19 2019-12-20 湖南长城医疗科技有限公司 Method for automatically constructing web service toolkit based on C # language
CN110795084A (en) * 2019-11-01 2020-02-14 腾讯科技(深圳)有限公司 Method, device and equipment for generating interface description file and readable storage medium
CN111338637A (en) * 2020-02-26 2020-06-26 腾讯科技(深圳)有限公司 Code generation method and device
CN111427567A (en) * 2020-03-20 2020-07-17 杭州涂鸦信息技术有限公司 Intelligent product rapid generation method, system and equipment thereof
CN111767070A (en) * 2020-06-30 2020-10-13 中国平安财产保险股份有限公司 API document management method and device, computer equipment and storage medium
CN111934940A (en) * 2020-09-24 2020-11-13 腾讯科技(深圳)有限公司 Configurated service request method and device, electronic equipment and storage medium
CN111966356A (en) * 2020-08-25 2020-11-20 珠海格力电器股份有限公司 Program code generation method, program code generation device, storage medium, and electronic device
CN112199112A (en) * 2020-09-30 2021-01-08 京东数字科技控股股份有限公司 Method, device, terminal equipment and storage medium for automatically configuring simulation service
CN112433717A (en) * 2020-12-18 2021-03-02 杭州米络星科技(集团)有限公司 Code automatic generation method and device and electronic equipment
CN112463261A (en) * 2020-11-20 2021-03-09 北京达佳互联信息技术有限公司 Interface calling method and device
CN112486824A (en) * 2020-11-30 2021-03-12 广州品唯软件有限公司 Use case code generation method and device, computer equipment and storage medium
WO2021052338A1 (en) * 2019-09-16 2021-03-25 杭州趣链科技有限公司 Smart contract client program generation method, system and device, and medium
CN112631569A (en) * 2020-12-30 2021-04-09 上海中通吉网络技术有限公司 gPRC-based method, device and equipment for automatically generating and completing front-end and back-end codes
CN112887390A (en) * 2021-01-20 2021-06-01 上海易校信息科技有限公司 Network request method
US11270213B2 (en) * 2018-11-05 2022-03-08 Convr Inc. Systems and methods for extracting specific data from documents using machine learning
US11580459B2 (en) 2018-11-05 2023-02-14 Convr Inc. Systems and methods for extracting specific data from documents using machine learning
CN117149166A (en) * 2023-10-30 2023-12-01 江苏德高物联技术有限公司 Method and device for generating data docking code of electromagnetic water meter

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090210861A1 (en) * 2008-02-20 2009-08-20 Mariana Alupului Dita doclet tool and method for extracting and analyzing api documentation
CN102750152A (en) * 2012-06-21 2012-10-24 新浪网技术(中国)有限公司 Method and device of application for generating a plurality of programming languages based on descriptive language
CN106951231A (en) * 2017-02-23 2017-07-14 微梦创科网络科技(中国)有限公司 A kind of computer software development approach and device
CN107273116A (en) * 2017-05-22 2017-10-20 互联天下科技发展(深圳)有限公司 The method that code is produced using the Code Generator based on framework
CN108268253A (en) * 2017-05-05 2018-07-10 平安科技(深圳)有限公司 Interface code generation method and terminal device
CN108491199A (en) * 2018-03-06 2018-09-04 福建天泉教育科技有限公司 A kind of method and terminal automatically generating interface

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090210861A1 (en) * 2008-02-20 2009-08-20 Mariana Alupului Dita doclet tool and method for extracting and analyzing api documentation
CN102750152A (en) * 2012-06-21 2012-10-24 新浪网技术(中国)有限公司 Method and device of application for generating a plurality of programming languages based on descriptive language
CN106951231A (en) * 2017-02-23 2017-07-14 微梦创科网络科技(中国)有限公司 A kind of computer software development approach and device
CN108268253A (en) * 2017-05-05 2018-07-10 平安科技(深圳)有限公司 Interface code generation method and terminal device
CN107273116A (en) * 2017-05-22 2017-10-20 互联天下科技发展(深圳)有限公司 The method that code is produced using the Code Generator based on framework
CN108491199A (en) * 2018-03-06 2018-09-04 福建天泉教育科技有限公司 A kind of method and terminal automatically generating interface

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
克里斯蒂安·科尔: "《iOS编程 第5版[M]》", 30 June 2017 *
李兆延,李俊,张焕国: "《移动互联应用"赢在起点"系列图书 IOS开发实践[M]》", 28 February 2018 *

Cited By (30)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11580459B2 (en) 2018-11-05 2023-02-14 Convr Inc. Systems and methods for extracting specific data from documents using machine learning
US11270213B2 (en) * 2018-11-05 2022-03-08 Convr Inc. Systems and methods for extracting specific data from documents using machine learning
US11734579B2 (en) 2018-11-05 2023-08-22 Convr Inc. Systems and methods for extracting specific data from documents using machine learning
CN110099122B (en) * 2019-05-07 2020-05-15 北京字节跳动网络技术有限公司 Method and apparatus for sending network request
CN110099122A (en) * 2019-05-07 2019-08-06 北京字节跳动网络技术有限公司 Method and apparatus for sending network request
CN110262783B (en) * 2019-05-22 2023-08-08 深圳华科云动力科技有限公司 Interface generation method and device and terminal equipment
CN110262783A (en) * 2019-05-22 2019-09-20 深圳华科云动力科技有限公司 A kind of interface creation method, device and terminal device
CN110297633A (en) * 2019-06-28 2019-10-01 百度在线网络技术(北京)有限公司 Code conversion method, device, equipment and storage medium
CN110297633B (en) * 2019-06-28 2023-05-23 百度在线网络技术(北京)有限公司 Transcoding method, device, equipment and storage medium
JP7315786B2 (en) 2019-09-16 2023-07-26 杭州趣鏈科技有限公司 Smart contract client program generation method, system, device, and medium
JP2022545489A (en) * 2019-09-16 2022-10-27 杭州趣鏈科技有限公司 Smart contract client program generation method, system, device, and medium
WO2021052338A1 (en) * 2019-09-16 2021-03-25 杭州趣链科技有限公司 Smart contract client program generation method, system and device, and medium
CN110597503A (en) * 2019-09-19 2019-12-20 湖南长城医疗科技有限公司 Method for automatically constructing web service toolkit based on C # language
CN110795084A (en) * 2019-11-01 2020-02-14 腾讯科技(深圳)有限公司 Method, device and equipment for generating interface description file and readable storage medium
CN110795084B (en) * 2019-11-01 2021-08-27 腾讯科技(深圳)有限公司 Method, device and equipment for generating interface description file and readable storage medium
CN111338637A (en) * 2020-02-26 2020-06-26 腾讯科技(深圳)有限公司 Code generation method and device
CN111427567A (en) * 2020-03-20 2020-07-17 杭州涂鸦信息技术有限公司 Intelligent product rapid generation method, system and equipment thereof
CN111427567B (en) * 2020-03-20 2023-08-18 杭州涂鸦信息技术有限公司 Intelligent product rapid generation method, system and equipment thereof
CN111767070A (en) * 2020-06-30 2020-10-13 中国平安财产保险股份有限公司 API document management method and device, computer equipment and storage medium
CN111966356A (en) * 2020-08-25 2020-11-20 珠海格力电器股份有限公司 Program code generation method, program code generation device, storage medium, and electronic device
CN111934940A (en) * 2020-09-24 2020-11-13 腾讯科技(深圳)有限公司 Configurated service request method and device, electronic equipment and storage medium
CN112199112A (en) * 2020-09-30 2021-01-08 京东数字科技控股股份有限公司 Method, device, terminal equipment and storage medium for automatically configuring simulation service
CN112463261A (en) * 2020-11-20 2021-03-09 北京达佳互联信息技术有限公司 Interface calling method and device
CN112486824A (en) * 2020-11-30 2021-03-12 广州品唯软件有限公司 Use case code generation method and device, computer equipment and storage medium
CN112486824B (en) * 2020-11-30 2024-05-03 广州品唯软件有限公司 Case code generation method, device, computer equipment and storage medium
CN112433717A (en) * 2020-12-18 2021-03-02 杭州米络星科技(集团)有限公司 Code automatic generation method and device and electronic equipment
CN112631569A (en) * 2020-12-30 2021-04-09 上海中通吉网络技术有限公司 gPRC-based method, device and equipment for automatically generating and completing front-end and back-end codes
CN112887390A (en) * 2021-01-20 2021-06-01 上海易校信息科技有限公司 Network request method
CN117149166A (en) * 2023-10-30 2023-12-01 江苏德高物联技术有限公司 Method and device for generating data docking code of electromagnetic water meter
CN117149166B (en) * 2023-10-30 2023-12-29 江苏德高物联技术有限公司 Method and device for generating data docking code of electromagnetic water meter

Similar Documents

Publication Publication Date Title
CN109614102A (en) Code automatic generation method, device, electronic equipment and storage medium
CN109634598A (en) A kind of page display method, device, equipment and storage medium
CN102325191B (en) Fully automatic treatment method and frame without page refresh
CN108984712A (en) Counting method, equipment and readable storage medium storing program for executing are made based on business scenario
US20100306738A1 (en) Templating system and method for updating content in real time
CN103049271A (en) Method and device for automatically generating description document of API (application program interface)
CN112711581B (en) Medical data checking method and device, electronic equipment and storage medium
CN112633691A (en) Method and device for generating custom approval process
CN110377892A (en) A kind of government intelligence form templat designing system
CN112463154A (en) Page generation method, device and system and electronic equipment
CN109840159A (en) Abnormality processing project management method, apparatus, computer installation and storage medium
CN110795697A (en) Logic expression obtaining method and device, storage medium and electronic device
CN114090162A (en) Front-end interface display method and related device of multi-tenant system
TW201610713A (en) Identifying and surfacing relevant report artifacts in documents
CN109271160A (en) Active rule construction method, device and computer system, medium
US8051110B2 (en) Identifying screen flows to support multiple entities and their diverse rules with a single application instance
CN109828759A (en) Code compiling method, device, computer installation and storage medium
CN110019207B (en) Data processing method and device and script display method and device
CN105302556A (en) Calculation realization method and system and server apparatus
US20220198153A1 (en) Model training
CN115801873A (en) Service distribution method, system, electronic device and storage medium
CN112487771B (en) Report generation method, report generation device and terminal
CN109165180A (en) A kind of method and system improving source of houses broker operating efficiency
CN113986494A (en) Interface processing method and device, electronic equipment and storage medium
CN113590358A (en) Service concurrency control method and device based on RPA

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20190412

RJ01 Rejection of invention patent application after publication