A method, apparatus, electronic device, and medium for data formatting

By pre-storing data formatting functions in storage files and directly calling them to achieve data formatting, the problem of frequent code modifications in existing technologies is solved, improving data formatting efficiency and system performance.

CN115495421BActive Publication Date: 2025-12-12INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202211164104.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-23
Publication Date
2025-12-12
Estimated Expiration
2042-09-23

AI Technical Summary

Technical Problem

In existing technologies, the data formatting process requires writing or modifying a large amount of code, resulting in low efficiency and impacting system performance.

Method used

The data formatting functions corresponding to the target data source are pre-stored, and can be retrieved from the stored file and directly called to achieve data formatting, avoiding the need to write or modify code.

Benefits of technology

It improves the efficiency of data formatting and reduces development time and system performance impact.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115495421B_ABST
    Figure CN115495421B_ABST
Patent Text Reader

Abstract

The application discloses a data formatting method and device, electronic equipment and medium, and relates to the field of computers. The method comprises the following steps: obtaining a target data source; obtaining a target data formatting function corresponding to the target data source from a storage file; and obtaining a formatting result of the target data source according to the target data formatting function. In the previous data formatting method, when the data source is formatted, a large amount of codes are changed or written. However, in the method of the application, the data formatting function corresponding to the target data source is stored in the storage file in advance, so that the large amount of codes do not need to be written, and the data is directly formatted by using the existing data formatting function, thereby improving the data formatting efficiency. In addition, the application further provides a data formatting device, electronic equipment and computer readable storage medium, which have the same or corresponding technical features and effects as the above-mentioned data formatting method.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the computer field, and in particular, to a data formatting method and device, electronic equipment and medium. BACKGROUND

[0002] With the rapid development of Internet technology, page display information is becoming more and more important. Page display information often needs data to support, and data formatting is an essential part of the page display process. In the prior art, specific data information is generally encapsulated on the Java side, and data is returned according to the agreed data format of page display. The client needs to use a remote interface to read the data to get the desired return value; or the client encapsulates the original data according to the agreed data format for the second time to get the agreed data format; or a third-party function library is referenced.

[0003] In the prior art, if the data is encapsulated by the Java layer and then returned to the client, the Java layer needs to perform a large amount of logical encapsulation on the underlying data. In the case where the data format needs to be changed, a large amount of code modification is required, which affects the performance and also consumes a lot of time. If the front-end developer formats the data, the developer generally writes code to format the data according to business needs. Since the requirements are scattered, the developer needs to write code to complete the development of some common data formatting functions every time, which wastes a lot of time and effort. Referring to a third-party function library can meet some requirements. For example, the existing Moment.js is a JavaScript tool library for parsing, verifying, operating, and displaying dates, which can only meet the demand for time formatting and cannot meet other data formatting requirements. If there are other data formatting requirements, other tool libraries or developers need to write code to achieve the purpose. Therefore, in the current data formatting, a large amount of code needs to be changed or written to implement, which consumes a lot of time and leads to a decrease in the efficiency of data formatting and affects the performance of the system.

[0004] Therefore, how to improve the efficiency of data formatting is a technical problem that needs to be solved by those skilled in the art. SUMMARY

[0005] The purpose of the present application is to provide a data formatting method, device, electronic equipment and medium for improving the efficiency of data formatting.

[0006] To solve the above technical problems, the present application provides a data formatting method, comprising:

[0007] obtaining a target data source;

[0008] obtaining a target data formatting function corresponding to the target data source from a storage file;

[0009] obtaining a formatting result of the target data source according to the target data formatting function.

[0010] Preferably, the establishing the storage file comprises:

[0011] obtaining a formatting rule of a current data source;

[0012] querying a current data formatting function corresponding to the current data source according to the formatting rule of the current data source;

[0013] judging whether the current data formatting function meets the formatting rule of the current data source;

[0014] if yes, storing the current data formatting function into the storage file.

[0015] Preferably, the method further comprises:

[0016] if the current data formatting function does not meet the formatting rule of the current data source, modifying the current data formatting function; and entering the step of storing the current data formatting function into the storage file.

[0017] Preferably, after judging that the current data formatting function meets the formatting rule of the current data source, and / or after modifying the current data formatting function, before storing the current data formatting function into the storage file, the method further comprises:

