Data processing method, device and equipment

文档序号:1936802 发布日期:2021-12-07 浏览:36次 中文

阅读说明:本技术 数据处理方法、装置及设备 (Data processing method, device and equipment ) 是由 韩松 于 2020-06-11 设计创作,主要内容包括:本发明实施例提供一种数据处理方法、装置及设备,该方法包括:获取业务请求,业务请求中包括第一业务的标识和请求参数,根据第一业务的标识,从多个候选业务实现类中确定与第一业务匹配的第一业务实现类,并根据请求参数执行第一业务实现类中的方法,得到业务请求对应的处理结果。通过将不同业务的实现流程进行隔离,即不同业务对应不同的业务实现类,能够提高业务代码的扩展性和可维护性,降低维护成本和维护难度;另外,当需要针对某种业务进行数据处理时,只需要找到并执行该业务对应的业务实现类,无需对其他业务实现类进行遍历执行,提高了执行效率。(The embodiment of the invention provides a data processing method, a device and equipment, wherein the method comprises the following steps: the method comprises the steps of obtaining a service request, wherein the service request comprises a first service identifier and a request parameter, determining a first service implementation class matched with a first service from a plurality of candidate service implementation classes according to the first service identifier, and executing methods in the first service implementation class according to the request parameter to obtain a processing result corresponding to the service request. By isolating the implementation flows of different services, namely different services correspond to different service implementation classes, the expansibility and maintainability of service codes can be improved, and the maintenance cost and the maintenance difficulty are reduced; in addition, when data processing is required to be performed on a certain service, only the service implementation class corresponding to the service needs to be found and executed, and traversing execution on other service implementation classes is not required, so that the execution efficiency is improved.)

1. A data processing method, comprising:

acquiring a service request, wherein the service request is used for indicating to process data of a first service, and the service request comprises an identifier and a request parameter of the first service;

determining a first service implementation class matched with the first service from a plurality of candidate service implementation classes according to the identifier of the first service;

and executing the method in the first service implementation class according to the request parameter to obtain a processing result corresponding to the service request.

2. The method of claim 1, wherein the first service implementation class comprises a base implementation class and an extended implementation class; the executing the method in the first service implementation class according to the request parameter to obtain a processing result corresponding to the service request includes:

and executing the method of the basic implementation class and the method of the extended implementation class according to the request parameters to obtain a processing result corresponding to the service request.

3. The method of claim 2, wherein the extended implementation class comprises: a plurality of first-level extension implementation classes; the method for executing the extended implementation class according to the request parameter comprises the following steps:

and determining a primary extension implementation class matched with the first service from the plurality of primary extension implementation classes according to the request parameters, and executing the method in the primary extension implementation class matched with the first service.

4. The method of claim 3, wherein the extended implementation class further comprises: a plurality of secondary extension implementation classes; after the method in the first-level extension implementation class matched with the first service is executed, the method further comprises the following steps:

and determining a secondary extension implementation class matched with the first service from the plurality of secondary extension implementation classes according to the request parameters, and executing the method in the secondary extension implementation class matched with the first service.

5. The method of claim 2, wherein the extended implementation class comprises a plurality of primary extended implementation classes; according to the request parameter, executing the method of the basic implementation class and executing the method of the extended implementation class, including:

according to the request parameters, executing a context creating method and a context loading method in the basic implementation class, and executing a context loading method in the extended implementation class to obtain context information corresponding to the first service;

executing a context matching method in the plurality of primary extension implementation classes according to the request parameters, and determining a primary extension implementation class matched with the first service from the plurality of primary extension implementation classes according to an execution result;

and executing the service processing method in the basic implementation class according to the context information corresponding to the first service, and executing the service processing method in the primary extension implementation class matched with the first service.

6. The method of claim 5, wherein the extended implementation class further comprises a plurality of secondary extended implementation classes; after executing the service processing method in the first-level extension implementation class matched with the first service, the method further comprises the following steps:

executing a context matching method in the plurality of secondary extension implementation classes according to the request parameters, and determining a secondary extension implementation class matched with the first service from the plurality of secondary extension implementation classes according to an execution result;

and executing a service processing method in a secondary expansion implementation class matched with the first service according to the context information corresponding to the first service.

7. The method of claim 6, wherein after the performing the service processing method in the second-level extension implementation class matching with the first service, further comprising:

and executing the database processing method in the basic implementation class.

8. The method according to claim 4 or 6, wherein the primary extension implementation class is used for extending the functions of the basic implementation class, and the secondary extension implementation class is used for extending the functions of the primary extension implementation class; alternatively, the first and second electrodes may be,

the primary extension implementation class is used for performing first-dimension extension on the functions of the basic implementation class, and the secondary extension implementation class is used for performing second-dimension extension on the functions of the basic implementation class.

9. A data processing apparatus, comprising:

an obtaining module, configured to obtain a service request, where the service request is used to instruct to process data of a first service, and the service request includes an identifier of the first service and a request parameter;

the processing module is used for determining a first service implementation class matched with the first service from a plurality of candidate service implementation classes according to the identifier of the first service;

the processing module is further configured to execute the method in the first service implementation class according to the request parameter, and obtain a processing result corresponding to the service request.

10. An electronic device, comprising: a memory for storing a computer program and a processor for executing the computer program to perform the method of any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that the computer-readable storage medium comprises a computer program which, when executed by a processor, implements the method of any one of claims 1 to 8.

