Code processing, service response method and device, computer device, storage medium

By stripping the control layer and database operation code in the MVC framework and building the logic layer and event layer, the problem of high code coupling in the Controller layer in the PHP framework is solved, vertical splitting and reusing of the code is realized, and clarity and maintenance convenience of the MVC framework are improved.

CN113986224BActive Publication Date: 2025-08-01HUBEI TIANRONGXIN NETWORK SECURITY TECH CO LTD +3
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111327659.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-10
Publication Date
2025-08-01
Estimated Expiration
2041-11-10

AI Technical Summary

Technical Problem

The existing PHP framework has high code coupling, resulting in increased code complexity and difficulty in maintaining and scaling.

Method used

By stripping the control layer and database operation code in the MVC framework, building the logic layer and event layer, reducing the coupling degree of the control layer, and separating the business implementation-related code to the event layer, realizing vertical splitting.

Benefits of technology

It reduces the code complexity of the control layer, improves the reusability and maintenance convenience of the code module, and simplifies the structure of the MVC framework.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113986224B_ABST
    Figure CN113986224B_ABST
Patent Text Reader

Abstract

The present application provides a code processing, service response method and apparatus, computer device, and storage medium. Among them, the code processing method includes: identifying the operation codes related to the database in the control layer code and / or the data layer code based on the control layer code and / or the data layer code in the MVC framework; stripping the operation codes related to the database in the control layer code from the control layer code and other steps. The present application can decouple the control layer code in the MVC framework, enabling the control layer in the MVC framework to purely perform task scheduling, and handing the operations on data entities and event operations to the logic layer and the event layer for processing. Furthermore, it reduces the code complexity in the control layer of the MVC framework and reduces the coupling degree of the control layer in the MVC framework, thereby improving the reusability of the code modules in the MVC framework, making the MVC framework clearer and more concise, and facilitating maintenance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology. Specifically, it relates to a code processing and business response method, device, computer equipment, and storage medium. Background Art

[0002] As a mainstream web development language, PHP has been applied in more and more web systems due to its concise syntax, convenient development, easy deployment, and increasing availability of third-party extensions, occupying 70% of the web application market. A variety of framework architectures have been proposed, developed, and applied. Currently, the mainstream architecture mode is MVC, and its concept has also been widely applied in the PHP language.

[0003] The goal of MVC is to separate the software user interface from the business logic to enhance the scalability, reusability, and maintainability of the code. The View layer is the interface, the Model layer is the business logic, and the Controller layer is used to dispatch the View layer and the Model layer, organizing the user interface and business logic reasonably together, acting as an adhesive. Therefore, the content in the Controller should be minimized to provide the greatest flexibility.

[0004] On the other hand, in the existing applications of various PHP frameworks, the basic mode of MVC has been implemented. However, due to the complexity of the business logic, the business code in the Controller layer of the PHP framework is extremely complex, and the coupling degree of the code is low. To address this technical problem, Chinese Patent CN201510778388.2 mentions solving the high-coupling problem in the Controller layer by adding controller modularization. In this invention, different business templates are distinguished as different controllers in the application, and different controllers represent a module function of a control layer, performing a horizontal split on the control layer.

[0005] However, although this horizontal split of the control layer splits the specific functional modules, the complexity of the front-end application's connection to the business has not been reduced, and the problem of the control layer's complexity cannot be well solved. Summary of the Invention

[0006] The purpose of the embodiments of this application is to provide a code processing and business response method, device, computer equipment, and storage medium, which are used to reduce the coupling degree of business code in the control layer, increase the reusability of code modules, make the program architecture more clear and concise, convenient for maintenance, and are used to respond to business requests based on a framework with low coupling degree.

[0007] To this end, the first aspect of this application discloses a code processing method, which includes:

[0008] Identify the operation codes related to the database in the control layer code and / or the data layer code based on the control layer code and / or the data layer code in the MVC framework;

[0009] Strip the operation codes related to the database in the control layer code from the control layer code, and / or strip the operation codes related to the database in the data layer code from the data layer code;

[0010] Construct a logic layer code based on the operation codes related to the database in the control layer code and / or the operation codes related to the database in the data layer code, where the logic layer code is used to call the data layer code to access the data entities stored in the data layer and return the processing results of the data entities to the control layer;