[0018] saving the current data formatting function into a cache area for caching the current data formatting function; and returning to the step of obtaining the formatting rule of the current data source;

[0019] if all data formatting functions are added into the cache area, entering the step of storing the current data formatting function into the storage file.

[0020] Preferably, the judging whether the current data formatting function meets the formatting rule of the current data source comprises:

[0021] obtaining an auxiliary parameter corresponding to the current data source;

[0022] judging whether the current data formatting function meets the formatting rule of the current data source according to the current data source of the current data formatting function and the auxiliary parameter;

[0023] if yes, entering the step of storing the current data formatting function into the storage file;

[0024] If not, the step of modifying the current data formatting function is entered.

[0025] Preferably, the step of judging whether the current data formatting function meets the formatting rule of the current data source comprises:

[0026] An example of using the formatting rule of the current function source is obtained.

[0027] According to the example of using the formatting rule of the current function source, it is judged whether the current data formatting function meets the formatting rule of the current data source.

[0028] If yes, the step of storing the current data formatting function into the storage file is entered.

[0029] If not, the step of modifying the current data formatting function is entered.

[0030] Preferably, the step of judging whether the current data formatting function meets the formatting rule of the current data source comprises:

[0031] The current data source and the auxiliary parameter corresponding to the current data source are obtained.

[0032] The current data source is formatted according to the auxiliary parameter corresponding to the current data source, and a first result of formatting is obtained.

[0033] The current data source is formatted according to the current data formatting function, and a second result of formatting is obtained.

[0034] According to the first result and the second result, it is judged whether the current data formatting function meets the formatting rule of the current data source.

[0035] If yes, the step of storing the current data formatting function into the storage file is entered.

[0036] If not, the step of modifying the current data formatting function is entered.

[0037] To solve the above technical problems, the application further provides a data formatting device, comprising:

[0038] A first obtaining module is configured to obtain a target data source.

[0039] A second obtaining module is configured to obtain a target data formatting function corresponding to the target data source from a storage file.

[0040] A third obtaining module is configured to obtain a formatting result of the target data source according to the target data formatting function.

[0041] To solve the above technical problems, the present application further provides an electronic device, comprising:

[0042] a memory for storing a computer program;

[0043] a processor for executing the computer program to implement the steps of the data formatting method.

[0044] To solve the above technical problems, the present application further provides a computer readable storage medium, the computer readable storage medium has a computer program stored thereon, the computer program is executed by a processor to implement the steps of the data formatting method.

[0045] The data formatting method provided by the present application comprises: obtaining a target data source; obtaining a target data formatting function corresponding to the target data source from a storage file; and obtaining a formatting result of the target data source according to the target data formatting function. In the previous data formatting method, the data formatting function is not configured in advance, but needs to be changed or written when formatting is needed, which reduces the efficiency of data formatting. In the method of the present application, the data formatting function corresponding to the target data source is stored in the storage file in advance, so that a large amount of code does not need to be written, but the data is directly formatted by the existing data formatting function, which improves the efficiency of data formatting.

[0046] In addition, the present application further provides a data formatting device, an electronic device and a computer readable storage medium, which have the same or corresponding technical features as the above-mentioned data formatting method, and the effects are the same. BRIEF DESCRIPTION OF DRAWINGS

[0047] To more clearly illustrate the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0048] Figure 1 A flowchart of a data formatting method provided by an embodiment of the present application;

[0049] Figure 2 A structural diagram of a data formatting device provided by an embodiment of the present application;

[0050] Figure 3 A structural diagram of an electronic device provided by another embodiment of the present application;

[0051] Figure 4 A schematic diagram of a data formatting service system provided by an embodiment of the present application;

[0052] Figure 5 The flowchart of the method for formatting data of the service system provided by the embodiment of the present application. DETAILED DESCRIPTION

[0053] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all the other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0054] The core of the present application is to provide a data formatting method, device, electronic equipment and medium, which is used to improve the efficiency of data formatting.