Technical Field

The embodiment of the invention relates to the technical field of computers, in particular to a data processing method, a data processing device and data processing equipment.

Background

As the functions of the application system are continuously expanded, the amount of codes of the application system is also continuously increased, so that the maintainability of the application system is continuously reduced.

At present, when a code of an application system is maintained, for example, a new service type needs to be added, or a new function needs to be added for a certain service type, an original code of the application system needs to be modified, and a new service type or a new function needs to be developed in a supplementary manner on the basis of the original code.

In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: the code universality and expansibility of the application system are poor, so that the code maintenance cost and maintenance difficulty are increased, and the code running efficiency is low.

Disclosure of Invention

The embodiment of the invention provides a data processing method, a data processing device and data processing equipment, which are used for reducing the code maintenance cost and the maintenance difficulty and improving the operation efficiency.

In a first aspect, an embodiment of the present invention provides a data processing method, including:

acquiring a service request, wherein the service request is used for indicating to process data of a first service, and the service request comprises an identifier and a request parameter of the first service;

determining a first service implementation class matched with the first service from a plurality of candidate service implementation classes according to the identifier of the first service;

and executing the method in the first service implementation class according to the request parameter to obtain a processing result corresponding to the service request.

In a possible implementation manner, the first service implementation class includes a basic implementation class and an extended implementation class; the executing the method in the first service implementation class according to the request parameter to obtain a processing result corresponding to the service request includes:

and executing the method of the basic implementation class and the method of the extended implementation class according to the request parameters to obtain a processing result corresponding to the service request.

In one possible implementation, the extended implementation class includes: a plurality of first-level extension implementation classes; the method for executing the extended implementation class according to the request parameter comprises the following steps:

and determining a primary extension implementation class matched with the first service from the plurality of primary extension implementation classes according to the request parameters, and executing the method in the primary extension implementation class matched with the first service.

In a possible implementation manner, the extended implementation class further includes: a plurality of secondary extension implementation classes; after the method in the first-level extension implementation class matched with the first service is executed, the method further comprises the following steps:

and determining a secondary extension implementation class matched with the first service from the plurality of secondary extension implementation classes according to the request parameters, and executing the method in the secondary extension implementation class matched with the first service.

In one possible implementation, the extended implementation class includes a plurality of primary extended implementation classes; according to the request parameter, executing the method of the basic implementation class and executing the method of the extended implementation class, including:

according to the request parameters, executing a context creating method and a context loading method in the basic implementation class, and executing a context loading method in the extended implementation class to obtain context information corresponding to the first service;

executing a context matching method in the plurality of primary extension implementation classes according to the request parameters, and determining a primary extension implementation class matched with the first service from the plurality of primary extension implementation classes according to an execution result;

and executing the service processing method in the basic implementation class according to the context information corresponding to the first service, and executing the service processing method in the primary extension implementation class matched with the first service.

In one possible implementation, the extended implementation class further includes a plurality of secondary extended implementation classes; after executing the service processing method in the first-level extension implementation class matched with the first service, the method further comprises the following steps:

executing a context matching method in the plurality of secondary extension implementation classes according to the request parameters, and determining a secondary extension implementation class matched with the first service from the plurality of secondary extension implementation classes according to an execution result;

and executing a service processing method in a secondary expansion implementation class matched with the first service according to the context information corresponding to the first service.

In a possible implementation manner, after the executing the service processing method in the second-level extended implementation class matched with the first service, the method further includes:

and executing the database processing method in the basic implementation class.

In a possible implementation manner, the primary extension implementation class is used to extend the functions of the basic implementation class, and the secondary extension implementation class is used to extend the functions of the primary extension implementation class; alternatively, the first and second electrodes may be,

the primary extension implementation class is used for performing first-dimension extension on the functions of the basic implementation class, and the secondary extension implementation class is used for performing second-dimension extension on the functions of the basic implementation class.

In a second aspect, an embodiment of the present invention provides a data processing apparatus, including:

an obtaining module, configured to obtain a service request, where the service request is used to instruct to process data of a first service, and the service request includes an identifier of the first service and a request parameter;

the processing module is used for determining a first service implementation class matched with the first service from a plurality of candidate service implementation classes according to the identifier of the first service;

the processing module is further configured to execute the method in the first service implementation class according to the request parameter, and obtain a processing result corresponding to the service request.

In a possible implementation manner, the first service implementation class includes a basic implementation class and an extended implementation class; the processing module is specifically configured to: and executing the method of the basic implementation class and the method of the extended implementation class according to the request parameters to obtain a processing result corresponding to the service request.

In one possible implementation, the extended implementation class includes: a plurality of first-level extension implementation classes; the processing module is specifically configured to: and determining a primary extension implementation class matched with the first service from the plurality of primary extension implementation classes according to the request parameters, and executing the method in the primary extension implementation class matched with the first service.

In a possible implementation manner, the extended implementation class further includes: a plurality of secondary extension implementation classes; the processing module is further specifically configured to: and determining a secondary extension implementation class matched with the first service from the plurality of secondary extension implementation classes according to the request parameters, and executing the method in the secondary extension implementation class matched with the first service.

In one possible implementation, the extended implementation class includes a plurality of primary extended implementation classes; the processing module is specifically configured to:

