CN110531967B - Code generation method and code generation device - Google Patents

Code generation method and code generation device Download PDF

Info

Publication number
CN110531967B
CN110531967B CN201910756552.8A CN201910756552A CN110531967B CN 110531967 B CN110531967 B CN 110531967B CN 201910756552 A CN201910756552 A CN 201910756552A CN 110531967 B CN110531967 B CN 110531967B
Authority
CN
China
Prior art keywords
service
input
output
logic
call
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.)
Active
Application number
CN201910756552.8A
Other languages
Chinese (zh)
Other versions
CN110531967A (en
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.)
Beijing Sankuai Online Technology Co Ltd
Original Assignee
Beijing Sankuai Online Technology 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 Beijing Sankuai Online Technology Co Ltd filed Critical Beijing Sankuai Online Technology Co Ltd
Priority to CN201910756552.8A priority Critical patent/CN110531967B/en
Publication of CN110531967A publication Critical patent/CN110531967A/en
Application granted granted Critical
Publication of CN110531967B publication Critical patent/CN110531967B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • 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)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Telephonic Communication Services (AREA)

Abstract

The present disclosure relates to a code generation method, comprising: determining input and output of an interface of the service aggregation service, input and output of service calling and input and output of service logic according to the received instruction; determining a calling sequence of each service call and each service logic according to the relation between the input and the output of the service call and the input and the output of the service logic, wherein the calling sequence does not divide the service call and/or the service logic after and/or in parallel; executable code is generated based on the call order, the input and output of the interface, the input and output of the service call, and the input and output of the business logic. According to the embodiment of the disclosure, the service call and the service logic with non-sequential call sequence can be called in parallel, and the service logic and the service call do not need to be called in sequence according to different services, which is beneficial to reducing thread switching and further reducing expenditure.

Description