[0011] Based on the control layer code in the MVC framework, identify the codes related to business implementation in the control layer code, and strip the codes related to business implementation in the control layer code from the control layer code to form an event layer code;

[0012] Construct the logic layer of the MVC framework according to the logic layer code and construct the event layer of the MVC framework according to the event layer code.

[0013] In the method of this application, by stripping the operation codes related to the database in the control layer code from the control layer code, and / or stripping the operation codes related to the database in the data layer code from the data layer code, the logic layer code and the event layer code can be constructed. In this way, the control layer code in the MVC framework can be decoupled, so that the control layer in the MVC framework purely performs task scheduling, and the operations on data entities and event operations are handed over to the logic layer and the event layer for processing. As a result, the code complexity in the control layer of the MVC framework is reduced, and the coupling degree of the control layer in the MVC framework is reduced. Furthermore, the reusability of the code modules in the MVC framework is improved, making the MVC framework clearer, more concise and easier to maintain.

[0014] Compared with the prior art, this application does not require horizontal splitting of the control layer according to the business type, so that the code complexity of the control layer can be better reduced. Especially in the prior art, as the number of services increases, horizontal splitting of the control layer based on the business type will generate many control modules, which in turn makes the code of the control layer become complex and not easy to maintain.

[0015] In the first aspect of the present application, as an alternative implementation, the codes related to business implementation in the control layer code include the codes related to the business requirements of sending text messages, initiating payment, third-party login, and token verification.

[0016] In this alternative implementation, by separating the codes related to the business requirements of sending text messages, initiating payment, third-party login, and token verification from the control layer, the control layer can be dedicated to task scheduling without performing specific business operations, thereby reducing the code complexity of the control layer. At the same time, by forming an event layer with the codes related to the business requirements of sending text messages, initiating payment, third-party login, and token verification, it is convenient to reuse these business operations.

[0017] In the first aspect of the present application, as an alternative implementation, the operation codes related to the database in the control layer code include the codes related to the definition of primary keys, automatic completion, data output formatting, type conversion, and table association.

[0018] In this alternative implementation, by separating the operation codes related to the database, including the codes related to the definition of primary keys, automatic completion, data output formatting, type conversion, and table association, from the control layer, the control layer can be dedicated to task scheduling without performing specific data entity operations, thereby reducing the code complexity of the control layer. At the same time, by forming a logic layer with the operation codes related to the database, including the codes related to the definition of primary keys, automatic completion, data output formatting, type conversion, and table association, it is convenient to reuse these data entity operations.

[0019] The second aspect of the present application discloses a business response method, which is applied to the method described in the first aspect of the present application. The method includes:

[0020] When a business request triggered by a user in the interface is received, the control layer in the MVC framework receives the business request and identifies the key operator identifier and / or business type carried by the business request;

[0021] Based on the control layer of the MVC framework and the key operator identifier, the logic layer of the MVC framework is called, so that the logic layer completes the operation on the target data entity according to the key operator identifier and obtains a first processing result;

[0022] And / or based on the control layer of the MVC framework and the business type, the event layer of the MVC framework is called, so that the event layer completes the target business operation according to the business type and obtains the second processing result;

[0023] Render the first processing result and the second processing result based on the view layer in the MVC framework to complete the response to the service request.

[0024] This application can use the method described in the first aspect of this application to respond to the user's service request. Furthermore, since the coupling degree between the control layer in the MVC framework and business operations and data entity operations is low, it is convenient to adjust and maintain the relevant code when business operations and data entity operations are modified.

[0025] In the second aspect of this application, as an optional implementation, before calling the event layer of the MVC framework based on the control layer and the service type of the MVC framework, so that the event layer completes the target business operation according to the service type and obtains the second processing result, the method further includes:

[0026] Determine whether the target business operation requires the first processing result. If the target business operation requires the first processing result, call the logic layer of the MVC framework so that the logic layer returns the first processing result to the event layer.

[0027] In this optional implementation, by determining whether the target business operation requires the first processing result, the mutual call between the event layer and the logic layer can be realized.

[0028] The third aspect of this application discloses a code processing device, and the device includes:

[0029] An identification module, configured to identify the operation code related to the database in the control layer code, and / or the operation code related to the database in the data layer code, based on the control layer code and / or the data layer code in the MVC framework;

