Method and device for executing business logic

By determining and mapping the entity state transition path as the business logic execution path, the business logic coupling problem in the prior art is solved, and the goal of clarifying the business logic effect and reducing costs is achieved.

CN119493554APending Publication Date: 2025-02-21BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311040813.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-17
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

In the prior art, multiple business logics are coupled together, making it difficult to reflect the role and effect of business logic, increasing the difficulty of development and maintenance.

Method used

By determining the entity state transition path between the initial entity state and the completion entity state, it is mapped as a business logic execution path and the included business logic is executed in response to a service call request.

Benefits of technology

The execution effect of each business logic is clarified, which facilitates understanding of business logic, reduces development and maintenance costs, and improves the execution efficiency of business logic.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119493554A_ABST
    Figure CN119493554A_ABST
Patent Text Reader

Abstract

The invention discloses a business logic execution method and device, and relates to the technical field of computers. A specific embodiment of the business logic execution method comprises the following steps: in response to a received service calling request, determining a corresponding initial entity state and a completion entity state; determining an entity state conversion path between the initial entity state and the completed entity state according to a dependency relationship between the entity states; and mapping the entity state conversion path into a business logic execution path, and executing business logic included in the business logic execution path to respond to the service calling request. According to the embodiment, the business logic is driven to execute through the entity state, the execution effect of each business logic can be clarified, the business logic can be understood conveniently, and the development cost and the maintenance cost are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for executing business logic. Background Art

[0002] Currently, business systems provide various services based on their own business logic. For example, the business logic for placing an order for goods in an e-commerce scenario is generally to deduct inventory first and then generate an order. Usually, multiple business logics are called each other through hard coding or are directly written together. When executing business logic, it is executed in the order in which each business logic is written.

[0003] In the process of implementing the present invention, the inventors found that the prior art has at least the following problems:

[0004] Multiple business logics are coupled together, which makes it difficult to reflect the role and effect of business logic, increasing the difficulty of development and maintenance. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a method and device for executing business logic, which can clarify the execution effect of each business logic, facilitate understanding of the business logic, and reduce development costs and maintenance costs.

[0006] To achieve the above object, according to a first aspect of an embodiment of the present invention, a method for executing business logic is provided, comprising:

[0007] In response to receiving the service call request, determining a corresponding initial entity state and a completed entity state;

[0008] Determine an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship between the entity states;

[0009] The entity state transition path is mapped to a business logic execution path, and the business logic included in the business logic execution path is executed to respond to the service call request.

[0010] Optionally, determining an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship between the entity states includes:

[0011] Traversing a dependency graph established according to dependency relationships between entity states, and determining a dependency relationship between the completed entity state and the initial entity state;

[0012] An entity state transition path between the initial entity state and the completed entity state is determined according to the dependency relationship.

[0013] Optionally, determining an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship includes:

[0014] Determine multiple candidate entity state transition paths between the initial entity state and the completed entity state based on the dependency relationship, filter out a target entity state transition path from the multiple candidate entity state transition paths, and use the target entity state transition path as the entity state transition path between the initial entity state and the completed entity state.

[0015] Optionally, filtering out a target entity state transition path from the plurality of candidate entity state transition paths includes:

[0016] Determining a set of entity states included in each entity state transition path according to the dependency relationship;

[0017] Determine the business logic set corresponding to each entity state set according to the preset mapping relationship;

[0018] A target business logic set with the smallest algorithm complexity is screened out from the business logic set, and an entity state transition path corresponding to the target business logic set is used as a target entity state transition path.

[0019] Optionally, mapping the entity state transition path to a business logic execution path includes:

[0020] Determining a target entity state included in the entity state transition path;

[0021] Determine the business logic corresponding to the target entity state according to the preset mapping relationship;

[0022] The business logic is sorted according to the arrangement order of the target entity states in the entity state transition path to obtain a business logic execution path.

[0023] Optionally, the entity state transition path includes a branch; and sorting the business logic according to the arrangement order of the target entity state in the entity state transition path includes:

[0024] dividing the entity state transition path into a plurality of entity state transition stages according to the branches;

[0025] In each entity state conversion phase, the business logics corresponding to the target entity states in the same branch are sorted according to the arrangement order, and the sorted business logics corresponding to the target entity states in different branches are merged;

[0026] The merged business logic is spliced ​​according to the arrangement order of each entity state conversion stage.

[0027] Optionally, the method further comprises:

[0028] In response to receiving the update request, the dependency relationship between the entity states is modified.

[0029] According to a second aspect of an embodiment of the present invention, there is provided a device for executing business logic, including:

[0030] A determination module, configured to determine a corresponding initial entity state and a completed entity state in response to receiving a service call request;

[0031] A generating module, configured to determine an entity state transition path between the initial entity state and the completed entity state according to a dependency relationship between entity states;

[0032] The execution module is used to map the entity state transition path into a business logic execution path, and execute the business logic included in the business logic execution path to respond to the service call request.

[0033] Optionally, determining an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship between the entity states includes:

[0034] Traversing a dependency graph established according to dependency relationships between entity states, and determining a dependency relationship between the completed entity state and the initial entity state;

[0035] An entity state transition path between the initial entity state and the completed entity state is determined according to the dependency relationship.

[0036] Optionally, determining an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship includes:

[0037] Determine multiple candidate entity state transition paths between the initial entity state and the completed entity state based on the dependency relationship, filter out a target entity state transition path from the multiple candidate entity state transition paths, and use the target entity state transition path as the entity state transition path between the initial entity state and the completed entity state.

[0038] Optionally, filtering out a target entity state transition path from the plurality of candidate entity state transition paths includes:

[0039] Determining a set of entity states included in each entity state transition path according to the dependency relationship;

[0040] Determine the business logic set corresponding to each entity state set according to the preset mapping relationship;

[0041] A target business logic set with the smallest algorithm complexity is screened out from the business logic set, and an entity state transition path corresponding to the target business logic set is used as a target entity state transition path.