Code generation method and code generation device
Technical Field
The present disclosure relates to the field of software technologies, and in particular, to a code generation method, a code generation apparatus, an electronic device, and a computer-readable storage medium.
Background
The business aggregation service can call a plurality of services, reorganize data of the called services, and provide services for displaying data aggregation for upper-layer applications.
In the related art, the development process of the business aggregation service is fixed, and a developer needs to write a code for service invocation and a code for business logic in a main process of an interface of the business aggregation service.
Since there are more services to be aggregated in the service aggregation service, different services have different service calls and service logic branches, and the execution order of the service calls and the service logic is relatively fixed, generally, the service logic and the service calls are executed for one service in the order from input to output, and then the service logic and the service calls are executed for another service in the order from input to output.
Disclosure of Invention
The present disclosure provides a code generation method, a code generation apparatus, an electronic device, and a computer-readable storage medium to solve the disadvantages of the related art.
According to a first aspect of embodiments of the present disclosure, there is provided a code generation method, including:
determining input and output of an interface of a business aggregation service, input and output of at least one service call, and input and output of at least one business logic according to the received instruction;
determining a calling sequence of each service call and each service logic according to the relation between the input and the output of the service call and the input and the output of the service logic, wherein the calling sequence does not divide the service call and/or the service logic to be called in parallel;
and generating executable codes according to the calling sequence, the input and the output of the interface, the input and the output of the service calling and the input and the output of the business logic.
Optionally, the determining, according to the received instruction, the input and the output of the interface, the input and the output of the at least one service call, and the input and the output of the at least one service logic includes:
determining the service logic in a plurality of alternative service logics according to the received first selection instruction, wherein the service logic is packaged in advance for service processing logic;
determining the service invocation from a plurality of candidate service invocations according to the received second selection instruction, wherein the jar packet coordinate and bean corresponding to at least one service invocation are pre-configured;
editing the input and output of the interface according to the received editing instruction;
and connecting the input and the input of the interface, the service call and the business logic according to the received connection instruction, and determining the input and the output of each service call and the input and the output of each business logic according to the connection result.
Optionally, the method further comprises:
storing the service processing logic corresponding to the service logic and the jar packet coordinate and bean corresponding to the service call in a first storage space;
and storing the input and the output of the interface, the input and the output of the service call and the input and the output of the business logic in a second storage space.
Optionally, before determining the calling order of each service call and each business logic according to the relationship between the input and output of the service call and the input and output of the business logic, the method further includes:
constructing a graph by taking business logic and service call as vertexes, taking the relation between the input and output of the service call and the input and output of the business logic as edges;
the number of the outgoing edges of the vertex is the number of the edges which take the vertex as a starting point and take the vertex as a terminal point.
Optionally, the determining, according to a relationship between the input and the output of the service call and the input and the output of the business logic, a call sequence of each service call and each business logic includes:
traversing the vertex of a first queue, wherein the in-degree of the vertex in the first queue is 0, and recording the service call and/or the call sequence between service logics corresponding to the vertex of the first queue as parallel call;
circulating the following steps:
taking out a vertex from the first queue, traversing the taken-out edges of the vertex, subtracting 1 from the degree of entrance of the end point of each edge, and taking the end point of the edge with the degree of entrance of 0 as the vertex and placing the end point of the edge into a second queue;
and recording the calling sequence between service calling and/or service logic corresponding to the top point of the second queue as parallel calling, and putting the top point of the second queue into the first queue.
Optionally, before generating the executable code, the method further comprises:
judging whether a loop exists in the calling sequence;
and if a loop exists in the calling sequence, generating prompt information.
According to a second aspect of the embodiments of the present disclosure, there is provided a code generation apparatus including:
the input/output determination module is used for determining the input and the output of an interface of the business aggregation service, the input and the output of at least one service call and the input and the output of at least one business logic according to the received instruction;
a calling sequence determining module, configured to determine a calling sequence of each service call and each service logic according to a relationship between an input and an output of the service call and an input and an output of the service logic, where the calling sequence does not include the service call and/or the service logic call in parallel first and/or last;
and the code generation module is used for generating executable codes according to the calling sequence, the input and the output of the interface, the input and the output of the service calling and the input and the output of the business logic.
Optionally, the input/output determination module includes:
the service logic determining submodule is used for determining the service logic in a plurality of alternative service logics according to the received first selection instruction, wherein the service logic is packaged in advance for processing the service;
the service call determining submodule is used for determining the service call in a plurality of alternative service calls according to the received second selection instruction, wherein the jar packet coordinate and bean corresponding to at least one service call are configured in advance;
the input and output editing submodule is used for editing the input and the output of the interface according to a received editing instruction;
and the connection establishing submodule is used for connecting the input and the input of the interface, the service call and the business logic according to the received connection instruction, and determining the input and the output of each service call and the input and the output of each business logic according to the connection result.
Optionally, the apparatus further comprises:
the first storage module is used for storing the service processing logic corresponding to the service logic, and the jar package coordinate and bean corresponding to the service call in a first storage space;
and the second storage module is used for storing the input and the output of the interface, the input and the output of the service call and the input and the output of the business logic in a second storage space.
Optionally, the apparatus further comprises:
the graph structure component module is used for constructing a graph by taking business logic and service call as vertexes, taking the relation between the input and the output of the service call and the input and the output of the business logic as edges;
the number of the outgoing edges of the vertex is the number of the edges which take the vertex as a starting point and take the vertex as a terminal point.
Optionally, the call order determination module is configured to:
traversing the vertex of a first queue, wherein the in-degree of the vertex in the first queue is 0, and recording the service call and/or the call sequence between service logics corresponding to the vertex of the first queue as parallel call;
circulating the following steps:
taking out a vertex from the first queue, traversing the taken-out edges of the vertex, subtracting 1 from the degree of entrance of the end point of each edge, and taking the end point of the edge with the degree of entrance of 0 as the vertex and placing the end point of the edge into a second queue;
and recording the calling sequence between service calling and/or service logic corresponding to the top point of the second queue as parallel calling, and putting the top point of the second queue into the first queue.
Optionally, the apparatus further comprises:
the loop judgment module is used for judging whether a loop exists in the calling sequence;
and the prompt generation module is used for generating prompt information under the condition that a loop exists in the calling sequence.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to implement the method of any of the above embodiments.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps in the method of any of the above embodiments.
According to the embodiment of the disclosure, the calling sequence can be determined according to the input and output of service calling and the input and output of the service logic method, so that the service calling and/or the service logic which is not first and/or later in the calling sequence can be called in parallel, the service logic and the service calling are not required to be called in sequence according to different services, thread switching is reduced, and further the expenditure is reduced.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
Fig. 1 is a schematic flow chart diagram illustrating a code generation method according to an embodiment of the present disclosure.
Fig. 2 is a schematic diagram illustrating a platform according to an embodiment of the present disclosure.
Fig. 3 is a schematic diagram illustrating a ClassDescribe according to an embodiment of the disclosure.
FIG. 4 is a schematic flow chart diagram illustrating another method of code generation in accordance with an embodiment of the present disclosure.
Fig. 5 is a schematic flow chart diagram illustrating yet another code generation method in accordance with an embodiment of the present disclosure.
FIG. 6 is a schematic flow chart diagram illustrating one method of determining a calling order in accordance with an embodiment of the present disclosure.
Fig. 7 is a schematic flow chart diagram illustrating yet another code generation method in accordance with an embodiment of the present disclosure.
Fig. 8 is a schematic diagram of a hardware structure of a device in which a code generation apparatus according to an embodiment of the present disclosure is located.
Fig. 9 is a schematic block diagram illustrating a code generation apparatus according to an embodiment of the present disclosure.
Fig. 10 is a schematic block diagram illustrating an input-output determination module in accordance with an embodiment of the present disclosure.
Fig. 11 is a schematic block diagram illustrating another code generation apparatus according to an embodiment of the present disclosure.
Fig. 12 is a schematic block diagram illustrating yet another code generation apparatus according to an embodiment of the present disclosure.
Fig. 13 is a schematic block diagram illustrating yet another code generation apparatus according to an embodiment of the present disclosure.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1 is a schematic flow chart diagram illustrating a code generation method according to an embodiment of the present disclosure. The code generation method shown in this embodiment may be applied to a platform for automatically generating code, and the platform may be based on a RESTful architecture.
As shown in fig. 1, the code generation method may include the steps of:
in step S1, according to the received instruction, determining input and output of an interface of the business aggregation service (the output of the interface may also be referred to as a return type), input and output of at least one service call, and input and output of at least one business logic;
it should be noted that the method shown in this embodiment may be applicable to implement a service aggregation service for multiple service calls (that is, at least one service call is multiple service calls), and may also be applicable to determine an output according to an input of one service call (that is, at least one service call is one service call). The following embodiments are mainly described in the case where the code generation method is applied to implement a service aggregation service for multiple service calls.
In one embodiment, the inputs and outputs of the interface of the business aggregation service may be manually edited by the developer, for example, the inputs may include an identification of the merchant, an identification of the user, an identification of the item, etc., and the outputs may include a rating of the merchant.
In one embodiment, the processing logic of the service in the service logic may be pre-packaged, and the jar packet coordinates and beans corresponding to the service called by the service call may be pre-configured.
The platform may display an operable business logic module, a research and development person may operate on the business logic module to generate a first selection instruction, the business logic module may display a plurality of alternative business logics, for example, may display the plurality of alternative business logics in a pull-down menu form, and the research and development person may select one business logic in the plurality of alternative business logics. The research and development personnel can operate on a plurality of business logic modules so as to determine a plurality of business logics on the platform.
The platform can display an operational RPC (Remote Procedure Call) module, the developer can operate on the RPC module to generate a second selection instruction, the RPC module can display a plurality of alternative service calls, for example, the developer can display a plurality of alternative service calls in a pull-down menu form, and the developer can select one service Call among the plurality of alternative service calls. A developer may operate on multiple RPC modules to determine multiple service calls on the platform.
Further, the research and development staff can connect the input and output of the interface, the service call and the business logic on the platform, and further determine the input and output of each service call and the input and output of each business logic according to the sequence from the input of the interface to the output of the interface according to the connection result.
Fig. 2 is a schematic diagram illustrating a platform according to an embodiment of the present disclosure.
As shown in FIG. 2, the platform provides an RPC module and a business logic module on the left side of the operation interface, wherein the R & D personnel can drag the RPC module and the business logic module on the left side into the edit bar on the right side.
In one embodiment, 2 RPC modules and 4 service logic modules may be dragged to the edit bar, wherein the service logic module may be accompanied by an "edit" button, and a developer may click on the edit button to display a pull-down menu in which a plurality of alternative service logics are displayed, and the developer may select among them. Correspondingly, the RPC module may also be accompanied by an "edit" button, and a developer may click the edit button to display a pull-down menu in which a plurality of alternative service calls are displayed, and the developer may select among them.
For example as shown in FIG. 2:
the interface input may be manually edited by a developer;
the first business logic is getShopID;
the second business logic is getCommonShopclass;
the third service logic is creatgetbotbaidinfo resultv 5;
the first service call is getStarbyShopID;
the second service call is getborardinfo;
the fourth service logic is an interface output, and the input after the aggregation of the first service call and the second service call structure may be, for example, getposscore.
In one embodiment, the RPC module may be accompanied by an "initiate condition" button, and when the button is clicked, a condition for initiating the corresponding RPC module may be set, for example, for the first service call getstarbyscope id, the initiate condition may be set such that commonsscope is less than a preset level, for example, the preset level is 5.
It should be noted that the interface input may be associated with a part of at least one service logic, for example, as shown in fig. 4, the interface input is associated with only getShopID in three service logics, that is, getShopID of the service logic depends on the entry of the interface input, and the other two service logics may not depend on the entry of the interface input.
In step S2, determining a calling order of each service call and each service logic according to a relationship between an input and an output of the service call and an input and an output of the service logic, wherein the calling order does not include the preceding and/or following service call and/or the service logic call in parallel;
in step S3, an executable code is generated according to the call sequence, the input and output of the interface, the input and output of the service call, and the input and output of the business logic.
In one embodiment, after determining the input and output of the interface, the input and output of the service call, and the input and output of the business logic, the call sequence of each service call and each business logic may be determined according to the relationship between the input and output of the service call and the input and output of the business logic, and for the service call and the business logic, if the call sequence is not first and/or last, the calls may be performed in parallel.
To ensure that the input of the input is received first and the return type of the output is output later, the calling order may be determined according to the direction from the input of the interface to the output of the interface.
For example, in fig. 2, the entry of the interface input should be the first received data, and the service logic getShopID may be called according to the entry, so that the service logic getShopID may be called first, and the service logic getcommonship and creatgetbackinfo result v5 are not associated with the interface input, so long as it is ensured that the two service logics are not called before the service logic getShopID, so that the three service logics are not called after who is divided, and thus may be called in parallel.
And the two service calls getStarbyShopID and getBasdInfo which are called first do not affect the return type output by the interface, so the calling order of the two service calls is not sequential and can be called in parallel.
It should be noted that, in addition to the case shown in fig. 2, there may be a case where the calling order of the service logic and the service call is not sequential, and then the service logic and the service call may be called in parallel.
According to the embodiment of the disclosure, the calling sequence can be determined according to the input and output of service calling and the input and output of the service logic method, so that the service calling and/or the service logic which is not first and/or later in the calling sequence can be called in parallel, the service logic and the service calling are not required to be called in sequence according to different services, thread switching is reduced, and further the expenditure is reduced.
Further, after the call sequence is determined, the determined call sequence may be saved, for example, a "save" button (not shown in fig. 2) may be provided in the platform, and the determined call sequence may be saved by clicking the button.
Executable code may further be automatically generated for the saved call order, the input and output of the interface, the input and output of the service call, and the input and output of the business logic.
The generated executable code includes, but is not limited to, a java source file, where the java source file corresponds to a class, and the class may be abstracted through a class descriptor, and the class descriptor in this embodiment may be as shown in fig. 3, where a packaName represents a package name of the class, a className represents a class name, a fieldNames represents a field list, a structClass represents a type corresponding to the field, an actultypelist represents a generic type of the class, and a parent represents a parent type of the class.
Service Model class (for example, containing name and address), interface input Controller class, interface main flow
Figure BDA0002168904520000091
The data structure corresponding to the class can be inherited from ClassDescripte. In this embodiment, the platform converts data such as service logic, service call, and the like defined by the interface into a data structure required by the java source file, and stores the data structure for subsequent use. When the business aggregation service corresponding to the java source file needs to be used subsequently, the java source file can be directly used.
FIG. 4 is a schematic flow chart diagram illustrating another method of code generation in accordance with an embodiment of the present disclosure. As shown in fig. 4, the determining the input and output of the interface, the input and output of the at least one service call, and the input and output of the at least one business logic according to the received command includes:
in step S11, according to the received first selection instruction, determining the service logic from a plurality of candidate service logics, where a service processing logic in the service logic is pre-packaged;
in step S12, according to the received second selection instruction, determining the service invocation from a plurality of candidate service invocations, where the jar packet coordinate and bean corresponding to the at least one service invocation are pre-configured;
editing the input and output of the interface according to the received editing instruction in step S13;
in step S14, according to the received connection instruction, the input and the input of the interface, the service call and the business logic are connected, and according to the connection result, the input and the output of each service call, and the input and the output of each business logic are determined.
In one embodiment, since the business logic has commonality, for example, getcommonshop as shown in fig. 2, may be to calculate a level average of a certain number of merchants, and the processing logic for the business in the business logic is common to all services in the business aggregation service. Besides the service logic, the service logic may also be, for example, calculating discount, and the processing logic for the discount service is: the latter 1 bit of the decimal point is reserved, if the latter 1 bit of the decimal point is 0, the decimal part is removed, and the business logic for calculating the discount is also common to the services in most business aggregation services.
If the discount is the selling price/original price for each business aggregation service, and the logic for processing the digits of the obtained floating point numbers is encoded, once the requirements of subsequent products are changed, the whole code needs to be modified. In the embodiment, by pre-packaging the service processing logic in the service logic, when performing service aggregation service, a research and development worker can input the first selection instruction through operation, so that the service logic is directly determined in a plurality of alternative service logics without repeatedly editing the service logic, and the service logic can be determined based on brief operation.
For service invocation, invoked service depends on jar package coordinates and beans, and the embodiment can enable research and development personnel to input a second selection instruction through operation when service aggregation service is carried out by pre-configuring jar package coordinates and beans corresponding to the service invocation, so that the service invocation is directly determined in a plurality of alternative service invocations without repeated configuration of jar package coordinates and beans of the service invocation, and the service invocation can be determined based on short operation.
For example, the business photo album information of the business shop image service provider called by the service call, the product requirement is to show the business picture on the applied business page, and the research and development staff can add the following configuration in pom.xml according to the latest jar package coordinate corresponding to the service in advance:
Figure BDA0002168904520000111
and adding bean similar to the following to applicationcontext.xml used by Spring:
<bean class="com.demo.ShopImageService">
<property>...</property>
</bean>
fig. 5 is a schematic flow chart diagram illustrating yet another code generation method in accordance with an embodiment of the present disclosure. As shown in fig. 5, the method further comprises:
in step S4, storing the service processing logic corresponding to the service logic, and the jar packet coordinate and bean corresponding to the service invocation in a first storage space;
in step S5, the input and output of the interface, the input and output of the service call, and the input and output of the business logic are stored in a second storage space.
In one embodiment, since the processing logic for the service in the service logic is pre-packaged, the jar packet coordinates and beans corresponding to the service call are pre-configured, and these pre-packaged, pre-configured operations may be performed before step S1. The input and output of the interface, the input and output of the service call, and the input and output of the business logic, which are different according to the instructions input by the developer each time, are performed in step S1.
Therefore, the time for processing the service logic in the service logic is packaged in advance, the time for calling the corresponding jar packet coordinate and bean of the service is configured in advance, and the input and output of the interface, the input and output of the service call and the input and output time of the service logic are determined earlier than the input instruction of a research and development staff.
Then the content for both occasions can be stored in different storage spaces. For example, the processing logic of the service in the service logic packaged in advance, the corresponding jar packet coordinate and bean of the service call configured in advance can be stored in the demo-auto storage space; the inputs and outputs of the interface, the inputs and outputs of the service call, and the inputs and outputs of the business logic may be stored in the demo-api memory space. Therefore, when different actual contents in the storage space are modified, another storage space does not need to be accessed, and the modification is finished by quickly querying the target.
Optionally, before determining the calling order of each service call and each business logic according to the relationship between the input and output of the service call and the input and output of the business logic, the method further includes:
constructing a graph by taking business logic and service call as vertexes, taking the relation between the input and output of the service call and the input and output of the business logic as edges;
the number of the outgoing edges of the vertex is the number of the edges which take the vertex as a starting point and take the vertex as a terminal point.
FIG. 6 is a schematic flow chart diagram illustrating one method of determining a calling order in accordance with an embodiment of the present disclosure. As shown in fig. 6, the determining the calling order of each service call and each business logic according to the relationship between the input and output of the service call and the input and output of the business logic includes:
in step S21, traversing a vertex of a first queue, where the in-degree of the vertex in the first queue is 0, and recording a call sequence between service calls and/or service logics corresponding to the vertex of the first queue as a parallel call;
circulating the following steps:
in step S22, a vertex is taken out from the first queue, outgoing edges of the taken vertex are traversed, the degree of entry of the end point of each outgoing edge is decreased by 1, and the end point of the outgoing edge with the degree of entry of 0 is taken as a vertex and placed in the second queue (until the first queue is empty);
in step S23, the call order between the service calls and/or business logic corresponding to the top of the second queue is recorded as parallel calls, and the top of the second queue is placed in the first queue (and the second queue is emptied).
In one embodiment, a graph (data structure) may be constructed with business logic and service calls as vertices, with the relationships between the inputs and outputs of the service calls, and the inputs and outputs of the business logic as edges;
the number of the outgoing edges of the vertex is the number of the edges which take the vertex as a starting point and take the vertex as a service call or a service logic as a vertex.
And aiming at the constructed graph, determining that the vertex with the degree of income of 0 is classified into a first queue, then traversing the vertex of the first queue, and recording the calling sequence between service calls and/or business logic corresponding to the vertex of the first queue as parallel calls.
Since the in-degree is 0, it indicates that there is no service call or service logic with the vertex as the end point, that is, the service call or service logic before the vertex is already called, and therefore, it is the turn that the service call or service logic corresponding to the vertex is called, and the service calls and/or service logic corresponding to all such vertices can be called in parallel.
Then, the top point in the first queue can be taken out, then the outgoing edges of the taken top points are traversed, the degree of entrance of the end point of each outgoing edge is reduced by 1, and the end point of the outgoing edge with the degree of entrance being 0 is taken as the top point and is placed into a second queue; and recording service calls and/or call sequences between the vertexes of the second queue as parallel calls, and putting the vertexes of the second queue into the first queue.
Since the service call and/or the service logic call corresponding to the vertex in the first queue are concurrently called, the call order of the service call and the service logic corresponding to the end point of the outgoing edge of the vertex in the first queue can be further judged.
For the vertex in the first queue, it is determined that it is called in parallel, and then the call order of the vertex does not need to be considered, so that the income taking the service call or business logic of the vertex as the end point of the edge is considered to be less than 1, that is, the income of the end point of the outgoing edge is subtracted by 1.
If the incomes of the endpoints after subtracting 1 from the incomes are 0, it indicates that service calls or service logics of the call sequences do not need to be considered before the endpoints with 0, the endpoints with 0 can be taken as the vertices and put into the second queue, and for the vertices in the second queue, the endpoints with 0 are essentially the endpoints with 0, that is, there are no other service calls or service logics needing to be called before the endpoints, so the call sequences of all the vertices in the second queue can be recorded as parallel calls, and then the vertices in the second queue are put into the first queue, and the judgment of the call sequences of all the vertices can be realized by circulating the above processes.
Fig. 7 is a schematic flow chart diagram illustrating yet another code generation method in accordance with an embodiment of the present disclosure. As shown in fig. 7, prior to generating the executable code, the method further comprises:
in step S6, it is determined whether a loop exists in the calling order;
in step S7, if a loop exists in the call order, a presentation information is generated.
In one embodiment, when a loop exists in the calling sequence, a loop call can occur during execution of the code, and a fault is caused, so that prompt information can be generated when the loop exists in the calling sequence, so that a user can manually intervene to adjust the calling sequence, and the reasonability of the calling sequence is ensured.
The embodiment of the code generation device disclosed by the invention can be applied to network equipment. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. The software implementation is taken as an example, and is formed by reading corresponding computer program instructions in the nonvolatile memory into the memory for operation through the processor of the device where the software implementation is located as a logical means. From a hardware aspect, as shown in fig. 8, which is a schematic diagram of a hardware structure of a device in which the code generation apparatus of the present disclosure is located, in addition to the processor, the network interface, the memory, and the nonvolatile memory shown in fig. 8, the device in which the apparatus is located in the embodiment may also include other hardware, such as a forwarding chip responsible for processing a packet, and the like; the device may also be a distributed device in terms of hardware structure, and may include multiple interface cards to facilitate expansion of message processing at the hardware level.
Fig. 9 is a schematic block diagram illustrating a code generation apparatus according to an embodiment of the present disclosure. The code generation apparatus shown in this embodiment may be applied to a platform for automatically generating code, and the platform may be based on a RESTful architecture.
As shown in fig. 9, the code generating apparatus may include:
an input/output determination module 1, configured to determine, according to a received instruction, input and output of an interface of a service aggregation service, input and output of at least one service call, and input and output of at least one service logic;
a calling sequence determining module 2, configured to determine a calling sequence of each service call and each service logic according to a relationship between an input and an output of the service call and an input and an output of the service logic, where the calling sequence does not include the preceding and/or the following service calls and/or the service logic calls in parallel;
and the code generation module 3 is used for generating executable codes according to the calling sequence, the input and the output of the interface, the input and the output of the service calling and the input and the output of the business logic.
Fig. 10 is a schematic block diagram illustrating an input-output determination module in accordance with an embodiment of the present disclosure. As shown in fig. 10, the input/output determination module 1 includes:
the service logic determining submodule 11 is configured to determine the service logic in a plurality of candidate service logics according to the received first selection instruction, where a service processing logic in the service logic is pre-packaged;
the service invocation determining submodule 12 is configured to determine the service invocation from a plurality of candidate service invocations according to the received second selection instruction, where coordinates and beans of a jar packet corresponding to the at least one service invocation are pre-configured;
the input/output editing submodule 13 is used for editing the input and output of the interface according to the received editing instruction;
and the connection establishing submodule 14 is used for connecting the input and the input of the interface, the service call and the business logic according to the received connection instruction, and determining the input and the output of each service call and the input and the output of each business logic according to the connection result.
Fig. 11 is a schematic block diagram illustrating another code generation apparatus according to an embodiment of the present disclosure. As shown in fig. 11, the apparatus further includes:
the first storage module 4 is used for storing the service processing logic corresponding to the service logic, and the jar packet coordinate and bean corresponding to the service call in a first storage space;
and the second storage module 5 is used for storing the input and the output of the interface, the input and the output of the service call and the input and the output of the business logic in a second storage space.
Fig. 12 is a schematic block diagram illustrating yet another code generation apparatus according to an embodiment of the present disclosure. As shown in fig. 12, the apparatus further includes:
a graph structure component module 6, which is used for constructing a graph by taking business logic and service call as vertexes, taking the relation between the input and output of the service call and the input and output of the business logic as edges;
the number of the outgoing edges of the vertex is the number of the edges which take the vertex as a starting point and take the vertex as a terminal point.
Optionally, the call order determination module is configured to:
traversing the vertex of a first queue, wherein the in-degree of the vertex in the first queue is 0, and recording the service call and/or the call sequence between service logics corresponding to the vertex of the first queue as parallel call;
circulating the following steps:
taking out a vertex from the first queue, traversing the taken-out edges of the vertex, subtracting 1 from the degree of entrance of the end point of each edge, and taking the end point of the edge with the degree of entrance of 0 as the vertex and placing the end point of the edge into a second queue;
and recording the calling sequence between service calling and/or service logic corresponding to the top point of the second queue as parallel calling, and putting the top point of the second queue into the first queue.
Fig. 13 is a schematic block diagram illustrating yet another code generation apparatus according to an embodiment of the present disclosure. As shown in fig. 13, the apparatus further includes:
a loop judgment module 7, configured to judge whether a loop exists in the call sequence;
and the prompt generation module 8 is configured to generate prompt information when a loop exists in the call sequence.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
An embodiment of the present disclosure also provides an electronic device, including:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to implement the method of any of the above embodiments.
Embodiments of the present disclosure also provide a computer-readable storage medium, on which a computer program is stored, which when executed by a processor implements the steps in the method according to any of the above embodiments.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed solution. One of ordinary skill in the art can understand and implement it without inventive effort.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (10)