[0055] With the rapid development of Internet technology, page display information is becoming more and more important. Page display information often needs data to support, and data formatting is an essential part of the page display process. For example, time unit, the data stored in the data storage layer is often a timestamp, which needs to be formatted by the developer into a specific time point or date; amount, the data stored in the data storage layer is generally a number or a string in yuan, which needs to be formatted by the developer into “ten thousand yuan” or “hundred million yuan” when the number is large; when downloading data, the data stored in the data storage layer is a number in bytes, which needs to be formatted by the developer into a string in “MB” or “GB” that is more readable and easier for users to understand; or volume, the data stored in the data storage layer is basic unit data (for example, cm 3 for basic unit), which needs to be formatted into m 3 , etc. In the prior art, a specific data information is generally encapsulated on the Java end, data is returned according to the agreed data format of page display, and the client needs to use a remote interface to read the data to get the desired return value; or the client encapsulates the original data according to the agreed data format for a second time to get the agreed data format; or a third-party function library is referenced. In the process of formatting data, these methods need to write and modify a large amount of code, which reduces the efficiency of data formatting. Therefore, in the present application, data formatting functions are stored in advance, and when formatting data, the corresponding data formatting function is directly called to format the data source, thereby greatly improving the efficiency of data formatting.

[0056] In order for the personnel in the technical field to better understand the present application, the present application will be further described in detail below with reference to the drawings and specific embodiments. Figure 1 The flowchart of the method for formatting data provided by the embodiment of the present application is as follows:Figure 1 The method comprises the following steps of:

[0057] S10: obtaining a target data source;

[0058] S11: obtaining a target data formatting function corresponding to the target data source from a storage file;

[0059] S12: obtaining a formatting result of the target data source according to the target data formatting function.

[0060] The target data source is original data that a user wants to format. The target data formatting function is a function encapsulated based on a front-end JavaScript language. The function can receive one target data source and zero or more auxiliary parameters. The result returned by the function after processing the target data source is the result of data formatting agreement. In the storage file, there are data formatting functions corresponding to different data sources. According to conventional data classification, a single file is stored in a directory of a server to store an executable function variable output by export. The backend will read the folder and file directory under the directory, and return the read directory structure and corresponding unique key value to the client. The client can query the target data formatting function by calling an interface, and realize the formatting of the target data source through the target data formatting function.

[0061] The method for data formatting provided in the embodiment comprises the following steps of: obtaining a target data source; obtaining a target data formatting function corresponding to the target data source from a storage file; and obtaining a formatting result of the target data source according to the target data formatting function. In the previous method for data formatting, the data formatting function is not configured in advance, but needs to be changed or written when formatting is needed, which reduces the efficiency of data formatting. In the method of the embodiment, the data formatting function corresponding to the target data source is stored in the storage file in advance, so that a large amount of code does not need to be written, but the data is directly formatted through the existing data formatting function, which improves the efficiency of data formatting.

[0062] In order to make the data formatting result obtained through the data formatting function in the storage file more accurate, the preferred embodiment is that the storage file is established by comprising the following steps of:

[0063] obtaining a formatting rule of a current data source;

[0064] querying a current data formatting function corresponding to the current data source according to the formatting rule of the current data source;

[0065] judging whether the current data formatting function meets the formatting rule of the current data source;

[0066] If yes, the current data formatting function is stored in the storage file.

[0067] In the implementation, if the current data formatting function does not meet the formatting rule of the current data source, the current data formatting function is modified, and the step of storing the current data formatting function into the storage file is entered.

[0068] In the embodiment, when the storage file is established, the current data formatting function corresponding to the current data source is determined according to the formatting rule of the current data source, so that the current data formatting function can be determined more accurately. In addition, the determined current data formatting function is compared with the formatting rule of the current data source, so that the accuracy of the selected function for formatting the current data source is further verified, and the formatting result of the current data source obtained according to the current data formatting function is more accurate. All data formatting functions are stored in the storage file, which can be screened and downloaded by the front-end developer, avoiding the front-end developer from writing a large amount of commonly used code, and avoiding the complexity of introducing various function tool libraries, thereby saving a large amount of development time for the front-end developer.

[0069] In the implementation, after it is judged that the current data formatting function meets the formatting rule of the current data source, and / or after the current data formatting function is modified, before the current data formatting function is stored into the storage file, the data formatting method further includes:

[0070] The current data formatting function is saved into a cache area for caching the current data formatting function, and the step of obtaining the formatting rule of the current data source is returned;

[0071] In the case that all data formatting functions are added to the cache area, the step of storing the current data formatting function into the storage file is entered.