[0030] A stripping module, configured to strip the operation code related to the database in the control layer code from the control layer code, and / or strip the operation code related to the database in the data layer code from the data layer code;

[0031] A construction module, configured to construct logic layer code according to the operation code related to the database in the control layer code, and / or the operation code related to the database in the data layer code, where the logic layer code is used to call the data layer code to access the data entity stored in the data layer and return the processing result of the data entity to the control layer;

[0032] The stripping module is further configured to identify the code related to business implementation in the control layer code based on the control layer code in the MVC framework, and strip the code related to business implementation in the control layer code from the control layer code to form event layer code;

[0033] The building block is further configured to build the logic layer of the MVC framework according to the logic layer code and build the event layer of the MVC framework according to the event layer code.

[0034] By executing the code processing method, the device of the present application can reduce the code complexity and coupling degree in the control layer of the MVC framework, thereby improving the reusability of the code modules in the MVC framework, making the MVC framework clearer and more concise, and facilitating maintenance.

[0035] In the third aspect of the present application, as an optional implementation, the code related to business implementation in the control layer code includes the code related to the business requirements of sending text messages, initiating payment, third-party login, and token verification.

[0036] The fourth aspect of the present application discloses a service response device, which includes:

[0037] A receiving module, configured to receive the service request based on the control layer in the MVC framework and identify the key operator identifier and / or service type carried by the service request when the user triggers a service request in the interface;

[0038] An invocation module, configured to invoke the logic layer of the MVC framework based on the control layer of the MVC framework and the key operator identifier, so that the logic layer completes the operation on the target data entity according to the key operator identifier and obtains a first processing result;

[0039] And / or the invocation module is further configured to invoke the event layer of the MVC framework based on the control layer of the MVC framework and the service type, so that the event layer completes the target service operation according to the service type and obtains the second processing result;

[0040] A rendering module, configured to render the first processing result and the second processing result based on the view layer in the MVC framework to complete the response to the service request.

[0041] By executing the service response method, the device of the present application has better code reusability and maintainability.

[0042] The fifth aspect of the present application discloses a computer device, including:

[0043] A processor; and

[0044] A memory, configured to store machine-readable instructions, which, when executed by the processor, execute the code processing method of the first aspect of the present application and the service response method of the second aspect of the present application.

[0045] By executing the code processing method and the service response method, the computer device of the present application can reduce the code complexity in the control layer of the MVC framework and the coupling degree of the control layer in the MVC framework, thereby improving the reusability of the code modules in the MVC framework, making the MVC framework clearer, more concise, and easier to maintain.

[0046] A sixth aspect of the present application discloses a storage medium storing a computer program, which is executed by a processor to perform the code processing method of the first aspect of the present application and the service response method of the second aspect of the present application.

[0047] By executing the code processing method and the service response method, the storage medium of the present application can reduce the code complexity in the control layer of the MVC framework and the coupling degree of the control layer in the MVC framework, thereby improving the reusability of the code modules in the MVC framework, making the MVC framework clearer, more concise, and easier to maintain. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] To more clearly illustrate the technical solutions of the embodiments of the present application, the following briefly introduces the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application and should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0049] Figure 1 is a schematic flowchart of the code processing method disclosed in Embodiment 1 of the present application;

[0050] Figure 2 is a schematic flowchart of a service response method disclosed in Embodiment 2 of the present application;

[0051] Figure 3 is a schematic structural diagram of a code processing device disclosed in Embodiment 3 of the present application;

[0052] Figure 4 is a schematic structural diagram of a service response device disclosed in Embodiment 4 of the present application;

[0053] Figure 5 is a schematic structural diagram of a computer device disclosed in Embodiment 5 of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0054] The following will describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application.

[0055] Embodiment 1

[0056] Please refer toFigure 1 , Figure 1 is a schematic flowchart of the code processing method disclosed in the embodiments of the present application. As Figure 1 shown, the code processing method of the embodiments of the present application includes the following steps:

[0057] 101. Based on the control layer code and / or data layer code in the MVC framework, identify the operation code related to the database in the control layer code, and / or the operation code related to the database in the data layer code;