1. A code generation method, comprising:
determining input and output of an interface of the service aggregation service according to the received editing instruction; determining at least one business logic in the multiple alternative business logics and at least one service call in the multiple alternative service calls according to the received selection instruction; according to the received connection instruction, connecting the input and the output of the interface, the service call and the business logic, and determining the input and the output of the service call and the input and the output of the business logic according to the connection result;
determining a calling sequence of each service call and each service logic according to the relation between the input and the output of the service call and the input and the output of the service logic, wherein the calling sequence does not divide the service call and/or the service logic to be called in parallel;
and generating executable codes according to the calling sequence, the input and the output of the interface, the input and the output of the service calling and the input and the output of the business logic.
2. The method of claim 1, wherein determining at least one business logic among a plurality of candidate business logics and at least one service invocation among a plurality of candidate service invocations according to the received selection instruction comprises:
determining the service logic in a plurality of alternative service logics according to the received first selection instruction, wherein the service logic is packaged in advance for service processing logic;
and determining the service call in a plurality of candidate service calls according to the received second selection instruction, wherein the jar packet coordinate and bean corresponding to at least one service call are configured in advance.
3. The method of claim 2, further comprising:
storing the service processing logic corresponding to the service logic and the jar packet coordinate and bean corresponding to the service call in a first storage space;
and storing the input and the output of the interface, the input and the output of the service call and the input and the output of the business logic in a second storage space.
4. The method of any of claims 1 to 3, wherein prior to determining the order of invocation of each said service call with each said business logic based on the relationships between the inputs and outputs of said service call and the inputs and outputs of said business logic, the method further comprises:
constructing a graph by taking business logic and service call as vertexes, taking the relation between the input and output of the service call and the input and output of the business logic as edges;
the number of the outgoing edges of the vertex is the number of the edges which take the vertex as a starting point and take the vertex as a terminal point.
5. The method of claim 4, wherein determining the calling order of each service call and each business logic according to the relationship between the inputs and outputs of the service call and the inputs and outputs of the business logic comprises:
traversing the vertex of a first queue, wherein the in-degree of the vertex in the first queue is 0, and recording the service call and/or the call sequence between service logics corresponding to the vertex of the first queue as parallel call;
circulating the following steps:
taking out a vertex from the first queue, traversing the taken-out edges of the vertex, subtracting 1 from the degree of entrance of the end point of each edge, and taking the end point of the edge with the degree of entrance of 0 as the vertex and placing the end point of the edge into a second queue;
and recording the calling sequence between service calling and/or service logic corresponding to the top point of the second queue as parallel calling, and putting the top point of the second queue into the first queue.
6. The method of any of claims 1 to 3, wherein prior to generating the executable code, the method further comprises:
judging whether a loop exists in the calling sequence;
and if a loop exists in the calling sequence, generating prompt information.
7. A code generation apparatus, comprising:
the input/output determining module is used for determining the input and the output of an interface of the business aggregation service according to the received editing instruction; determining at least one business logic in the multiple alternative business logics and at least one service call in the multiple alternative service calls according to the received selection instruction; according to the received connection instruction, connecting the input and the output of the interface, the service call and the business logic, and determining the input and the output of the service call and the input and the output of the business logic according to the connection result;
a calling sequence determining module, configured to determine a calling sequence of each service call and each service logic according to a relationship between an input and an output of the service call and an input and an output of the service logic, where the calling sequence does not include the service call and/or the service logic call in parallel first and/or last;
and the code generation module is used for generating executable codes according to the calling sequence, the input and the output of the interface, the input and the output of the service calling and the input and the output of the business logic.
8. The apparatus of claim 7, wherein the input output determination module comprises:
the service logic determining submodule is used for determining the service logic in a plurality of alternative service logics according to the received first selection instruction, wherein the service logic is packaged in advance for processing the service;
and the service call determining submodule is used for determining the service call in a plurality of candidate service calls according to the received second selection instruction, wherein the jar packet coordinate and bean corresponding to at least one service call are configured in advance.
9. An electronic device, comprising:
a processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to implement the method of any one of claims 1 to 6.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN201910756552.8A 2019-08-16 2019-08-16 Code generation method and code generation device Active CN110531967B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910756552.8A CN110531967B (en) 2019-08-16 2019-08-16 Code generation method and code generation device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910756552.8A CN110531967B (en) 2019-08-16 2019-08-16 Code generation method and code generation device