[0072] In the embodiment, each current data formatting function is first added to the cache area, and then each current data formatting function in the cache area is stored into the storage file. The cache area can temporarily store the selected current data formatting function, and the use of the current data formatting function can be understood.

[0073] In the implementation, in order to judge whether the current data formatting function meets the formatting rule of the current data source, at least the following three ways can be implemented.

[0074] Method one: obtaining an auxiliary parameter corresponding to the current data source;

[0075] According to the current data source and the auxiliary parameter of the current data formatting function, it is judged whether the current data formatting function meets the formatting rule of the current data source;

[0076] If yes, a step of storing the current data formatting function into a storage file is entered;

[0077] If no, a step of modifying the current data formatting function is entered.

[0078] Method two: obtaining a usage example of the formatting rule of the current function source;

[0079] According to the usage example, it is judged whether the current data formatting function meets the formatting rule of the current data source;

[0080] If yes, a step of storing the current data formatting function into a storage file is entered;

[0081] If no, a step of modifying the current data formatting function is entered.

[0082] Method three: obtaining the current data source and an auxiliary parameter corresponding to the current data source;

[0083] According to the auxiliary parameter corresponding to the current data source, the current data source is formatted, and a first result of the formatting is obtained;

[0084] According to the current data formatting function, the current data source is formatted, and a second result of the formatting is obtained;

[0085] According to the first result and the second result, it is judged whether the current data formatting function meets the formatting rule of the current data source;

[0086] If yes, a step of storing the current data formatting function into a storage file is entered;

[0087] If no, a step of modifying the current data formatting function is entered.

[0088] The embodiment provides three methods of judging whether the current data formatting function meets the formatting rule of the current data source, so that the judgment of the current data formatting function is more flexible.

[0089] In the above embodiment, the method of data formatting is described in detail, and the present application also provides an embodiment of a data formatting device and an electronic device. It should be noted that the embodiment of the device part is described from two angles, one is based on the functional module angle, and the other is based on the hardware angle.

[0090] Figure 2 The structural diagram of the data formatting device provided by an embodiment of the present application. The embodiment is based on the functional module angle, and includes:

[0091] The first acquisition module 10 is configured to acquire a target data source;

[0092] The second obtaining module 11 is configured to obtain a target data formatting function corresponding to the target data source from a storage file.

[0093] The third obtaining module 12 is configured to obtain a formatting result of the target data source according to the target data formatting function.

[0094] Since the embodiments of the device part correspond to the embodiments of the method part, the embodiments of the device part are described in the description of the embodiments of the method part, and are not described here.

[0095] The device for data formatting provided in the embodiment obtains a target data source through the first obtaining module, obtains a target data formatting function corresponding to the target data source from a storage file through the second obtaining module, and obtains a formatting result of the target data source according to the target data formatting function through the third obtaining module. In the previous device for data formatting, the data formatting function is not configured in advance, but needs to be changed or written through a large amount of code when formatting is needed, which reduces the efficiency of data formatting. In the device of the embodiment, the data formatting function corresponding to the target data source is stored in the storage file in advance, so that a large amount of code does not need to be written, but the data is directly formatted through the existing data formatting function, which improves the efficiency of data formatting.

[0096] Figure 3 The structure diagram of the electronic device provided in another embodiment of the present application is provided. The embodiment is based on the hardware angle, as shown in the figure, the electronic device includes: Figure 3

[0097] The memory 20 is configured to store a computer program.

[0098] The processor 21 is configured to execute the computer program to implement the steps of the method for data formatting mentioned in the above embodiments.

[0099] The electronic device provided in the embodiment can include but is not limited to a smart phone, a tablet computer, a notebook computer or a desktop computer, etc.

[0100] ​The processor 21 can include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one of a hardware form of a digital signal processor (DSP), a field-programmable gate array (FPGA), a programmable logic array (PLA), etc. The processor 21 can also include a main processor and a coprocessor. The main processor is a processor for processing data in a wake-up state, also referred to as a central processing unit (CPU). The coprocessor is a low-power processor for processing data in a standby state. In some embodiments, the processor 21 can be integrated with a graphics processing unit (GPU) for rendering and drawing content required to be displayed by the display screen. In some embodiments, the processor 21 can further include an artificial intelligence (AI) processor for processing computing operations related to machine learning.

