CN117170776A - Service logic execution method and device - Google Patents

Service logic execution method and device Download PDF

Info

Publication number
CN117170776A
CN117170776A CN202311139568.7A CN202311139568A CN117170776A CN 117170776 A CN117170776 A CN 117170776A CN 202311139568 A CN202311139568 A CN 202311139568A CN 117170776 A CN117170776 A CN 117170776A
Authority
CN
China
Prior art keywords
service
attribute
policy
strategy
business
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311139568.7A
Other languages
Chinese (zh)
Inventor
刘亚苹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Tuoxian Technology Co Ltd
Original Assignee
Beijing Jingdong Tuoxian 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 Jingdong Tuoxian Technology Co Ltd filed Critical Beijing Jingdong Tuoxian Technology Co Ltd
Priority to CN202311139568.7A priority Critical patent/CN117170776A/en
Publication of CN117170776A publication Critical patent/CN117170776A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a device for executing business logic, and relates to the technical field of computers. One embodiment of the execution method of the business logic comprises the following steps: responding to a received service logic execution request, and acquiring a corresponding parameter entering object; identifying a first business attribute and a strategy attribute from object attributes included in the parameter entry object; packaging the first service attribute into a persistent object, and converting the strategy attribute into a service strategy implementation class; and executing the business logic included in the business strategy implementation class on the persistent object to respond to the business logic execution request. According to the embodiment, the object attributes of the parameter entering objects are divided, corresponding encapsulation, conversion and other operations are executed according to the division result, the effect of each object attribute in the execution process of the service logic can be clarified, the service logic is simplified, and the service logic is convenient to develop and maintain.

Description