Publications (2)

Publication Number Publication Date
CN110531967A CN110531967A (en) 2019-12-03
CN110531967B true CN110531967B (en) 2021-09-24

Family

ID=68663333

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910756552.8A Active CN110531967B (en) 2019-08-16 2019-08-16 Code generation method and code generation device

Country Status (1)

Country Link
CN (1) CN110531967B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111782207B (en) * 2020-06-23 2024-07-23 北京青云科技股份有限公司 Task stream code generation method, device, equipment and storage medium
CN114461198B (en) * 2021-12-27 2024-05-28 上海交通大学四川研究院 Program generation method, device, equipment and medium based on visual low code

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103944902A (en) * 2010-08-13 2014-07-23 华为技术有限公司 Method, device and equipment for aggregating Mashup service for service
US8924472B1 (en) * 2011-08-20 2014-12-30 Datastax, Inc. Embedding application services in a distributed datastore
CN108228149A (en) * 2016-12-19 2018-06-29 北京京东尚科信息技术有限公司 It is a kind of can dynamical assemble service APP method for interface adaptation and device
CN108279866A (en) * 2018-01-24 2018-07-13 马上消费金融股份有限公司 Method, device and medium for arranging and executing business process
CN109491777A (en) * 2018-11-12 2019-03-19 北京字节跳动网络技术有限公司 Task executing method, device, equipment and storage medium
CN109902077A (en) * 2018-12-29 2019-06-18 阿里巴巴集团控股有限公司 A kind of service request processing method, device and equipment

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2008511934A (en) * 2004-08-31 2008-04-17 インターナショナル・ビジネス・マシーンズ・コーポレーション Architecture for enterprise data integration systems
CN107229619B (en) * 2016-03-23 2020-07-28 阿里巴巴集团控股有限公司 Method and device for counting and displaying calling condition of internet service link
US10122788B2 (en) * 2016-03-29 2018-11-06 Amazon Technologies, Inc. Managed function execution for processing data streams in real time
CN106445556B (en) * 2016-10-18 2019-08-30 中国银行股份有限公司 A kind of visual code generation method and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103944902A (en) * 2010-08-13 2014-07-23 华为技术有限公司 Method, device and equipment for aggregating Mashup service for service
US8924472B1 (en) * 2011-08-20 2014-12-30 Datastax, Inc. Embedding application services in a distributed datastore
CN108228149A (en) * 2016-12-19 2018-06-29 北京京东尚科信息技术有限公司 It is a kind of can dynamical assemble service APP method for interface adaptation and device
CN108279866A (en) * 2018-01-24 2018-07-13 马上消费金融股份有限公司 Method, device and medium for arranging and executing business process
CN109491777A (en) * 2018-11-12 2019-03-19 北京字节跳动网络技术有限公司 Task executing method, device, equipment and storage medium
CN109902077A (en) * 2018-12-29 2019-06-18 阿里巴巴集团控股有限公司 A kind of service request processing method, device and equipment

