Method, apparatus, device and storage medium for driving front-end and back-end services
By using the front-end-driven back-end service approach, front-end developers can customize templates and data processing logic, solving the problem of data inconsistency between front-end and back-end development and improving development and communication efficiency.
Patent Information
- Application Number
- CN202010635966.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-03
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2040-07-03
AI Technical Summary
In the existing web development model, front-end developers cannot obtain data structures or data processing logic that match the business situation, which leads to repeated communication between front-end and back-end developers, resulting in low development efficiency.
By using a front-end-driven back-end service approach, requests from the front-end page are received, product and template identifiers are parsed, the target template is obtained, the target data is determined, and then sent to the front-end page. Front-end developers can customize templates to meet business needs, reducing communication costs caused by inconsistencies between front-end and back-end data.
It reduces communication costs for front-end and back-end developers, improves development efficiency, enables front-end developers to customize data processing logic, and simplifies the development process.
Smart Images

Figure CN111966347B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, computer device, and storage medium for front-end driving back-end services. Background Technology
[0002] The existing web development model involves front-end developers creating webpage templates, which are then handed over to back-end developers for data population and page output. In this process, the front-end developer acts as the interface generator, while the back-end handles data formatting and processing logic. Because front-end and back-end development are independent, the front-end may struggle to obtain data structures or processing methods that align with business requirements. To resolve this, repeated communication between front-end and back-end developers is necessary to arrive at an API response that fits the current business logic, leading to low development efficiency. Summary of the Invention
[0003] To address the aforementioned technical problems, this application provides a method, apparatus, computer device, and storage medium for front-end-driven back-end services.
[0004] This application provides a method for front-end-driven back-end services, including:
[0005] Receive requests sent from the front-end page, which include product identifiers and template identifiers;
[0006] The request is parsed to obtain the product identifier and template identifier;
[0007] Obtain the target template determined by the product identifier and template identifier. The target template includes template parameters defined using a front-end language.
[0008] The target data is determined by the template parameters;
[0009] Send the target data to the front-end page.
[0010] This application provides a front-end-driven back-end service apparatus, comprising:
[0011] The request receiving module is used to receive requests sent by the front-end page, which carry product identifiers and template identifiers.
[0012] The parsing module is used to parse the request to obtain the product identifier and template identifier;
[0013] The template acquisition module is used to acquire the target template determined by the product identifier and the template identifier. The target template includes template parameters defined using a front-end language.
[0014] The data determination module is used to determine the target data based on template parameters;
[0015] The data sending module is used to send target data to the front-end page.
[0016] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to perform the following steps:
[0017] The request is parsed to obtain the product identifier and template identifier;
[0018] Obtain the target template determined by the product identifier and template identifier. The target template includes template parameters defined using a front-end language.
[0019] The target data is determined by the template parameters;
[0020] Send the target data to the front-end page.
[0021] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0022] The request is parsed to obtain the product identifier and template identifier;
[0023] Obtain the target template determined by the product identifier and template identifier. The target template includes template parameters defined using a front-end language.
[0024] The target data is determined by the template parameters;
[0025] Send the target data to the front-end page.
[0026] The aforementioned method, apparatus, computer device, and storage medium for front-end-driven back-end services include: receiving a request sent by a front-end page, the request carrying a product identifier and a template identifier; parsing the request to obtain the product identifier and template identifier; obtaining a target template jointly determined by the product identifier and template identifier, the target template including template parameters defined using a front-end language; determining target data through the template parameters; and sending the target data to the front-end page. The corresponding target template is written using a front-end programming language. If the back-end detects the target template during service execution, it executes the logic in the target template. After executing the logic in the target template, the back-end logic continues to execute. By using a front-end programming language to write templates, front-end developers can customize corresponding templates according to business needs, thereby reducing communication costs caused by inconsistencies between front-end and back-end data and accelerating development efficiency. Attached Figure Description
[0027] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0028] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0029] Figure 1 This is a flowchart illustrating a method for front-end driving back-end services in one embodiment;
[0030] Figure 2 This is a flowchart illustrating a method for front-end driving back-end services in one embodiment;
[0031] Figure 3 This is a structural block diagram of a front-end driving back-end service device in one embodiment;
[0032] Figure 4 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0034] like Figure 1 As shown, in one embodiment, a method for a front-end to drive a back-end service is provided. This method is applied to a processor, see reference... Figure 1 The method of front-end driving back-end service specifically includes the following steps:
[0035] Step S201: Receive the request sent by the front-end page.
[0036] In this embodiment, the request includes a product identifier and a template identifier.
[0037] Step S202: Parse the request to obtain the product identifier and template identifier.
[0038] Step S203: Obtain the target template determined by the product identifier and the template identifier.
[0039] In this specific embodiment, the target template includes template parameters defined using a front-end language.
[0040] Step S204: Determine the target data using template parameters.
[0041] Step S205: Send the target data to the front-end page.
[0042] Specifically, the front-end page can include traditional HTML pages and mini-program pages, etc. A request refers to a computer instruction sent by the front-end page to retrieve data. This computer instruction carries a product identifier and a template identifier, which can be customized as needed, such as using numbers, text, or symbols, or one or more of these. The product identifier identifies the product, and the template identifier identifies the template. The same template can be applied to multiple products, and one product can correspond to multiple templates. The template is a data template, and the template parameters in the template can define the data format, data processing logic, etc. The data format includes the data return format and the data retrieval format, etc. The template parameters include parameter identifiers and / or template functions. The template functions include data processing functions and calling functions. The data processing functions are used to directly process the data corresponding to the parameters in the template, and the calling functions are used to call the functions defined by the backend and use those functions to process the data to obtain the corresponding data processing results. The template functions include input parameters and output parameters. Input parameters refer to the parameters input into the template function, and output parameters refer to the parameters obtained after executing the template function.
[0043] A unique target template is determined based on the product identifier and template identifier. The request can carry one or more template identifiers; when multiple template identifiers exist, the corresponding target template is determined based on each identifier. The target template is a data template defined by a front-end language. A front-end language refers to the programming language used by front-end developers to write front-end logic, such as JavaScript and jQuery. JavaScript is an interpreted scripting language, a dynamically typed, weakly typed, prototype-based language with built-in type support. Its interpreter, called the JavaScript engine, is part of the browser and is widely used as a client-side scripting language. It is used on HTML (an application of Standard Generalized Markup Language) web pages to add dynamic functionality. The programming language used for backend service execution can be Go, Python, Java, etc. Go (GOlang) is a statically typed, compiled language developed by Robert Griesemer, Rob Pike, and Ken Thompson of Google. Go's syntax is similar to C, but it features memory safety, garbage collection (GC), structuring, and CSP-style concurrent computation.
[0044] In one embodiment, the target template, written in a front-end language, can implement any processing that conforms to the syntax and logic of the front-end programming language. Front-end developers are involved in the development of the template layer, acquiring, processing, and assembling data or calling backend functions according to business requirements to generate the corresponding target template.
[0045] In one embodiment, the target template is integrated into the backend. During service execution, the backend injects data and functions into the target template, enabling the target template to call data or functions from the backend service. When editing the target template, the frontend adds data processing logic to it, assembling the required data based on its business needs.
[0046] A data retrieval request is generated based on the product identifier and template identifier. Upon receiving this request, the backend parses it to obtain the product identifier and template identifier. Data is then retrieved from the corresponding database using parameter identifiers in the template parameters and / or template functions within the target template. The target data is returned to the frontend page, which can either display the data directly or process it before display. The target data can be data with HTML tags or data in JSON format. Because JSON data cannot be directly displayed on the frontend, it needs to be processed according to the frontend's display requirements before being displayed. Specifically, upon receiving the JSON data, the frontend parses it, combines the data with frontend tags to obtain data carrying frontend tags, and then renders this data onto the page. Data with HTML tags can be directly rendered and displayed on the page.
[0047] In one embodiment, the target template can be stored as a file or as data. For example, it can be stored as a file in a file library. Adding or modifying a target template requires modifying the content of the file when stored as a file, and directly modifying the data when stored as data. For instance, the target template can be stored as a file in GitLab, and then GitLab's hook function can be used to synchronously store changes in a MongoDB database when new or modified code is added. Here, GitLab is a code management tool, and MongoDB is a distributed file storage-based database written in C++, designed to provide scalable, high-performance data storage solutions for web applications. Storing it as data refers to developing an online target template editing page, and directly storing the target templates generated by the online editing page into the database as data.
[0048] The aforementioned method for front-end-driven back-end services includes: receiving a request sent by a front-end page, the request carrying a product identifier and a template identifier; parsing the request to obtain the product identifier and template identifier; obtaining a target template determined jointly by the product identifier and template identifier, the target template including template parameters defined using a front-end language; determining the target data through the template parameters; and sending the target data to the front-end page. By using a front-end programming language to write the corresponding target template, if the back-end detects the target template during service execution, it executes the logic within the target template. After executing the logic within the target template, it continues executing the back-end logic. Using a front-end programming language to write the template allows front-end developers to customize the corresponding template according to business needs, thereby reducing problems caused by inconsistencies between front-end and back-end data.
[0049] In one embodiment, step S204 includes: determining a data format based on template parameters, the data format including a first format and a second format; when the data format is the first data format, obtaining first data through template parameters and using the first data as the target data; when the data format is the second data format, obtaining second data through template parameters, injecting the second data into the target template to obtain a first template, and using the first template as the target data.
[0050] Specifically, the data format defines the form of the returned data. Front-end developers can customize the returned data format according to their needs, such as defining it as JSON format or data format with HTML tags. The first data format refers to JSON format, and the second data format refers to the data format with HTML tags. When the data format is JSON, the corresponding data is directly obtained according to the template parameters, and the obtained data is returned directly as the target data. When the data format is data format with HTML tags, the obtained data is injected into the target template to obtain the first template, which is then used as the target data and returned as the first template.
[0051] Almost all front-end pages support JSON data format, and some front-end pages also support data formatted with HTML tags. Front-end developers can define the data format to be returned based on the type of front-end page and / or business requirements. Developers can define the corresponding data format according to their needs to ensure that the returned data conforms to the current business requirements.
[0052] In one embodiment, the template parameters include a parameter identifier. Determining the target data through the template parameters includes: determining third data based on the parameter identifier and using the third data as the target data.
[0053] Specifically, a parameter identifier is used to identify a parameter. Data corresponding to the parameter identifier is retrieved based on this identifier, and the retrieved data is used as the target data. In practical applications, there are scenarios where data is directly retrieved. In such cases, parameter identifiers can be defined directly in the template. Data corresponding to the parameter identifier is then directly retrieved from the backend execution service according to the parameter identifier, resulting in third data. This third data is then used as the target data and returned.
[0054] In one embodiment, the template parameters include a template function, which includes input parameters and output parameters. Determining the target data using the template parameters includes: obtaining fourth data based on the input parameters; substituting the fourth data into the template function to obtain the data corresponding to the output parameters; and using the data corresponding to the output parameters as the target data.
[0055] Specifically, a template function is a function that processes data. A template function can have one or more input and output parameters. The process involves obtaining the value of each input parameter, executing the template function, and obtaining the value of each output parameter. The output parameter values are then used as the fourth data (target data). Template functions can either directly process the data obtained from the target template or call a function that has already been obtained. In practical applications, the data obtained from the backend service may differ from the data required by the frontend. To meet business requirements, the frontend needs to process the data provided by the backend, which is achieved through template functions to process the data obtained from the backend and ensure that the processed data meets the frontend's business needs.
[0056] In one embodiment, the template parameters include a parameter identifier and a template function, and the data obtained by using the template parameters and the data obtained by executing the template function are used as the target data.
[0057] Specifically, in practical applications, some data can be directly obtained from the backend, while other data requires further processing. Therefore, when defining template parameters, parameter identifiers and template functions are defined within the template. The parameter identifiers are used to directly retrieve the required data from the backend, and the template functions are used to process the data retrieved from the backend or to call backend functions to obtain the desired data.
[0058] In one embodiment, step S302 includes: determining the target database based on the product identifier, searching the target database for a template with the same identifier as the template identifier, and obtaining the target template.
[0059] Specifically, the target database refers to the database that stores the parameters of the product corresponding to the product identifier. The process involves searching the corresponding database based on the product identifier, and then searching for the template within that database based on the template identifier to obtain the target template.
[0060] In one embodiment, the above-described method for front-end driving back-end services further includes: obtaining context information; and determining target data based on template parameters and context information.
[0061] Specifically, context information refers to the data and / or functions obtained during the backend service execution process. Injecting the context information into the target template involves injecting the data and / or functions from the context information into the target template. The corresponding data is retrieved from the context information using the parameter identifiers in the target template. Based on the template function in the target template, the corresponding function and / or the parameter values of the input parameters corresponding to the template function are retrieved from the context information. The template function is then executed to obtain the corresponding data. The data retrieved based on the parameter identifiers in the target template and / or the data obtained by executing the template function are used as the target data.
[0062] In one embodiment, the target template includes user name, age, height, and weight, etc. Based on the parameter identifiers of the user name, height, and weight, the data corresponding to these parameter identifiers is obtained from the data injected into the target template. Age can be calculated using an age calculation function. That is, based on the input parameters (user's date of birth and current time), the specific values of the user's date of birth and current time are obtained from the data injected into the target template, and the age is calculated based on these specific values (output parameter).
[0063] In one embodiment, generating a target template includes: receiving template parameters, wherein the template parameters are parameters corresponding to the product identifier; generating a target template based on the template parameters, wherein the target template has a unique template identifier.
[0064] Specifically, front-end developers write or select template parameters, which include parameter identifiers and / or template functions. These template parameters are determined based on the product's business requirements, and each product has a unique product identifier. A corresponding target template is generated based on the template parameters, and each target template has a unique template identifier.
[0065] In one embodiment, the target template defines the template's background, icon, title, items, etc.
[0066] In one embodiment, the JS template can be published using a visual JavaScript template publishing platform. By publishing the template separately, the template and backend service can be decoupled during the publishing phase, allowing for flexible and adaptable updates and deployments.
[0067] In one embodiment, for ease of illustration, the target template is a JavaScript template, and the backend execution environment is Go. (See also...) Figure 2The aforementioned method for front-end-driven back-end services includes:
[0068] Step S301, GO Service. A GO service refers to executing backend logic using the GO language. The GO service uses a corresponding toolkit to add JavaScript parsing and execution capabilities to the service, such as the Otto dependency package. During function execution within the backend service, if a JS template exists, the JavaScript parser will be injected into it, i.e., step S302 will be executed.
[0069] Step S302, JS Template. Execute the JavaScript logic. The GOlang runtime parses the JavaScript and injects the GOlang runtime context into the JavaScript environment, allowing the JavaScript context to access data from the GO environment and call functions within the GO environment. After execution, the GO logic continues, i.e., step S303 is executed.
[0070] Step S303, GO service. Execute the GO service to return data to the front end.
[0071] Step S304, data output.
[0072] Step S305, Front-end interface. Render the front-end page based on the output data.
[0073] In one embodiment, if no JavaScript template is detected when executing GO logic, the GO logic continues to be executed.
[0074] In one embodiment, front-end developers can use familiar JavaScript to develop logic within the template, and / or implement module-based development. They can develop and extract common templates or public functions based on business needs. Common templates can be used by multiple products, and modifications can be made during use to generate product-specific templates. Public functions are functions that can be used by multiple templates. For example, if the backend receives a URL request like `getInsurePage?productCode=TT01&templateName=insure_form`, the backend deconstructs this URL to obtain `productCode` (product identifier) and `templateName` (template identifier). Based on `productCode` and `templateName`, it searches the corresponding database for the appropriate template and uses the matching template as the target template.
[0075] The aforementioned front-end-driven back-end service method further separates data. Back-end developers integrate JavaScript templates into their services, injecting data and functions from the service execution process into the templates. This allows the JavaScript within the templates to smoothly call data or functions from the back-end services. Front-end developers can then process the data within the JavaScript templates, assembling the most needed data based on front-end business requirements. Back-end developers only need to focus on the flow of basic business data, without needing to understand the business logic itself. They then assemble the data according to the business requirements and provide the assembled data to the front-end.
[0076] Existing front-end data-driven frameworks move the integration of data and templates to the front end, meaning page rendering changes based on data variations. This case study presents a data-driven model that spans both front-end and back-end, enabling joint debugging between them. Joint debugging refers to collaborative testing between the front-end and back-end, typically where each side operates independently, unable to transcend the boundaries between the two. Using the method described in this case, joint debugging between the front-end and back-end requires no intervention from back-end developers. Back-end developers only need to provide the basic business logic already implemented with JavaScript templates, saving communication costs for both parties and accelerating development progress.
[0077] By processing data through target templates developed on the front end, the data layer and backend logic are partially decoupled. This exposes the data layer's integration capabilities for front-end developers to use. Furthermore, because these integration capabilities are based on front-end languages, front-end developers can directly use familiar languages, reducing the learning curve for backend languages and improving development efficiency.
[0078] Figure 1 This is a flowchart illustrating a method for front-end driving back-end services in one embodiment. It should be understood that, although... Figure 1 The steps in the flowchart are shown sequentially as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order in which these steps are executed, and they can be performed in other orders. Figure 1 At least some of the steps in the process may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least some of the sub-steps or stages of other steps.
[0079] In one embodiment, such as Figure 3 As shown, a front-end-driven back-end service apparatus 200 is provided, comprising:
[0080] The request receiving module 201 is used to receive requests sent by the front-end page, which carry product identifiers and template identifiers.
[0081] Parsing module 202 is used to parse the request to obtain the product identifier and template identifier.
[0082] The template acquisition module 203 is used to acquire the target template determined by the product identifier and the template identifier. The target template includes template parameters defined using a front-end language.
[0083] The data determination module 204 is used to determine the target data through template parameters.
[0084] The data sending module 205 is used to send target data to the front-end page.
[0085] In one embodiment, the data determination module 204 is specifically used to determine the data format according to the template parameters. The data format includes a first format and a second format. When the data format is the first data format, the first data is obtained through the template parameters and used as the target data. When the data format is the second data format, the second data is obtained through the template parameters, the second data is injected into the target template to obtain the first template and used as the target data.
[0086] In one embodiment, the data determination module 204 is specifically used to determine the third data based on the parameter identifier, and use the third data as the target data, wherein the template parameters include the parameter identifier.
[0087] In one embodiment, the data determination module 204 is further configured to substitute the fourth data obtained according to the input parameters into the template function to obtain the data corresponding to the output parameters, and use the data corresponding to the output parameters as the target data, wherein the template parameters include the template function, and the template function includes the input parameters and the output parameters.
[0088] In one embodiment, the template acquisition module 203 is specifically used to determine the target database based on the product identifier; from the target database, it searches for a template with the same identifier as the template identifier to obtain the target template.
[0089] In one embodiment, the aforementioned front-end-driven back-end service apparatus 200 further includes:
[0090] The context information acquisition module is used to acquire context information.
[0091] The data determination module 204 is specifically used to determine the target data based on template parameters and context information.
[0092] In one embodiment, a template generation module is used to generate a target template.
[0093] In this embodiment, the template generation module is specifically used to receive template parameters, which are parameters corresponding to the product identifier; and to generate a target template based on the template parameters, wherein the target template has a unique template identifier.
[0094] In one embodiment, the aforementioned front-end-driven back-end service apparatus 200 further includes:
[0095] The template storage module is used to save the target template as a file or as data.
[0096] Figure 4 An internal structural diagram of a computer device in one embodiment is shown. Figure 4 As shown, the computer device is connected via a system bus to a processor, memory, network interface, input device, and display screen. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and may also store computer programs. When executed by the processor, these programs enable the processor to implement a front-end-driven back-end service method. The internal memory may also store computer programs, which, when executed by the processor, enable the processor to perform the front-end-driven back-end service method. The display screen can be an LCD screen or an e-ink screen. The input device can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device's casing, or an external keyboard, touchpad, or mouse.
[0097] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0098] In one embodiment, the front-end-driven back-end service apparatus 200 provided in this application can be implemented as a computer program, which can be implemented in, for example... Figure 4 It runs on the computer device shown. The computer device's memory can store the various program modules that make up the front-end driver back-end service, for example, Figure 3 The diagram shows a request receiving module 201, a parsing module 202, a template acquisition module 203, a data determination module 204, and a data sending module 205. The computer program comprised of these modules causes the processor to execute the steps of the front-end driving back-end service methods described in the various embodiments of this application.
[0099] For example, Figure 4The computer device shown can be used as follows Figure 3 The request receiving module 201 in the front-end-driven back-end service device shown receives requests sent by the front-end page, which carry product identifiers and template identifiers. The computer device can parse the request using the parsing module 202 to obtain the product identifier and template identifier. The computer device can obtain the target template determined by the product identifier and template identifier using the template acquisition module 203. The target template includes template parameters defined using the front-end language. The computer device can determine the target data using the template parameters using the data determination module 204. The computer device can send the target data to the front-end page using the data sending module 205.
[0100] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of any embodiment of the above-described front-end-driven back-end service method.
[0101] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of any embodiment of the above-described front-end-driven back-end service method.
[0102] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps of any embodiment of the front-end-driven back-end service method described above.
[0103] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.
[0104] It should be noted that, in this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0105] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for front-end-driven back-end services, characterized in that, The method includes: Receive a request sent by the front-end page, the request carrying a product identifier and a template identifier; The request is parsed to obtain the product identifier and the template identifier; Obtain a target template determined by the product identifier and the template identifier. The target template includes template parameters defined using a front-end language. The target template is capable of processing any syntax logic that conforms to the front-end programming language. The target template is generated by the front-end developer. The template parameters include parameter identifiers and / or template functions. The parameter identifiers are used to identify parameters, and the template functions are used to process the data obtained from the back-end so that the processed data meets the front-end business requirements. The target data is determined using the template parameters; Send the target data to the front-end page; Specifically, determining the target data through the template parameters includes: obtaining data from the corresponding database through the parameter identifiers and / or template functions in the template parameters to obtain the target data.
2. The method according to claim 1, characterized in that, The step of determining the target data through the template parameters includes: The data format is determined based on the template parameters, and the data format includes a first data format and a second data format. When the data format is the first data format, the first data is obtained through the template parameters, and the first data is used as the target data; When the data format is the second data format, the second data is obtained through the template parameters, the second data is injected into the target template to obtain the first template, and the first template is used as the target data.
3. The method according to claim 1, characterized in that, The template parameters include parameter identifiers, and determining the target data through the template parameters includes: The third data is determined based on the parameter identifier, and the third data is used as the target data.
4. The method according to claim 1, characterized in that, The template parameters include a template function, which includes input parameters and output parameters. Determining the target data using the template parameters includes: The fourth data is obtained based on the input parameters; Substitute the fourth data into the template function to obtain the data corresponding to the output parameter; The data corresponding to the output parameters is used as the target data.
5. The method according to claim 1, characterized in that, The step of obtaining the target template determined jointly by the product identifier and the template identifier includes: The target database is determined based on the product identifier; From the target database, a template with the same identifier as the template identifier is searched to obtain the target template.
6. The method according to claim 1, characterized in that, The method further includes: Obtain context information; Determining the target data using the template parameters includes: determining the target data based on the template parameters and the context information.
7. The method according to claim 1, characterized in that, The steps for generating the target template include: Receive the template parameters, wherein the template parameters are the parameters corresponding to the product identifier; The target template is generated based on the template parameters, and the target template has a unique template identifier.
8. The method according to claim 7, characterized in that, The method further includes: Save the target template as a file; or The target template is stored in data form.
9. A device for front-end driving back-end services, characterized in that, The device includes: The request receiving module is used to receive requests sent by the front-end page, the requests carrying product identifiers and template identifiers; The parsing module is used to parse the request to obtain the product identifier and the template identifier; The template acquisition module is used to acquire a target template determined by the product identifier and the template identifier. The target template includes template parameters defined using a front-end language. The target template is capable of processing any syntax logic that conforms to the front-end programming language. The target template is generated by the front-end developer. The template parameters include parameter identifiers and / or template functions. The parameter identifiers are used to identify parameters, and the template functions are used to process the data obtained from the back-end so that the processed data meets the front-end business requirements. The data determination module is used to determine the target data based on the template parameters; A data sending module is used to send the target data to the front-end page; The data determination module is used to: obtain data from the corresponding database through the parameter identifier and / or template function in the template parameters to obtain the target data.
10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.
12. A computer program product or computer program comprising computer instructions stored in a computer-readable storage medium, wherein a processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions to cause the computer device to perform the steps of the method of any one of claims 1 to 8.
Citation Information
Patent Citations
Query control method and system of page data
CN102456004A