Data development method and device, electronic equipment and storage medium

A common code library with ECMAScript Modules for front-end and CommonJS for back-end projects addresses inconsistent data types, enhancing data type consistency, reducing errors, and optimizing development processes.

CN119248338APending Publication Date: 2025-01-03BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411211938.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

Inconsistent data types between front-end and back-end projects due to separate development and maintenance by different teams, leading to development delays and complex maintenance.

Method used

Creating a common code library in a Monorepo to define and maintain shared data types, using ECMAScript Modules for front-end and CommonJS for back-end, ensuring consistent data types through centralized management and multiple build targets.

Benefits of technology

Ensures data type consistency, reduces errors and maintenance costs, improves collaboration efficiency, and simplifies version control by promoting unified data type definitions and centralized management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248338A_ABST
    Figure CN119248338A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data development method and device, electronic equipment and a storage medium, which are applied to the technical field of information, and the method comprises the following steps: creating data of a data type shared by a plurality of service request ends in a public code library; and when a data request sent by any service request end is received, sending the data of the data type to the service request end, so that the service request end executes the data of the data type. According to the method, data of a data type shared by service request ends can be created, and then when a data request sent by any service request end is received, the data of the data type is sent to the service request end, so that the service request end executes the data of the data type, and the data of the data type is introduced into the service request end; the problem that the project data types of the service request end are inconsistent is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of information technology, and in particular to a data development method, device, electronic equipment and storage medium. Background Art

[0002] At present, the software development process often includes front-end projects and back-end projects. Among them, the front-end project is generally responsible for the user interface and user experience, including the design, layout, interaction and style of the web page. The goal of the front-end project is generally to ensure that the user interface is attractive and user-friendly, as well as to optimize the user experience, such as page loading speed and interaction effects. The back-end project is mainly to handle the logic and data operations of the application, including database management, server-side programming and business logic. The focus of the back-end project is to ensure the rigor of business logic data processing and data throughput performance, as well as to handle data storage, reading and processing, interact with the database, and return the processing results to the front-end.

[0003] Then, during the development of front-end and back-end projects, they are generally developed by different teams. Since the front-end and back-end teams define and maintain data types separately, this often leads to inconsistent data types, causing development delays and complex maintenance. Summary of the invention

[0004] The purpose of the embodiments of the present invention is to provide a data development method, device, electronic device and storage medium to solve the problem of inconsistent data types of front-end and back-end projects. The specific technical solution is as follows:

[0005] In a first aspect of the present invention, a data development method is provided, the method comprising:

[0006] In the public code base, create data of data types that are shared by multiple business request terminals;

[0007] When a data request sent by any service request end is received, data of the data type is sent to the service request end, so that the service request end executes the data of the data type.

[0008] In a possible implementation, creating data of a data type shared by multiple service request terminals in a common code base includes:

[0009] Create a public module library in the open source distributed version control system Git;

[0010] In the common module library, data of the MaterialEntity data type shared by multiple service request terminals are set.

[0011] In a possible implementation, in the common module library, data of the MaterialEntity data type shared by multiple service request terminals is set, including:

[0012] In the package.json file of the public module library, multiple service request ends are set to correspond to multiple formats of codes for multiple build targets.

[0013] In a possible implementation, before setting data of the MaterialEntity data type shared by multiple service request terminals in the common module library, the method further includes:

[0014] Import the local library into the package.json file;

[0015] In the common module library, data of the MaterialEntity data type shared by multiple service request terminals are set, including:

[0016] In the common module library, data of data types commonly used in the local library are respectively introduced.

[0017] In a possible implementation, the multiple business request ends include a front end and a back end; in the front end project, data of the MaterialEntity data type is introduced through ECMAScript Modules; in the back end project, data of the MaterialEntity data type is introduced through CommonJS.

[0018] In a possible implementation, the front end is used to execute data of the data type and send the execution result to the back end; the back end is used to execute data of the data type to parse the received execution result.

[0019] In a second aspect of the present invention, a data development device is provided, the device comprising:

[0020] A data creation module is used to create data of data types shared by multiple business request terminals in a common code library;