Also Published As

Publication number Publication date
CN110531967A (en) 2019-12-03

Similar Documents

Publication Publication Date Title
CN111258773B (en) Service call flow information processing method and device and electronic equipment
CN107230092B (en) Accounting processing method and device and server
US10621640B2 (en) Augmented and virtual reality quote-to-cash system
CN111262897B (en) Service call routing processing method, device and system
CN113312116B (en) System and method for offloading application extension script execution from an application hosting infrastructure
CN113467824B (en) Data processing method, device, equipment and storage medium
CN110531967B (en) Code generation method and code generation device
CN111258772A (en) Service calling information processing method, device and system
CN110942377A (en) Method and system for implementing asynchronous verification of telecom CRM (customer relationship management) service
CN114693296A (en) Coupon management method and device, electronic equipment and storage medium
CN111258567A (en) Service code development processing method and device
US11120513B2 (en) Capital chain information traceability method, system, server and readable storage medium
CN113360043A (en) Service processing method and device
CN112036853A (en) Payment method, payment mode configuration method, device and equipment
CN111435484B (en) Task cooperative processing method, device, equipment and system
CN109889906B (en) Shopping method and related equipment
CN117251157A (en) User interface generation method, device, equipment and medium
JP4093033B2 (en) Service component selection support method
CN114581088A (en) Aggregated payment method, device and system for SaaS (software as a service) system
CN112258300B (en) Auditing method and device for order generation
CN114529412A (en) Resource processing method and device based on block chain
CN113888340A (en) Docking processing method, device, equipment and storage medium for configured insurance products
CN111506340A (en) Business rule information processing method, device and system
CN109766047A (en) Calculation formula implementation method, device, computer equipment and storage medium in document
US20220291939A1 (en) Systems and methods for executing a process using a lightweight java workflow orchestration library and a graph data structure

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
GR01 Patent grant
GR01 Patent grant