[0042] Optionally, mapping the entity state transition path to a business logic execution path includes:

[0043] Determining a target entity state included in the entity state transition path;

[0044] Determine the business logic corresponding to the target entity state according to the preset mapping relationship;

[0045] The business logic is sorted according to the arrangement order of the target entity states in the entity state transition path to obtain a business logic execution path.

[0046] Optionally, the entity state transition path includes a branch; and sorting the business logic according to the arrangement order of the target entity state in the entity state transition path includes:

[0047] dividing the entity state transition path into a plurality of entity state transition stages according to the branches;

[0048] In each entity state conversion phase, the business logics corresponding to the target entity states in the same branch are sorted according to the arrangement order, and the sorted business logics corresponding to the target entity states in different branches are merged;

[0049] The merged business logic is spliced ​​according to the arrangement order of each entity state conversion stage.

[0050] Optionally, the device further comprises:

[0051] The modification module is used to modify the dependency relationship between the entity states in response to receiving an update request.

[0052] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, including:

[0053] one or more processors;

[0054] a storage device for storing one or more programs,

[0055] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any one of the above embodiments.

[0056] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method described in any one of the above embodiments is implemented.

[0057] An embodiment of the above invention has the following advantages or beneficial effects: by driving the execution of business logic through entity state, the role and effect of each business logic can be clarified, which is convenient for understanding business logic and reducing development cost and maintenance cost; by determining the dependency relationship between entity states based on the dependency graph, the entity state transition path can be quickly determined, which is conducive to improving the execution efficiency of business logic; by screening out the target entity state transition path from multiple entity state transition paths, the entity state transition path can be simplified, and the business logic execution path can be prevented from containing unnecessary business logic, thereby further improving the execution efficiency of business logic; by screening the target entity state transition path by algorithm complexity, the business logic included in the business logic execution path is easier to execute, takes less time, and saves system resources; each entity state has corresponding business logic, and the execution order of multiple business logics is determined according to the arrangement order of the entity states, and multiple business logics are decoupled, so that the business logic can be executed more flexibly; by dividing the entity state transition path into multiple stages, the business logic in each stage is sorted, and the execution order between different stages is guaranteed, which can further improve the flexibility of business logic execution and ensure accurate and efficient execution of business logic.

[0058] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0060] Figure 1 is a schematic diagram of the main process of the method for executing the business logic according to an embodiment of the present invention;

[0061] Figure 2 is a schematic diagram of entity state dependency according to a reference embodiment of the present invention;

[0062] Figure 3 is a schematic diagram of a dependency graph according to a reference embodiment of the present invention;

[0063] Figure 4 is a schematic diagram of mapping a business logic execution path according to a reference embodiment of the present invention;

[0064] Figure 5 is a schematic diagram of dividing entity state transition paths according to a reference embodiment of the present invention;

[0065] Figure 6 It is a schematic diagram of the main process of a method for executing business logic according to a reference embodiment of the present invention;

[0066] Figure 7 is a schematic diagram of the main process of a method for executing business logic according to another reference embodiment of the present invention;

[0067] Figure 8 is a schematic diagram of main modules of a device for executing service logic according to an embodiment of the present invention;

[0068] Fig. 9 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0069] Fig.10 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0070] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0071] It should be noted that in the technical solution of the present invention, the collection, use, storage, sharing and transfer of user personal information involved are in compliance with the provisions of relevant laws and regulations, and it is necessary to inform the user and obtain the user's consent or authorization. When applicable, the user's personal information is de-identified and / or anonymized and / or encrypted.

[0072] The business system provides various services based on the business logic it runs. Usually, multiple business logics are called each other through hard coding or are directly written together. When executing business logic, it is executed in the order in which each business logic is written.

[0073] For example, in an e-commerce scenario, the product browsing stage includes two business logics, namely, viewing inventory and rendering a page. The page includes multiple page areas, namely, a product attribute screening area, a product inventory display area, and a platform information navigation area. In the product browsing stage, only the product inventory display area needs to be re-rendered. However, multiple business logics for rendering different page areas are coupled together, and some unnecessary page areas are often rendered when rendering the page, which reduces page rendering efficiency and occupies system resources.

[0074] For another example, in an e-commerce scenario, the product ordering process includes two business logics, namely deducting inventory and generating orders. These two business logics are often written in the same business method, and the corresponding business codes are intertwined. When viewing the business method, you can only see that the business method is used for product orders, but it is difficult to distinguish each business logic and its function and effect, which makes the business code difficult to understand. When adding a new service or modifying an existing service, it is necessary to directly modify the business logic coupled together in the business method, consuming a lot of energy to find the business code belonging to the same business logic, increasing the difficulty of development and maintenance.

[0075] In view of this, according to a first aspect of an embodiment of the present invention, a method for executing business logic is provided.

[0076] Figure 1 FIG. 1 is a schematic diagram of the main process of the method for executing the business logic according to an embodiment of the present invention. Figure 1 As shown, the method for executing the business logic according to the embodiment of the present invention mainly includes the following steps S101 to S103.

[0077] Step S101, in response to receiving a service call request, determining a corresponding initial entity state and a completed entity state.

[0078] A data entity is an object with multiple data and behaviors. A data entity exists in the form of an entity class (object instance) in the business logic. Accordingly, the entity class has multiple attributes and methods. A data entity has multiple entity states, and the multiple entity states of a data entity are converted to each other during the execution of the business logic. The entity state of a data entity is stored as an attribute of the data entity inside the data entity, or the association between the data entity and the corresponding entity state is stored using a cache, a database, or the like. A data entity has a unique identifier, which is used to distinguish different data entities and does not change with the conversion of the entity state. For example, in an e-commerce platform, each commodity is a data entity. Specifically, the commodity has attributes such as price, quantity, brand, model, and production date. The commodity has methods such as listing, delisting, increasing inventory, decreasing inventory, and modifying prices. The commodity has multiple entity states such as being on sale, discontinued, successful replenishment, successful price modification, and passed quality inspection. For a commodity whose entity state is discontinued, the entity state of the commodity is converted to successful replenishment by executing the replenishment method, and then the entity state of the commodity is converted to being on sale by executing the listing method. For another example, each order is a data entity. Specifically, an order has attributes such as the ordering user, generation time, product information, delivery address, contact information, etc. An order has methods such as generation, cancellation, viewing, archiving, comparison, statistics, etc. An order has multiple entity states such as order generation success, order cancellation success, storage success, etc. By executing the order generation method, a new order with an entity state of successful order generation is generated.