according to the request parameters, executing a context creating method and a context loading method in the basic implementation class, and executing a context loading method in the extended implementation class to obtain context information corresponding to the first service;

executing a context matching method in the plurality of primary extension implementation classes according to the request parameters, and determining a primary extension implementation class matched with the first service from the plurality of primary extension implementation classes according to an execution result;

and executing the service processing method in the basic implementation class according to the context information corresponding to the first service, and executing the service processing method in the primary extension implementation class matched with the first service.

In one possible implementation, the extended implementation class further includes a plurality of secondary extended implementation classes; the processing module is further specifically configured to:

executing a context matching method in the plurality of secondary extension implementation classes according to the request parameters, and determining a secondary extension implementation class matched with the first service from the plurality of secondary extension implementation classes according to an execution result;

and executing a service processing method in a secondary expansion implementation class matched with the first service according to the context information corresponding to the first service.

In a possible implementation manner, the processing module is further specifically configured to: and executing the database processing method in the basic implementation class.

In a possible implementation manner, the primary extension implementation class is used to extend the functions of the basic implementation class, and the secondary extension implementation class is used to extend the functions of the primary extension implementation class; alternatively, the first and second electrodes may be,

the primary extension implementation class is used for performing first-dimension extension on the functions of the basic implementation class, and the secondary extension implementation class is used for performing second-dimension extension on the functions of the basic implementation class.

In a third aspect, an embodiment of the present invention provides an electronic device, including: a memory for storing a computer program and a processor for executing the computer program to perform the method according to any of the first aspect.

In a fourth aspect, the present invention provides a computer-readable storage medium including a computer program, which when executed by a processor implements the method according to any one of the first aspect.

The embodiment of the invention provides a data processing method, a device and equipment, wherein the method comprises the following steps: the method comprises the steps of obtaining a service request, wherein the service request comprises a first service identifier and a request parameter, determining a first service implementation class matched with a first service from a plurality of candidate service implementation classes according to the first service identifier, and executing methods in the first service implementation class according to the request parameter to obtain a processing result corresponding to the service request. By isolating the implementation flows of different services, namely different services correspond to different service implementation classes, the expansibility and maintainability of service codes can be improved, and the maintenance cost and the maintenance difficulty are reduced; in addition, when data processing is required to be performed on a certain service, only the service implementation class corresponding to the service needs to be found and executed, and traversing execution is not required to be performed on other service implementation classes, so that the execution efficiency is improved.

Drawings

The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.

FIG. 1 is a diagram illustrating a possible system architecture to which embodiments of the present invention are applicable;

fig. 2 is a schematic diagram of a service implementation class provided in an embodiment of the present invention;

FIG. 3 is a schematic diagram of a hierarchy of an application system according to an embodiment of the present invention;

FIG. 4 is a diagram illustrating the definition and implementation of a basic implementation class according to an embodiment of the present invention;

FIG. 5 is a diagram illustrating the definition and implementation of a first-level extension implementation class according to an embodiment of the present invention;

FIG. 6 is a diagram illustrating the definition and implementation of a two-level extension implementation class according to an embodiment of the present invention;

FIG. 7 is a flow chart illustrating a data processing method according to an embodiment of the present invention;

FIG. 8 is a flow chart illustrating a data processing method according to another embodiment of the present invention;

FIG. 9 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present invention;

fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.

With the above figures, certain embodiments of the invention have been illustrated and described in more detail below. The drawings and the description are not intended to limit the scope of the inventive concept in any way, but rather to illustrate it by those skilled in the art with reference to specific embodiments.

Detailed Description

Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.

With the development of network technology, the functions of application systems are continuously expanded. One application system may support multiple service types. Taking the e-commerce system as an example, the e-commerce system can support merchant business, order business, review business and the like.

The business is divided according to the business dimension, and the business can be further divided into businesses corresponding to different types of businesses. For example: retail merchant business, large customer merchant business, important customer (KA) merchant business, and the like. The order business is divided according to order dimensions, and the order business can be further divided into businesses corresponding to different types of orders. For example: ordinary customer order business, large customer order business, purchase order business, quit supply order business, internal distribution order business and the like. For the rechecking service, the rechecking service is divided according to the dimension of the order to be rechecked, and the rechecking service can be further divided into: common customer order rechecking business, large customer order rechecking, internal configuration order rechecking and the like.

As the types of merchants accessed by the e-commerce system and the types of orders supported by the e-commerce system increase, different merchants or different orders may have different personalization requirements. For example, each time a merchant is accessed, corresponding functions need to be developed according to personalized requirements of the merchant, or the functions need to be modified on the basis of original codes, new functions and logic branches need to be supplemented, and the like.

In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: the code universality and expansibility of the application system are poor, so that the code maintenance cost and maintenance difficulty are increased, and the code running efficiency is low. The method is mainly characterized in that:

(1) when a new service needs to be added or a new function needs to be added for a certain service type, a serious problem of program re-research and development exists, code expansibility is poor, research and development personnel need a large amount of research and development time, and code maintenance cost and dimension difficulty are continuously increased.

(2) The original codes are modified to complement and develop new service types or new functions, so that the intrusion of the original codes is seriously influenced, a large amount of regression tests are required to be carried out, the stability of a system is influenced, and the code maintenance cost and the maintenance difficulty are further increased.

