Service implementation method and device
By defining preset base classes and business classes, and using the common logic and task type acquisition logic in the base class, the problem in the existing technology that developers need to repeatedly develop similar codes is solved, and an efficient and friendly business implementation method is realized. Improved development efficiency and standardization.
Patent Information
- Application Number
- CN202410758559.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-09-03
AI Technical Summary
Existing business implementation methods require developers to repeatedly develop similar codes, which affects business implementation efficiency. As a result, developers must not only focus on business logic processing codes, but also on the operation and processing logic of shared tables.
By defining preset base classes and business classes, and using the general logic in the base class and the task type acquisition logic in the business class, an efficient and friendly implementation method of the business is realized, allowing developers to focus on business logic processing and avoiding repeated development of similar code.
It improves development efficiency, saves R&D costs, enables developers to focus on the logical processing of the business itself, reduces the workload of repeated development, and improves the standardization and maintainability of business implementation.
Smart Images

Figure CN118585181A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and device for implementing a service. Background Art
[0002] In the distributed scheduled task scheduling framework, the pending tasks of each business are usually maintained and distributed through a common table, and each business develops different processing logic to handle the corresponding tasks. For example, for asynchronous point issuance business and asynchronous inventory rollback business, each pending point issuance task and inventory rollback task is maintained in a common asynchronous task table, and the asynchronous point issuance business obtains pending point issuance tasks by regularly querying the common table.
[0003] In the process of implementing the present invention, the inventors found that the prior art has the following problems: The existing business implementation method requires developers to repeatedly develop similar codes when implementing business logic, such as codes for querying shared tables and processing business execution results. As a result, developers not only have to pay attention to the logical processing code of the business itself, but also need to pay attention to related operations and processing logic of shared tables, which affects the efficiency of business implementation. Summary of the invention
[0004] In view of this, the embodiments of the present invention provide a method and device for implementing a business, which realizes an efficient and friendly business implementation method, so that developers can focus on the code of the logical processing of the business itself, improve development efficiency, and save R&D costs.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for implementing a service is provided, including: In response to receiving a business implementation request, determining a task type of a task to be processed of the business and a business logic processing class; According to the task type, a business class is established, and the business class is used as a subclass that inherits a preset base class, where the base class contains the common logic for executing the business; Execute business according to base class, business class, and business logic processing class.
[0006] Optionally, before using the business class as a subclass that inherits a preset base class, the business implementation method also includes: determining the general logic for implementing the business and the relationship between various logical points in the general logic; based on the general logic and the relationship between various logical points, determining the code corresponding to the base class and constructing the base class.
[0007] Optionally, when the to-be-processed tasks of a business are determined by querying the task types in a common table, the general logic includes: task type acquisition logic and to-be-processed task query logic.
[0008] Optionally, the business is executed according to the base class, the business class, and the business logic processing class, including: based on the inheritance of the task type acquisition logic of the base class by the business class, the task type is obtained from the business class; based on the inheritance of the pending task query logic of the base class by the business class, the pending tasks corresponding to the task type under the business are obtained from the common table; from the correspondence between the pre-established task type and the class name of the business logic processing class, the class name of the business logic processing class corresponding to the task type is queried; according to the class name of the business logic processing class, the business logic processing class is called to process the pending tasks to obtain the execution result of the business logic processing class.
[0009] Optionally, the general logic also includes: business execution result processing logic; after obtaining the execution result of the business logic processing class, the business implementation method also includes: based on the business class inheriting the business execution result processing logic of the base class, updating the processing status of the pending tasks in the public table according to the execution result.
[0010] Optionally, the general logic also includes: task lock processing logic; after obtaining the pending tasks of the business, the implementation method of the business also includes: based on the inheritance of the task lock processing logic of the base class by the business class, locking the pending tasks through optimistic locking, and determining that the locking is successful; after obtaining the execution result of the logic processing class, the implementation method of the business also includes: based on the inheritance of the task lock processing logic of the base class by the business class, unlocking the pending tasks.
[0011] Optionally, the general logic also includes: logic for parsing tasks to be processed; when the data information in the tasks to be processed does not meet the data format requirements of the business logic processing class, before calling the business logic processing class to process the tasks to be processed, the business implementation method also includes: based on the business class's inheritance of the base class's logic for parsing tasks to be processed, parsing and format conversion of the data information in the tasks to be processed.
[0012] According to a second aspect of an embodiment of the present invention, a device for implementing a service is provided, including: A business logic determination module, used to determine the task type of the task to be processed of the business and the business logic processing class in response to receiving the business implementation request; The business class inheritance module is used to establish a business class for a business according to the task type, and use the business class as a subclass that inherits a preset base class, wherein the base class contains the general logic for executing the business; The business implementation module is used to execute business based on base classes, business classes, and business logic processing classes.
[0013] According to a third aspect of an embodiment of the present invention, there is provided an electronic implementation device for a service, including: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method provided in the first aspect of the embodiment of the present invention.
[0014] According to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method provided by the first aspect of the embodiment of the present invention is implemented.
[0015] According to a fifth aspect of an embodiment of the present invention, there is provided a computer program product, including a computer program, which implements the method provided in the first aspect of the embodiment of the present invention when the computer program is executed by a processor.
[0016] An embodiment of the invention has the following advantages or beneficial effects: by responding to receiving a business implementation request, determining the task type of the business's pending tasks and the business logic processing class; establishing a business class for the business based on the task type, and using the business class as a subclass that inherits a preset base class, wherein the base class contains the common logic for executing the business; executing the technical solution of the business based on the base class, the business class, and the business logic processing class, realizing an efficient and friendly business implementation method, allowing developers to focus on the logic processing code of the business itself, improving development efficiency, and saving R&D costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention. Figure 1 is a schematic diagram of the main process of a method for implementing a service according to an embodiment of the present invention; Figure 2 It is a complete flow chart of a method for implementing a service of an embodiment of the present invention; Figure 3 is a schematic diagram of main modules of a device for implementing a service according to an embodiment of the present invention; Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention may be applied; Figure 5 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0018] It should be noted that the acquisition, storage and application of user personal information involved in the technical solution of the present disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0019] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0020] The existing business implementation method requires developers to repeatedly develop similar codes when implementing business logic, such as codes for querying common tables and processing business execution results. As a result, developers not only have to pay attention to the logical processing code of the business itself, but also need to pay attention to related operations and processing logic of public tables, which affects the efficiency of business implementation and cannot meet the actual application needs well.
[0021] In order to solve the above problems existing in the prior art, the present invention proposes a method for implementing a business, based on a preset base class, a new business class inheriting the base class is created, and the task type of the business task to be processed is defined in the business class, and then the business is executed in combination with the determined business logic processing class and the base class. An efficient and friendly business implementation method is implemented, so that developers can focus on the code of the logic processing of the business itself, improve development efficiency, and save R&D costs.
[0022] In the introduction to the embodiments of the present invention, the terms and their meanings are as follows: Spring container: In a spring-based application, application objects live in a spring container. The spring container is responsible for creating, assembling, and configuring objects, and managing the entire life cycle of objects (from birth to death). The container is the core of the Spring framework.
[0023] Figure 1 is a schematic diagram of the main process of the method for implementing the service according to an embodiment of the present invention, such as Figure 1 As shown, the method for implementing the service in the embodiment of the present invention includes the following steps S101 to S103.
[0024] Step S101: in response to receiving a service implementation request, determining the task type of the service task to be processed and the service logic processing class.
[0025] Specifically, in the scheduling framework of distributed timed tasks, each task is maintained and distributed through a common table. In order to improve the efficiency of task distribution, the embodiment of the present invention allocates the task type of the corresponding pending task to each business, and formulates the assignment rule of the task type. For example, for the asynchronous point issuance business, according to the parameters of the business and the assignment rule, the task type of the corresponding pending point issuance task is determined to be 2. When a business implementation request is received, the task type of the pending task of the business is determined according to the assignment rule of the task type of the pending task of the business, and the specific business logic processing class code of the business written by the developer is obtained.
[0026] Step S102: Establish a business class for the business according to the task type, and use the business class as a subclass that inherits a preset base class, wherein the base class contains a common logic for executing the business.
[0027] Specifically, considering that each business has similar overall execution processes in the process of determining pending tasks through a common table and executing their own business logic, a basic class containing common logic for executing the business, also called a base class, is established based on the execution processes of these businesses. Then, based on the task type determined above, the specific acquisition code of the task type is defined in the business class of the business, and the business class is set to inherit the preset base class, that is, the business class is a subclass of the base class. In this way, each business class shares the base class logic, and there is no need to repeatedly develop similar logic in the business.
[0028] According to one embodiment of the present invention, before using the business class as a subclass that inherits a preset base class, the business implementation method also includes: determining the general logic for implementing the business, and the association relationship between various logical points in the general logic; based on the general logic and the association relationship between various logical points, determining the code corresponding to the base class and constructing the base class.
[0029] Specifically, the base class of the embodiment of the present invention essentially provides a standardized and unified execution process for the implementation of each business. Before the business class is used as a subclass that inherits the preset base class, the general logic for implementing the business is first determined, that is, the common logic that each business needs to use. The general logic is composed of various logic points, and there is a certain association between the various logic points, for example, which logic point is executed first, and the execution order of each logic point. Then, based on the determined general logic, the code corresponding to each logic point of the general logic is clarified; based on the association between each logic point, the code corresponding to each logic point is combined and process-organized into the base class code.
[0030] The embodiment of the present invention takes into account the presence of a large number of repeated execution actions in the business implementation related to scheduled tasks, and organizes, summarizes, and arranges the common logic corresponding to these repeated execution actions into a base class (foundation class). In this way, the business implementation of various scheduled tasks can inherit the common logic in the base class to avoid repeated development of similar codes, which not only improves the business implementation efficiency and reduces the workload of R&D personnel, but also is more conducive to the standardization of various business implementations and makes it easier to troubleshoot problems.
[0031] According to another embodiment of the present invention, when the pending tasks of a service are determined by querying the task type in the common table, the general logic includes: task type acquisition logic and pending task query logic.
[0032] Specifically, the business implementation method of the embodiment of the present invention is mainly applied to the specific scenario in which the pending tasks of the business are determined by querying the task type in the common table, such as in the distribution system of distributed scheduled tasks, each business obtains the corresponding pending tasks by querying the common table of scheduled tasks. In this case, since each business needs to obtain the corresponding task type and query the table, the above-mentioned general logic includes the logic points of the task type acquisition logic and the logic points of the pending task query logic. Accordingly, the association between these two logic points is clarified, and the task type obtained according to the task type acquisition logic is used for the pending task query logic. It can be obtained that the task type acquisition logic precedes the pending task query logic, and the result of the task type is the input parameter of the pending task query logic. Based on this, the base class code is constructed.
[0033] It should be noted that the task type acquisition logic in the base class of the embodiment of the present invention is defined in the form of abstract method code. Taking into account that different business classes correspond to different task types, in order to ensure that the business class must define the specific code implementation for task type acquisition, the abstract method code for task type acquisition needs to be defined in the base class to standardize and constrain the specific method code for task type acquisition in the business class, and implement the subsequent acquisition of the task type based on the specific method code for task type acquisition in the business class.
[0034] Step S103: Execute the service according to the base class, the service class, and the service logic processing class.
[0035] Specifically, according to the inheritance relationship between the above-mentioned business class and the base class, as well as the specific business logic processing class code of the business, the general logic of the business is executed by inheriting the base class, and then combined with the specific business logic processing class code, a complete business execution process is realized.
[0036] According to one embodiment of the present invention, the business is executed according to the base class, the business class, and the business logic processing class, including: based on the inheritance of the task type acquisition logic of the base class by the business class, the task type is acquired from the business class; based on the inheritance of the pending task query logic of the base class by the business class, the pending tasks corresponding to the task type under the business are acquired from the common table; the class name of the business logic processing class corresponding to the task type is queried from the correspondence relationship between the pre-established task type and the class name of the business logic processing class; according to the class name of the business logic processing class, the business logic processing class is called to process the pending task to obtain the execution result of the business logic processing class.
[0037] Specifically, in the case where the general logic includes task type acquisition logic and pending task query logic, the business class inherits the task type acquisition logic in the base class and uses the task type defined therein as the return value. Then, according to the task type, the pending task query logic in the base class is inherited, and the pending task corresponding to the task type is queried from the common table. Subsequently, the class name of the specific business logic processing class code defined above is queried from the correspondence between the pre-established task type and the class name of the business logic processing class, and then, according to the queried class name, the business logic processing class code corresponding to the class name is obtained from the spring container, and the method code in the business logic processing class is called to process the pending task, and the execution result of the business is obtained. It can be understood that the correspondence between the pre-established task type and the class name of the business logic processing class can be stored in the form of a file alone. When querying the class name, it can be queried from the file, or it can be stored in the base class. The specific storage form is determined according to the number of business types.
[0038] The embodiment of the present invention associates the personalized task types and business logic processing classes in the business implementation process with the general logic in the base class, utilizes the task type acquisition logic and the pending task query logic in the base class, and through the correspondence between the task type and the class name of the business logic processing class, collaboratively and efficiently executes specific pending tasks.
[0039] According to another embodiment of the present invention, the general logic also includes: business execution result processing logic; after obtaining the execution result of the business logic processing class, the business implementation method also includes: based on the business class inheriting the business execution result processing logic of the base class, updating the processing status of the tasks to be processed in the public table according to the execution result.
[0040] Specifically, for the scenario of querying the assigned tasks through the common table, in order to distinguish between processed tasks and pending tasks and prevent the business from treating the queried processed tasks as pending tasks, each task stored in the common table has corresponding status information. After obtaining the execution result of the business logic processing class, the business class inherits the business execution result processing logic of the base class, and updates the execution result in the processing status of the corresponding pending task in the common table according to the execution result of the specific business logic processing class on the pending task. At this time, the pending task in the table has become a processed task. It can be understood that if there is an abnormality in the execution result, the relevant alarm information such as the pending task can be directly prompted to check.
[0041] Based on the business execution result processing logic in the base class, through the inheritance of the base class by the business class, the business class can reuse the code of the business execution result processing logic in the base class, and after obtaining the execution result of the business logic processing class, the execution result is updated to the processing status or processing result of the corresponding pending task in the public table, so as to effectively distinguish between the processed tasks and pending tasks in the public table, and prepare data for the subsequent query of a new round of pending tasks.
[0042] According to another embodiment of the present invention, the general logic also includes: task lock processing logic; after obtaining the pending tasks of the business, the implementation method of the business also includes: based on the inheritance of the task lock processing logic of the base class by the business class, locking the pending tasks through optimistic locking, and determining that the locking is successful; after obtaining the execution result of the logic processing class, the implementation method of the business also includes: based on the inheritance of the task lock processing logic of the base class by the business class, unlocking the pending tasks.
[0043] Specifically, considering that the common table is provided for shared use by various services in the distributed cluster, concurrency problems are inevitable. For example, if the points issuance business of two services queries the common table at the same time, points will be issued twice. In order to avoid concurrent processing of tasks, the general logic of the base class also includes task lock processing logic. After obtaining the pending tasks of the business, the embodiment of the present invention inherits the task lock processing logic in the base class, locks the acquired pending tasks through optimistic locking, prevents concurrency, and after obtaining the execution result of the business logic processing class, inherits the task lock processing logic in the base class, unlocks the pending tasks, and updates the processing status of the pending tasks. It can be understood that if the locking is unsuccessful, it means that the task is currently being executed and the task is abandoned.
[0044] The embodiment of the present invention fully considers the high concurrency of the scheduling scenario of distributed timed tasks. In order to ensure the processing uniqueness of the tasks to be processed, the task lock processing logic is added to the general logic. After determining the tasks to be processed and the execution results of the logic processing class corresponding to the tasks to be processed, locking and unlocking operations are performed respectively to achieve concurrency control of the tasks to be processed and better ensure the correctness and orderliness of business execution.
[0045] According to another embodiment of the present invention, the general logic also includes: logic for parsing tasks to be processed; when the data information in the task to be processed does not meet the data format requirements of the business logic processing class, before calling the business logic processing class to process the task to be processed, the business implementation method also includes: based on the business class's inheritance of the base class's logic for parsing tasks to be processed, parsing and format conversion of the data information in the task to be processed.
[0046] Specifically, the common logic in the base class also includes the task parsing logic to be processed. Before calling the business logic processing class to process the task to be processed, it is determined whether the data information of the task to be processed meets the data format requirements of the business logic processing class. In the case that the data information in the task to be processed does not meet the data format requirements of the business logic processing class, the business class inherits the task parsing logic to be processed in the base class, parses the data information in the task to be processed, and converts the format of the parsing result according to the data format in the business logic processing class to obtain the task to be processed that meets the data format requirements.
[0047] In order to further ensure the smooth execution of the pending tasks, considering that the data information of the pending tasks may come from different platforms or services, and different platforms or services may have different data format outputs. The embodiment of the present invention also adds the pending task parsing logic to the general logic of the base class, so as to ensure the consistency of the data format before executing the pending tasks. It can not only ensure the smooth execution of the pending tasks, but also detect the abnormal data information that cannot be converted in format in advance and report it in time, so as to avoid adding the data information in abnormal format to the execution of the pending tasks, affecting and interfering with other tasks being executed.
[0048] Through the execution process of the above business, it can be known that for software developers, they only need to define a business class that contains the task type of the pending tasks of the business, and make the business class inherit the preset base class, and then determine the specific business logic processing class code, so that the complete process of the business can be executed in a standardized, fast and efficient manner. Moreover, as long as the business class and the business logic processing class are correct, the reliability of the business implementation can be guaranteed. It can be understood that when the common logic of each business changes or is updated, the corresponding logic point in the base class can be directly adjusted and updated, achieving good scalability and maintainability, so as to be better applied to more application scenarios.
[0049] Figure 2 It is a complete flow diagram of the implementation method of the business of the embodiment of the present invention. It is mainly divided into three parts, a base class, a business class (a subclass that inherits the base class) and a business logic processing class. The business class inherits the base class and executes the business according to the execution process in the base class. First, the business class inherits the task type acquisition logic in the base class, executes the specific method code for task type acquisition in the business class, and obtains the current task type. According to the task type, the pending task query logic in the base class is inherited to obtain the pending tasks of the business from the common table. Traverse the pending tasks to determine whether the data information of the pending tasks meets the data format requirements of the business logic processing class. If not, based on the inheritance of the pending task parsing logic in the base class, the data information in the pending tasks is parsed and format converted. Then, based on the inheritance of the task lock processing logic in the base class, the pending tasks are locked. If the locking fails, the tasks are abandoned. If the locking succeeds, the class name of the business logic processing class corresponding to the task type is queried from the correspondence between the pre-established task type and the class name of the business logic processing class. According to the class name, the corresponding business logic processing class code is obtained from the spring container, and the doProcess(task) method of the business logic processing class is called to process the task to be processed and obtain the returned business execution result. Finally, based on the inheritance of the task lock processing logic in the base class, the task to be processed is unlocked, and based on the inheritance of the business execution result processing logic in the base class, the processing status of the corresponding task to be processed is updated according to the execution result, thus realizing the complete business process.
[0050] Figure 3 FIG. 1 is a schematic diagram of the main modules of the device for implementing the service according to an embodiment of the present invention. Figure 3 As shown, the service implementation device 300 mainly includes a service logic determination module 301 , a service class inheritance module 302 and a service implementation module 303 .
[0051] The business logic determination module 301 is used to determine the task type of the task to be processed of the business and the business logic processing class in response to receiving the business implementation request; The business class inheritance module 302 is used to establish a business class of a business according to the task type, and use the business class as a subclass that inherits a preset base class, wherein the base class contains the general logic for executing the business; The business implementation module 303 is used to execute the business according to the base class, the business class, and the business logic processing class.
[0052] According to one embodiment of the present invention, the service implementation device 300 also includes a base class construction module (not shown in the figure), which is used to: determine the general logic for implementing the service and the association relationship between various logic points in the general logic before using the service class as a subclass that inherits the preset base class; determine the code corresponding to the base class according to the general logic and the association relationship between various logic points, and construct the base class.
[0053] According to another embodiment of the present invention, when the pending tasks of a service are determined by querying the task type in the common table, the general logic includes: task type acquisition logic and pending task query logic.
[0054] According to another embodiment of the present invention, the business implementation module 303 is also used to: obtain the task type from the business class based on the inheritance of the task type acquisition logic of the base class by the business class; obtain the pending tasks corresponding to the task type under the business from the common table based on the inheritance of the pending task query logic of the base class by the business class; query the class name of the business logic processing class corresponding to the task type from the correspondence between the pre-established task type and the class name of the business logic processing class; call the business logic processing class to process the pending tasks according to the class name of the business logic processing class to obtain the execution result of the business logic processing class.
[0055] According to another embodiment of the present invention, the general logic also includes: business execution result processing logic; the business implementation device 300 also includes an execution result processing module (not shown in the figure), which is used to: after obtaining the execution result of the business logic processing class, based on the business class's inheritance of the base class's business execution result processing logic, update the processing status of the task to be processed in the public table according to the execution result.
[0056] According to another embodiment of the present invention, the general logic also includes: task lock processing logic; the business implementation device 300 also includes a task locking module (not shown in the figure), which is used to: after obtaining the pending tasks of the business, based on the inheritance of the task lock processing logic of the base class by the business class, lock the pending tasks through optimistic locking, and determine that the locking is successful; the business implementation device 300 also includes a task unlocking module (not shown in the figure), which is used to: after obtaining the execution result of the logic processing class, based on the inheritance of the task lock processing logic of the base class by the business class, unlock the pending tasks.
[0057] According to another embodiment of the present invention, the general logic also includes: a logic for parsing tasks to be processed; when the data information in the tasks to be processed does not meet the data format requirements of the business logic processing class, the business implementation device 300 also includes a task parsing module (not shown in the figure), which is used to: before calling the business logic processing class to process the tasks to be processed, based on the business class's inheritance of the base class's parsing logic for tasks to be processed, parse and format convert the data information in the tasks to be processed.
[0058] Figure 4 is an exemplary system architecture diagram to which embodiments of the present invention can be applied.
[0059] like Figure 4 As shown, system architecture 400 may include terminal devices 401, 402, 403, network 404 and server 405. Network 404 is used to provide a medium for communication links between terminal devices 401, 402, 403 and server 405. Network 404 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0060] Users can use terminal devices 401, 402, 403 to interact with server 405 through network 404 to receive or send messages, etc. Various communication client applications, such as business implementation applications, etc., can be installed on terminal devices 401, 402, 403 (only as an example).
[0061] The terminal devices 401 , 402 , and 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0062] The server 405 may be a server that provides various services, such as a background management server (only an example) that provides support for the services performed by the user using the terminal devices 401, 402, and 403. The background management server may determine the task type of the task to be processed and the business logic processing class of the service in response to receiving the service implementation request; establish a business class of the service according to the task type, and use the business class as a subclass that inherits a preset base class, wherein the base class contains the general logic for executing the service; perform services and other processing according to the base class, the business class, and the business logic processing class, and feed back the processing results (such as business execution results, etc. - only an example) to the terminal device.
[0063] It should be noted that the service implementation method provided in the embodiment of the present invention is generally executed by the server 405 , and accordingly, the service implementation device is generally set in the server 405 .
[0064] It should be understood that Figure 4The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0065] Reference below Figure 5 , which shows a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 5 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0066] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the system 500 are also stored. The CPU 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0067] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that a computer program read therefrom is installed into the storage section 508 as needed.
[0068] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the central processing unit (CPU) 501, the above-mentioned functions defined in the system of the present invention are executed.
[0069] It should be noted that the computer-readable medium shown in 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 may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination thereof.
[0070] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0071] The units involved in the embodiments of the present invention may be implemented by software or hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes: a business logic determination module, a business class inheritance module and a business implementation module.
[0072] The names of these modules do not, in some cases, constitute a limitation on the modules themselves. For example, a business implementation module can also be described as "a module for executing business based on base classes, business classes, and business logic processing classes."
[0073] On the other hand, the present invention also provides a computer-readable medium, which may be included in the device described in the embodiment; or may exist independently without being assembled into the device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the device, the device includes: in response to receiving a service implementation request, determining the task type of the task to be processed of the service, and the service logic processing class; according to the task type, establishing a service class of the service, and using the service class as a subclass that inherits a preset base class, wherein the base class contains the general logic for executing the service; and executing the service according to the base class, the service class, and the service logic processing class.
[0074] The technical solution according to the embodiment of the present invention has the following advantages or beneficial effects: by responding to receiving a business implementation request, determining the task type of the pending task of the business and the business logic processing class; establishing a business class of the business according to the task type, and using the business class as a subclass that inherits a preset base class, wherein the base class contains the common logic for executing the business; executing the technical solution of the business according to the base class, the business class, and the business logic processing class, realizes an efficient and friendly business implementation method, so that developers can focus on the code of the logic processing of the business itself, improve development efficiency, and save R&D costs.
[0075] The specific implementation methods described herein do not constitute limitations on the scope of protection of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention shall be included in the scope of protection of the present invention.
Claims
1. A method for implementing a service, characterized in that: include: In response to receiving a business implementation request, determining a task type of a task to be processed of the business and a business logic processing class; According to the task type, a business class of the business is established, and the business class is used as a subclass that inherits a preset base class, wherein the base class contains a common logic for executing the business; The business is executed according to the base class, the business class, and the business logic processing class.
2. The method according to claim 1, characterized in that Before using the business class as a subclass that inherits a preset base class, the method further includes: Determine the general logic for implementing the business, and the association relationship between various logic points in the general logic; According to the general logic and the association relationship between the various logic points, the code corresponding to the base class is determined and the base class is constructed.
3. The method according to claim 2, characterized in that In the case where the pending tasks of the business are determined by querying the task type in the common table, the general logic includes: task type acquisition logic and pending task query logic.
4. The method according to claim 3, characterized in that Executing the service according to the base class, the service class, and the service logic processing class includes: Based on the inheritance of the task type acquisition logic of the base class by the business class, the task type is acquired from the business class; Based on the inheritance of the query logic of pending tasks of the base class by the business class, obtaining the pending tasks corresponding to the task type under the business from the common table; Querying the class name of the business logic processing class corresponding to the task type from the pre-established correspondence between the task type and the class name of the business logic processing class; According to the class name of the business logic processing class, the business logic processing class is called to process the task to be processed, and the execution result of the business logic processing class is obtained.
5. The method according to claim 4, characterized in that The general logic also includes: business execution result processing logic; After obtaining the execution result of the business logic processing class, the method further includes: Based on the inheritance of the business execution result processing logic of the base class by the business class, the processing status of the to-be-processed task in the public table is updated according to the execution result.
6. The method according to claim 4, characterized in that The general logic also includes: task lock processing logic; After obtaining the pending tasks of the business, the method further includes: based on the inheritance of the task lock processing logic of the base class by the business class, locking the pending tasks through optimistic locking, and determining whether the locking is successful; After obtaining the execution result of the logic processing class, the method further includes: unlocking the task to be processed based on the inheritance of the task lock processing logic of the base class by the business class.
7. The method according to claim 4, characterized in that The general logic also includes: pending task parsing logic; When the data information in the task to be processed does not meet the data format requirement of the business logic processing class, before calling the business logic processing class to process the task to be processed, the method further includes: Based on the inheritance of the task parsing logic of the base class by the business class, the data information in the task to be processed is parsed and format converted.
8. A device for implementing a service, characterized in that: include: A business logic determination module, configured to determine, in response to receiving a business implementation request, a task type of a task to be processed of the business and a business logic processing class; A business class inheritance module, used to establish a business class of the business according to the task type, and use the business class as a subclass that inherits a preset base class, wherein the base class contains a common logic for executing the business; The business implementation module is used to execute the business according to the base class, the business class, and the business logic processing class.
9. A mobile electronic device terminal, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