[0079] The received service call request is parsed to obtain the initial entity state of the first data entity and the completed entity state of the second data entity. The initial entity state is the entity state that the first data entity is in when the service call request is received, and the completed entity state is the entity state that the second data entity should be in after executing the relevant business logic to respond to the service call request. It should be noted that both the first data entity and the second data entity may include multiple data entities, and the first data entity and the second data entity may be the same, may not be completely the same, or may be completely different.

[0080] Exemplarily, the received service call request is parsed to obtain "{'start':'EntityA1,EntityA2';'finish':'EntityA3-B1,EntityA4-B2'}", wherein "'start':'EntityA1,EntityA2'" indicates that the initial entity state is the entity state currently in which data entity A1 and data entity A2 are located, and the current entity state of data entity A1 and data entity A2 is determined by querying the attributes of data entity A1 and data entity A2 or retrieving a preset entity-state association table, thereby obtaining the initial entity state, and "'finish':'EntityA3-B1,EntityA4-B2'" indicates that the entity state B1 of data entity A3 and the entity state B2 of data entity A4 are taken as the completed entity state; when the service call request is received, the data entity does not meet the conditions for completing the entity state, that is, it does not meet the following conditions: the entity state of data entity A3 is B1 and the entity state of data entity A4 is B2.

[0081] Determining the corresponding initial entity state and completed entity state according to the service call request is conducive to driving the execution of business logic according to the entity state, decoupling the business logic from the service call request, and making the response process of the service call request more flexible.

[0082] Step S102: determining an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship between entity states.

[0083] There is a dependency relationship between different entity states, and the dependency relationship indicates the conversion order between different entity states. For example, "the entity state C1 of the first data entity depends on the entity state C2 of the second data entity" means that the entity state of the first data entity can only be converted to entity state C1 after the entity state of the second data entity is converted to entity state C2. Therefore, according to the above dependency relationship, the entity state conversion path between entity state C1 and entity state C2 is "from entity state C2 of the second data entity to entity state C1 of the first data entity". For another example, "the order (data entity) is generated successfully (entity state) depends on the inventory deduction of the product (data entity) successfully (entity state)", that is, "the product inventory deduction is successful" before "the order is generated successfully", so the entity state conversion path is "from the inventory deduction of the product is successful to the order generation success".

[0084] An entity state can depend on one or more other entity states. Specifically, the entity state C3 of the first data entity depends on the entity state C4 of the second data entity and the entity state C5 of the third data entity, indicating that the entity state of the first data entity can only be converted to entity state C3 after the entity state of the second data entity is converted to entity state C4 and the entity state of the third data entity is converted to entity state C5. More specifically, the entity state C6 of the first data entity depends on the entity state C7 of the second data entity or the entity state C8 of the third data entity, indicating that the entity state of the first data entity can only be converted to entity state C6 after the entity state of the second data entity is converted to entity state C7 or the entity state of the third data entity is converted to entity state C8. It should be noted that the first data entity, the second data entity and the third data entity in the above statement can be the same data entity or different data entities.

[0085] Pre-configure the dependencies between different entity states. For example, use a configuration file to store the dependencies between different entity states, using the following format "EntityD1.StateC9 = EntityD2.StateC10, EntityD3.StateC11" to indicate that "the entity state C9 of data entity D1 depends on the entity state C10 of data entity D2 and the entity state C11 of data entity D3"; when the program starts or after receiving a service call request, traverse the configuration file and read the dependencies. As another example, the dependency between different usage states is marked by annotations, and an annotation class EntityState is defined, which has two fields: the field state represents the first entity state, and the field dependentState represents the second entity state on which the first entity state depends, wherein the data type of the second entity state is an array, list, or other data type that can include multiple entity states, and the following format "@(EntityD4.StateC12=EntityD5.StateC13:EntityD6.StateC14)" is used to indicate that "the entity state C12 of data entity D4 depends on the entity state C13 of data entity D5 or the entity state C14 of data entity D6"; the annotation is marked on the program startup class or other custom classes, and when the program starts, the dependency is read by scanning the annotations on the class package.

[0086] After determining the initial entity state and the completed entity state, the first-layer entity state on which the completed entity state depends is found by traversing the configuration file or retrieving the cache, database table, etc. that stores the dependency relationship. If the first-layer entity state is not the initial entity state, continue to search for the second-layer entity state on which the first-layer entity state depends, and repeat the above steps until the initial entity state is found after passing through multiple layers of dependency relationships; according to the multiple layers of dependency relationships between the completed entity state and the initial entity state, an entity state conversion path from the initial entity state to the completed entity state is reversely established.

[0087] Figure 2 FIG. 1 is a schematic diagram of entity state dependency according to a reference embodiment of the present invention. For example, Figure 2 As shown, dependency relationship 201 indicates that entity state 1-1 of data entity 1 depends on entity state 2-1 of data entity 2, that is, the entity state of data entity 1 can be converted to entity state 1-1 only after the entity state of data entity 2 is converted to entity state 2-1; dependency relationship 202 indicates that entity state 1-2 of data entity 1 depends on multiple entity states such as entity state 2-2 of data entity 2 and entity state 3-2 of data entity 3; dependency relationship 203 indicates that entity state 1-3 of data entity 1 depends on entity state 2-3 of data entity 2, or entity state 1-3 of data entity 1 depends on entity state 3-3 of data entity 3, or entity state 1-3 of data entity 1 depends on other entity states. Since the entity states on which entity state 1-3 of data entity 1 depends are in an "or" relationship, they are represented by arrows of different types (solid line, dashed line, dotted line).