[0021] The data sending module is used to send data of the data type to any service request end when receiving a data request sent by the service request end, so that the service request end executes the data of the data type.

[0022] In a possible implementation, the data creation module is specifically used to create a common module library in the open source distributed version control system Git; in the common module library, data of the MaterialEntity data type shared by multiple business request terminals is set.

[0023] In a possible implementation, the data creation module is specifically used to set codes in multiple formats corresponding to multiple construction targets for multiple business request ends in the package.json file of the public module library.

[0024] In a possible implementation, the device further includes:

[0025] The file import module is used to import the local library in the package.json file;

[0026] The data creation module is specifically used to import data of the common data types in the local library into the public module library.

[0027] In a possible implementation, the multiple business request ends include a front end and a back end; in the front end project, data of the MaterialEntity data type is introduced through ECMAScript Modules; in the back end project, data of the MaterialEntity data type is introduced through CommonJS.

[0028] In a possible implementation, the front end is used to execute data of the data type and send the execution result to the back end; the back end is used to execute data of the data type to parse the received execution result.

[0029] In another aspect of the present invention, there is provided an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0030] Memory, used to store computer programs;

[0031] The processor is used to implement any of the above-mentioned data development methods when executing the program stored in the memory.

[0032] In another aspect of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any of the above-mentioned data development methods is implemented.

[0033] In yet another aspect of the present invention, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned data development methods.

[0034] The embodiments of the present invention provide a data development method, device, electronic device and storage medium, which creates data of a data type shared by multiple business request terminals in a common code library; upon receiving a data request sent by any business request terminal, the data of the data type is sent to the business request terminal, so that the business request terminal executes the data of the data type. By creating data of a data type shared by the business request terminals, and then upon receiving a data request sent by any business request terminal, the data of the data type is sent to the business request terminal, so that the business request terminal executes the data of the data type, the data of the data type is introduced into the business request terminal, and the problem of inconsistent data types of business request terminal items is solved. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0036] Figure 1 A schematic diagram of a flow chart of a data development method in an embodiment of the present invention;

[0037] Figure 2 Another schematic diagram of a data development method in an embodiment of the present invention;

[0038] Figure 3 A schematic diagram of a process of introducing a local library in an embodiment of the present invention;

[0039] Figure 4 A structural diagram of a data development system in an embodiment of the present invention

[0040] Figure 5 A data flow diagram of the data development method in an embodiment of the present invention

[0041] Figure 6 A structural diagram of a data development device in an embodiment of the present invention

[0042] Figure 7 It is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION

[0043] The technical solutions in the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.

[0044] In order to solve the problem of inconsistent data types during the development of front-end and back-end projects, which is caused by different teams developing and defining and maintaining data types respectively, resulting in delayed development progress and complex maintenance, the embodiments of the present application provide a data development method, device, electronic device and storage medium.

[0045] In the first aspect of the present invention, a data development method is first provided. Figure 1 , the method comprising:

[0046] Step S11, creating data of a data type shared by multiple service request terminals in a common code library;

[0047] Step S12, when receiving a data request sent by any service request end, sending data of the data type to the service request end, so that the service request end executes the data of the data type.

[0048] Corresponding to the above step S11, in the common code library, a common module library can be created in Monorepo (a single repository containing multiple projects) to create data of data types shared by multiple business request ends, which is specifically used to define and maintain data types shared by business request ends. Business request end projects such as frontend and backend can rely on this common module, thereby ensuring data type consistency through references between modules.

[0049] Corresponding to the above step S12, when a data request is received from any business request end, the data of the data type is sent to the business request end so that the business request end executes the data of the data type. A data type file can be created in the library directory, for example, the created data type file is MaterialEntity.ts, and the data type is defined therein. The introduction of the data type in the business request end can ensure that the data type is used on demand at the business request end, for example, the MaterialEntity.ts file can be introduced in the business request end project respectively.

[0050] It can be seen that through the method of the embodiment of the present application, data of a data type shared by the business request end can be created, and then when a data request sent by any business request end is received, the data of the data type is sent to the business request end, so that the business request end executes the data of the data type, thereby introducing the data of the data type into the business request end, thereby solving the problem of inconsistent data types of business request end projects.