[0058] 102. Strip the operation code related to the database from the control layer code in the control layer code, and / or strip the operation code related to the database from the data layer code in the data layer code;

[0059] 103. Construct the logic layer code according to the operation code related to the database in the control layer code, and / or the operation code related to the database in the data layer code, where the logic layer code is used to call the data layer code to access the data entity stored in the data layer and return the processing result of the data entity to the control layer;

[0060] 104. Based on the control layer code in the MVC framework, identify the code related to business implementation in the control layer code, and strip the code related to business implementation from the control layer code to form the event layer code;

[0061] 105. Construct the logic layer of the MVC framework according to the logic layer code and construct the event layer of the MVC framework according to the event layer code.

[0062] In the embodiments of the present application, the MVC (Model-View-Controller) framework is mainly used for the hierarchical development of application programs, and then separates the software user interface business logic to enhance the code scalability, reusability, and maintainability. Among them, the View layer is the interface, the Model layer is the business model (data model), and the Controller layer is used to schedule the View layer and the Mode layer to reasonably organize the user interface and business logic together. Currently, the code of a Controller mainly includes: the code for implementing business logic, and the code for operating on the data entity machine in the Model.

[0063] Currently, there is also a solution in the prior art to reduce the coupling degree between the Controller layer and the business logic. This solution is to set multiple Controller layers according to the business, so that each Controller layer is associated with one business logic instead of controlling multiple business logics. For example, set 3 Controller layers, and these three Controller layers are respectively used to be associated with Business 1, Business 2, and Business 3, rather than one Controller layer being used to be associated with Business 1, Business 2, and Business 3 at the same time. That is, this technical solution horizontally splits the Controller layer, so that the Controller only contains code related to one business and does not contain code related to multiple businesses. In this way, the code complexity of the Controller is reduced, and the Controller is not coupled with multiple businesses. However, although this solution horizontally splits the Controller according to different businesses, it does not split and simplify the code under one business. For example, assume that a software has two businesses, one is the business of implementing face login, and the other is the business of implementing third-party payment. According to the above method, only the original Controller is split into two Controllers (controllers) and used to implement the control logic of face login and the control logic of third-party payment respectively. However, the code in each Controller is not further vertically split. In this way, as the number of Controllers increases, the overall code complexity of the Controller layer in MVC has not been reduced.

[0064] In contrast, in the embodiments of the present application, the operation codes related to the database in the control layer code (the code corresponding to the control logic in the Controller) are stripped from the control layer code, and / or the operation codes related to the database in the data layer code are stripped from the data layer code, and then the logic layer code is constructed. In this way, by stripping the above codes, the code complexity in the Controller is further simplified, and the logic layer code formed after stripping can be called by multiple Controllers, thereby improving the reusability of the logic layer code. For example, ControllerA can call the logic layer code to implement Service A, and ControllerB can call the logic layer code to implement Service B. On the other hand, in the embodiments of the present application, the codes related to service implementation in the control layer code in the Controller are stripped to form the event layer code, which can further simplify the code complexity in the Controller and enable the event layer code to be reused. For example, assuming that both Service A and Service B need to use third-party authentication, the Controller corresponding to Service A can implement third-party authentication by calling the event layer code, and the Controller corresponding to Service B can also implement third-party authentication by calling the event layer code, so that there is no need to write the codes related to implementing third-party authentication in the Controller corresponding to Service A and then write the codes related to implementing third-party authentication in the Controller corresponding to Service B. To sum up, compared with the prior art, the embodiments of the present application can vertically split the codes in the Controller, thereby simplifying the codes in the Controller. On the other hand, the logic layer code and the event layer code obtained by vertical splitting can be reused by the Controller, thereby improving the reusability of this part of the codes.

[0065] In the embodiments of the present application, the control layer code in the MVC framework refers to the code in the Controller in the MVC framework.

[0066] In the embodiments of the present application, the control layer code in the MVC framework refers to the code in the Controller in the MVC framework.

[0067] In the embodiments of the present application, the data layer code in the MVC framework refers to the code in the Model in the MVC framework.

[0068] In the embodiments of the present application, the operation code related to the database in the control layer code refers to the code used to operate the database, such as operations like reading from the database, querying business-related data, etc. It should be noted that the data layer code in the MVC framework is used to implement more underlying data operations, such as defining primary keys, automatic completion, data output formatting, type conversion, table association definition, etc., which are strongly related to the database. On the other hand, when implementing a certain function, the logic layer code can call the data layer code in the MVC framework to achieve it.