[0088] Exemplarily, the initial entity state is the entity state E4 of the data entity D10, and the completed entity state is the entity state E1 of the data entity D7; the dependency relationship in the configuration file includes "{'D7.E1=D8.E2','D8.E2=D9.E3','D9.E3=D10.E4'}", wherein the entity state E1 of the data entity D7 depends on the entity state E2 of the data entity D8, the entity state E2 of the data entity D8 depends on the entity state E3 of the data entity D9, and the entity state E3 of the data entity D9 depends on the entity state E4 of the data entity D8. According to the entity state E4 of entity D10; therefore, according to the multi-layer dependency in the above configuration file, the entity state conversion path from the entity state E4 of data entity D10 to the entity state E1 of data entity D7 is reversely established, and "D10.E4-D9.E3-D8.E2-D7.E1" is obtained, that is, first convert from "the entity state E4 of data entity D10" to "the entity state E3 of data entity D9", then convert to "the entity state E2 of data entity D8", and finally convert to "the entity state E1 of data entity D7".

[0089] Each entity state corresponds to an execution result. The entity state transition path between the initial entity state and the completed entity state can be determined quickly and accurately through dependencies. This can clarify the business meaning of each entity state transition and facilitate updating of existing dependencies.

[0090] According to a reference embodiment of the present invention, when determining the entity state conversion path between the initial entity state and the completed entity state according to the dependency relationship between the entity states, the dependency graph established according to the dependency relationship between the entity states is traversed, and the dependency graph can be established in advance or in real time. The entity state is used as the vertex of the dependency graph, and the dependency relationship between different entity states is used as the edge between different vertices. For example, the entity state F1 of the first data entity depends on the entity state F2 of the second data entity, and there is an edge from the entity state F1 to the entity state F2 in the dependency graph. The edge formed by one entity state depending on multiple entity states (for example, the entity state F1 depends on the entity state F3 and the entity state F4, or the entity state F1 depends on the entity state F3 or the entity state F4) is marked. The vertex corresponding to the completed entity state is found from the dependency graph, and the breadth-first search or the depth-first search is performed with the vertex as the starting point until the initial entity state is found, and the edge and vertex connecting the completed entity state and the initial entity state are mapped to the corresponding dependency relationship; and the entity state conversion path between the initial entity state and the completed entity state is reversely established according to the dependency relationship.

[0091] Figure 3 is a schematic diagram of a dependency graph according to a reference embodiment of the present invention. Figure 3As shown, dependency graph 301 includes multiple vertices and multiple edges, each vertex represents the entity state of a data entity, for example, vertex 1-1 represents the entity state 1 of data entity 1, and the other vertices are analogous. Vertex 1-1 has edges pointing to vertex 2-1 and vertex 3-1, indicating that the entity state 1 of data entity 1 depends on the entity state 1 of data entity 2 and the entity state 1 of data entity 3 (i.e., the entity state 1 of data entity 1 can only be obtained after the entity state 1 of data entity 2 and the entity state 1 of data entity 3 are obtained first); the entity state 1 of data entity 2 depends on the entity state 1 of data entity 4 or the entity state 2 of data entity 4 (i.e., the entity state 1 of data entity 4 or the entity state 2 of data entity 4 is obtained first before the entity state 1 of data entity 2 is obtained). Since the entity state 1 of data entity 4 and the entity state 2 of data entity 4 are in an "or" relationship, vertex 2-1 points to vertex 4-1 and vertex 4-2 through two types of edges (solid line edge and dotted line edge). When vertex 1 - 1 represents the completed entity state and vertex 1 - 2 represents the initial entity state, two entity state transition paths between the completed entity state and the initial entity state are obtained according to dependency graph 301 , including entity state transition path 302 and entity state transition path 303 .

[0092] According to another reference embodiment of the present invention, when determining the entity state transition path between the initial entity state and the completed entity state according to the dependency relationship, find the vertex corresponding to the completed entity state from the dependency graph, and perform a breadth-first search or a depth-first search with the vertex as the starting point until all paths with the vertex as the starting point are traversed, and then find multiple groups of edges and vertices connecting the initial entity state and the completed entity state, that is, multiple candidate entity state transition paths. Filter out the target entity state transition path from the multiple candidate entity state transition paths; for example, calculate the number of edges and vertices included in each candidate entity state transition path, and use the candidate entity state transition path with the smallest number of edges and vertices as the target entity state transition path; for another example, each entity state belongs to a data entity, and each data entity has a corresponding business category attribute (for example, in the field of e-commerce, the business category attributes include: catering business, tourism business, financial business, logistics business, etc.), determine the corresponding target business category attribute according to the service call request, and filter out the target entity state transition path whose entity states all meet the target business category attribute from the multiple candidate entity state transition paths. The target entity state transition path is taken as the entity state transition path between the initial entity state and the completed entity state.

[0093] Exemplarily, the initial entity state is the entity state H1 of the data entity G1, and the completed entity state is the entity state H3 of the data entity G3. The multiple candidate entity state transition paths include “{'G1.H1-G2.H2-G3.H3', 'G1.H1-G2.H2–G4.H4-G3.H3'}”, where “'G1.H1-G2.H2-G3.H3'” indicates that the candidate entity state transition path is “converted from the entity state H1 of the data entity G1 to the entity state H2 of the data entity G2, and then to the entity state H3 of the data entity G3”. "body state H3", and the other candidate entity transition paths are analogous; since the previous candidate entity state transition path includes three entity states and the next candidate entity state transition path includes four entity states, therefore, according to the above-mentioned "minimum number principle", the previous candidate entity state transition path is selected as the target entity state transition path; from the perspective of business category, only the business category attributes corresponding to data entity G4 and the service call request are different, therefore, the previous candidate entity state transition path whose entity states meet the business category attribute requirements is selected as the target entity state transition path.