[0051] In one possible implementation, see Figure 2Step S11 creates data of data types shared by multiple service request terminals in a common code library, including:

[0052] Step S111, creating a public module library in the open source distributed version control system Git;

[0053] Step S112: setting data of the MaterialEntity data type shared by multiple service request terminals in the common module library.

[0054] In a possible implementation, the multiple business request ends include a front end and a back end; in the front end project, the data of the MaterialEntity data type is introduced by ECMAScript Modules; in the back end project, the data of the MaterialEntity data type is introduced by CommonJS. In a possible implementation, the front end is used to execute the data of the data type and send the execution result to the back end; the back end is used to execute the data of the data type to parse the received execution result. In an example, in the business logic or component of the front end project, the MaterialEntity data type is introduced by ESM (ECMAScript Modules, a JavaScript modular solution). For example, the introduced code is: typescript import{MaterialEntity}from"@***-vip / oasis-library"; in the front end project, the data type is introduced in this way, which ensures the unity and consistency of the project type. For example, the MaterialEntity type is used in the front end Component.vue file to define the attribute type of the component, so that the developer has clear type constraints during the development process and reduces errors. In the backend project, you can introduce the MaterialEntity data type through CommonJS (an application programming interface used by ordinary applications). For example, the introduced code is: typescript const{MaterialEntity}=require("@iXX-vip / oasis-library"), where XX can represent the company logo, such as the pinyin of the company's abbreviation; this introduction method can be applied to a pure Node.js environment. For example, in a service file in a Node.js application, the MaterialEntity type definition is introduced to ensure the correct parsing and processing of data by the front and back ends.

[0055] In a possible implementation, in the common module library, data of a MaterialEntity (a programming language module) data type shared by multiple service request ends is set, including: in the package.json file of the common module library, codes of multiple formats corresponding to multiple build targets of multiple service request ends are set. In the embodiment of the present application, the build target generates JS (JavaScript, a directly interpreted scripting language) code in different formats in order to take into account the requirements of the module system in different environments. Different build targets can be defined in the package.json file of the library to generate JS code in different formats.

[0056] Specifically, define build targets and scripts. You can define build targets in the package.json file of the library project to generate JS code in different formats of modules, such as:

[0057]

[0058] "default":". / src / index.ts"

[0059] },

[0060] "files":[

[0061] "dist",

[0062] "src"

[0063] ],

[0064] "engines":{

[0065] "node":">=10"

[0066] },

[0067] "scripts":{

[0068] "dev":"concurrently pnpm:dev:*",

[0069] "build":"concurrently pnpm:build:*",

[0070] "dev:esm":"tsc-w--project tsconfig.esm.json",

[0071] "dev:cjs":"tsc-w--project tsconfig.cjs.json",

[0072] "build:esm":"tsc--project tsconfig.esm.json",

[0073] "build:cjs":"tsc--project tsconfig.cjs.json"

[0074] }

[0075] The exports attribute is used to define the module's exit point, allowing the same module to be loaded in a variety of different ways.

[0076] The scripts property defines different build commands, specifically for ESM (a JavaScript modularization solution) and CommonJS modules.

[0077] In a possible implementation, in the common module library, before setting the data of the MaterialEntity data type shared by multiple service request terminals, see Figure 3 , the method further comprises:

[0078] Step S31, introducing the local library into the package.json file;

[0079] In the common module library, data of the MaterialEntity data type shared by multiple service request terminals are set, including:

[0080] Step S32: In the common module library, respectively import data of the data types commonly used in the local library.

[0081] In the embodiment of the present application, by referencing the local library in the front-end and back-end, it can be ensured that the front-end and back-end projects use a consistent library version. Specifically, the local library can be introduced in the package.json of the front-end and back-end projects.

[0082] In an example, the code for introducing the local library in the package.json of the front-end and back-end projects can be:

[0083] json

[0084] "dependencies":{

[0085] "@iXX-vip / oasis-library":"workspace:^0.0.0"

[0086] }