(3) In the application system code maintained in the above manner, a special judgment for some special merchants often occurs, for example, there are a large number of blocks of if (merchant identifier ═ 111 ") { special flow processing }. Thus, when the program of the application system is executed, the above-mentioned special judgment may be performed for all service types, which may result in a decrease in the code running efficiency.

It can be understood that as the business functions of the application system are expanded, the code amount of the application system is increased, and the degree of influence of the above technical problems on the application system is increased.

An embodiment of the present invention provides a data processing method, which is designed to solve at least one of the above technical problems. Fig. 1 is a schematic diagram of a possible system architecture to which the embodiment of the present invention is applicable. As shown in fig. 1, the system architecture includes a client and a server. The client can initiate a service request to the server, and the server can process data according to the service request and return a data processing result to the client. In some examples, the client and the server may be integrated in one electronic device. In other examples, the client and the server may be located in different electronic devices, respectively. This embodiment is not limited to this.

The data processing method provided by the embodiment can be executed by the server. In this embodiment, the processing procedures of different services are isolated, that is, different services correspond to different service implementation classes. Thus, when data processing is required for a certain service, only the service implementation class corresponding to the service needs to be found and executed. When a new service is needed, only the service implementation class corresponding to the new service needs to be developed, and no influence is brought to other service implementation classes. When a certain service needs to be deleted, only the service implementation class corresponding to the service needs to be deleted, and other service implementation classes are not affected. When the function of a certain service needs to be modified, only part of methods in the service implementation class corresponding to the service need to be modified, and other service implementation classes cannot be affected. Therefore, the expansibility and maintainability of the code are improved, and the execution efficiency can also be improved.

The following describes the technical solution of the present invention and how to solve the above technical problems with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present invention will be described below with reference to the accompanying drawings.

For the convenience of understanding, the design manner of the service implementation class in the present invention is first described with reference to fig. 2 to 6.

Specifically, a service implementation class corresponding to each service is defined and implemented for each service. For example, a service implementation class 1 is defined for a service 1, and is used for implementing a data processing flow related to the service 1; a service implementation class 2 is defined for the service 2 and is used for implementing a data processing flow related to the service 2; a service implementation class 3 is defined for the service 3, and is used for implementing a data processing flow related to the service 3, and the like.

In this embodiment, each service implementation class may specifically include one or more classes. When multiple classes are included, different classes may be used to implement different functions of the service.

Optionally, the service implementation class corresponding to one service may include a basic implementation class and an extended implementation class. The basic implementation class is used for realizing the common function related to the service, and the extended implementation class is used for realizing the personalized function related to the service.

Fig. 2 is a schematic diagram of a service implementation class according to an embodiment of the present invention. Assume that the application system includes an order service, a review service, and a merchant service. As shown in fig. 2, for each service, a basic implementation class is defined, and for each sub-service of the service, an extended implementation class corresponding to the sub-service is defined.

Taking the order service as an example, the order service may be further divided into a plurality of sub-services, for example: ordinary customer order business, large customer order business, purchase order business, quit supply order business, internal distribution order business and the like. Common service logic generally exists among the different sub-services, and meanwhile, personalized and differentiated service logic may also exist in each sub-service. Therefore, the basic implementation class corresponding to the order service can be developed according to the common service logic among the plurality of sub-services, and the extended implementation class corresponding to each sub-service can be developed according to the personalized service logic of each sub-service. Taking the extended implementation class corresponding to the general customer order service as an example, some personalized service logics (such as parameter verification, data setting, message sending and the like) existing in the general customer order service, that is, service logics which are not possessed by other order services (such as the large customer order service, the purchase order service and the like) are all implemented in the extended implementation class corresponding to the general customer order service. Thus, as shown in fig. 2, the service implementation classes corresponding to the order service include a basic implementation class and a plurality of extended implementation classes.

The structures of the service implementation classes corresponding to the review service and the merchant service are similar, and are not described herein again.

Optionally, when the service is more finely divided, the extension implementation class may be implemented hierarchically, for example, the extension implementation class may include a first-level extension implementation class and a second-level extension implementation class.

In some embodiments, the primary extension implementation class is used to extend the functions of the basic implementation class, and the secondary extension implementation class is used to extend the functions of the primary extension implementation class. For example, in fig. 2, if the general customer order service is addressed, there are also more detailed divisions, such as: ordinary retail customer order business, ordinary group-buying customer order business, etc. At this time, the general customer order service expansion implementation class may be used as a primary expansion implementation class, and the primary expansion implementation class may further be associated with one or more secondary expansion implementation classes, where each secondary expansion implementation class is used to implement a personalized service logic of a finer sub-service (for example, the general retail customer order service expansion implementation class, the general group purchase customer order service expansion implementation class, and the like, which are not shown in fig. 2). Therefore, the extension implementation class structure of each service is clear, different sub-services are isolated from each other, and extension and maintenance are facilitated.

In other embodiments, the primary extension implementation class is used for performing first-dimension extension on the function of the basic implementation class, and the secondary extension implementation class is used for performing second-dimension extension on the function of the basic implementation class. That is, the primary extension implementation class and the secondary extension implementation class may extend the base implementation class from different dimensions. For example, the primary extension implementation classes may be divided by merchant dimension (retail, large customer, Ka merchant, etc.), and the secondary extension implementation classes are divided by order dimension (customer order, merchant order, purchase order, stock order, etc.). Therefore, the first-level extension implementation class and the second-level extension implementation class can be combined as required, and the implementation is more flexible.

In this embodiment, one service may correspond to 1 basic implementation class, 0 or more primary extension implementation classes, and 0 or more secondary extension implementation classes. The basic implementation class and the extended implementation class can be associated through the service identifier. For example, the basic implementation class, the primary extension implementation class, and the secondary extension implementation class corresponding to the service may be determined according to the identifier of the service.

It should be noted that in this embodiment, two-stage expansion is taken as an example for illustration, and in practical application, more stages of expansion may also exist. Also, different services may include different levels of expansion, e.g., order services include two levels of expansion, merchant services include three levels of expansion, etc.

Fig. 3 is a schematic diagram of a hierarchy of an application system according to an embodiment of the present invention. As shown in fig. 3, the upper layer of the application system is a service layer, and the lower layer is a service layer. In the service layer, after the application service obtains the service request, the service executor executes the service data processing process. In the processing flow of the service executor, the dynamic matching execution of the basic implementation class and the extended implementation class can be supported. For example, which basic implementation class is executed is matched through the service identifier, and further, which extended implementation class or classes are executed is/are dynamically matched in a plurality of extended implementation classes associated with the service identifier. The extension implementation class of each service may only include a primary extension implementation class, and may also include a primary extension implementation class and a secondary extension implementation class. By adopting a dynamic matching mode to execute the basic implementation class and the extension implementation class, the extension is more flexible, and the execution efficiency can be improved.

With reference to fig. 3, the service layer is used to provide basic services to the service layer, and its internal method can provide a single function for the service layer to be flexibly used by the service layer. Meanwhile, the capability method of the service layer supports dynamic expansion, and can be realized by matching expansion according to the dynamic expansion mode of the service layer, so that the effect of dynamically executing partial codes is achieved.

The definition and implementation of the basic implementation class and the extended implementation class are described below with reference to specific examples.

Fig. 4 is a schematic diagram of definition and implementation of a basic implementation class according to an embodiment of the present invention. The basic implementation class definition shown in fig. 4 is a Main (Main) flow definition class in the service execution process, and each service needs to contain a unique implementation of the class, i.e. the implementation of the Main flow service. The method contained by the basic implementation class is defined as follows:

(1) and creating context () for creating context information of the business process, wherein the context () can be expanded and customized, and the request parameters are set in the context information.

(2) And loading context () for setting context information, mainly querying related data from a database according to the request parameters, and setting the related data into the context information.

(3) And the business processing () is used for setting a business processing result in the context information, and comprises the following steps: task objects, object results, list of objects to operate on (insert, update, delete) the database, etc.

(4) And database processing () for operating the database.

In fig. 4, the order service is taken as an example, and the implementation of the basic implementation class corresponding to the order service is illustrated, including the implementation of the above 4 methods.

Fig. 5 is a schematic diagram of the definition and implementation of a first-level extension implementation class according to an embodiment of the present invention. As shown in fig. 5, the definition of a primary extension (extended) implementation class is a primary extension (extended) flow definition class in the service execution process, and each service flow may include 0 to N implementation classes, that is, there may be no primary extension implementation class, or N primary extension implementation classes. The method included in the first-level extension implementation class is defined as follows:

(1) and matching context () used for determining whether the primary extension implementation class is matched with the current service request. For example, the current service request requests to process the customer order, but the primary extension implementation class is implemented for the work quitting order, which indicates that the current service request does not match the primary extension implementation class.

(2) And loading context () for setting context information, mainly querying related data from a database according to the request parameters, and setting the related data into the context information.

(3) And the business processing () is used for setting a business processing result in the context information, and comprises the following steps: task objects, object results, list of objects to operate on (insert, update, delete) the database, etc.

Fig. 5 illustrates, by taking an order service as an example, implementation of first-level extension implementation classes corresponding to a general customer order service and a large customer order service, where the two first-level extension implementation classes include implementation of the above 3 methods. It should be noted that, in the specific implementation process, only part of the 3 methods may be implemented in the first-level extension implementation class.

Fig. 6 is a schematic diagram of the definition and implementation of a two-level extension implementation class according to an embodiment of the present invention. As shown in fig. 6, the definition of the secondary extension (extended) implementation is a secondary extension (extended) flow definition class in the service execution process, and the definition of the primary extension implementation class may be extended, and each service flow may include 0 to N such implementations, that is, there may be no secondary extension implementation class, or N secondary extension implementation classes. The method included in the first-level extension implementation class is defined as follows:

(1) and matching context () for determining whether the secondary extended implementation class matches the current service request. For example, the current service request requests to process the customer order, but the secondary extension implementation class is implemented for the work quitting order, which indicates that the current service request does not match the secondary extension implementation class.

(2) And the business processing () is used for setting a business processing result in the context information, and comprises the following steps: task objects, object results, list of objects to operate on (insert, update, delete) the database, etc.

In fig. 6, the order service is taken as an example to illustrate the implementation of the two-level extension implementation classes corresponding to the ordinary retail customer order service and the ordinary group purchase customer order service, and the two-level extension implementation classes include the implementation of the above 2 methods. It should be noted that, in the specific implementation process, only part of the 2 methods described above may be implemented in the secondary extension implementation class.

In the embodiment, the service processing flow is divided into the basic implementation flow and the extended implementation flow, so that the service is isolated effectively, the code implementation is more standard, and the expandability and maintainability of the code are improved. When some kind of extended service needs to be deleted, only the extended implementation class corresponding to the extended service needs to be deleted, so that the maintenance is simpler.

Based on the service implementation class described in any of the above embodiments, the data processing method provided in the embodiment of the present invention is introduced below.

Fig. 7 is a flowchart illustrating a data processing method according to an embodiment of the present invention. As shown in fig. 7, the method of this embodiment may include:

s701: the method comprises the steps of obtaining a service request, wherein the service request is used for indicating to process data of a first service, and the service request comprises an identifier and request parameters of the first service.

Illustratively, the client sends a service request to the server according to a data processing requirement of the first service, so as to instruct the server to process the data of the first service. The server receives a service request from the client. The first service may be any service that the client requests to process, for example, the first service may be an order service, a merchant service, or a review service.

The service request includes an identifier of the first service and a request parameter. The identifier of the first service may be information capable of uniquely identifying the service, and may be, for example, a service name, a service number, and the like. The request parameter is used for indicating the detailed information of the data to be processed of the first service. It should be understood that for different services, their corresponding request parameters may be different. For example, when the first service is an order service, the request parameter may further indicate an order type, for example, indicating whether a general customer order needs to be processed, a large customer order needs to be processed, a purchase order needs to be processed, or the like.

S702: and determining a first service implementation class matched with the first service from a plurality of candidate service implementation classes according to the identifier of the first service.

Specifically, the service end defines and implements a service implementation class corresponding to each service in advance. Thus, after receiving the service request, the server can dynamically match the first service implementation class matched with the first service from the multiple service implementation classes according to the identifier of the first service carried in the service request.

S703: and executing the method in the first service implementation class according to the request parameter to obtain a processing result corresponding to the service request.

After the server determines the first service implementation class, the server may execute the method in the first service implementation class according to the request parameter to obtain a processing result corresponding to the service request.

In this embodiment, the implementation flows of different services are isolated, that is, different services correspond to different service implementation classes. Therefore, when data processing is required to be performed on a certain service, only the service implementation class corresponding to the service needs to be found and executed, and traversing execution on other service implementation classes is not required, so that the execution efficiency is improved.

In addition, because different services correspond to different service implementation classes, when a new service type is required, only the service implementation class corresponding to the new service type needs to be developed, and no influence is brought to other service implementation classes. When a certain service type needs to be deleted, only the service implementation class corresponding to the service type needs to be deleted, and other service implementation classes are not affected. When the function of a certain service type needs to be modified, only part of methods in the service implementation class corresponding to the service type need to be modified, and other service implementation classes cannot be influenced. Therefore, the expansibility and maintainability of the code are improved.

Optionally, the first service implementation class may include a basic implementation class and an extended implementation class. Correspondingly, S703 may specifically include: and executing the method of the basic implementation class and the method of the extended implementation class according to the request parameters, thereby obtaining a processing result corresponding to the service request.

The execution order of the basic implementation class and the extended implementation class is not limited. The methods in the basic implementation class and the extended implementation class may be executed sequentially or alternately. In some examples, the execution order of the methods in the base implementation class and the extended implementation class may also be dynamically determined, i.e., there may be different execution orders for different traffic types.

In this embodiment, the number of the extension implementation classes included in the first service implementation class may be one or more, and when the server executes the method, only part of the extension implementation classes may be executed. For example, dynamic matching may be used to determine which methods of extending the implementation classes to perform.

Optionally, the extension implementation class may include a plurality of first-level extension implementation classes.

In this case, the server may determine, according to the request parameter, a primary extension implementation class matched with the first service from the plurality of primary extension implementation classes, and execute the method in the primary extension implementation class matched with the first service. For example, taking the first service as an order service as an example, if the request parameter indicates that data processing is performed on the order service of the ordinary client, the primary extension implementation class for processing the order of the ordinary client is determined from the multiple primary extension implementation classes associated with the order service, so that only the method in the determined primary extension implementation class needs to be executed, and the methods in other primary extension implementation classes do not need to be executed in a traversing manner, thereby improving the execution efficiency.

Optionally, the extension implementation class may further include a plurality of secondary extension implementation classes.

In this case, after executing the method in the first-level extension implementation class, the server may further include: and according to the request parameters, acquiring a secondary extension implementation class matched with the first service from a plurality of secondary extension implementation classes, and executing the method in the secondary extension implementation class matched with the first service. For example, taking the first service as an order service as an example, if the request parameter indicates that data processing is performed on the order service of the ordinary retail customer, determining a secondary extension implementation class for processing the order of the ordinary retail customer from a plurality of secondary extension implementation classes associated with the order service, so that only the method in the determined secondary extension implementation class needs to be executed, and the methods in other secondary extension implementation classes do not need to be executed in a traversal manner, thereby improving the execution efficiency.

The following describes a data processing procedure in this embodiment with a specific example, in conjunction with the definition and implementation of the basic implementation class and the extended implementation class shown in fig. 4 to 6.

Fig. 8 is a flowchart illustrating a data processing method according to another embodiment of the present invention. As shown in fig. 8, the method of the present embodiment includes:

s801: and acquiring a service request, wherein the service request comprises the identifier of the first service and a request parameter.

Specifically, the application system of the server includes a service interface, and the service interface receives a service request sent by the client. The server executes the data processing flow of S802 to S811 described below.

S802: and according to the identification of the first service, determining a first service implementation class matched with the first service from a plurality of candidate service implementation classes, wherein the first service implementation class comprises a basic implementation class, a plurality of primary extension implementation classes and a plurality of secondary extension implementation classes.

Illustratively, if the first service is an order service, a service implementation class corresponding to the order service is determined from a plurality of candidate service implementation classes, where the service implementation class may specifically include a basic implementation class, a plurality of primary extension implementation classes (e.g., a general customer order service extension implementation class, a large customer order service extension implementation class, etc.), and a plurality of secondary extension implementation classes (a general retail customer order service extension implementation class, a general group-buying user order service extension implementation class, etc.).

S803: a create context method in the base implementation class is performed.

Specifically, according to the request parameter, a method for creating a context in the basic implementation class is executed to obtain context information corresponding to the first service, and the request parameter is set to the context information.

S804: the load context method in the base implementation class is executed.

Specifically, the method for loading the context in the basic implementation class is executed according to the request parameters, and mainly sets the parameters in the context information. For example, relevant data is obtained from a database or a third-party system according to the request parameters and is set in the context information.

S805: and executing the context matching method in the multiple primary extension implementation classes according to the request parameters, and determining the primary extension implementation class matched with the first service from the multiple primary extension implementation classes according to the execution result.

Specifically, for a plurality of primary extension implementation classes included in the first service implementation class, a context matching method is executed according to the request parameters, so as to determine whether each primary extension implementation class is matched with the first service. Thus, the primary extension implementation class matched with the first service is determined from the plurality of primary extension implementation classes.

Assuming that the request parameter in the service request indicates to perform data processing on the order service of the ordinary customer, the matched primary extended implementation class may be: and expanding the implementation class of the ordinary customer order business.

It should be understood that the matching result may vary depending on the request parameters. That is, the number of matched first-level extension implementation classes may be 0, 1 or more. If the number of the matched primary extension implementation classes is 0, S806 and S808 do not need to be executed.

S806: and executing a context loading method in the first-level extension implementation class matched with the first service.

Specifically, according to the request parameters, the method for loading the context in the matched primary extension implementation class is executed, and mainly sets the parameters in the context information. For example, relevant data is obtained from a database or a third-party system according to the request parameters and is set in the context information.

S807: and executing the service processing method in the basic implementation class.

Specifically, according to the context information obtained in the above steps, a service processing method in the basic implementation class is executed to process the relevant data of the service request, for example: and modifying, calculating, sending third-party data and the like are carried out on the request data.

S808: and executing the service processing method in the primary extension implementation class matched with the first service.

Specifically, according to the context information obtained in the above steps, a service processing method in the matched primary extension implementation class is executed to process the relevant data of the service request, for example: and modifying, calculating, sending third-party data and the like are carried out on the request data.

S809: and executing the context matching method in the multiple secondary expansion implementation classes according to the request parameters, and determining a secondary expansion implementation class matched with the first service from the multiple secondary expansion implementation classes according to the execution result.

Specifically, for a plurality of secondary extension implementation classes included in the first service implementation class, a context matching method is executed according to the request parameters, so as to determine whether each secondary extension implementation class is matched with the first service. In this way, the secondary extension implementation class matched with the first service is determined from the plurality of secondary extension implementation classes.

Assuming that the request parameter in the service request indicates data processing for the order service of the general retail customer, the matched secondary extension implementation class may be: and expanding the implementation class of the order service of the ordinary retail customer.

It should be understood that the matching result may vary depending on the request parameters. That is, the number of matched secondary extension implementation classes may be 0, 1, or more. If the number of the matched secondary extension implementation classes is 0, S810 does not need to be executed.

S810: and executing the service processing method in the second-level expansion implementation class matched with the first service.

Specifically, according to the context information obtained in the above steps, a service processing method in the matched secondary extension implementation class is executed to process the relevant data of the service request, for example: and modifying, calculating, sending third-party data and the like are carried out on the request data.

S811: a database processing method in the base implementation class is performed.

Specifically, according to the context information obtained in the above steps, a database processing method in the basic implementation class is executed, that is, a database modification is performed on the data processing result of the service request.

S812: and obtaining a data processing result corresponding to the service request.

After the data processing process from S802 to S811, the data processing result corresponding to the service request is obtained. Further, the server may return the data processing result to the client.

In this embodiment, when executing the data processing flow of the first service, the basic implementation class and the extended implementation class that are matched with the first service are determined according to the identifier of the first service, and then which extended implementation classes to execute are determined according to the request parameter. Through the dynamic control, aiming at different services, only the basic implementation class or the extended implementation class matched with the services needs to be executed, so that the execution efficiency is improved, and the isolation between the services is ensured. In addition, when a certain service is no longer needed, the basic implementation class and/or the extended implementation class associated with the service can be directly deleted, so that the implementation of other services is not influenced, and the stability of an application system is ensured.

Fig. 9 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present invention. The data processing device of this embodiment may be in the form of software and/or hardware, and the device may be disposed at a server. As shown in fig. 9, the data processing apparatus 10 provided in this embodiment may include: an acquisition module 11 and a processing module 12.

The acquiring module 11 is configured to acquire a service request, where the service request is used to instruct to process data of a first service, and the service request includes an identifier of the first service and a request parameter;

a processing module 12, configured to determine, according to the identifier of the first service, a first service implementation class that matches the first service from multiple candidate service implementation classes;

the processing module 12 is further configured to execute the method in the first service implementation class according to the request parameter, so as to obtain a processing result corresponding to the service request.

In a possible implementation manner, the first service implementation class includes a basic implementation class and an extended implementation class; the processing module 12 is specifically configured to: and executing the method of the basic implementation class and the method of the extended implementation class according to the request parameters to obtain a processing result corresponding to the service request.

In one possible implementation, the extended implementation class includes: a plurality of first-level extension implementation classes; the processing module 12 is specifically configured to: and determining a primary extension implementation class matched with the first service from the plurality of primary extension implementation classes according to the request parameters, and executing the method in the primary extension implementation class matched with the first service.

In a possible implementation manner, the extended implementation class further includes: a plurality of secondary extension implementation classes; the processing module 12 is further specifically configured to: and determining a secondary extension implementation class matched with the first service from the plurality of secondary extension implementation classes according to the request parameters, and executing the method in the secondary extension implementation class matched with the first service.

In one possible implementation, the extended implementation class includes a plurality of primary extended implementation classes; the processing module 12 is specifically configured to:

according to the request parameters, executing a context creating method and a context loading method in the basic implementation class, and executing a context loading method in the extended implementation class to obtain context information corresponding to the first service;

executing a context matching method in the plurality of primary extension implementation classes according to the request parameters, and determining a primary extension implementation class matched with the first service from the plurality of primary extension implementation classes according to an execution result;

and executing the service processing method in the basic implementation class according to the context information corresponding to the first service, and executing the service processing method in the primary extension implementation class matched with the first service.

In one possible implementation, the extended implementation class further includes a plurality of secondary extended implementation classes; the processing module 12 is further specifically configured to:

executing a context matching method in the plurality of secondary extension implementation classes according to the request parameters, and determining a secondary extension implementation class matched with the first service from the plurality of secondary extension implementation classes according to an execution result;

and executing a service processing method in a secondary expansion implementation class matched with the first service according to the context information corresponding to the first service.

In a possible implementation manner, the processing module 12 is further specifically configured to: and executing the database processing method in the basic implementation class.

In a possible implementation manner, the primary extension implementation class is used to extend the functions of the basic implementation class, and the secondary extension implementation class is used to extend the functions of the primary extension implementation class; alternatively, the first and second electrodes may be,

the primary extension implementation class is used for performing first-dimension extension on the functions of the basic implementation class, and the secondary extension implementation class is used for performing second-dimension extension on the functions of the basic implementation class.

The data processing apparatus provided in this embodiment may be configured to execute the technical solution in any of the method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.

Fig. 10 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. The electronic device can be used as a server. As shown in fig. 10, the electronic device 20 of the present embodiment includes: a processor 21 and a memory 22; a memory 22 for storing a computer program; a processor 21 for executing the computer program stored in the memory to implement the data processing method in the above-described embodiments. Reference may be made in particular to the description relating to the method embodiments described above.

Alternatively, the memory 22 may be separate or integrated with the processor 21.

When the memory 22 is a device independent from the processor 21, the electronic device 20 may further include: a bus 23 for connecting the memory 22 and the processor 21.

Optionally, the electronic device 20 may further comprise a communication component 24 for communicating with the client.

The electronic device provided in this embodiment may be configured to execute the technical solution in any of the method embodiments, and the implementation principle and the technical effect are similar, which are not described herein again.

An embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium includes a computer program, and the computer program is used to implement the technical solutions in any of the above method embodiments.

An embodiment of the present invention further provides a chip, including: the system comprises a memory, a processor and a computer program, wherein the computer program is stored in the memory, and the processor runs the computer program to execute the technical scheme of any one of the method embodiments.

In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described device embodiments are merely illustrative, and for example, the division of the modules is only one logical division, and other divisions may be realized in practice, for example, a plurality of modules may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.

The modules described as separate parts may or may not be physically separate, and parts displayed as modules may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.

In addition, functional modules in the embodiments of the present invention may be integrated into one processing unit, or each module may exist alone physically, or two or more modules are integrated into one unit. The unit formed by the modules can be realized in a hardware form, and can also be realized in a form of hardware and a software functional unit.

The integrated module implemented in the form of a software functional module may be stored in a computer-readable storage medium. The software functional module is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention.

It should be understood that the Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in the incorporated application may be directly implemented by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.

The memory may comprise a high-speed RAM memory, and may further comprise a non-volatile storage NVM, such as at least one disk memory, and may also be a usb disk, a removable hard disk, a read-only memory, a magnetic or optical disk, etc.

The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the buses in the figures of the present invention are not limited to only one bus or one type of bus.

The storage medium may be implemented by any type or combination of volatile or non-volatile memory devices, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.

An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. Of course, the storage medium may also be integral to the processor. The processor and the storage medium may reside in an Application Specific Integrated Circuits (ASIC). Of course, the processor and the storage medium may reside as discrete components in an electronic device or host device.

Those of ordinary skill in the art will understand that: all or a portion of the steps of implementing the above-described method embodiments may be performed by hardware associated with program instructions. The program may be stored in a computer-readable storage medium. When executed, the program performs steps comprising the method embodiments described above; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.

Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.

It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.

22页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种微服务集成产品的交付方法、设备及介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!