[0094] Screening out a target entity state transition path from multiple candidate entity state transition paths can simplify the entity state transition path, avoid the entity state transition path containing unnecessary or overly complex entity state transition processes, and facilitate improving the execution efficiency of business logic.

[0095] According to another reference embodiment of the present invention, when the target entity state transition path is screened out from multiple candidate entity state transition paths, the entity state set included in each candidate entity state transition path is determined according to the dependency relationship, that is, all entity states included in each candidate entity state transition path. According to the preset mapping relationship, the business logic set corresponding to each entity state set is determined; each entity state corresponds to a business logic, and the business logic is a method for converting entity states and implementing service calls, and the business logic is also a code that meets the grammatical requirements. The complexity of each business logic is determined, specifically, the number of loop statements, method call statements, database query statements, database storage statements, etc. included in the business logic is counted, each statement corresponds to an algorithm complexity, and the complexity corresponding to the statements included in the business logic is added to obtain the complexity of the business logic. The complexity of the business logic included in each business logic set is added to obtain the complexity of each business logic set, and the target business logic set with the smallest algorithm complexity is screened out from multiple business logic sets, and the entity state transition path corresponding to the target business logic set is used as the target entity state transition path.

[0096] Exemplarily, the algorithm complexity of the loop statement is preset to be 10, the algorithm complexity of the database query or storage statement is preset to be 5, and the algorithm complexity of the method call statement is preset to be 2; the first candidate entity state transition path includes entity state J1, entity state J2 and entity state J3, and the second candidate entity state transition path includes entity state J1, entity state J4, entity state J5 and entity state J3; therefore, the difference between the first candidate entity state transition path and the second candidate entity state transition path lies in entity state J2, entity state J4 and entity state J5; wherein, the business logic corresponding to entity state J2 includes 3 loop statement and 2 database storage statements, therefore, the algorithm complexity of the business logic corresponding to entity state J2 is 3*10+2*5=40, the business logic corresponding to entity state J4 includes 1 loop statement and 1 method call statement, and the business logic corresponding to entity state J5 includes 1 loop statement and 1 database storage statement, therefore, the algorithm complexity of the business logic corresponding to entity state J4 and entity state J5 is 2*10+1*5+1*2=27, therefore, the algorithm complexity corresponding to the second candidate entity state transition path is smaller, and the second candidate entity state transition path is taken as the target entity state transition path.

[0097] By screening the target entity state transition path by algorithm complexity, the business logic included in the business logic execution path is easier to execute, takes less time, and saves system resources.

[0098] Step S103: Map the entity state transition path to a business logic execution path, and execute the business logic included in the business logic execution path to respond to the service call request.

[0099] Each entity state corresponds to a business logic, and the business logic is used to obtain the corresponding entity state. For example, "user registration is successful" (entity state) corresponds to the "register()" method (business logic), which means that the entity state obtained by executing the register() method is that the user registration is successful. After obtaining the entity state transition path, each entity state included in the entity state transition path is converted into the corresponding business logic, for example, by querying the configuration file, or scanning the annotations marked on each method, or searching the cache or database to determine the business logic name corresponding to the entity state. The execution order of different business logics is determined according to the connection relationship between different entity states in the entity state transition path. In the case where entity state K1 depends on entity state K2 and entity state K3, the corresponding entity state transition path is shown as entity state K2 and entity state K3 pointing to entity state K1 respectively. Therefore, entity state K1, entity state K2 and entity state K3 are mapped to corresponding business logic respectively, and the business logic of entity state K2 and entity state K3 are executed before the business logic of entity state K1. As for the business logic of entity state K2 and the business logic of entity state K3, any business logic can be executed first, and the execution order of these two business logics is not restricted. As for the case where entity state K4 depends on entity state K5 or entity state K6, since there are two entity state transition paths, it has been simplified in the previous steps, and the situation similar to the above "dependence on entity state K5 or entity state K6" will not appear here. According to the business logic name included in the business logic and the execution order between different business logic names, the corresponding methods are called in sequence and the corresponding business logic is executed, so as to realize service call and respond to service call request.

[0100] Figure 4 Schematic diagram of mapping the execution path of business logic according to a reference embodiment of the present invention. Figure 4 As shown, the business logic execution path is composed of Figure 3 The entity state transition path mapping shown is obtained. Specifically, each entity state in the entity state transition path 302 is mapped to the corresponding business logic to obtain the business logic execution path 401, wherein the execution order of business logic 2-1, business logic 4-2 and business logic 3-1, business logic 4-3 is not limited, as long as it is guaranteed that business logic 4-2 and business logic 4-3 have been executed before business logic 1-2 is executed; each entity state in the entity state transition path 303 is mapped to the corresponding business logic to obtain the business logic execution path 402, wherein the execution order of business logic 2-1, business logic 4-1 and business logic 3-1, business logic 4-3 is not limited, as long as it is guaranteed that business logic 4-1 and business logic 4-3 have been executed before business logic 1-2 is executed.

[0101] Exemplarily, the entity state transition path corresponding to entity state K7, entity state K8 and entity state K9 is "K7-K8-K9". According to the pre-set mapping relationship, each entity state in the entity state transition path is replaced with the corresponding business logic, and the business logic execution path is "first execute the business logic corresponding to entity state K7, then execute the business logic corresponding to entity state K8, and finally execute the business logic corresponding to entity state K9".

[0102] Based on the mapping relationship, the entity state transition path is mapped to the business logic execution path, and the entity state corresponding to each business logic is clarified, which makes it easier to understand the meaning of the business logic, reduces development and maintenance costs, and can decouple service call requests from corresponding business logic, so as to execute business logic more flexibly.

[0103] According to a reference embodiment of the present invention, when mapping an entity state transition path to a business logic execution path, the entity state transition path is traversed, and the entity states included in the entity state transition path are used as target entity states; the business logic corresponding to each target entity state is determined according to a preset mapping relationship; the arrangement order of each target entity state in the entity state transition path is determined, and the corresponding business logic is sorted according to the arrangement order of the target entity to obtain the business logic execution path.