[0101] The memory 20 can include one or more computer-readable storage media, which can be non-transitory. The memory 20 can further include a high-speed random access memory, and a nonvolatile memory such as one or more disk storage devices, flash storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein the computer program is loaded and executed by the processor 21, and can implement the related steps of the data formatting method disclosed in any of the preceding embodiments. In addition, the resources stored by the memory 20 can further include an operating system 202 and data 203, etc., and the storage manner can be temporary storage or permanent storage. The operating system 202 can include Windows, Unix, Linux, etc. The data 203 can include but is not limited to data related to the data formatting method mentioned above.

[0102] In some embodiments, the electronic device can further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.

[0103] Those skilled in the art can understand that, Figure 3 The structure shown in the figure does not constitute a limitation on the electronic device, and can include more or fewer components than those shown in the figure.

[0104] The electronic device provided in this application includes a memory and a processor. When the processor executes a program stored in the memory, it can implement the following method: a data formatting method. Compared to previous data formatting devices, which did not pre-configure data formatting functions and required modifying or writing a large amount of code to perform formatting, thus reducing the efficiency of data formatting, the electronic device in this embodiment pre-stores the data formatting functions corresponding to the target data source in the storage file. Therefore, it is not necessary to write a large amount of code; instead, the data is formatted directly using the existing data formatting functions, improving the efficiency of data formatting.

[0105] This application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps described in the above method embodiments.

[0106] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0107] The computer-readable storage medium provided in this application includes the data formatting method mentioned above, with the same effect.

[0108] To enable those skilled in the art to better understand the present application, the following description is provided in conjunction with the appendix. Figure 4 Appendix Figure 5 The present application will be further described in detail with reference to specific embodiments. Figure 4 This is a schematic diagram of a data formatting service system provided in an embodiment of this application. Figure 4As shown, the service system comprises a storage module 1, a target function query module 2, a target function processing unit editing module 3, a target function processing unit cache area 4, and a commonly used file storage module 5. The storage module 1 is configured to store target function processing units; the target function query module 2 is configured to enable a user to query a target function, click a target function processing unit name to enter a page where the target function processing unit is located, and the page displays a target function processing unit code content, usage examples, a target data source input box, and an auxiliary parameter input box, and the user can input a target data source and auxiliary parameters to query a formatted result of the target data source; the target function processing unit editing module 3 is configured to generate a new function processing unit based on a code configuration input by the user; the target function processing unit cache area 4 is configured to temporarily store a target function processing unit selected by the user; and the commonly used file storage module 5 is configured to enable the user to store a collection of target function processing units that have been used by the user for reuse.

[0109] Specifically, the storage module 1: according to the conventional data classification, the server stores the executable function variable exported in a single file in a certain directory. The backend will read the folder and file directory under the directory, and return the read directory structure and the corresponding unique key value to the client. The client can query the collection of target function processing units by calling the interface; the collection is the root directory of the target function processing unit, which is divided into multiple subdirectories according to the data classification. The user can view the name information of the target function processing unit from the subdirectory.

[0110] The target function query module 2: the user can click each level of directory to query the target function processing unit required by the target data source formatting rule. Clicking the name of the target function processing unit can enter the page where the target function processing unit is located. The unique key value corresponding to the target function processing unit is used as a key parameter to call the backend interface. The backend interface reads the file content and returns it to the client in the form of a file stream. The user can view the detailed code and examples of the target function processing unit. The examples show what kind of processing result will be obtained after the target data source is processed by the target function processing unit.

[0111] The target function processing unit editing module 3: the user finds the target function processing unit, views the target function processing unit code, or views the target function processing unit usage examples. If it does not meet the requirements, the user can click the “edit” button. An editor will appear on the target function processing unit page. The user can edit and modify the code of the target function processing unit. Clicking the “save” button can add the new code of the edited target function processing unit to the target function processing unit cache area.

[0112] Target function processing unit cache area 4: the user queries the target function processing unit through the target function query module, views the code and use example of the target function processing unit, and if the target data source formatting requirement is met, the user can click the "add to file" button, and the target function processing unit is added to the function processing unit cache area for temporarily storing the target function processing unit selected by the user. If the code and use example of the target function processing unit do not meet the target data source formatting requirement of the user, the user can edit and modify the current target function processing unit through the target function processing unit editing module, and then click the "save" button, so that the new code of the edited target function processing unit is added to the target function processing unit cache area.