[0087] In this way, you can ensure that the front-end and back-end projects reference the same local library version, further improving data type consistency and facilitating project version management.

[0088] It can be seen that through the scheme of the embodiment of the present application, it is possible to achieve centralized management of data types, and by defining common modules and data type files, ensure that the front and back ends use consistent type definitions, and reduce problems caused by inconsistent types. It also supports multiple build targets, generates JS code in various formats during build, adapts to the needs of various environments, and improves the compatibility and flexibility of the project. It is also possible to achieve unified reference of local libraries, and the front and back end projects reference the same local library version, which simplifies version management, ensures data type consistency, and reduces maintenance costs.

[0089] In order to illustrate the solution of the embodiment of the present application, the following is further described in conjunction with specific embodiments. Figure 4 and Figure 5 , the solution of the embodiment of the present application, Figure 4 In the Monorepo, create the Library public module, the Client front-end project, the Server back-end project, the Library public module, and the MaterialEntity.ts obtained by the example, for example, MaterialEntity.ts, and then reference the data in the public module in the Client front-end project and the Server back-end project respectively. Through the CI / CD system (continuous integration / continuous delivery), Monorepo can be used to implement the Monorepo management method, and the front-end and back-end projects can be managed in a Monorepo warehouse; achieve consistency, the front-end and back-end projects share the same data type definition module, avoiding problems caused by inconsistent types; and achieve efficient collaboration, the front-end and back-end code changes can be synchronized immediately, reducing communication costs and time costs; and simplify version control, all codes are in the same warehouse, version control is simpler and clearer, and it is easy to manage and track problems. Figure 5In the process, the front-end developer, CI / CD system, and back-end developer interact with the Client front-end project, the Server back-end project, and the Monorepo, and the Client front-end project and the Server back-end project interact with the Library public module, and then interact with MaterialEntity.ts. The centralized management of data types in the embodiment of the present application can create a public module under the library directory of the Monorepo warehouse to define and maintain the data types shared by the front and back ends. To achieve type consistency, by centrally managing data types, the consistency of the front and back ends in data types is ensured, and interface call failures and data parsing errors are reduced; and maintenance costs are reduced. Centralized management reduces the complexity of version control and synchronization, making code maintenance simpler and more intuitive. The multiple module reference methods in the embodiment of the present application can realize the introduction of type files by the front-end project through the ESM method, and the introduction of type files by the back-end project through the CommonJS method, improve flexibility, support different module reference methods, ensure that data type modules can be used correctly in various runtime environments, and improve compatibility, effectively support the runtime environments of different ecosystems, and enhance the versatility and scalability of the project. The type safety and code quality of the embodiments of the present application can enhance type safety through centrally defined data types in front-end and back-end projects. It can not only improve code quality, reduce human errors through type constraints and checks, improve code reliability and maintainability, but also reduce bugs. Type safety greatly reduces the possibility of type errors, thereby reducing runtime bugs and unforeseen problems.

[0090] It can be seen that the scheme of the embodiment of the present application can improve the code quality, improve the consistency and maintainability of the code through unified data type definition and centralized management, reduce errors caused by type inconsistency, and thus improve the code quality; and reduce development costs, reduce the workload of maintaining data types separately on the front and back ends, greatly reduce maintenance costs and repetitive work, and at the same time reduce communication costs, improve team collaboration efficiency, and optimize the development process, simplify the complexity of front-end and back-end collaboration and version control, make the development, testing and deployment processes more efficient and smooth, and improve the development experience; improve support for extension and flexibility, support multiple module reference methods (ESM and CommonJS), ensure correct use in various runtime environments, and improve the versatility and extensibility of the system; and promote teamwork, through collaborative development on the same platform, promote close cooperation between the front and back end teams, and improve the execution efficiency and collaboration effect of the overall project.

[0091] In a second aspect of the present invention, a data development device is also provided. Figure 6 , the device comprises:

[0092] The data creation module 601 is used to create data of a data type shared by multiple service request terminals in a common code library;

[0093] The data sending module 602 is used to send data of the data type to any service request end when receiving a data request sent by the service request end, so that the service request end executes the data of the data type.