[0104] Exemplarily, the entity state transition path is "L1-L2&L3-L4", wherein entity state L1 (corresponding business logic is M1) depends on entity state L2 (corresponding business logic is M2) and entity state L3 (corresponding business logic is M3), and entity state L2 and entity state L3 both depend on entity state L4 (corresponding business logic is M4); the arrangement order of entity state L1 is 1, the arrangement order of entity state L2 and entity state L3 are both 2, and the arrangement order of entity state L4 is 3; the business logic is sorted according to the arrangement order of the entity state to obtain the business logic execution path "M1-M2-M3-M4" or "M1-M3-M2-M4", and the corresponding business logic is executed in sequence according to the business logic execution path.

[0105] Each entity state has corresponding business logic. The execution order of multiple business logics is determined according to the arrangement order of the entity states, multiple business logics are decoupled, the execution effect of each business logic is clarified, and the business logic can be executed more flexibly.

[0106] According to another reference embodiment of the present invention, the entity state transition path includes one or more branches, a group of branches is a plurality of sub-paths in the entity state transition path, and both ends of the plurality of sub-paths of the same group of branches are the same entity state. Figure 5is a schematic diagram of dividing entity state transition paths according to a reference embodiment of the present invention. For example, Figure 5 As shown, the stage division path 501 is based on the branch pair Figure 3 The entity state transition path 302 in the embodiment is divided into stages. Specifically, the entity state transition path is divided at the branch start and the branch end to obtain the first stage, the second stage and the third stage included in the stage division path 501. Each branch may include one or more branches. When sorting the business logic, the entity state transition path is divided into multiple entity state transition stages according to the starting point and the end point of the branch. In each entity state transition stage, only one sub-path that is not a branch or multiple sub-paths belonging to a group of branches are included. Since other branches may be included in the branch, other entity state transition stages may be included in the entity state transition stage. In each entity state transition stage, the business logic corresponding to the target entity state in the same branch is sorted according to the arrangement order of the entity state, and the sorted business logic corresponding to the target entity state in different branches is merged, that is, the order of the target entity state in the same branch is maintained, and the order of the target entity state between different branches is not limited; the merged business logic is spliced ​​according to the arrangement order of each entity state transition stage, that is, the arrangement order between different entity state transition stages is maintained.

[0107] For example, Figure 5 As shown, the first stage and the third stage each include only one entity state, so the entity state can be directly converted into business logic, wherein the entity state corresponding to vertex 1-1 is mapped to business logic 1-1, and other mapping relationships are analogous; the second stage includes two branches, the entity state in each branch is mapped to the corresponding business logic and the arrangement order is maintained, the business logic of the two branches is merged, and the execution order of the business logic corresponding to each branch is maintained during the merger, and the execution order of the business logic included in different branches is not restricted. Finally, the business logic of the three stages is spliced ​​in the order of stage division to obtain 4 business logic execution paths, including: business logic execution path 502, business logic execution path 503, business logic execution path 504, business logic execution path 505, business logic execution path 506 and business logic execution path 507. One of the multiple business logic execution paths is selected to execute the corresponding business logic.

[0108] Each entity state has corresponding business logic. Multiple business logic execution paths are determined according to the arrangement order of the entity states, and the execution effect of each business logic is clarified, so that the business logic can be executed more flexibly.

[0109] According to another reference embodiment of the present invention, the entity state, the dependency between the entity states, and the mapping relationship between the entity state and the business logic are modifiable, and the method further includes: parsing the received update request to obtain the target dependency between the entity states. In the case where the entity state corresponding to the target dependency does not exist, the corresponding entity state and the target dependency are added to the configuration file, cache or database. In the case where the entity state corresponding to the target dependency exists, the old dependency corresponding to the entity state is searched in the configuration file, cache or database, and the old dependency is replaced with the dependency obtained by parsing. The method further includes: parsing the modification request to obtain the mapping relationship between the entity state and the business logic, and in the case where the mapping relationship does not exist, the mapping relationship is added to the configuration file, cache or database, or, in the case where the corresponding entity state and business logic exist, the mapping relationship is used to update the old mapping relationship.

[0110] Modifying entity states, dependencies between entity states, and mappings between entity states and business logic can further flexibly implement service calls, execute business logic, facilitate business development and maintenance, and save costs.

[0111] Figure 6 FIG. 1 is a schematic diagram of the main process of a method for executing business logic according to a reference embodiment of the present invention. Figure 6 As shown, the execution method of the business logic may include:

[0112] Step S601, in response to receiving a service call request, determining a corresponding initial entity state and a completed entity state;

[0113] Step S602, traversing a dependency graph established according to the dependency relationships between entity states, and determining the dependency relationship between the completed entity state and the initial entity state;

[0114] Step S603, determining an entity state transition path between an initial entity state and a completed entity state according to the dependency relationship;

[0115] Step S604, determining the target entity state included in the entity state transition path, and determining the business logic corresponding to the target entity state according to a preset mapping relationship;

[0116] Step S605, sorting the business logic according to the order of the target entity states in the entity state transition path to obtain the business logic execution path;

[0117] Step S606: execute the business logic included in the business logic execution path to respond to the service call request.

[0118] The specific implementation content of the method for executing the business logic of the above-mentioned reference embodiment of the present invention has been described in detail in the above-mentioned method for executing the business logic, so the repeated content will not be described here.

[0119] Figure 7 FIG. 1 is a schematic diagram of the main process of a method for executing business logic according to another reference embodiment of the present invention. Figure 7 As shown, the execution method of the business logic may include:

[0120] Step S701, in response to receiving a service call request, determining a corresponding initial entity state and a completed entity state;

[0121] Step S702, traversing a dependency graph established according to the dependency relationships between entity states, and determining the dependency relationship between the completed entity state and the initial entity state;