[0069] In the embodiments of the present application, the code related to business implementation in the control layer code refers to the code for implementing business logic. For example, in the process of face recognition, the code related to image recognition is the code related to business implementation.

[0070] In the embodiments of the present application, as an alternative implementation, the code related to business implementation in the control layer code includes the code related to the business requirements of sending text messages, initiating payments, third-party login, and token verification.

[0071] In this alternative implementation, by separating the code related to the business requirements of sending text messages, initiating payments, third-party login, and token verification from the control layer, the control layer can be dedicated to task scheduling without performing specific business operations, thereby reducing the code complexity of the control layer. At the same time, by forming an event layer with the code related to the business requirements of sending text messages, initiating payments, third-party login, and token verification, it is convenient to reuse these business operations.

[0072] In the embodiments of the present application, as an alternative implementation, the operation code related to the database in the control layer code includes the code related to the definition of primary keys, automatic completion, data output formatting, type conversion, and table association.

[0073] In this alternative implementation, by separating the operation code related to the database, including the code related to the definition of primary keys, automatic completion, data output formatting, type conversion, and table association, from the control layer, the control layer can be dedicated to task scheduling without performing specific data entity operations, thereby reducing the code complexity of the control layer. At the same time, by forming a logic layer with the operation code related to the database, including the code related to the definition of primary keys, automatic completion, data output formatting, type conversion, and table association, it is convenient to reuse these data entity operations.

[0074] Embodiment 2

[0075] Please refer to Figure 2 , Figure 2It is a schematic flowchart of a service response method disclosed in an embodiment of the present application. Among them, this method is applied to the code processing method in Embodiment 1 of the present application. As Figure 2 shown, the service response method of the embodiment of the present application includes the following steps:

[0076] 201. When a service request triggered by a user in the interface is received, the control layer in the MVC framework receives the service request and identifies the key operator identifier and / or service type carried by the service request;

[0077] 202. Based on the control layer of the MVC framework and the key operator identifier, the logic layer of the MVC framework is called, so that the logic layer completes the operation on the target data entity according to the key operator identifier and obtains a first processing result;

[0078] 203. And / or based on the control layer of the MVC framework and the service type, the event layer of the MVC framework is called, so that the event layer completes the target service operation according to the service type and obtains a second processing result;

[0079] 204. Based on the view layer in the MVC framework, the first processing result and the second processing result are rendered to complete the response to the service request.

[0080] The embodiment of the present application can use the method in Embodiment 1 of the present application to respond to the service request of the user. Furthermore, since the coupling degree between the control layer in the MVC framework and the service operation and the data entity operation is low, it is convenient to adjust and maintain the relevant code when the service operation and the data entity operation are modified.

[0081] In the embodiment of the present application, as an optional implementation manner, before step 203: based on the control layer of the MVC framework and the service type, the event layer of the MVC framework is called, so that the event layer completes the target service operation according to the service type and obtains a second processing result, the method of the embodiment of the present application further includes the following steps:

[0082] Judge whether the target service operation requires the first processing result. If the target service operation requires the first processing result, call the logic layer of the MVC framework, so that the logic layer returns the first processing result to the event layer.

[0083] In this optional implementation manner, by judging whether the target service operation requires the first processing result, the mutual call between the event layer and the logic layer can be realized.

[0084] Embodiment 3

[0085] Please refer to Figure 3 , Figure 3 It is a schematic structural diagram of a code processing device disclosed in an embodiment of the present application. As Figure 3 shown, the device of the embodiment of the present application includes the following functional modules:

[0086] An identification module 301, configured to identify operation codes related to a database in the control layer code and / or operation codes related to the database in the data layer code based on the control layer code and / or the data layer code in the MVC framework;

[0087] A stripping module 302, configured to strip the operation codes related to the database in the control layer code from the control layer code and / or strip the operation codes related to the database in the data layer code from the data layer code;

[0088] A construction module 303, configured to construct logic layer code according to the operation codes related to the database in the control layer code and / or the operation codes related to the database in the data layer code, where the logic layer code is used to call the data layer code to access data entities stored in the data layer and return the processing results of the data entities to the control layer;