Service logic execution method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for executing service logic.
Background
When executing service logic, multi-layer encapsulation is generally performed on the parameter entering object carried by the service logic execution request according to service requirements, and then corresponding persistence operation is executed according to encapsulation results. For example, the execution system of the business logic is divided into a control layer, a business layer and a persistence layer, each layer encapsulates the parameter entering object and transmits the parameter entering object to the next layer, and finally, persistence operation is carried out on the encapsulation result in the persistence layer. The reference object includes a plurality of object attributes that are encapsulated together and passed layer by layer during the encapsulation process.
In carrying out the present invention, the inventors have found that at least the following problems exist in the prior art:
the encapsulation result includes the object attribute which does not participate in the execution of the business logic, so that the business logic redundancy is complex, and the research, development and maintenance costs are high.
Disclosure of Invention
In view of this, the embodiments of the present invention provide a method and an apparatus for executing service logic, which can simplify service logic and facilitate the development and maintenance of service logic.
To achieve the above object, according to a first aspect of an embodiment of the present invention, there is provided a method for executing service logic, including:
responding to a received service logic execution request, and acquiring a corresponding parameter entering object;
identifying a first business attribute and a strategy attribute from object attributes included in the parameter entry object;
packaging the first service attribute into a persistent object, and converting the strategy attribute into a service strategy implementation class;
and executing the business logic included in the business strategy implementation class on the persistent object to respond to the business logic execution request.
Optionally, encapsulating the first service attribute as a persistent object includes:
encapsulating the first service attribute into a service object;
identifying retrieval attributes and/or storage attributes from object attributes included in the business objects according to the marking information of the business objects;
And encapsulating the identified retrieval attribute and/or storage attribute into a persistent object.
Optionally, encapsulating the retrieval attribute as a persistent object includes:
packaging the retrieval attribute as a retrieval object;
identifying retrieval sub-attributes of different retrieval types from object attributes included in the retrieval object according to the marking information of the retrieval object;
and encapsulating the identified retrieval sub-attribute into a persistent object.
Optionally, the method further comprises:
identifying a second service attribute from object attributes included in the service object according to the marking information of the service object;
and packaging the second service attribute into a persistent object.
Optionally, converting the policy attribute into a service policy implementation class includes:
determining corresponding service strategy codes according to the strategy attributes;
and generating a corresponding service policy implementation class according to the service policy code.
Optionally, generating a corresponding service policy implementation class according to the service policy code includes:
mapping the service policy code into a service policy realization class name;
and generating a corresponding service policy implementation class according to the service policy implementation class name.
Optionally, mapping the service policy code to a service policy implementation class name includes:
traversing a preset custom enumeration class, and judging whether a service enumeration attribute included in the custom enumeration class is matched with the service policy code;
and taking a custom enumeration class with the service enumeration attribute matched with the service policy code as a target enumeration class, and taking a policy realization attribute included in the target enumeration class as the service policy realization class name.
Optionally, mapping the service policy code to a service policy implementation class name includes:
traversing a preset strategy mapping table, and determining a service strategy realization class name with a mapping relation with the service strategy code.
Optionally, determining a corresponding service policy code according to the policy attribute includes:
determining a coding formula corresponding to the strategy attribute;
and replacing the placeholder in the coding formula by using the strategy attribute to obtain a corresponding service strategy code.
Optionally, before generating the corresponding service policy implementation class according to the service policy encoding, the method further includes:
encrypting the service policy code.
Optionally, the method further comprises:
And storing the business strategy codes into a cache and/or a database.
According to a second aspect of an embodiment of the present invention, there is provided an execution apparatus of service logic, including:
the acquisition module is used for responding to the received service logic execution request and acquiring a corresponding parameter entering object;
the identification module is used for identifying a first service attribute and a strategy attribute from object attributes included in the parameter entering object;
the encapsulation conversion module is used for encapsulating the first service attribute into a persistent object and converting the strategy attribute into a service strategy implementation class
And the execution module is used for executing the business logic included in the business strategy implementation class on the persistent object so as to respond to the business logic execution request.
Optionally, encapsulating the first service attribute as a persistent object includes:
encapsulating the first service attribute into a service object;
identifying retrieval attributes and/or storage attributes from object attributes included in the business objects according to the marking information of the business objects;
and encapsulating the identified retrieval attribute and/or storage attribute into a persistent object.
Optionally, encapsulating the retrieval attribute as a persistent object includes:
Packaging the retrieval attribute as a retrieval object;
identifying retrieval sub-attributes of different retrieval types from object attributes included in the retrieval object according to the marking information of the retrieval object;
and encapsulating the identified retrieval sub-attribute into a persistent object.
Optionally, the apparatus further comprises:
the re-identification module is used for identifying a second service attribute from object attributes included in the service object according to the marking information of the service object;
and the repackaging module is used for packaging the second service attribute into a persistent object.
Optionally, converting the policy attribute into a service policy implementation class includes:
determining corresponding service strategy codes according to the strategy attributes;
and generating a corresponding service policy implementation class according to the service policy code.
Optionally, generating a corresponding service policy implementation class according to the service policy code includes:
mapping the service policy code into a service policy realization class name;
and generating a corresponding service policy implementation class according to the service policy implementation class name.
Optionally, mapping the service policy code to a service policy implementation class name includes:
traversing a preset custom enumeration class, and judging whether a service enumeration attribute included in the custom enumeration class is matched with the service policy code;
And taking a custom enumeration class with the service enumeration attribute matched with the service policy code as a target enumeration class, and taking a policy realization attribute included in the target enumeration class as the service policy realization class name.
Optionally, mapping the service policy code to a service policy implementation class name includes:
traversing a preset strategy mapping table, and determining a service strategy realization class name with a mapping relation with the service strategy code.
Optionally, determining a corresponding service policy code according to the policy attribute includes:
determining a coding formula corresponding to the strategy attribute;
and replacing the placeholder in the coding formula by using the strategy attribute to obtain a corresponding service strategy code.
Optionally, the apparatus further comprises:
and the encryption module is used for encrypting the service policy codes.
Optionally, the apparatus further comprises:
and the storage module is used for storing the business strategy codes into a cache and/or a database.
According to a third aspect of an embodiment of the present invention, there is provided an electronic apparatus including:
one or more processors;
storage means for storing one or more programs,
the one or more processors implement the method of any of the embodiments described above when the one or more programs are executed by the one or more processors.
According to a fourth aspect of embodiments of the present invention, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements a method according to any of the embodiments described above.
One embodiment of the above invention has the following advantages or benefits: the object attributes of the input objects are subjected to attribute division, and corresponding encapsulation, conversion and other operations are executed according to the division result, so that the effect of each object attribute in the service logic execution process can be clarified, the service logic is simplified, and the service logic is convenient to develop and maintain; the object attribute is identified according to the marking information of the service object and the marking information of the search object and is packaged into a persistent object, so that a set of standard packaging specifications can be provided, the object attribute is flexibly packaged, and unnecessary object attribute is prevented from being packaged; different marking information and multiple recognition processes are set, so that different packaging requirements can be met, the coupling degree between object attributes is reduced, and the readability of codes is improved; the service policy implementation class is determined according to the policy attribute, so that the service logic execution request and the service logic are decoupled, the service logic is flexibly executed, and the new service logic is conveniently expanded or the existing service logic is conveniently modified; the service policy codes are encrypted, so that the service policy codes can be desensitized, and the security of service logic is improved.
Further effects of the above-described non-conventional alternatives are described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main flow of a method of executing business logic according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the overall flow of a method of execution of business logic according to one referenceable embodiment of the invention;
FIG. 3 is a schematic diagram of policy attribute transformation for a method of execution of business logic according to one referenceable embodiment of the invention;
FIG. 4 is a schematic diagram of policy implementation class generation for a method of execution of business logic according to one referenceable embodiment of the invention;
FIG. 5 is a schematic diagram of the main flow of a method of executing business logic according to one referenceable embodiment of the invention;
FIG. 6 is a schematic diagram of the main flow of a method of executing business logic according to another referenceable embodiment of the invention;
FIG. 7 is a schematic diagram of the main flow of a method of executing business logic according to yet another referenceable embodiment of the invention;
FIG. 8 is a schematic diagram of the major modules of an execution device of business logic according to an embodiment of the present invention;
FIG. 9 is an exemplary system architecture diagram in which embodiments of the present invention may be applied;
fig. 10 is a schematic diagram of a computer system suitable for use in implementing an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention will now be described with reference to the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding, and are to be considered merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In the technical scheme of the invention, the related processes of collecting, using, storing, sharing, transferring and the like of the personal information of the user accord with the regulations of related laws and regulations, the user needs to be informed and obtain the consent or the authorization of the user, and when the personal information of the user is applicable, the technical processes of de-identification and/or anonymization and/or encryption are performed on the personal information of the user.
When executing service logic, multi-layer encapsulation is generally performed on the parameter entering object carried by the service logic execution request according to service requirements, and then corresponding persistence operation is executed according to encapsulation results. For example, the execution system of the business logic is divided into a control layer, a business layer and a persistence layer, each layer encapsulates the parameter entering object and transmits the parameter entering object to the next layer, and finally, persistence operation is carried out on the encapsulation result in the persistence layer. The reference object includes a plurality of object attributes that are encapsulated together and passed layer by layer during the encapsulation process.
The encapsulation result comprises object attributes which do not participate in the execution of the business logic, so that the business logic redundancy is complex, and the research, development and maintenance costs are high; and the encapsulation process and the persistence process are hard-coded in the business logic, the business logic is mutually coupled and has poor flexibility, and it is difficult to expand new business logic or modify the existing business logic.
In view of this, according to a first aspect of an embodiment of the present invention, there is provided a method for executing business logic.
Fig. 1 is a schematic diagram of a main flow of a method for executing business logic according to an embodiment of the present invention. As shown in fig. 1, the method for executing service logic according to the embodiment of the present invention mainly includes the following steps S101 to S104.
Step S101, responding to a received service logic execution request, and acquiring a corresponding parameter entering object.
The service logic executing request is initiated by a user at the front end, or the service logic executing request is automatically initiated by an executing main body of the embodiment of the invention; for example, when a user searches for a commodity through a keyword by using an electronic commerce platform, a service logic execution request for searching for commodity information is sent to an execution main body of the embodiment of the invention, or when the user applies for mailing of the commodity by using a logistics platform, a service logic execution request for storing mailing information is sent to the execution main body of the embodiment of the invention; for another example, when backing up or archiving business data, the execution body of the embodiment of the invention automatically initiates a business logic execution request for data backup or data archiving based on the timing task.
Analyzing the service logic execution request, acquiring parameters carried by the service logic execution request, packaging the acquired parameters into one or more parameter entering objects, wherein each parameter carried by the service logic execution request corresponds to one object attribute in the parameter entering objects, and the parameter entering objects comprise a plurality of object attributes. The object attribute included in the reference object is form data filled in by a user on a front-end page, default data preset on the front-end page, service data carried by the user when automatically generating a service logic execution request, and the like.
Illustratively, the service logic execution request for querying the commodity information is "http:// A1/A2/A3 name=a4 & maxprice=100 & minprice=50", where "A1/A2/A3" represents an interface for receiving the service logic execution request, and "name=a4 & maxprice=100 & minprice=50" represents parameters carried by the service logic execution request, and specifically, the parameters include: commodity name "A4", commodity maximum price 100, commodity minimum price 50; and packaging the parameters into a parameter entering object, wherein the parameter entering object comprises a plurality of object attributes such as commodity name, commodity highest price, commodity lowest price and the like.
And acquiring a parameter entering object corresponding to the service logic execution request, and providing a data base for object attribute division.
Step S102, identifying a first service attribute and a policy attribute from object attributes included in the reference object.
The object attributes of the participating objects comprise a first service attribute and a policy attribute; the first service attribute is an object attribute with actual service meaning, and is used as a data source in the process of processing a service logic execution request to directly participate in executing the service logic; the policy attribute is an object attribute for indicating the service policy, corresponding service logic is executed according to the service policy indicated by the policy attribute, and the policy attribute is an object attribute which does not have actual service meaning and does not participate in executing the service logic.
Object attributes included in the reference object are identified, and a first service attribute and a policy attribute are determined. For example, a custom annotation is added on the object attribute of the participating object in advance, different custom annotations are used for distinguishing the first service attribute and the policy attribute, and the custom annotation can be added on all the object attributes or on a part of the object attributes; after the entry object is acquired, the custom annotation marked on the object attribute is scanned, and whether the object attribute is a first service attribute or a policy attribute is determined. For another example, a preset configuration file is traversed, and which object attributes are respectively corresponding to the first service attribute and the policy attribute of the reference object are searched.
The method comprises the steps of setting user-defined notes "@ strategy" and "@ business" in advance, wherein an object attribute marked with "@ strategy" is a policy attribute, and an object attribute marked with "@ business" is a first business attribute; the parametrization object B1 comprises an object attribute C1, an object attribute C2 and an object attribute C3; after the participating object B1 is scanned, it is determined that the object attribute C1 is marked with a custom annotation @ strategy ", and the object attribute C2 is marked with a custom annotation @ business", so that the object attribute C1 is used as a policy attribute and the object attribute C2 is used as a first service attribute.
Still further exemplary, the reference object B2 includes an object attribute C4, an object attribute C5, an object attribute C6; reading a preset configuration file to obtain configuration information { B2: { strategy: C5; business: C6} ", thereby determining that in the participating object B2, object attribute C5 is a policy attribute and object attribute C6 is a first business attribute.
According to preset information such as user-defined notes and configuration files, the first service attribute and the strategy attribute are identified from the parameter entering object, the service boundary of the object attribute can be standardized, the service logic is simplified, the object attributes with different purposes are prevented from being coupled together, and the service logic is convenient to develop and maintain.
Step S103, the first service attribute is encapsulated into a persistent object, and the strategy attribute is converted into a service strategy implementation class.
After the first business attribute is identified, the first business attribute is encapsulated into a persistent object (Persistant Object, PO), which is an object for performing the persistence operation, the object attributes of the persistent object comprising the first business attribute. For example, a persistent object is initialized and then the object attributes of the initialized persistent object are assigned using the first business attribute. The persistent object includes only the first business attribute in the enrolled object and does not include the policy attribute.
After identifying the policy attributes, converting the policy attributes into a service policy implementation class, wherein the service policy implementation class is an implementation class with service logic, and specifically, the service logic of the service policy implementation class is used for processing service logic execution requests. For example, the policy attributes are determined by scanning annotations marked on the object attributes, specifically, multiple annotations representing the policy attributes are preset, different annotations representing the policy attributes correspond to different service policy implementation classes, and the service policy implementation class corresponding to the policy attributes is determined according to the annotations.
The method includes the steps that a plurality of custom notes for labeling policy attributes, such as "@ strategyImpl1", "@ strategyImpl2", "@ strategyImpl3", and the like, are preset, wherein the name of each custom note corresponds to one service policy implementation class name; because the custom annotation marked on the policy attribute is "@ strategyImpl1", the service policy implementation class name corresponding to the policy attribute is "strategyImpl1" (or the corresponding service policy implementation class name is searched according to "strategyImpl 1"); after the service policy implementation class name is determined, a corresponding service policy implementation class is generated according to the service policy implementation class name.
According to the method, a persistent object is packaged according to the first service attribute, and a service policy implementation class is generated according to the policy attribute, so that each object attribute can only participate in necessary service logic, the object attributes with different purposes are prevented from being coupled together, the service logic is simplified, and the research and development cost and the maintenance cost are reduced.
According to a reference embodiment of the present invention, in the process of encapsulating the first service attribute into the persistent Object, the first service attribute is encapsulated into a service Object (BO), where the service Object is an Object for performing a service operation, for example, calculating, delivering, mapping, splicing, etc. service data, where the Object attribute of the service Object includes the first service attribute.
And then identifying the retrieval attribute and/or the storage attribute from the object attribute included in the service object according to the mark information of the service object, wherein the mark information of the service object can be a custom annotation marked on the object attribute of the service object or can be mark information stored in a configuration file. The search attribute is an object attribute for a search class persistence operation, for example, the search attribute is the lowest price, the attribute value is 50, and the search attribute is used for searching for commodities with a price of 50 yuan or more; the storage attribute is an object attribute for a storage class persistence operation, for example, the storage attribute is a user name, the attribute value is qwer, and the storage attribute is used for updating a corresponding user name in a database. The search attribute and the storage attribute are marked on the object attribute of the business object by using different custom annotations in advance, or the search attribute or the configuration information of the storage attribute is set for the object attribute of the business object in the configuration file. And respectively packaging the identified retrieval attribute and the storage attribute into persistent objects.
The method comprises the steps of setting custom notes "@ search" and "@ storage" in advance, wherein an object attribute marked with "@ search" is a retrieval attribute, and an object attribute marked with "@ storage" is a storage attribute; the business object D1 comprises an object attribute E1, an object attribute E2 and an object attribute E3; after the service object D1 is scanned, it is determined that the object attribute E1 is marked with the custom annotation "@ search", and the object attribute E2 is marked with the custom annotation "@ storage", so that the object attribute C1 is used as a search attribute and the object attribute C2 is used as a storage attribute.
Further exemplary, the business object D2 includes an object attribute E4, an object attribute E5, an object attribute E6; reading a preset configuration file to obtain configuration information { D2: { search: E5; storage: E6} ", thereby determining that in business object D2, object attribute E5 is a retrieval attribute and object attribute E6 is a storage attribute.
According to preset information such as user-defined notes, configuration files and the like, the retrieval attributes and the storage attributes are identified from the service objects, the service boundaries of the object attributes can be further standardized, service logic is simplified, the object attributes for different persistence operations are prevented from being coupled together, and the service logic is convenient to develop and maintain.
According to another exemplary embodiment of the present invention, in the process of encapsulating the search attribute as a persistent object, the search attribute is encapsulated as a search object, where the search object is an object for performing a search class persistence operation, and the object attribute of the search object includes the search attribute.
And then identifying retrieval sub-attributes of different retrieval types from object attributes included in the retrieval object according to the tag information of the retrieval object, wherein the tag information of the retrieval object can be a custom annotation marked on the object attribute of the retrieval object or can be tag information stored in a configuration file. The retrieval sub-attribute includes: single-value accurate retrieval sub-attribute, multi-value accurate retrieval sub-attribute, single-value fuzzy retrieval sub-attribute, multi-value fuzzy retrieval sub-attribute and the like; for example, the multi-value accurate retrieval sub-attribute includes: commodity name F1 and brand manufacturer F2, the multi-value accurate search sub-attribute is used for searching: a commercial product having a trade name of F1 and a brand manufacturer of F2; for another example, the multi-value fuzzy retrieval sub-attribute includes: a keyword F3, a first publication date F4, a second publication date F5, the multi-value fuzzy search sub-attribute for searching: the book name contains a keyword F3 and the publication date is between F4 and F5. Various search sub-attributes are marked on the object attributes of the search object by using different custom annotations in advance, and each object attribute is marked with at most one search sub-attribute, or configuration information of the various search sub-attributes is set for the object attributes of the search object in a configuration file. And encapsulating the identified retrieval sub-attribute into a persistent object.
Illustratively, custom annotations of "@ single", "@ multiple", "@ like" and "@ multiple" are preset, wherein the object attribute marked with "@ single" is a single-value accurate retrieval sub-attribute, the object attribute marked with "@ multiple" is a multi-value accurate retrieval sub-attribute, the object attribute marked with "@ like" is a single-value fuzzy retrieval sub-attribute, and the object attribute marked with "@ multiple" is a multi-value fuzzy retrieval sub-attribute; the search object G1 comprises an object attribute H1, an object attribute H2 and an object attribute H3; after the search object G1 is scanned, it is determined that the object attribute H1 is marked with a custom note @ single ", the object attribute H2 is marked with a custom note @ like, and the object attribute H3 is marked with a custom note @ multiple", so that the object attribute H1 is used as a single-value accurate search sub-attribute, the object attribute H2 is used as a single-value fuzzy search sub-attribute, and the object attribute H3 is used as a multi-value accurate search sub-attribute.
According to preset information such as user-defined notes, configuration files and the like, various retrieval sub-attributes are identified from the retrieval objects, the service boundaries of the object attributes can be further standardized, service logic is simplified, object attributes for different retrieval type persistence operations are prevented from being coupled together, and development and maintenance of the service logic are facilitated.
According to a further referenceable embodiment of the invention, the method further comprises: and identifying a second service attribute from object attributes included in the service object according to the marking information of the service object, wherein the second service attribute is an object attribute with actual service meaning, and is taken as a data source to directly participate in executing the service logic in the process of processing the service logic executing request. Marking the first service attribute and the second service attribute by using different custom annotations in advance, or configuring object attributes corresponding to the first service attribute and the second service attribute in a configuration file in advance. And determining a second service attribute by scanning the custom annotation on the object attribute of the service object, or traversing the configuration file, and determining the second service attribute included in the service object. After determining the second attribute, the second business attribute is encapsulated as a persistent object.
In the process of encapsulating the first service attribute into the persistent object, the first service attribute may be encapsulated into the service object for multiple times according to actual service requirements, and then the object attribute for encapsulating into the persistent object is identified from the service object after multiple encapsulation, where the encapsulation times of the service object and the identification times of the service attribute are not limited. For example, two service layers are preset, in the first service layer, a first service attribute is encapsulated as a first service object and transferred to the second service layer, in the second service layer, a second service attribute is identified from the first service object, then the second service attribute is encapsulated as a second service object, then a third service attribute is identified from the second service object, and finally the third service attribute is encapsulated as a persistent object.
The method comprises the steps of setting user-defined notes "@ business1" and "@ business2" in advance, wherein an object attribute marked with "@ business1" is a first service attribute, and an object attribute marked with "@ business2" is a second service attribute; the parameter entering object J1 comprises an object attribute K1, an object attribute K2 and an object attribute K3; after the object J1 is scanned, determining that the object attribute K1 and the object attribute K2 are marked with a custom annotation @ business 1', and taking the object attribute K1 and the object attribute K2 of the object as first service attributes; encapsulating the object attribute K1 and the object attribute K2 into a service object J2; after the service object J2 is scanned, it is determined that the object attribute K1 is marked with the custom annotation "@ business2", so that the object attribute K1 of the service object J2 is used as the second service attribute.
And (3) carrying out multiple packaging and identification according to the first service attribute, and then obtaining a persistent object, wherein each object attribute can only participate in necessary service logic, so that the service attributes with different purposes are prevented from being coupled together, the service attributes are decoupled, the service logic is simplified, and the research and development cost and the maintenance cost are reduced.
According to a referenceable embodiment of the present invention, in the process of converting a policy attribute into a service policy implementation class, determining a corresponding service policy code according to the policy attribute, for example, performing operations such as case-case conversion and character mapping on the policy attribute in the case that the policy attribute includes english letters; in the case that the policy attributes include numbers, rounding the policy attributes, preserving valid numbers, mapping the numbers, and the like; and in the case that a plurality of strategy attributes exist, splicing the plurality of strategy attributes by using a preset connector. After the service policy code is obtained, a corresponding service policy implementation class is generated according to the service policy code, for example, the service policy code is used as a key, and the service policy implementation class stored in the cache or the mapping set is searched.
The policy attribute is a character string "qWErt", all capital characters in the policy attribute are converted into lowercase characters, so that "qWErt" is obtained, character mapping is carried out on the character string according to a preset mapping table, wherein characters "a-i" are mapped into characters "L1", characters "j-o" are mapped into characters "L2", characters "p-z" are mapped into characters "L3", and the policy attribute is mapped into service policy codes "L3L3L 3L1L3L3" according to the rule; and then obtaining the corresponding service policy implementation class from the cache according to the service policy code CCACC.
Further exemplary, a plurality of segments such as 1-100, 101-200, 201-300, etc. are preset, and each segment corresponds to a service policy implementation class; and under the condition that the policy attribute is the number '123', determining the corresponding number segment as '101-200', and acquiring the service policy implementation class corresponding to the number segment.
The strategy attributes with different values are mapped into the service strategy codes, so that the service strategy implementation class can be flexibly determined, and the generation efficiency of the service strategy implementation class is improved.
According to another embodiment of the present invention, in the process of generating the corresponding service policy implementation class according to the service policy code, the service policy code is mapped to a service policy implementation class name, for example, a preset prefix string is spliced at the beginning of the service policy code, or a preset suffix string is spliced at the end of the service policy code, so as to obtain the service policy implementation class.
After obtaining the class name of the service policy implementation class, generating a corresponding service policy implementation class according to the service policy implementation class name, specifically, presetting a custom bean factory, registering a service policy implementation class acquisition class in the custom bean factory, and acquiring an instance object of the service policy implementation class from the custom bean factory according to the service policy implementation class name.
Illustratively, after obtaining the service policy code "asdfg", splicing a preset suffix character string "Strategy" at the end of the service policy code to obtain a service policy implementation class name "asdfgStrategy"; then, in the implementation class of the application ContextAware interface, based on the application Context context object of the spring framework, a getBasan ("asdfgStrategy") method is called, and the service policy implementation class can be obtained from the custom bean factory.
The corresponding service policy implementation class is obtained according to the service policy implementation class name, so that the service policy implementation class can be obtained rapidly and accurately, and the execution efficiency of service logic is improved conveniently.
According to a further embodiment of the present invention, in mapping the service policy code to a service policy implementation class name, traversing a preset custom enumeration class, where the custom enumeration class is used to store service enumeration attributes and policy implementation attributes, and the service enumeration attributes are used to match the service policy code, for example, in a case where the service enumeration attributes and the service policy code are equal, or in a case where the service policy code includes the service enumeration attributes, determining that the service enumeration attributes and the service policy code match; and taking the custom enumeration class with the service enumeration attribute matched with the service policy code as a target enumeration class, acquiring the policy realization attribute included in the target enumeration class, and taking the policy realization attribute as a service policy realization class name.
Illustratively, a plurality of custom enumeration classes are preset in the service code, each custom enumeration class corresponds to a service policy implementation class, and the corresponding service policy implementation class name is defined into the custom enumeration class; traversing the custom enumeration class, matching the service enumeration attribute in the custom enumeration class with the service enumeration attribute, judging whether the service enumeration attribute is the same as the service policy code or whether the service policy code contains the service enumeration attribute, if the service enumeration attribute is the same as or contains the service enumeration attribute, successfully matching, returning the corresponding policy realization attribute contained in the custom enumeration, and taking the policy realization attribute as a service policy realization class name.
The service policy implementation class name is determined through the custom enumeration class, so that the service policy implementation class name is convenient to manage, a new service policy implementation class name is easy to expand or an existing service policy implementation class name is easy to modify, and the service policy implementation class name can be accurately and rapidly determined.
According to a further embodiment of the present invention, in the process of mapping the service policy code into the service policy implementation class name, a preset policy mapping table is traversed, where the mapping table is used to store a mapping relationship between the service policy code and the service policy implementation class name, and in the process of traversing the policy mapping table, the service policy code is searched, and the service policy implementation class name having a mapping relationship with the service policy code is determined. Under the condition of adding the service policy realization class, a piece of mapping relation data is newly added in the policy mapping table, and the newly added mapping relation data comprises the service policy code and the corresponding service policy realization class name.
The preset strategy mapping table is shown as "{ ' ariuy ': strategyBean1'; ' lkjhg ' strategyBean2'; ' mnbvc ': strategyBean3' }; and under the condition that the service policy code is 'lkjhg', traversing the policy mapping table to obtain a corresponding service policy implementation class name of 'strategyBean 2'.
The service policy implementation class names are determined through the policy mapping table, so that the service policy implementation class names are convenient to manage, new service policy implementation class names are easy to expand or existing service policy implementation class names are easy to modify, and the service policy implementation class names can be accurately and rapidly determined.
According to a referenceable embodiment of the present invention, in determining a corresponding service policy code according to a policy attribute, determining a coding formula corresponding to the policy attribute, where the coding formula includes: the system comprises a placeholder and a connector, wherein a plurality of placeholders are connected by the connector. For example, different coding formulas are set in different service scenes, specifically, different coding formulas of connectors or different coding formulas of placeholders and connector arrangement sequences are set; and determining a service scene according to the strategy attribute, and determining a corresponding coding formula according to the service scene. After the coding formula is confirmed, the attribute value of the strategy attribute is used for replacing the placeholder in the coding formula, and one strategy attribute is used for replacing one placeholder, so that the code consisting of the strategy attribute and the connector, namely the service strategy code, is obtained.
Illustratively, there are a plurality of policy attributes such as a policy attribute M1, a policy attribute M2, and a policy attribute M3, wherein the policy attribute M1 represents a service scenario, a corresponding encoding formula is determined to be "{ field-1} _ { field-2} _ { field-3 _..a _ { field-n }", wherein "{ field-1}", "{ field-2}", "{ field-n }" represents a plurality of placeholders, an underlined "_" represents a connector, and the plurality of policy attributes replace the placeholders in the encoding formula to obtain the service policy encoding as "m1_m2_m3".
The coding formula is determined according to the strategy attribute, so that the service strategy code can be flexibly generated, and the service strategy code is decoupled from the service logic; different coding formulas are used in different service scenes, so that the different service scenes can be distinguished conveniently; and the strategy attribute is brought into the coding formula, so that the service strategy code uniquely corresponding to the strategy attribute can be generated, and the uniqueness of the service strategy code is effectively ensured.
According to another referenceable embodiment of the invention, before generating the corresponding traffic policy implementation class from the traffic policy encoding, the method further comprises: the traffic policy codes are encrypted, for example, using an encryption algorithm such as MD5, SHA1, etc. Illustratively, the encryption step is embodied in an encoding formula, specifically, the service policy is encoded and encrypted using MD5, resulting in an encoding formula of "MD5 ({ placeholder-1} { link } { placeholder-n }", where, "{ placeholder-1}".. "{ placeholder-n }" is a plurality of placeholders, "{ link }" is a connector, e.g., underlined, plus, minus, slash, star, percentage, etc., and MD5 (..) represents encrypting the entire traffic policy code. After encrypting the service policy codes, generating corresponding service policy implementation classes by using the encrypted service policy codes.
According to another referenceable embodiment of the present invention, the policy attributes are encrypted before replacing placeholders in the encoding formula with the policy attributes. For example, the policy attributes are encrypted using an encryption algorithm such as MD5, SHA1, or the like. And then, replacing the placeholder in the coding formula by using the encrypted strategy attribute. Illustratively, the encryption step is embodied in an encoding formula, specifically, encryption of the policy attributes using MD5, resulting in an encoding formula of "{ MD5 ({ placeholder-1 }) } { link } { MD5 ({ placeholder-n }) }", where "{ placeholder-1}" is a plurality of placeholders, "{ link }" is a connector, { MD5 (.) }) represents encryption of each policy attribute.
The service policy codes or the policy attributes are encrypted, so that the service policy codes or the policy attributes can be desensitized, information leakage is avoided, and the safety of service logic execution is improved.
According to a further referenceable embodiment of the invention, the method further comprises: after the business strategy code is generated, the business strategy code is stored in a cache and a database. For example, the policy attribute is used as a key, the service policy code is used as a value, and the value is stored in the Redis cache, or the information such as the policy attribute, the service policy code, the generation time of the service policy code and the like is used as a data record and stored in the MySQL database. After the service logic executes the request, deleting the information such as the strategy attribute, the service strategy code and the like stored in the cache or the database, or setting the use state of the information as invalid, so as to avoid the interference of the information on the subsequent service logic executing process.
The service policy codes are stored in a cache or a database, so that the memory space can be saved, and the service policy codes or the policy attributes are prevented from being lost.
And step S104, executing the business logic included in the business strategy implementation class on the persistent object so as to respond to the business logic execution request.
After obtaining the persistent object and the service policy implementation class, calling a method of the service policy implementation class, taking the persistent object as a method reference, and executing service logic such as searching, storing, deleting, updating and the like included in the service policy implementation class on the persistent object. For example, the persistent object is stored in the database, or a part of fields included in the target data record in the database are replaced by the object attribute included in the persistent object, or the data record with the same or similar attribute value in the database is retrieved according to the object attribute included in the persistent object, or the data record with the same or similar attribute value in the database is deleted according to the object attribute included in the persistent object. And acquiring the execution result of the service logic, and returning the execution result to the initiator of the service logic execution request to complete the response process of the service logic execution request.
Through multi-layer division of the object attributes, the object attributes can only participate in necessary service logic, the packaging process is normalized, the service policy implementation class is dynamically determined, the service logic and the interfaces are decoupled, the service logic is decoupled, and the service logic is flexibly and efficiently executed.
Fig. 2 is a schematic diagram of an overall flow of a method of executing business logic according to one referenceable embodiment of the invention. Illustratively, as shown in fig. 2, after receiving a service logic execution request, a corresponding parameter entering object is obtained, and the parameter entering object is identified to obtain a policy attribute and a first service attribute; packaging the first service attribute into a service object, and identifying the object attribute of the service object again to obtain a plurality of service attributes such as a retrieval attribute, a storage attribute, a second service attribute, a third service attribute and the like; after multiple service attributes such as the second service attribute, the third service attribute and the like are identified and packaged again for multiple times, a persistent object is obtained; encapsulating the retrieval attribute into a retrieval object, identifying object attributes included in the retrieval object to obtain single-value accurate retrieval sub-attributes, multi-value accurate retrieval sub-attributes, single-value fuzzy retrieval sub-attributes, multi-value fuzzy retrieval sub-attributes and the like, and encapsulating each retrieval sub-attribute to obtain a corresponding persistent object; packaging the storage attribute to obtain a corresponding persistent object; generating a durable object according to the first service attribute, obtaining a service policy code by using the service attribute code, storing the service policy code into a Redis cache or a database, acquiring the service policy code from the Redis cache or the database, and generating a corresponding service policy implementation class; after the persistent object and the service policy implementation class are obtained, the persistent operation included in the service policy implementation class is executed on the persistent object, the database is added, deleted, revised and checked, a service logic execution result is generated, and the service logic execution result is returned to the initiator of the service logic execution request.
Fig. 3 is a schematic diagram of policy attribute transformation of an execution method of business logic according to one referenceable embodiment of the present invention. Illustratively, as shown in fig. 3, after obtaining a plurality of policy attributes such as policy attribute 1, policy attribute 2, policy attribute 3, and the like, a target encoding formula is screened out from the encoding formula set, then placeholders in the target encoding formula are replaced by the plurality of policy attributes, a service policy code is obtained, and finally the service policy code is stored in a dis cache and a database.
FIG. 4 is a schematic diagram of policy implementation class generation for a method of execution of business logic according to one referenceable embodiment of the invention. For example, as shown in fig. 4, a service policy code is first obtained from a Redis cache, then a preset custom enumeration class is traversed, a target enumeration class matched with the service policy code is selected from a plurality of custom enumeration classes, an attribute value of a policy implementation attribute is obtained from the target enumeration class as a service policy implementation class name, and then in an application context interface implementation class, a service policy implementation class corresponding to the service policy implementation class name is obtained from a bean factory by using an application context object.
Fig. 5 is a schematic diagram of the main flow of a method for executing business logic according to one referenceable embodiment of the invention. As shown in fig. 5, the method for executing the business logic may include:
step S501, responding to a received service logic execution request, and acquiring a corresponding parameter entering object;
step S502, identifying a first business attribute and a strategy attribute from object attributes included in the parameter entering object;
step S503, packaging the first business attribute as a business object;
step S504, identifying the retrieval attribute and the storage attribute from the object attributes included in the business object according to the marking information of the business object;
step S505, respectively packaging the retrieval attribute and the storage attribute into persistent objects;
step S506, converting the strategy attribute into a service strategy realization class;
in step S507, service logic included in the service policy implementation class is executed on the persistent object, in response to the service logic execution request.
The implementation of the method for executing service logic according to the above embodiment of the present invention has been described in detail, and therefore, the description thereof will not be repeated here.
Fig. 6 is a schematic diagram of the main flow of a method for executing business logic according to another exemplary embodiment of the present invention. As shown in fig. 6, the method for executing the business logic may include:
Step S601, responding to a received service logic execution request, and acquiring a corresponding parameter entering object;
step S602, identifying a first business attribute and a strategy attribute from object attributes included in the parameter entry object;
step S603, the first business attribute is packaged into a business object;
step S604, identifying the retrieval attribute and the storage attribute from the object attributes included in the business object according to the marking information of the business object;
step S605, encapsulating the retrieval attribute as a retrieval object;
step S606, identifying the retrieval sub-attributes of different retrieval types from the object attributes included in the retrieval object according to the marking information of the retrieval object;
step S607, respectively packaging the retrieval sub-attribute and the storage attribute of different retrieval types into persistent objects;
step S608, corresponding business strategy codes are determined according to strategy attributes;
step S609, generating a corresponding service policy implementation class according to the service policy code;
in step S610, service logic included in the service policy implementation class is executed on the persistent object in response to the service logic execution request.
The implementation of the method for executing service logic according to the embodiment of the present invention has been described in detail in the above description, and thus the description thereof will not be repeated here.
Fig. 7 is a schematic diagram of main flow of a method for executing business logic according to still another embodiment of the present invention. As shown in fig. 7, the method for executing the business logic may include:
step S701, responding to a received service logic execution request, and acquiring a corresponding parameter entering object;
step S702, identifying a first business attribute and a strategy attribute from object attributes included in the parameter entry object;
step S703, encapsulating the first service attribute into a first service object, identifying a second service attribute from the first service object, and encapsulating the second service attribute into a second service object;
step S704, the first service attribute is packaged as a first service object, the second service attribute is identified from the first service object, and the second service attribute is packaged as a second service object;
step S705, encapsulating the retrieval attribute as a retrieval object;
step S706, identifying the retrieval sub-attributes of different retrieval types from the object attributes included in the retrieval object according to the marking information of the retrieval object;
step S707, respectively packaging the retrieval sub-attribute and the storage attribute of different retrieval types into persistent objects;
step S708, corresponding business strategy codes are determined according to strategy attributes;
Step S709, encrypting the service policy code by using an MD5 encryption algorithm;
step S710, storing the encrypted business strategy code into a database;
step S711, generating corresponding service strategy realization classes according to service strategy codes;
step S712, executing the business logic included in the business policy implementation class on the persistent object in response to the business logic execution request.
The implementation of the method for executing business logic according to the above embodiment of the present invention has been described in detail, and therefore will not be described in detail here.
According to a second aspect of an embodiment of the present invention, there is provided an execution apparatus of service logic.
Fig. 8 is a schematic diagram of main modules of an execution device of service logic according to an embodiment of the present invention, and as shown in fig. 8, the execution device 800 of service logic mainly includes:
an obtaining module 801, configured to obtain a corresponding parameter entry object in response to receiving a service logic execution request;
an identifying module 802, configured to identify a first service attribute and a policy attribute from object attributes included in the parameter entry object;
encapsulation conversion module 803 for encapsulating the first service attribute into a persistent object and converting the policy attribute into a service policy implementation class
An executing module 804, configured to execute, on the persistent object, service logic included in the service policy implementation class, in response to the service logic execution request.
According to a referenceable embodiment of the invention, encapsulating the first business attribute as a persistent object comprises:
encapsulating the first service attribute into a service object;
identifying retrieval attributes and/or storage attributes from object attributes included in the business objects according to the marking information of the business objects;
and encapsulating the identified retrieval attribute and/or storage attribute into a persistent object.
According to another referenceable embodiment of the invention, encapsulating the retrieval attributes as persistent objects comprises:
packaging the retrieval attribute as a retrieval object;
identifying retrieval sub-attributes of different retrieval types from object attributes included in the retrieval object according to the marking information of the retrieval object;
and encapsulating the identified retrieval sub-attribute into a persistent object.
According to a further exemplary embodiment of the present invention, the service logic executing device 800 further includes:
the re-identification module is used for identifying a second service attribute from object attributes included in the service object according to the marking information of the service object;
And the repackaging module is used for packaging the second service attribute into a persistent object.
According to a further referenceable embodiment of the invention, converting the policy attributes into a traffic policy implementation class comprises:
determining corresponding service strategy codes according to the strategy attributes;
and generating a corresponding service policy implementation class according to the service policy code.
According to a further embodiment of the present invention, generating a corresponding service policy implementation class according to the service policy code includes:
mapping the service policy code into a service policy realization class name;
and generating a corresponding service policy implementation class according to the service policy implementation class name.
According to a referenceable embodiment of the present invention, mapping the service policy code into a service policy implementation class name includes:
traversing a preset custom enumeration class, and judging whether a service enumeration attribute included in the custom enumeration class is matched with the service policy code;
and taking a custom enumeration class with the service enumeration attribute matched with the service policy code as a target enumeration class, and taking a policy realization attribute included in the target enumeration class as the service policy realization class name.
According to another referenceable embodiment of the present invention, mapping the service policy code into a service policy implementation class name includes:
traversing a preset strategy mapping table, and determining a service strategy realization class name with a mapping relation with the service strategy code.
According to a further referenceable embodiment of the invention, determining a corresponding service policy code from said policy attributes comprises:
determining a coding formula corresponding to the strategy attribute;
and replacing the placeholder in the coding formula by using the strategy attribute to obtain a corresponding service strategy code.
According to a further embodiment of the present invention, the service logic execution device 800 further includes:
and the encryption module is used for encrypting the service policy codes.
According to a further exemplary embodiment of the present invention, the service logic execution apparatus 800 further includes:
and the storage module is used for storing the business strategy codes into a cache and/or a database.
It should be noted that, in the embodiment of the present invention, the specific implementation content of the execution device of the service logic is already described in detail in the execution method of the service logic, so that the description is not repeated here.
According to the technical scheme of the embodiment of the invention, the object attributes of the parameter entering object are subjected to attribute division, and corresponding operations such as encapsulation, conversion and the like are executed according to the division result, so that the effect of each object attribute in the execution process of the service logic can be clarified, the service logic is simplified, and the development and maintenance of the service logic are facilitated; the object attribute is identified according to the marking information of the service object and the marking information of the search object and is packaged into a persistent object, so that a set of standard packaging specifications can be provided, the object attribute is flexibly packaged, and unnecessary object attribute is prevented from being packaged; different marking information and multiple recognition processes are set, so that different packaging requirements can be met, the coupling degree between object attributes is reduced, and the readability of codes is improved; the service policy implementation class is determined according to the policy attribute, so that the service logic execution request and the service logic are decoupled, the service logic is flexibly executed, and the new service logic is conveniently expanded or the existing service logic is conveniently modified; the service policy codes are encrypted, so that the service policy codes can be desensitized, and the security of service logic is improved.
According to a third aspect of an embodiment of the present invention, there is provided an electronic device for executing business logic, including: one or more processors; and the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors are enabled to realize the method provided by the first aspect of the embodiment of the invention.
According to a fourth aspect of embodiments of the present invention, there is provided a computer readable medium having stored thereon a computer program which when executed by a processor implements the method provided by the first aspect of embodiments of the present invention.
Fig. 9 illustrates an exemplary system architecture 900 of a business logic execution method or a business logic execution device to which embodiments of the present invention may be applied.
As shown in fig. 9, system architecture 900 may include terminal devices 901, 902, 903, a network 904, and a server 905. The network 904 is the medium used to provide communications links between the terminal devices 901, 902, 903 and the server 905. The network 904 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
A user may interact with the server 905 over the network 904 using the terminal devices 901, 902, 903 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 901, 902, 903, such as: business execution class applications, business viewing class applications, search class applications, instant messaging tools, mailbox clients, social platform software, and the like (by way of example only).
Terminal devices 901, 902, 903 may be a variety of electronic devices having a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop and desktop computers, and the like.
The server 905 may be a server that provides various services, such as a background management server (merely an example) that provides support for execution requests of business logic sent upstream with the terminal apparatuses 901, 902, 903. The background management server can respond to the received service logic execution request to acquire a corresponding parameter entering object; identifying a first business attribute and a strategy attribute from object attributes included in the parameter entry object; packaging the first service attribute into a persistent object, and converting the strategy attribute into a service strategy implementation class; executing business logic included in the business strategy implementation class on the persistent object to respond to the business logic execution request; and feeds back the execution of the service logic (only by way of example) to the terminal device.
It should be noted that, the method for executing the service logic provided in the embodiment of the present invention is generally executed by the server 905, and accordingly, the device for executing the service logic is generally disposed in the server 905. The method for executing the service logic provided by the embodiment of the invention can also be executed by the terminal equipment 901, 902 and 903, and correspondingly, the executing device of the service logic can be arranged in the terminal equipment 901, 902 and 903.
It should be understood that the number of terminal devices, networks and servers in fig. 9 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 10, there is illustrated a schematic diagram of a computer system 1000 suitable for use in implementing an embodiment of the present invention. The terminal device shown in fig. 10 is only an example, and should not impose any limitation on the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 10, the computer system 1000 includes a Central Processing Unit (CPU) 1001, which can execute various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 1002 or a program loaded from a storage section 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, ROM 1002, and RAM 1003 are connected to each other by a bus 1004. An input/output (I/O) interface 1005 is also connected to bus 1004.
The following components are connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output portion 1007 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc., and a speaker, etc.; a storage portion 1008 including a hard disk or the like; and a communication section 1009 including a network interface card such as a LAN card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The 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, or the like, is installed as needed in the drive 1010, so that a computer program read out therefrom is installed as needed in the storage section 1008.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication portion 1009, and/or installed from the removable medium 1011. The above-described functions defined in the system of the embodiment of the present invention are performed when the computer program is executed by a Central Processing Unit (CPU) 1001.
It should be noted that, the computer readable medium shown in the embodiments of the present invention may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In embodiments of the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in embodiments of the present invention, the computer-readable signal medium may comprise a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer programs according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules involved in the embodiments of the present invention may be implemented in software or in hardware. The described modules may also be provided in a processor, for example, as: a processor includes an acquisition module, an identification module, a package conversion module, and an execution module, where the names of the modules do not in some cases limit the module itself, e.g., the acquisition module may also be described as a "module that acquires a participant.
As another aspect, the embodiment of the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiment; or may be present alone without being fitted into the device. The computer readable medium carries one or more programs which, when executed by a device, implement the method of: responding to a received service logic execution request, and acquiring a corresponding parameter entering object; identifying a first business attribute and a strategy attribute from object attributes included in the parameter entry object; packaging the first service attribute into a persistent object, and converting the strategy attribute into a service strategy implementation class; and executing the business logic included in the business strategy implementation class on the persistent object to respond to the business logic execution request.
According to the technical scheme of the embodiment of the invention, the object attributes of the parameter entering object are subjected to attribute division, and corresponding operations such as encapsulation, conversion and the like are executed according to the division result, so that the effect of each object attribute in the execution process of the service logic can be clarified, the service logic is simplified, and the development and maintenance of the service logic are facilitated; the object attribute is identified according to the marking information of the service object and the marking information of the search object and is packaged into a persistent object, so that a set of standard packaging specifications can be provided, the object attribute is flexibly packaged, and unnecessary object attribute is prevented from being packaged; different marking information and multiple recognition processes are set, so that different packaging requirements can be met, the coupling degree between object attributes is reduced, and the readability of codes is improved; the service policy implementation class is determined according to the policy attribute, so that the service logic execution request and the service logic are decoupled, the service logic is flexibly executed, and the new service logic is conveniently expanded or the existing service logic is conveniently modified; the service policy codes are encrypted, so that the service policy codes can be desensitized, and the security of service logic is improved.
The above detailed description should not be construed as limiting the scope of the embodiments of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives can occur depending upon 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 scope of the embodiments of the present invention.

Claims (14)

1. A method for executing business logic, comprising:
responding to a received service logic execution request, and acquiring a corresponding parameter entering object;
identifying a first business attribute and a strategy attribute from object attributes included in the parameter entry object;
packaging the first service attribute into a persistent object, and converting the strategy attribute into a service strategy implementation class;
and executing the business logic included in the business strategy implementation class on the persistent object to respond to the business logic execution request.
2. The method of claim 1, wherein encapsulating the first business attribute as a persistent object comprises:
encapsulating the first service attribute into a service object;
identifying retrieval attributes and/or storage attributes from object attributes included in the business objects according to the marking information of the business objects;
And encapsulating the identified retrieval attribute and/or storage attribute into a persistent object.
3. The method of claim 2, wherein encapsulating the retrieval attributes as persistent objects comprises:
packaging the retrieval attribute as a retrieval object;
identifying retrieval sub-attributes of different retrieval types from object attributes included in the retrieval object according to the marking information of the retrieval object;
and encapsulating the identified retrieval sub-attribute into a persistent object.
4. The method according to claim 2, wherein the method further comprises:
identifying a second service attribute from object attributes included in the service object according to the marking information of the service object;
and packaging the second service attribute into a persistent object.
5. The method of claim 1, wherein converting the policy attributes into a business policy implementation class comprises:
determining corresponding service strategy codes according to the strategy attributes;
and generating a corresponding service policy implementation class according to the service policy code.
6. The method of claim 5, wherein generating a corresponding traffic policy implementation class from the traffic policy code comprises:
Mapping the service policy code into a service policy realization class name;
and generating a corresponding service policy implementation class according to the service policy implementation class name.
7. The method of claim 6, wherein mapping the service policy code into a service policy implementation class name comprises:
traversing a preset custom enumeration class, and judging whether a service enumeration attribute included in the custom enumeration class is matched with the service policy code;
and taking a custom enumeration class with the service enumeration attribute matched with the service policy code as a target enumeration class, and taking a policy realization attribute included in the target enumeration class as the service policy realization class name.
8. The method of claim 6, wherein mapping the service policy code into a service policy implementation class name comprises:
traversing a preset strategy mapping table, and determining a service strategy realization class name with a mapping relation with the service strategy code.
9. The method of claim 5, wherein determining a corresponding traffic policy code based on the policy attributes comprises:
determining a coding formula corresponding to the strategy attribute;
And replacing the placeholder in the coding formula by using the strategy attribute to obtain a corresponding service strategy code.
10. The method of claim 5, wherein prior to generating the corresponding traffic policy implementation class from the traffic policy encoding, the method further comprises:
encrypting the service policy code.
11. The method of claim 5, wherein the method further comprises:
and storing the business strategy codes into a cache and/or a database.
12. An apparatus for executing business logic, comprising:
the acquisition module is used for responding to the received service logic execution request and acquiring a corresponding parameter entering object;
the identification module is used for identifying a first service attribute and a strategy attribute from object attributes included in the parameter entering object;
the encapsulation conversion module is used for encapsulating the first service attribute into a persistent object and converting the strategy attribute into a service strategy implementation class;
and the execution module is used for executing the business logic included in the business strategy implementation class on the persistent object so as to respond to the business logic execution request.
13. An electronic device, comprising:
One or more processors;
storage means for storing one or more programs,
the one or more processors implement the method of any of claims 1-11 when the one or more programs are executed by the one or more processors.
14. A computer readable medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-11.
CN202311139568.7A 2023-09-05 2023-09-05 Service logic execution method and device Pending CN117170776A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311139568.7A CN117170776A (en) 2023-09-05 2023-09-05 Service logic execution method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311139568.7A CN117170776A (en) 2023-09-05 2023-09-05 Service logic execution method and device

Publications (1)

Publication Number Publication Date
CN117170776A true CN117170776A (en) 2023-12-05

Family

ID=88940701

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311139568.7A Pending CN117170776A (en) 2023-09-05 2023-09-05 Service logic execution method and device

Country Status (1)

Country Link
CN (1) CN117170776A (en)

Similar Documents

Publication Publication Date Title
CN111460129B (en) Method, device, electronic equipment and storage medium for generating identification
US20200286014A1 (en) Information updating method and device
CN110895472A (en) Method and device for identifying service change
CN112988770B (en) Method, device, electronic equipment and storage medium for updating serial number
CN113626223A (en) Interface calling method and device
CN113434527A (en) Data processing method and device, electronic equipment and storage medium
CN111858486A (en) File classification method and device
CN109740130B (en) Method and device for generating file
CN115002062B (en) Message processing method, device, equipment and readable storage medium
CN112818026A (en) Data integration method and device
CN117170776A (en) Service logic execution method and device
CN113641633B (en) File processing method, apparatus, electronic device, medium, and computer program
US20230418842A1 (en) Data processing independent of storage, format or schema
CN114116675A (en) Data archiving method and device
CN109308299B (en) Method and apparatus for searching information
CN113704222A (en) Method and device for processing service request
CN112256566A (en) Test case preservation method and device
CN111460269B (en) Information pushing method and device
CN115688711B (en) Document merging method, device, equipment and storage medium
CN117892355B (en) Multiparty data joint analysis method and system based on privacy protection
CN118170677A (en) Data analysis method, device, electronic equipment and computer readable medium
CN118210781A (en) Compatible database generation method and computing device
CN117291483A (en) Order processing method and device
CN118069539A (en) Data processing method, device, electronic equipment and storage medium
CN117672477A (en) Inspection project management method and device

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