[0122] Step S703, determining a plurality of candidate entity state transition paths between the initial entity state and the completed entity state according to the dependency relationship;

[0123] Step S704, selecting an entity state transition path between an initial entity state and a completed entity state from a plurality of entity state transition paths according to the algorithm complexity;

[0124] Step S705, determining the target entity state included in the entity state transition path, and determining the business logic corresponding to the target entity state according to a preset mapping relationship;

[0125] Step S706, dividing the entity state transition path into a plurality of entity state transition stages according to the branches;

[0126] Step S707, in each entity state conversion phase, sorting the business logics corresponding to the target entity states in the same branch according to the arrangement order, and merging the sorted business logics corresponding to the target entity states in different branches;

[0127] Step S708, splicing the merged business logic according to the arrangement order of each entity state transition stage to obtain the business logic execution path;

[0128] Step S709: execute the business logic included in the business logic execution path to respond to the service call request.

[0129] The specific implementation content of the business logic execution method of another reference embodiment of the present invention has been described in detail in the business logic execution method described above, so the repeated content will not be described here.

[0130] According to a second aspect of an embodiment of the present invention, a device for executing business logic is provided.

[0131] Figure 8 is a schematic diagram of the main modules of the execution device of the service logic according to the embodiment of the present invention, such as Figure 8 As shown, the business logic execution device 800 mainly includes:

[0132] A determination module 801, configured to determine a corresponding initial entity state and a completed entity state in response to receiving a service call request;

[0133] A generating module 802, configured to determine an entity state transition path between the initial entity state and the completed entity state according to a dependency relationship between entity states;

[0134] The execution module 803 is used to map the entity state transition path into a business logic execution path, and execute the business logic included in the business logic execution path to respond to the service call request.

[0135] According to a reference embodiment of the present invention, determining an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship between entity states includes:

[0136] Traversing a dependency graph established according to dependency relationships between entity states, and determining a dependency relationship between the completed entity state and the initial entity state;

[0137] An entity state transition path between the initial entity state and the completed entity state is determined according to the dependency relationship.

[0138] According to another reference embodiment of the present invention, determining an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship includes:

[0139] Determine multiple candidate entity state transition paths between the initial entity state and the completed entity state based on the dependency relationship, filter out a target entity state transition path from the multiple candidate entity state transition paths, and use the target entity state transition path as the entity state transition path between the initial entity state and the completed entity state.

[0140] According to another reference embodiment of the present invention, selecting a target entity state transition path from the plurality of candidate entity state transition paths includes:

[0141] Determining a set of entity states included in each entity state transition path according to the dependency relationship;

[0142] Determine the business logic set corresponding to each entity state set according to the preset mapping relationship;

[0143] A target business logic set with the smallest algorithm complexity is screened out from the business logic set, and an entity state transition path corresponding to the target business logic set is used as a target entity state transition path.

[0144] According to another reference embodiment of the present invention, mapping the entity state transition path to a business logic execution path includes:

[0145] Determining a target entity state included in the entity state transition path;

[0146] Determine the business logic corresponding to the target entity state according to the preset mapping relationship;

[0147] The business logic is sorted according to the arrangement order of the target entity states in the entity state transition path to obtain a business logic execution path.

[0148] According to another reference embodiment of the present invention, the entity state transition path includes branches; and the business logic is sorted according to the arrangement order of the target entity state in the entity state transition path, including:

[0149] dividing the entity state transition path into a plurality of entity state transition stages according to the branches;

[0150] In each entity state conversion phase, the business logics corresponding to the target entity states in the same branch are sorted according to the arrangement order, and the sorted business logics corresponding to the target entity states in different branches are merged;

[0151] The merged business logic is spliced ​​according to the arrangement order of each entity state conversion stage.

[0152] According to a reference embodiment of the present invention, the business logic execution device 800 further includes:

[0153] The modification module is used to modify the dependency relationship between the entity states in response to receiving an update request.

[0154] It should be noted that the specific implementation content of the execution device of the business logic in the embodiment of the present invention has been described in detail in the above-mentioned business logic execution method, so the repeated content will not be described again here.

[0155] According to the technical solution of the embodiment of the present invention, by driving the execution of business logic through entity state, the role and effect of each business logic can be clarified, which is convenient for understanding the business logic and reducing the development cost and maintenance cost; by determining the dependency relationship between entity states based on the dependency graph, the entity state transition path can be quickly determined, which is conducive to improving the execution efficiency of the business logic; by screening out the target entity state transition path from multiple entity state transition paths, the entity state transition path can be simplified, and the business logic execution path can be prevented from containing unnecessary business logic, thereby further improving the execution efficiency of the business logic; by screening the target entity state transition path by algorithm complexity, the business logic included in the business logic execution path is easier to execute, takes less time, and saves system resources; each entity state has corresponding business logic, and the execution order of multiple business logics is determined according to the arrangement order of the entity states, and the multiple business logics are decoupled, so that the business logic can be executed more flexibly; the entity state transition path is divided into multiple stages, the business logic in each stage is sorted, and the execution order between different stages is guaranteed, which can further improve the flexibility of business logic execution and ensure accurate and efficient execution of business logic.

[0156] According to a third aspect of an embodiment of the present invention, there is provided an electronic device for executing business logic, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method provided by the first aspect of the embodiment of the present invention.

[0157] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.

[0158] Fig. 9 An exemplary system architecture 900 is shown to which the method for executing business logic or the apparatus for executing business logic according to the embodiments of the present invention can be applied.

[0159] like Fig. 9 As shown, system architecture 900 may include terminal devices 901, 902, 903, network 904 and server 905. Network 904 is used to provide a medium for communication links between terminal devices 901, 902, 903 and server 905. Network 904 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0160] The user can use the terminal devices 901, 902, 903 to interact with the server 905 through the network 904 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 901, 902, 903, such as business logic execution applications, business logic viewing applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0161] The terminal devices 901 , 902 , and 903 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers, etc.