[0089] The stripping module 302 is further configured to identify the codes related to business implementation in the control layer code based on the control layer code in the MVC framework, and strip the codes related to business implementation in the control layer code from the control layer code to form event layer code;

[0090] The construction module 303 is further configured to construct the logic layer of the MVC framework according to the logic layer code and construct the event layer of the MVC framework according to the event layer code.

[0091] By executing the code processing method, the device according to the embodiment of the present application can vertically split the code in the Controller, thereby simplifying the code in the Controller. On the other hand, the logic layer code and event layer code obtained by vertical splitting can be reused by the Controller, thereby improving the reusability of this part of the code. In the embodiment of the present application, as an optional implementation manner, the codes related to business implementation in the control layer code include codes related to the service requirements of sending text messages, the service requirements of initiating payments, the service requirements of third-party logins, and the service requirements of token verification.

[0092] Embodiment 4

[0093] Please refer to Figure 4 , Figure 4 which is a schematic structural diagram of a service response device disclosed in the embodiment of the present application. As Figure 4 shown, the device according to the embodiment of the present application includes the following functional modules:

[0094] A receiving module 401, configured to receive a service request and identify a key operator identifier and / or service type carried by the service request based on the control layer in the MVC framework when a service request triggered by a user in the interface;

[0095] A calling module 402, configured to call the logic layer of the MVC framework based on the control layer of the MVC framework and the key operator identifier, so that the logic layer completes operations on the target data entity according to the key operator identifier and obtains a first processing result;

[0096] And / or the calling module 402 is further configured to call the event layer of the MVC framework based on the control layer of the MVC framework and the service type, so that the event layer completes the target service operation according to the service type and obtains a second processing result;

[0097] A rendering module 403, configured to render the first processing result and the second processing result based on the view layer in the MVC framework to complete the response to the service request.

[0098] The device according to the embodiment of the present application has better code reusability and maintainability by executing the service response method.

[0099] Embodiment Five

[0100] Please refer to Figure 5 , Figure 5 which is a schematic structural diagram of a computer device disclosed in the embodiment of the present application. As Figure 5 shown, the computer device according to the embodiment of the present application includes:

[0101] A processor 501; and

[0102] A memory 502, configured to store machine-readable instructions, which, when executed by the processor 501, execute the code processing method according to Embodiment One of the present application and the service response method according to Embodiment Two of the present application.

[0103] The computer device according to the embodiment of the present application can reduce the code complexity in the control layer of the MVC framework and reduce the coupling degree of the control layer in the MVC framework by executing the code processing method and the service response method, thereby improving the reusability of the code modules in the MVC framework, making the MVC framework clearer and more concise, and facilitating maintenance.

[0104] Embodiment Six

[0105] The embodiment of the present application discloses a storage medium storing a computer program, and the computer program is executed by a processor to perform the code processing method according to Embodiment One of the present application and the service response method according to the second embodiment of the present application.

[0106] By executing the code processing method and the service response method, the storage medium according to the embodiments of the present application can vertically split the code in the Controller, thereby simplifying the code in the Controller. On the other hand, the logic layer code and the event layer code obtained by vertical splitting can be reused by the Controller, thereby improving the reusability of this part of the code. In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical function division, and there may be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some communication interfaces, and the indirect couplings or communication connections of devices or units can be in electrical, mechanical or other forms.

[0107] In addition, the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0108] Furthermore, in each embodiment of the present application, the various functional modules can be integrated together to form an independent part, or each module can exist alone, or two or more modules can be integrated to form an independent part.

[0109] It should be noted that if the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods in the various embodiments of the present application. And the aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.

[0110] In this document, relational terms such as first and second are used solely to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.

[0111] The above are only embodiments of the present application and are not intended to limit the protection scope of the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included within the protection scope of the present application.

Claims

