Micro-service-based business processing method, apparatus and device, and storage medium
Patent Information
- Application Number
- CN202310994304.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-08
- Publication Date
- 2026-09-11
- Estimated Expiration
- 2043-08-08
AI Technical Summary
[0005]本申请提供一种基于微服务的业务处理方法、装置、设备及存储介质,用以解决现有基于微服务的业务处理中微服务的调用流程复杂、整个代码过于厚重、维护难度和维护成本都过高等问题
Smart Images

Figure CN117014515B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of big data technology, and in particular to a business processing method, apparatus, device and storage medium based on microservices. Background Technology
[0002] As the types of transaction businesses increase, microservices that implement different functions are also emerging. Front-end access microservices serve as the entry point for receiving front-end requests, and are used to call different microservices to perform corresponding business processing according to different transaction scenarios.
[0003] However, in real-world applications, there are situations where the names of the parameters sent by the front-end differ from those used by the back-end microservices. This necessitates processing the front-end parameters and the back-end microservices to ensure correct microservice invocation and business processing. Currently, this is typically handled by writing code for each transaction field individually. However, due to the large number of transaction types, especially when calling numerous microservices and dealing with a large number of parameter fields, the code becomes excessively cumbersome, leading to high maintenance difficulty and costs.
[0004] Therefore, there is an urgent need for a new microservice-based business processing method to simplify the microservice calling process and reduce the overall maintenance difficulty and cost. Summary of the Invention
[0005] This application provides a microservice-based business processing method, apparatus, device, and storage medium to solve the problems of complex microservice call processes, excessively thick code, and high maintenance difficulty and cost in existing microservice-based business processing.
[0006] Firstly, this application provides a microservice-based business processing method, the method comprising:
[0007] Obtain business request information sent by the front end; wherein, the business request information includes a pending business code;
[0008] Based on the business request information, the value of the front-end sent parameters is determined; wherein, the front-end sent parameters are the front-end parameter information involved when calling the microservice to process the pending business indicated by the pending business code;
[0009] The first configuration file is retrieved, and the values of the backend usage parameters are determined based on the values of the frontend uploaded parameters and the first configuration file. The backend usage parameters are the corresponding backend parameter information required when calling the microservice to process the pending business indicated by the pending business code. The first configuration file includes the mapping relationship information between the frontend uploaded parameters and the backend usage parameters.
[0010] Based on the value of the backend usage parameters, the microservice is invoked to process the pending business indicated by the pending business code, and the backend return parameters are determined; wherein, the backend return parameters represent the processing result of the microservice in processing the pending business indicated by the pending business code.
[0011] Return response information to the front end; wherein, the response information includes the value of the parameter returned by the back end and the value of the parameter displayed on the front end.
[0012] Optionally, based on the values of the parameters sent from the front end and the first configuration file, the values of the parameters used in the back end are determined, including:
[0013] Read the value of the front-end uploaded parameter, traverse the first configuration file, and if it is determined that there is a back-end usage parameter in the first configuration file that corresponds to the front-end uploaded parameter, then assign the value of the front-end uploaded parameter to the corresponding value of the back-end usage parameter to obtain the value of the back-end usage parameter.
[0014] Optionally, based on the business request information, the values of the parameters sent by the front end are determined, including:
[0015] The business request information is parsed, and based on the pending business code in the business request information, the microservice invocation method corresponding to the pending business indicated by the pending business code is determined; wherein, the microservice invocation method includes parameters sent from the front end;
[0016] Based on the parsed business request information, the parameters sent by the front end are configured to obtain the values of the parameters sent by the front end.
[0017] Optionally, based on the value of the backend usage parameters, the microservice is invoked to process the pending task indicated by the pending task code, and the backend return parameters are determined, including:
[0018] Based on the value of the backend usage parameters, and in accordance with the calling order of the pending business indicated by the processing pending business code, each microservice is called sequentially to execute the business processing task.
[0019] The processing results obtained after each microservice executes the business processing task in the order of invocation are determined as the backend return parameters.
[0020] Optionally, before returning response information to the front end, the method further includes:
[0021] The second configuration file is retrieved, and the values of the front-end display parameters are determined based on the backend returned parameters and the second configuration file; wherein, the front-end display parameters are the corresponding parameter information of the backend returned parameters displayed on the front end, and the second configuration file includes the mapping relationship information between the backend returned parameters and the front-end display parameters, as well as the field length of the value of the front-end display parameters;
[0022] The response information is generated based on the values of the front-end display parameters.
[0023] Optionally, based on the backend returned parameters and the second configuration file, the values of the frontend display parameters are determined, including:
[0024] Read the value of the backend returned parameter, traverse the second configuration file, and if it is determined that there is a frontend display parameter in the second configuration file that corresponds to the backend returned parameter, then process the value of the backend returned parameter based on the field length of the value of the frontend display parameter;
[0025] The processed backend return parameter value is assigned to the corresponding value of the frontend display parameter to obtain the value of the frontend display parameter.
[0026] Optionally, based on the field length of the value of the front-end displayed parameter, the value of the back-end returned parameter is processed, including:
[0027] If it is determined that the field length of the value of the front-end display parameter is less than the field length of the value of the back-end returned parameter, then the value of the back-end returned parameter is truncated.
[0028] Secondly, this application provides a microservice-based business processing apparatus, the apparatus comprising:
[0029] The acquisition unit is used to acquire business request information sent by the front end; wherein, the business request information includes a pending business code;
[0030] A configuration unit is used to determine the value of the front-end uploaded parameters based on the business request information; wherein, the front-end uploaded parameters are front-end parameter information involved when calling the microservice to process the pending business indicated by the pending business code;
[0031] A matching unit is used to retrieve a first configuration file and determine the value of a backend usage parameter based on the value of the frontend-up parameter and the first configuration file; wherein, the backend usage parameter is the corresponding backend parameter information required when calling the microservice to process the pending business indicated by the pending business code, and the first configuration file includes the mapping relationship information between the frontend-up parameter and the backend usage parameter;
[0032] A business processing unit is used to call a microservice to process the pending business indicated by the pending business code based on the value of the backend usage parameters, and determine the backend return parameters; wherein, the backend return parameters represent the processing result of the microservice in processing the pending business indicated by the pending business code.
[0033] A sending unit is used to return response information to the front end; wherein the response information includes the value of the front end display parameter of the back end returned by the back end.
[0034] Thirdly, this application provides an electronic device, the electronic device comprising: a processor, and a memory communicatively connected to the processor;
[0035] The memory stores computer-executed instructions;
[0036] The processor executes computer execution instructions stored in the memory to implement the method described above.
[0037] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described above.
[0038] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, is used to implement the method described above.
[0039] This application provides a microservice-based business processing method, apparatus, device, and storage medium, comprising: acquiring business request information sent by a frontend; wherein the business request information includes a pending business code; determining the value of frontend-up parameters based on the business request information; wherein the frontend-up parameters are frontend parameter information involved when calling a microservice to process the pending business indicated by the pending business code; retrieving a first configuration file, and determining the value of backend-used parameters based on the value of the frontend-up parameters and the first configuration file; wherein the backend-used parameters are corresponding backend parameter information required when calling a microservice to process the pending business indicated by the pending business code, and the first configuration file includes mapping relationship information between frontend-up parameters and backend-used parameters; calling a microservice to process the pending business indicated by the pending business code based on the value of the backend-used parameters, and determining backend-return parameters; wherein the backend-return parameters represent the processing result of the microservice processing the pending business indicated by the pending business code; and returning response information to the frontend; wherein the response information includes the value of the backend-return parameters displayed on the frontend. The proposed solution uses configuration files to map front-end parameters to back-end parameters, without requiring changes to other calling logic. This simplifies the process of calling microservices to handle business logic. When front-end and / or back-end parameters change, no code modification is needed, or only minor modifications are required, such as modifying the configuration file. This approach offers greater flexibility and scalability, facilitates subsequent maintenance, reduces maintenance difficulty, and lowers maintenance costs. Attached Figure Description
[0040] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0041] Figure 1 A flowchart illustrating a microservice-based business processing method provided in this application embodiment;
[0042] Figure 2 A flowchart illustrating a method for generating response information provided in an embodiment of this application;
[0043] Figure 3 A schematic diagram of the structure of a microservice-based business processing device provided in this application embodiment;
[0044] Figure 4 A schematic diagram of the structure of another microservice-based business processing device provided in an embodiment of this application;
[0045] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0046] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0047] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0048] It should be noted that if this application involves user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.), all of which are information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with relevant laws, regulations and standards, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0049] It should be noted that the microservice-based business processing method, apparatus, device, and storage medium of this application can be used in the field of big data technology, or in any field other than big data technology. This application does not limit the application field of the microservice-based business processing method, apparatus, device, and storage medium.
[0050] Microservices are an architecture and organizational approach to developing software in which software consists of small, independent services that communicate through well-defined APIs. Microservice architecture makes applications easier to scale and develop faster, thereby accelerating innovation and shortening time to market for new features.
[0051] The front-end microservice serves as the entry point for receiving front-end requests and invoking different microservices for corresponding business processing based on different transaction scenarios. However, in real-world applications, there are situations where the names of parameters sent by the front-end differ from those used by the back-end microservices, making the microservice invocation process complex and difficult to implement. Currently, the common approach is to write code for each transaction field individually to handle the parameters sent by the front-end and those required by the back-end microservices. However, with over 400 existing transaction types, approximately 12 microservices may need to be invoked. When there are many microservices and parameter fields, this coding approach results in an overly cumbersome application codebase, leading to excessively high maintenance difficulty and costs. Furthermore, adding new transactions or changing fields in existing transactions requires code modifications, further increasing maintenance difficulty and costs, and making the approach inflexible and inconvenient to implement.
[0052] To address the aforementioned issues, this application provides a microservice-based business processing method. It pre-establishes a mapping relationship between the fields submitted by the front-end and the fields used in the back-end for each type of transaction. Microservice calls and maintenance are performed via configuration files for unified management. When new or modified fields are added, the entire code logic remains unchanged; only the configuration file needs to be modified, without altering the original code. This approach unifies the processing logic, simplifies code development, and increases scalability and flexibility.
[0053] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0054] Figure 1 This is a flowchart illustrating a microservice-based business processing method provided in an embodiment of this application. The execution entity in this embodiment can be a microservice-based business processing device, which can be located on an electronic device, such as a mobile terminal, mobile phone, tablet, or computer; this application does not impose any limitations. This embodiment uses a microservice-based business processing device as an example for detailed explanation.
[0055] like Figure 1 As shown, the microservice-based business processing method provided in this embodiment includes:
[0056] S101. Obtain the business request information sent by the front end; the business request information includes the pending business code.
[0057] For example, when calling a microservice for business processing, the microservice-based business processing device of this application first obtains business request information sent by the front end. This business request information can be received from the front end accessing the microservice, and it should include a pending business code (i.e., a pending business ID). Based on the pending business code, the corresponding pending business can be determined, and then the corresponding business processing scheme can be determined based on the pending business, that is, the microservice to be called and its calling logic can be determined. Of course, the business request information can also include other information according to actual needs, and this application does not impose any restrictions.
[0058] S102. Based on the business request information, determine the value of the front-end sent parameters; wherein, the front-end sent parameters are the front-end parameter information involved when calling the microservice to process the pending business code.
[0059] For example, after obtaining the business request information sent by the front end, the microservice-based business processing device of this application can determine the value of the front end-up parameters based on the business request information. The front end-up parameters refer to the front end parameter information involved when calling a microservice to process the pending business indicated by the pending business code, such as the name, identifier, or fields of the microservice to be called on the front end.
[0060] This application does not impose restrictions on how the values of parameters sent to the front end are determined based on business request information. In one example, determining the values of parameters sent to the front end based on business request information could include:
[0061] S1021. Parse the business request information, and based on the pending business code in the business request information, determine the microservice calling method corresponding to the pending business indicated by the pending business code; wherein, the microservice calling method includes the parameters sent by the front end.
[0062] S1022. Based on the parsed business request information, configure the parameters sent by the front end and obtain the values of the parameters sent by the front end.
[0063] For example, the microservice-based business processing apparatus of this application can parse business request information, determine the specific content contained in the business request information, and then determine the pending business indicated by the pending business code based on the pending business code in the business request information. This allows for the determination of a microservice invocation scheme for processing the pending business, which includes front-end uploaded parameters. Then, based on the parsed business request information (i.e., the specific content contained in the business request information), the front-end uploaded parameters are configured to obtain their values.
[0064] S103. Retrieve the first configuration file and determine the value of the backend usage parameters based on the values of the parameters sent by the frontend and the first configuration file. The backend usage parameters are the corresponding backend parameter information required when calling the microservice to process the pending business code. The first configuration file includes the mapping relationship information between the parameters sent by the frontend and the backend usage parameters.
[0065] For example, the microservice-based business processing device of this application retrieves a first configuration file, wherein the first configuration file should be the configuration file corresponding to the pending business indicated by the pending business code. When processing different pending businesses, the corresponding first configuration file is also different. The first configuration file should include mapping relationship information between front-end uploaded parameters and back-end used parameters, wherein the back-end used parameters refer to the corresponding back-end parameter information required when calling the microservice to process the pending business indicated by the pending business code.
[0066] For example, since the specific names of the parameters sent from the front end and the parameters used in the back end may be different, this application determines the value of the parameters used in the back end based on the value of the parameters sent from the front end determined based on the business request information and the first configuration file retrieved, so as to correctly call the microservice to process pending business in the future.
[0067] Furthermore, this application does not limit the specific form of the first configuration file. For example, the first configuration file can be a properties configuration file. For instance, the first configuration file might have the following form:
[0068] In the first configuration file, "method_RECEIVE = RFPARAM1|RBPARAM1,RFPARAM2|RBPARAM2,RFPARAM3|RBPARAM3", the parameters before the vertical bar are the parameters sent by the front end, and the parameters after the vertical bar are the parameters used by the back end. This first configuration file can be used to determine the mapping relationship between the parameters sent by the front end and the parameters used by the back end.
[0069] This application does not restrict how the values of parameters used in the backend are determined based on the values of parameters sent from the frontend and the first configuration file. For example, it can be implemented using reflection. Java's reflection mechanism allows the creation of objects of any class, the understanding of the class to which any object belongs, the understanding of the member variables and methods of any class, and the invocation of the attributes and methods of any object during program execution. This ability to dynamically obtain program information and dynamically invoke objects is called Java's reflection mechanism, which is considered key to dynamic languages. This application can also utilize reflection to determine the values of parameters used in the backend based on the values of parameters sent from the frontend and the first configuration file.
[0070] In one example, determining the values of parameters used by the backend based on the values of parameters sent from the frontend and the first configuration file can include:
[0071] Read the value of the parameter sent from the front end, traverse the first configuration file, and if it is determined that there is a backend usage parameter in the first configuration file that corresponds to the parameter sent from the front end, then assign the value of the parameter sent from the front end to the corresponding value of the backend usage parameter to obtain the value of the backend usage parameter.
[0072] For example, the microservice-based business processing device of this application reads the values of front-end uploaded parameters and simultaneously traverses the retrieved first configuration file. Based on the values of the front-end uploaded parameters and the front-end uploaded parameters and back-end usage parameters in the first configuration file, the value of the back-end usage parameter can be determined. Specifically, the configuration file can be used as a reference. If it is determined that a back-end usage parameter corresponding to the front-end uploaded parameter exists in the first configuration file, and the value of the front-end uploaded parameter determined based on the business request information also exists, then the value of the front-end uploaded parameter is assigned to the corresponding value of the back-end usage parameter to obtain the value of the back-end usage parameter, so that subsequent business processing can be performed based on the value of the back-end usage parameter. If it is determined that a back-end usage parameter corresponding to the front-end uploaded parameter exists in the first configuration file, but the front-end uploaded parameter determined based on the business request information does not exist or its corresponding value does not exist, then the back-end usage parameter can be determined to be an empty string (null). If it is determined that the front-end uploaded parameter determined based on the business request information does not exist in the first configuration file, then the front-end uploaded parameter is not retrieved and can be directly discarded. Thus, the correspondence between the parameters between the front-end and back-end, and the value of the front-end uploaded parameter in the back-end usage parameter are determined, thereby facilitating subsequent business processing.
[0073] In addition, when assigning the value of the parameter sent from the front end to the corresponding value of the parameter used in the back end, if the character lengths of the two do not match, certain processing can be performed, such as truncating extra characters, etc. This application does not impose any restrictions.
[0074] S104. Based on the value of the backend usage parameters, call the microservice to process the pending business indicated by the pending business code, and determine the backend return parameters; wherein, the backend return parameters represent the processing result of the microservice processing the pending business indicated by the pending business code.
[0075] For example, once the value of the front-end uploaded parameter in the back-end usage parameter is determined, the microservice-based business processing device of this application can call the microservice to process the pending business indicated by the pending business code based on the value of the back-end usage parameter, thereby obtaining the back-end returned parameter.
[0076] In one example, based on the value of the parameters used by the backend, the microservice is invoked to process the pending task indicated by the pending task code. The parameters returned by the backend can include:
[0077] S1041. Based on the value of the backend usage parameters, and in accordance with the calling order of the pending business as indicated by the processing pending business code, each microservice is called sequentially to execute the business processing task.
[0078] S1042. The processing results obtained after each microservice has completed its business processing tasks in the order of invocation are determined as the backend return parameters.
[0079] For example, once the value of the backend parameter is determined, the corresponding microservice to be called and the parameter information involved are also determined. When processing business, each microservice is called in turn to execute the business processing task according to the calling order of the pending business code. After all microservices have completed their corresponding business processing tasks, the processing result is obtained. The obtained processing result is the parameter that the backend should return.
[0080] This application does not impose restrictions on the parameters returned by the backend, but they should correspond to the pending tasks, and each pending task should have a corresponding type of backend returned parameter.
[0081] S105. Return response information to the front end; the response information includes the values of the parameters returned by the back end and the parameters displayed on the front end.
[0082] For example, after completing the business processing, the microservice-based business processing device of this application returns response information to the front end, including the values of the parameters returned by the back end and the parameters displayed on the front end, so that the user can view the business processing results on the front end.
[0083] The microservice-based business processing method provided in this application includes: obtaining business request information sent by a frontend; wherein the business request information includes a pending business code; determining the value of frontend-up parameters based on the business request information; wherein the frontend-up parameters are frontend parameter information involved when calling the microservice to process the pending business indicated by the pending business code; retrieving a first configuration file, and determining the value of backend-used parameters based on the value of the frontend-up parameters and the first configuration file; wherein the backend-used parameters are corresponding backend parameter information required when calling the microservice to process the pending business indicated by the pending business code, and the first configuration file includes mapping relationship information between the frontend-up parameters and the backend-used parameters; calling the microservice to process the pending business indicated by the pending business code based on the value of the backend-used parameters, and determining backend-returned parameters; wherein the backend-returned parameters represent the processing result of the microservice processing the pending business indicated by the pending business code; and returning response information to the frontend; wherein the response information includes the value of the backend-returned parameters displayed on the frontend. The proposed solution uses configuration files to map front-end parameters to back-end parameters, without requiring changes to other calling logic. This simplifies the process of calling microservices to handle business logic. When front-end and / or back-end parameters change, no code modification is needed, or only minor modifications are required, such as modifying the configuration file. This approach offers greater flexibility and scalability, facilitates subsequent maintenance, reduces maintenance difficulty, and lowers maintenance costs.
[0084] Based on the above embodiments, in some examples, there may be inconsistencies between the parameters returned by the backend and the parameters displayed on the frontend. Therefore, before returning response information to the frontend, it is necessary to perform certain conversion processing on the parameters returned by the backend to generate correct response information.
[0085] For example, Figure 2 This is a flowchart illustrating a method for generating response information provided in an embodiment of this application. Figure 2 As shown in the embodiments of this application, the method for generating response information includes:
[0086] S201. Retrieve the second configuration file and determine the values of the front-end display parameters based on the backend return parameters and the second configuration file. The front-end display parameters are the corresponding parameter information of the backend return parameters displayed on the front end. The second configuration file includes the mapping relationship information between the backend return parameters and the front-end display parameters, as well as the field length of the values of the front-end display parameters.
[0087] S202. Generate response information based on the values of the front-end display parameters.
[0088] For example, when generating response information, the microservice-based business processing device of this application first retrieves a second configuration file. This second configuration file corresponds to the processing result obtained after the microservice processes the pending business code. Different transaction businesses should have different second configuration files. The second configuration file may include mapping information between backend return parameters and frontend display parameters, as well as the field length of the frontend display parameter values. Frontend display parameters refer to the corresponding parameter information displayed on the frontend based on the backend return parameters. This application does not limit their specific content; it is determined based on the pending business, such as transaction result information, query result information, etc. Based on the backend return parameters obtained from processing the pending business and the retrieved second configuration file, the values of the frontend display parameters can be determined so that response information can be generated based on these values.
[0089] This application does not restrict how the values of the front-end display parameters are determined based on the backend returned parameters and the second configuration file; it can also be implemented using reflection. In one example, determining the values of the front-end display parameters based on the backend returned parameters and the second configuration file could include:
[0090] S10. Read the value of the parameter returned by the backend, traverse the second configuration file, and if it is determined that there is a front-end display parameter in the second configuration file that corresponds to the parameter returned by the backend, then process the value of the parameter returned by the backend based on the field length of the value of the front-end display parameter.
[0091] S20. Assign the processed backend returned parameter value to the corresponding value of the frontend display parameter to obtain the frontend display parameter value.
[0092] For example, this application's microservice-based business processing device reads the value of the backend returned parameter and simultaneously traverses the retrieved second configuration file. Then, based on the read backend returned parameter value and the mapping relationship information between the backend returned parameter and the frontend display parameter in the second configuration file, it determines the value of the frontend display parameter. Specifically, taking the second configuration file as an example, if it is determined that a frontend display parameter corresponding to the backend returned parameter exists in the second configuration file, and the value of the backend returned parameter also exists, then the value of the backend returned parameter is processed based on the field length of the frontend display parameter value in the second configuration file to obtain the processed backend returned parameter value. This processed backend returned parameter value is then assigned to the corresponding value of the frontend display parameter to obtain the value of the frontend display parameter. However, if it is determined that a frontend display parameter corresponding to the backend returned parameter exists in the second configuration file, but the backend returned parameter does not exist or its corresponding value does not exist, then the value of the frontend display parameter is determined to be an empty string.
[0093] For example, processing the value of the parameter returned by the backend based on the field length of the value of the parameter displayed on the frontend can include:
[0094] If it is determined that the field length of the parameter value displayed on the front end is less than the field length of the parameter value returned by the back end, then the value of the parameter returned by the back end will be truncated.
[0095] For example, by comparing the field length of the value of the front-end displayed parameter with the field length of the corresponding value of the back-end returned parameter, if it is determined that the field length of the value of the front-end displayed parameter is less than the field length of the value of the back-end returned parameter, the value of the back-end returned parameter is truncated, retaining only the first part of the field length, and then the truncated value of the returned parameter is assigned to the corresponding value of the front-end displayed parameter to obtain the value of the front-end displayed parameter.
[0096] This application does not impose any restrictions on the specific form of the second configuration file. For example, the second configuration file can be a properties configuration file. For instance, the second configuration file might have the following format:
[0097] In the second configuration file, “method_FEEDBACK=FFPARAM1|FBPARAM1|1,FFPARAM2|FBPARAM2|6,FFPARAM3|FBPARAM3|16,FFPARAM4|FBPARAM4|11”, the parameter before the first vertical bar can be the front-end display parameter, the parameter between the two vertical bars can be the back-end return parameter, and the last parameter is the field length of the value of the front-end display parameter.
[0098] For example, if the field length of the parameter value displayed on the front end is 10, while the field length of the parameter value returned by the back end is 12, the value of the parameter returned by the back end needs to be truncated, keeping only the first 10 field lengths.
[0099] The method for generating response parameters provided in this application includes: retrieving a second configuration file; determining the value of a front-end display parameter based on the backend returned parameters and the second configuration file; wherein the front-end display parameter is the corresponding parameter information of the backend returned parameters displayed on the front end; the second configuration file includes mapping relationship information between the backend returned parameters and the front-end display parameters, as well as the field length of the value of the front-end display parameter; and generating response information based on the value of the front-end display parameter. This embodiment also determines the value of the front-end display parameter through a configuration file, which is simple to implement, applicable to various scenarios, requires no large amount of code support, reduces code maintenance, and is easy to configure, expand, and maintain. After generating the response information, it is returned to the front end for user viewing.
[0100] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0101] Figure 3 This is a schematic diagram of the structure of a microservice-based business processing device provided in an embodiment of this application. Figure 3 As shown, the microservice-based business processing device 30 provided in this application embodiment includes an acquisition unit 301, a configuration unit 302, a matching unit 303, a business processing unit 304, and a sending unit 305.
[0102] The acquisition unit 301 is used to acquire business request information sent by the front end; the business request information includes the pending business code.
[0103] Configuration unit 302 is used to determine the value of front-end sent parameters based on business request information; wherein, the front-end sent parameters are the front-end parameter information involved when calling the microservice to process the pending business code.
[0104] Matching unit 303 is used to retrieve the first configuration file and determine the value of the backend usage parameter based on the value of the frontend uploaded parameter and the first configuration file; wherein, the backend usage parameter is the corresponding backend parameter information required when calling the microservice to process the pending business code. The first configuration file includes the mapping relationship information between the frontend uploaded parameter and the backend usage parameter.
[0105] The business processing unit 304 is used to call the microservice to process the pending business indicated by the pending business code based on the value of the backend usage parameters, and determine the backend return parameters; wherein, the backend return parameters represent the processing result of the microservice processing the pending business indicated by the pending business code.
[0106] The sending unit 305 is used to return response information to the front end; wherein, the response information includes the values of the parameters returned by the back end and the parameters displayed on the front end.
[0107] The apparatus provided in this embodiment can be used to execute the methods of the above embodiments. Its implementation principle and technical effects are similar, and will not be described again here.
[0108] Figure 4 This is a schematic diagram of another microservice-based business processing device provided in an embodiment of this application. Figure 4 As shown, the microservice-based business processing device 40 provided in this application embodiment includes an acquisition unit 401, a configuration unit 402, a matching unit 403, a business processing unit 404, and a sending unit 405.
[0109] The acquisition unit 401 is used to acquire business request information sent by the front end; the business request information includes the pending business code.
[0110] Configuration unit 402 is used to determine the value of front-end uploaded parameters based on business request information; wherein, the front-end uploaded parameters are the front-end parameter information involved when calling the microservice to process the pending business code.
[0111] Matching unit 403 is used to retrieve the first configuration file and determine the value of the backend usage parameter based on the value of the frontend uploaded parameter and the first configuration file; wherein, the backend usage parameter is the corresponding backend parameter information required when calling the microservice to process the pending business code. The first configuration file includes the mapping relationship information between the frontend uploaded parameter and the backend usage parameter.
[0112] The business processing unit 404 is used to call the microservice to process the pending business indicated by the pending business code based on the value of the backend usage parameters, and determine the backend return parameters; wherein, the backend return parameters represent the processing result of the microservice processing the pending business indicated by the pending business code.
[0113] The sending unit 405 is used to return response information to the front end; wherein, the response information includes the values of the parameters returned by the back end and the parameters displayed on the front end.
[0114] In one example, matching unit 403 is specifically used to read the value of the parameter sent by the front end, traverse the first configuration file, and if it is determined that there is a backend usage parameter in the first configuration file that corresponds to the parameter sent by the front end, then the value of the parameter sent by the front end is assigned to the corresponding value of the backend usage parameter to obtain the value of the backend usage parameter.
[0115] In one example, configuration unit 402 includes parsing module 4021 and configuration processing module 4022.
[0116] The parsing module 4021 is used to parse business request information and determine the microservice calling method corresponding to the pending business indicated by the pending business code based on the pending business code in the business request information; wherein, the microservice calling method includes parameters sent from the front end.
[0117] The configuration processing module 4022 is used to configure the parameters sent by the front end based on the parsed business request information and obtain the values of the parameters sent by the front end.
[0118] In one example, the business processing unit 404 includes a call processing module 4041 and a parameter determination module 4042.
[0119] The call processing module 4041 is used to sequentially call each microservice to execute business processing tasks based on the value of the parameters used in the background and in the order of calling the pending business indicated by the processing pending business code.
[0120] The parameter determination module 4042 is used to determine the processing results obtained by each microservice after it has completed the business processing tasks in the order of invocation as the parameters returned by the backend.
[0121] In one example, the device 40 also includes a response unit 406, which includes a parameter matching module 4061 and a generation module 4062.
[0122] The parameter matching module 4061 is used to retrieve the second configuration file and determine the value of the front-end display parameter based on the backend returned parameters and the second configuration file. The front-end display parameter is the corresponding parameter information of the backend returned parameters displayed on the front end. The second configuration file includes the mapping relationship information between the backend returned parameters and the front-end display parameters, as well as the field length of the value of the front-end display parameter.
[0123] The generation module 4062 is used to generate response information based on the values of the parameters displayed on the front end.
[0124] In one example, the parameter matching module 4061 includes a parameter processing module 40611 and an assignment module 40612.
[0125] The parameter processing module 40611 is used to read the value of the parameter returned by the backend, traverse the second configuration file, and if it is determined that there is a front-end display parameter in the second configuration file that corresponds to the parameter returned by the backend, then the value of the parameter returned by the backend is processed based on the field length of the value of the front-end display parameter.
[0126] The assignment module 40612 is used to assign the value of the processed backend returned parameter to the corresponding value of the frontend display parameter, so as to obtain the value of the frontend display parameter.
[0127] In one example, the parameter processing module 40611 is further used to truncate the value of the parameter returned by the backend if it is determined that the field length of the value of the parameter displayed on the front end is less than the field length of the value of the parameter returned by the backend.
[0128] The apparatus provided in this embodiment can be used to execute the methods of the above embodiments. Its implementation principle and technical effects are similar, and will not be described again here.
[0129] It should be noted that the division of the various modules in the above device is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. These modules can be implemented entirely in software via processing element calls; they can be fully implemented in hardware; or some modules can be implemented in software via processing element calls, while others are implemented in hardware. Furthermore, they can be stored as program code in the device's memory, and the data processing modules can be called and executed by a specific processing element. The implementation of other modules is similar. These modules can be fully or partially integrated together, or implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. During implementation, each step of the above method or each of the above modules can be completed through integrated logic circuits in the hardware of the processor element or through software instructions.
[0130] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 5 As shown, the electronic device 50 includes a processor 501 and a memory 502 communicatively connected to the processor.
[0131] The memory 502 stores computer-executable instructions; the processor 501 executes the computer-executable instructions stored in the memory 502 to implement the method as described above.
[0132] In the specific implementation of the aforementioned electronic device, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. A general-purpose processor can be a microprocessor or any conventional processor. The methods disclosed in the embodiments of this application can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0133] This application also provides a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, are used to implement the methods described in any of the foregoing embodiments.
[0134] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to computer instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0135] This application also provides a computer program product, including a computer program that, when executed by a processor, is used to implement the method as described in any of the foregoing embodiments.
[0136] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.
[0137] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.
Claims
1. A microservice-based business processing method, characterized in that, The method includes: Obtain business request information sent by the front end; wherein, the business request information includes a pending business code; The business request information is parsed, and based on the pending business code in the business request information, the microservice invocation method corresponding to the pending business indicated by the pending business code is determined; wherein, the microservice invocation method includes front-end uploaded parameters; based on the parsed business request information, the front-end uploaded parameters are configured to obtain the values of the front-end uploaded parameters; wherein, the front-end uploaded parameters are front-end parameter information involved when calling the microservice to process the pending business indicated by the pending business code; The value of the front-end uploaded parameter is read, and the first configuration file is traversed. If it is determined that there is a back-end usage parameter in the first configuration file that corresponds to the front-end uploaded parameter, the value of the front-end uploaded parameter is assigned to the corresponding value of the back-end usage parameter to obtain the value of the back-end usage parameter. The back-end usage parameter is the corresponding back-end parameter information required when calling the microservice to process the pending business indicated by the pending business code. The first configuration file includes the mapping relationship information between the front-end uploaded parameter and the back-end usage parameter. Based on the value of the backend usage parameters, each microservice is sequentially invoked to execute business processing tasks according to the invocation order of the pending business code; the processing result obtained by each microservice after executing the business processing task in the invocation order is determined as the backend return parameter; wherein, the backend return parameter represents the processing result of the microservice in processing the pending business code. Return response information to the front end; wherein, the response information includes the value of the parameter returned by the back end and the value of the parameter displayed on the front end.
2. The method according to any one of claims 1, characterized in that, Before returning response information to the front end, the method further includes: The second configuration file is retrieved, and the values of the front-end display parameters are determined based on the backend returned parameters and the second configuration file; wherein, the front-end display parameters are the corresponding parameter information of the backend returned parameters displayed on the front end, and the second configuration file includes the mapping relationship information between the backend returned parameters and the front-end display parameters, as well as the field length of the value of the front-end display parameters; The response information is generated based on the values of the front-end display parameters.
3. The method according to claim 2, characterized in that, Based on the backend returned parameters and the second configuration file, the values of the frontend display parameters are determined, including: Read the value of the backend returned parameter, traverse the second configuration file, and if it is determined that there is a frontend display parameter in the second configuration file that corresponds to the backend returned parameter, then process the value of the backend returned parameter based on the field length of the value of the frontend display parameter; The processed backend return parameter value is assigned to the corresponding value of the frontend display parameter to obtain the value of the frontend display parameter.
4. The method according to claim 3, characterized in that, Based on the field length of the values of the front-end displayed parameters, the values of the back-end returned parameters are processed, including: If it is determined that the field length of the value of the front-end display parameter is less than the field length of the value of the back-end returned parameter, then the value of the back-end returned parameter is truncated.
5. A microservice-based business processing device, characterized in that, The device includes: The acquisition unit is used to acquire business request information sent by the front end; wherein, the business request information includes a pending business code; A configuration unit is used to parse the business request information, determine the microservice invocation method corresponding to the pending business indicated by the pending business code based on the pending business code in the business request information; wherein, the microservice invocation method includes front-end uploaded parameters; and configure the front-end uploaded parameters based on the parsed business request information to obtain the value of the front-end uploaded parameters; wherein, the front-end uploaded parameters are front-end parameter information involved when calling the microservice to process the pending business indicated by the pending business code. A matching unit is used to read the value of the front-end uploaded parameter, traverse the first configuration file, and if it is determined that there is a back-end usage parameter in the first configuration file corresponding to the front-end uploaded parameter, then the value of the front-end uploaded parameter is assigned to the corresponding value of the back-end usage parameter to obtain the value of the back-end usage parameter; wherein, the back-end usage parameter is the corresponding back-end parameter information required when calling the microservice to process the pending business indicated by the pending business code, and the first configuration file includes the mapping relationship information between the front-end uploaded parameter and the back-end usage parameter; The business processing unit is configured to, based on the value of the backend usage parameters, sequentially invoke each microservice to execute business processing tasks according to the invocation order of the pending business indicated by the pending business code; and determine the processing result obtained by each microservice after sequentially executing the business processing tasks according to the invocation order as the backend return parameter; wherein, the backend return parameter represents the processing result of the microservice in processing the pending business indicated by the pending business code; A sending unit is used to return response information to the front end; wherein the response information includes the value of the front end display parameter of the back end returned by the back end.
6. An electronic device, characterized in that, The electronic device includes: a processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1 to 4.
8. A computer program product, characterized in that, Includes a computer program, which, when executed by a processor, is used to implement the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Service parameter transmission method and device
CN110602056A
Front-end and rear-end separated interface request processing method and device
CN113918129A