[0162] The server 905 may be a server that provides various services, such as a background management server (for example only) that provides support for business logic execution requests sent from upstream terminal devices 901, 902, and 903. In response to receiving a service call request, the background management server may determine the corresponding initial entity state and completed entity state; determine the entity state transition path between the initial entity state and the completed entity state according to the dependency relationship between the entity states; map the entity state transition path to a business logic execution path, execute the business logic included in the business logic execution path, and respond to the service call request; and feed back the business logic execution status (for example only) to the terminal device.

[0163] It should be noted that the execution method of the business logic provided in the embodiment of the present invention is generally executed by the server 905, and accordingly, the execution device of the business logic is generally set in the server 905. The execution method of the business logic provided in the embodiment of the present invention can also be executed by the terminal devices 901, 902, and 903, and accordingly, the execution device of the business logic can be set in the terminal devices 901, 902, and 903.

[0164] It should be understood that Fig. 9 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0165] Reference below Fig.10 , which shows a schematic diagram of the structure of a computer system 1000 of a terminal device suitable for implementing an embodiment of the present invention. Fig.10 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0166] like Fig.10As shown, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the system 1000 are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0167] The following components are connected to the I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN card, a modem, etc. The communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage section 1008 as needed.

[0168] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, the above-mentioned functions defined in the system of the embodiment of the present invention are executed.

[0169] It should be noted that the computer-readable medium shown in the embodiment of the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In an embodiment of the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In an embodiment of the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0170] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0171] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a determination module, a generation module, and an execution module, wherein the names of these modules do not constitute a limitation on the modules themselves under certain circumstances, for example, the determination module may also be described as a "module for determining an initial view state and a completed entity state".

[0172] As another aspect, an embodiment of the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device implements the following method: in response to receiving a service call request, determining the corresponding initial entity state and completed entity state; determining the entity state transition path between the initial entity state and the completed entity state according to the dependency relationship between the entity states; mapping the entity state transition path to a business logic execution path, and executing the business logic included in the business logic execution path to respond to the service call request.

[0173] According to the technical solution of the embodiment of the present invention, by driving the execution of business logic through entity state, the role and effect of each business logic can be clarified, which is convenient for understanding the business logic and reducing the development cost and maintenance cost; by determining the dependency relationship between entity states based on the dependency graph, the entity state transition path can be quickly determined, which is conducive to improving the execution efficiency of the business logic; by screening out the target entity state transition path from multiple entity state transition paths, the entity state transition path can be simplified, and the business logic execution path can be prevented from containing unnecessary business logic, thereby further improving the execution efficiency of the business logic; by screening the target entity state transition path by algorithm complexity, the business logic included in the business logic execution path is easier to execute, takes less time, and saves system resources; each entity state has corresponding business logic, and the execution order of multiple business logics is determined according to the arrangement order of the entity states, and the multiple business logics are decoupled, so that the business logic can be executed more flexibly; the entity state transition path is divided into multiple stages, the business logic in each stage is sorted, and the execution order between different stages is guaranteed, which can further improve the flexibility of business logic execution and ensure accurate and efficient execution of business logic.

[0174] The above specific implementations do not constitute a limitation on the protection scope of the embodiments of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the embodiments of the present invention should be included in the protection scope of the embodiments of the present invention.

Claims

1. A method for executing business logic, characterized in that: include: In response to receiving the service call request, determining a corresponding initial entity state and a completed entity state; Determine an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship between the entity states; The entity state transition path is mapped to a business logic execution path, and the business logic included in the business logic execution path is executed to respond to the service call request.

2. The method according to claim 1, characterized in that Determining an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship between the entity states includes: Traversing a dependency graph established according to dependency relationships between entity states, and determining a dependency relationship between the completed entity state and the initial entity state; An entity state transition path between the initial entity state and the completed entity state is determined according to the dependency relationship.

3. The method according to claim 2, characterized in that Determining an entity state transition path between the initial entity state and the completed entity state according to the dependency relationship includes: Determine multiple candidate entity state transition paths between the initial entity state and the completed entity state based on the dependency relationship, filter out a target entity state transition path from the multiple candidate entity state transition paths, and use the target entity state transition path as the entity state transition path between the initial entity state and the completed entity state.

4. The method according to claim 3, characterized in that: Filtering out a target entity state transition path from the plurality of candidate entity state transition paths includes: Determining a set of entity states included in each entity state transition path according to the dependency relationship; Determine the business logic set corresponding to each entity state set according to the preset mapping relationship; A target business logic set with the smallest algorithm complexity is screened out from the business logic set, and an entity state transition path corresponding to the target business logic set is used as a target entity state transition path.

5. The method according to claim 1, characterized in that Mapping the entity state transition path to a business logic execution path includes: Determining a target entity state included in the entity state transition path; Determine the business logic corresponding to the target entity state according to the preset mapping relationship; The business logic is sorted according to the arrangement order of the target entity states in the entity state transition path to obtain a business logic execution path.

6. The method according to claim 5, characterized in that The entity state transition path includes branches; and the business logic is sorted according to the arrangement order of the target entity state in the entity state transition path, including: dividing the entity state transition path into a plurality of entity state transition stages according to the branches; In each entity state conversion phase, the business logics corresponding to the target entity states in the same branch are sorted according to the arrangement order, and the sorted business logics corresponding to the target entity states in different branches are merged; The merged business logic is spliced ​​according to the arrangement order of each entity state transition stage.

7. The method according to claim 1, characterized in that The method further comprises: In response to receiving the update request, the dependency relationship between the entity states is modified.

8. A device for executing business logic, characterized in that: include: A determination module, configured to determine a corresponding initial entity state and a completed entity state in response to receiving a service call request; A generating module, configured to determine an entity state transition path between the initial entity state and the completed entity state according to a dependency relationship between entity states; The execution module is used to map the entity state transition path into a business logic execution path, and execute the business logic included in the business logic execution path to respond to the service call request.

9. An electronic device, characterized in that: include: One or more processors; A storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.