[0094] In a possible implementation, the data creation module is specifically used to create a common module library in the open source distributed version control system Git; in the common module library, data of the MaterialEntity data type shared by multiple business request terminals is set.

[0095] In a possible implementation, the data creation module is specifically used to set codes in multiple formats corresponding to multiple construction targets for multiple business request ends in the package.json file of the public module library.

[0096] In a possible implementation, the device further includes:

[0097] The file import module is used to import the local library in the package.json file;

[0098] The data creation module is specifically used to import data of the common data types in the local library into the public module library.

[0099] In a possible implementation, the multiple business request ends include a front end and a back end; in the front end project, data of the MaterialEntity data type is introduced through ECMAScript Modules; in the back end project, data of the MaterialEntity data type is introduced through CommonJS.

[0100] In a possible implementation, the front end is used to execute data of the data type and send the execution result to the back end; the back end is used to execute data of the data type to parse the received execution result.

[0101] It can be seen that through the device of the embodiment of the present application, a common module can be created, and then data of a data type shared by the front-end project and the back-end project can be created in the created common module, thereby introducing data of this data type into the front-end project and the back-end project. Since both the front-end project and the back-end project reference data from the same source, the problem of inconsistent data types between the front-end and back-end projects is solved.

[0102] The embodiment of the present invention further provides an electronic device, such as Figure 7 As shown, it includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, wherein the processor 701, the communication interface 702, and the memory 703 communicate with each other through the communication bus 704.

[0103] Memory 703, used for storing computer programs;

[0104] The processor 701 is used to execute the program stored in the memory 703 to implement the following steps:

[0105] In the public code base, create data of data types that are shared by multiple business request terminals;

[0106] When a data request sent by any service request end is received, data of the data type is sent to the service request end, so that the service request end executes the data of the data type.

[0107] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0108] The communication interface is used for communication between the above terminal and other devices.

[0109] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0110] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0111] In another embodiment of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the data development method described in any one of the above embodiments is implemented.

[0112] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the data development method described in any one of the above embodiments.

[0113] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0114] It should be noted that, in this article, relational terms such as first and second, etc. 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 these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0115] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, storage medium and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0116] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A data development method, characterized in that: The method comprises: In the public code base, create data of data types that are shared by multiple business request terminals; When a data request sent by any service request end is received, data of the data type is sent to the service request end, so that the service request end executes the data of the data type.

2. The method according to claim 1, characterized in that The data of the data type shared by multiple business request terminals is created in the common code library, including: Create a public module library in the open source distributed version control system Git; In the common module library, data of the MaterialEntity data type shared by multiple service request terminals are set.

3. The method according to claim 2, characterized in that In the common module library, data of the MaterialEntity data type shared by multiple service request terminals are set, including: In the package.json file of the public module library, multiple service request ends are set to correspond to multiple formats of codes for multiple build targets.

4. The method according to claim 3, characterized in that In the common module library, before setting data of the MaterialEntity data type shared by multiple service request terminals, the method further includes: Import the local library into the package.json file; In the common module library, data of the MaterialEntity data type shared by multiple service request terminals are set, including: In the common module library, data of data types commonly used in the local library are respectively introduced.

5. The method according to claim 2, characterized in that: The multiple business request ends include a front end and a back end; in the front end project, data of the MaterialEntity data type is introduced through ECMAScript Modules; in the back end project, data of the MaterialEntity data type is introduced through CommonJS.

6. The method according to claim 5, characterized in that The front end is used to execute data of the data type and send the execution result to the back end; the back end is used to execute data of the data type to parse the received execution result.

7. A data development device, characterized in that: The device comprises: A data creation module is used to create data of data types shared by multiple business request terminals in a common code library; The data sending module is used to send data of the data type to any service request end when receiving a data request sent by the service request end, so that the service request end executes the data of the data type.

8. The device according to claim 7, characterized in that The data creation module is specifically used to create a common module library in the open source distributed version control system Git; in the common module library, data of the MaterialEntity data type shared by multiple business request terminals are set.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 6 when executing a program stored in a memory.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 6 are implemented.