[0113] Common file storage module 5: the target function processing unit cache area has met all target data source formatting requirements of the user, and the user can click "store file" to save the file content of the current target function processing unit cache area.

[0114] Figure 5 The flowchart of the method for formatting data of the service system provided by the embodiment of the application. As shown in the figure, the method comprises the following steps. Figure 5

[0115] S13: obtaining the formatting rule of the target function source;

[0116] S14: querying the target function processing unit according to the formatting rule of the target function source;

[0117] S15: viewing the code logic and use example of the target function processing unit;

[0118] S16: determining whether the target function processing unit meets the formatting rule of the target function source; if not, proceeding to step S17; if yes, proceeding to step S18;

[0119] S17: editing and modifying the code of the target function processing unit;

[0120] S18: saving the target function processing unit to the target function processing unit cache area; and returning to step S13;

[0121] S19: storing the file.

[0122] Specifically, the first step is to obtain the formatting rule of the target function source, and according to the rule, the corresponding target function processing unit is queried according to the directory classification through the target function query module.

[0123] ​Second step: click the target function processing unit name, enter the directory where the target function processing unit is located; the client calls the backend interface with the unique key value corresponding to the target function processing unit as the key parameter, the backend interface reads the file content, and returns it to the client in the form of a file stream; the client converts the file stream and displays it in the code editor, the user can view the code logic of the target function processing unit, and determine whether the target data source format and auxiliary parameters of the target function processing unit meet the formatting rules of the target function source; or view the formatting rules usage example of the target function source, and determine whether the target function processing unit meets the target data source formatting rules; or input the target data source, according to the prompt input auxiliary parameters, click the "format" button, the client will pass the target function processing unit code, parameters and put into the execution stack execution, get the target data source formatting result, the user can view whether the target data source conversion result meets the expected result of the target data source formatting rule.

[0124] Third step: based on the previous step, if the target function processing unit meets the target data source formatting rule, click the "add to file" button, the client will call the interface, pass the key value corresponding to the target function processing unit to the backend as the key parameter, the backend reads the corresponding file content and adds it to the temporary cache file.

[0125] Fourth step: based on the second step, if the target function processing unit does not meet the target data source formatting rule, the user determines whether the target function processing unit can be modified based on the code logic to meet the target data source formatting rule requirements. If the modified target function processing unit can meet the target data source formatting rule requirements, click the "edit" button, a code editor will pop up on the target function processing unit page, the code editor content is the target function processing unit content, the user can edit and modify the code of the target function processing unit, then click the "save" button, the client calls the interface and passes the modified content to the backend as the key parameter, the backend reads the content and appends it to the temporary cache file.

[0126] Fifth step: continue to obtain the next target function source formatting rule, and execute the first to fourth steps in a loop until all target function processing units of the target function source formatting rule are added to the target function processing unit cache area. Then click the "store file" button, a dialog box will pop up, the user can input the storage file name, click the "save" button, and the temporary cache file will be added to the file storage module list with the input file name.

[0127] Step 6: Based on step 5, after all the target function processing units of the target function source format rule processing are added to the target function processing unit cache area, the target function processing unit cache area provides a "download" button. Clicking the download button can download the target file generated by the target function processing unit set cached in the target function processing unit cache area. Alternatively, entering the file storage module list, finding the target file, and clicking the "download" button can also download the target file.

[0128] Step 7: The developer can copy the target file to the project and import a certain target function processing unit in the component that needs to format the target data source through import to format the target data source.

[0129] The data formatting service system provided in the embodiment can be used by users to query the result of formatting a certain data. The system can also provide a lightweight code set of the target function processing unit for converting the target data source into the result according to the formatting rule for the front-end developer to filter and download for use, thereby avoiding the front-end developer from writing a large amount of commonly used code and avoiding the complexity of introducing various function tool libraries, and saving a large amount of development time for the front-end developer.

[0130] The above describes in detail the method, device, electronic device, and medium for data formatting provided in the application. The embodiments in the specification are described in a progressive manner, and each embodiment mainly describes the differences from other embodiments. The same or similar parts of each embodiment can be understood by referring to each other. For the device disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple, and the relevant parts can be understood by referring to the method part. It should be noted that the ordinary skilled in the art can make some improvements and modifications to the application without departing from the principles of the application, and these improvements and modifications also fall within the protection scope of the claims of the application.