1. A code processing method, characterized in that The method includes: Based on the control layer code and / or data layer code in the MVC framework, identifying the database-related operation code in the control layer code and / or the database-related operation code in the data layer code; Stripping the database-related operation code in the control layer code from the control layer code and / or stripping the database-related operation code in the data layer code from the data layer code; Constructing logic layer code according to the database-related operation code in the control layer code and / or the database-related operation code in the data layer code, wherein the logic layer code is used to call the data layer code to access the data entity stored in the data layer and return the processing result of the data entity to the control layer; Based on the control layer code in the MVC framework, identifying the code related to business implementation in the control layer code and stripping the code related to business implementation in the control layer code from the control layer code to form event layer code; Constructing the logic layer of the MVC framework according to the logic layer code and constructing the event layer of the MVC framework according to the event layer code; Moreover, the code related to business implementation in the control layer code includes the code related to the business requirements of sending text messages, initiating payment, third-party login, and token verification.

2. The method according to claim 1, wherein The database-related operation code in the control layer code includes the code related to the definition of primary keys, auto-completion, data output formatting, type conversion, and table association.

3. A service response method, characterized in that, The method is applied to the method described in any one of claims 1-2, and the method includes: When a business request is triggered by a user in the interface, receiving the business request based on the control layer in the MVC framework and identifying the key operator identifier and / or business type carried by the business request; Based on the control layer of the MVC framework and the key operator identifier, calling the logic layer of the MVC framework, so that the logic layer completes the operation on the target data entity according to the key operator identifier and obtains a first processing result; And / or based on the control layer of the MVC framework and the business type, calling the event layer of the MVC framework, so that the event layer completes the target business operation according to the business type and obtains a second processing result; Rendering the first processing result and the second processing result based on the view layer in the MVC framework to complete the response to the business request.

4. The method according to claim 3, wherein Before calling the event layer of the MVC framework based on the control layer of the MVC framework and the business type, so that the event layer completes the target business operation according to the business type and obtains the second processing result, the method further includes: Judging whether the target business operation requires the first processing result. If the target business operation requires the first processing result, calling the logic layer of the MVC framework so that the logic layer returns the first processing result to the event layer.

5. A code processing device, characterized in that, The device includes: An identification module, configured to identify operation codes related to a database in the control layer code and / or data layer code based on the control layer code and / or data layer code in the MVC framework; A stripping module, configured to strip the operation codes related to the database from the control layer code in the control layer code and / or strip the operation codes related to the database from the data layer code in the data layer code; A construction module, configured to construct logic layer code according to the operation codes related to the database in the control layer code and / or the operation codes related to the database in the data layer code, wherein the logic layer code is used to call the data layer code to access data entities stored in the data layer and return the processing results of the data entities to the control layer; The stripping module is further configured to identify the codes related to business implementation in the control layer code based on the control layer code in the MVC framework, and strip the codes related to business implementation in the control layer code from the control layer code to form event layer code; The construction module is further configured to construct the logic layer of the MVC framework according to the logic layer code and construct the event layer of the MVC framework according to the event layer code; Moreover, the codes related to business implementation in the control layer code include codes related to the service requirements of sending text messages, initiating payment services, third-party login services, and token verification services.

6. A service response device, characterized in that, The service response device is applied to the code processing device as claimed in claim 5, and the service response device includes: A receiving module, configured to, when a service request triggered by a user in the interface is received, receive the service request based on the control layer in the MVC framework and identify the key operator identifier and / or service type carried by the service request; An invocation module, configured to invoke the logic layer of the MVC framework based on the control layer of the MVC framework and the key operator identifier, so that the logic layer completes the operation on the target data entity according to the key operator identifier and obtains a first processing result; And / or the invocation module is further configured to invoke the event layer of the MVC framework based on the control layer of the MVC framework and the service type, so that the event layer completes the target service operation according to the service type and obtains a second processing result; A rendering module, configured to render the first processing result and the second processing result based on the view layer in the MVC framework to complete the response to the service request.

7. A computer device, characterized in that, Comprising: A processor; And A memory, configured to store machine-readable instructions, which, when executed by the processor, execute the code processing method as claimed in any one of claims 1-2, and the service response method as claimed in any one of claims 3-5.

8. A storage medium, characterized in that, The storage medium stores a computer program, and the computer program is executed by the processor to execute the code processing method as claimed in any one of claims 1-2, and the service response method as claimed in any one of claims 3-4.

Citation Information

Patent Citations

  • Realizing method and system of WEB management platform in WVC (model, view, controller) mode

    CN105468355A

  • Service processing method, device and system based on MVC layering

    CN106790067A