[0131] It should also be noted that in the specification, the relationship terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between the entities or operations. Moreover, the terms "include", "contain" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.

Claims

1. A method of data formatting, characterized by, The method comprises: obtaining a target data source; obtaining a target data formatting function corresponding to the target data source from a storage file; obtaining a formatting result of the target data source according to the target data formatting function; establishing the storage file comprises: obtaining a formatting rule of a current data source; querying a current data formatting function corresponding to the current data source according to the formatting rule of the current data source; determining whether the current data formatting function meets the formatting rule of the current data source; if yes, storing the current data formatting function to the storage file; wherein the determining whether the current data formatting function meets the formatting rule of the current data source comprises: determining whether the current data formatting function meets the formatting rule of the current data source according to a current data source of the current data formatting function and an auxiliary parameter corresponding to the current data source, or determining whether the current data formatting function meets the formatting rule of the current data source according to a use example of the formatting rule of the current function source, or determining whether the current data formatting function meets the formatting rule of the current data source according to a result of formatting the current data source according to the auxiliary parameter corresponding to the current data source and a result of formatting the current data source according to the current data formatting function; the auxiliary parameter corresponding to the current data source is a parameter required to be input in the data formatting function; the method further comprises: in the case that the current data formatting function does not meet the formatting rule of the current data source, modifying the current data formatting function; and entering the step of storing the current data formatting function to the storage file.

2. The method of data formatting of claim 1, wherein, after determining that the current data formatting function meets the formatting rule of the current data source, and / or after modifying the current data formatting function, before storing the current data formatting function to the storage file, the method further comprises: saving the current data formatting function to a cache area for caching the current data formatting function; and returning to the step of obtaining the formatting rule of the current data source; in the case that all data formatting functions are added to the cache area, entering the step of storing the current data formatting function to the storage file.

3. The method of data formatting of claim 2, wherein, the determining whether the current data formatting function meets the formatting rule of the current data source comprises: obtaining the current data source and the auxiliary parameter corresponding to the current data source; formatting the current data source according to the auxiliary parameter corresponding to the current data source, and obtaining a first result of formatting; formatting the current data source according to the current data formatting function, and obtaining a second result of formatting; determining whether the current data formatting function meets the formatting rule of the current data source according to the first result and the second result; if yes, entering the step of storing the current data formatting function to the storage file; if no, entering the step of modifying the current data formatting function.

4. An apparatus for data formatting, characterized by The method comprises: The first obtaining module is configured to obtain a target data source; The second obtaining module is configured to obtain a target data formatting function corresponding to the target data source from a storage file The third obtaining module is configured to obtain a formatting result of the target data source according to the target data formatting function; The storage file is established by: Obtaining a formatting rule of a current data source; Querying a current data formatting function corresponding to the current data source according to the formatting rule of the current data source; Determining whether the current data formatting function meets the formatting rule of the current data source; If yes, storing the current data formatting function in the storage file; The determination of whether the current data formatting function meets the formatting rule of the current data source includes: determining whether the current data formatting function meets the formatting rule of the current data source according to a current data source of the current data formatting function and an auxiliary parameter corresponding to the current data source, or determining whether the current data formatting function meets the formatting rule of the current data source according to a use example of the formatting rule of the current function source, or determining whether the current data formatting function meets the formatting rule of the current data source according to a result of formatting the current data source according to the auxiliary parameter corresponding to the current data source and a result of formatting the current data source according to the current data formatting function; the auxiliary parameter corresponding to the current data source is a parameter that needs to be input in the data formatting function; Further comprising: If the current data formatting function does not meet the formatting rule of the current data source, modifying the current data formatting function; and entering the step of storing the current data formatting function in the storage file.

5. An electronic device, comprising: The computer program is stored on the computer readable storage medium and is executed by the processor to implement the steps of the data formatting method according to any one of claims 1 to 3. The computer program is stored on the computer readable storage medium and is executed by the processor to implement the steps of the data formatting method according to any one of claims 1 to 3. ​ 6. A computer-readable storage medium, characterized in that, ​

Citation Information

Patent Citations

  • Data table migrating method and device

    CN105205117A

  • Data processing method, device and equipment

    CN112860777A

  • Clinical test data conversion method and device, computer equipment and storage medium

    CN113971993A