Method for simulating background cry interface service based on node, electronic equipment and storage medium
Based on the Node simulation background CRUD interface service, the time loss of the R & D joint adjustment stage and the problem of serious dependence between personnel rely on personnel have been solved, and the CRUD interface services are quickly created, and the efficiency of software development has been improved.
Patent Information
- Application Number
- CN202411409574.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-01-24
AI Technical Summary
In the existing technology, there are serious problems of time loss and resource dependence among personnel in the joint research and development stage, resulting in low software development efficiency.
By Node -based simulation background CRUD interface services, the visual project table and Nodejs Express module packaging routing modular requesting service is used to quickly create the access path of the CRUD interface to reduce the dependence between personnel.
It realizes the rapid creation of crud simulation interface services for each module in the project development process, simplifies the development process, improves software development efficiency, and reduces the inefficiency of personnel interdependence.
Smart Images

Figure CN119357265A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of software technology, and in particular relates to a method, electronic equipment and storage medium based on node simulation background CRUD interface service. Background Art
[0002] Nowadays, front-end technologies and frameworks are developing rapidly. For current front-end development practitioners, front-end personnel are increasingly required to have back-end development ideas and master basic full-stack development capabilities. In actual development work, when back-end personnel are developing multiple projects in parallel and have no time to provide necessary support to front-end personnel, front-end personnel also need to rely on their own technology stack to achieve loose coupling with back-end personnel.
[0003] In addition, as business needs gradually increase, some complex and difficult requirements are bound to be tight and demanding. Under multiple contradictions, it is becoming increasingly important and necessary to minimize the mutual dependence and mutual constraints of technical personnel in the collaborative links of the software development process and improve the efficiency of software development. Summary of the invention
[0004] In view of this, the present invention provides a method, electronic device and storage medium for simulating background CRUD interface service based on Node to solve the problems of time loss and serious resource dependence between personnel in the R&D joint debugging stage in the prior art.
[0005] In the first aspect, the present invention provides a method for simulating background CRUD interface services based on Node, including: creating a visual project table based on a local database; encapsulating a routing modular request service based on the visual project table and the Express module of NodeJS to obtain an access path for the CRUD interface.
[0006] In some embodiments, a routing modular request service is encapsulated based on the visual project table and the express module of nodejs to obtain an access path of the CRUD interface, specifically including: modifying the corresponding table name in each interface code based on the visual project table; introducing a routing module based on the visual project table in the main entry file index.js; modifying the database configuration file db.config.js according to the routing module based on the visual project table, configuring the connection and basic information of the local database, and obtaining the access path of the CRUD interface.
[0007] In some implementations, the corresponding table name in each interface code is modified based on the visualization project table, specifically including: copying the userRouter.js file of the node routing module, wherein the node routing module has four interfaces; and modifying the names of the four interfaces to table names respectively.
[0008] In some implementations, the four interfaces include: an interface for querying a piece of data, an interface for querying all data, an interface for inserting a piece of data, and an interface for updating data.
[0009] In some implementations, the method for simulating a background CRUD interface service based on a node further includes: customizing, extending, and performing secondary development on the interface code according to business needs.
[0010] In some implementations, the 3001 port service is enabled locally.
[0011] In some implementations, the method for simulating background CRUD interface services based on Node also includes: using EJS templates to add HTML pages to achieve dynamic rendering.
[0012] In some implementations, the method for simulating a background CRUD interface service based on Node also includes: installing an ExcelJS plug-in based on Node to implement file export.
[0013] In a second aspect, the present invention also provides an electronic device, comprising: at least one processor; a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can: create a visual project table based on a local database; encapsulate a routing modular request service based on the visual project table and the Express module of NodeJS to obtain an access path of a CRUD interface.
[0014] In a third aspect, the present invention provides a storage medium storing a computer program, which, when executed by a processor, implements any of the methods described in item 1 for simulating a background CRUD interface service based on a node.
[0015] The beneficial effects of the present invention are:
[0016] With simple process-based operations and simple code copying and configuration, you can quickly create a relatively neat series of CRUD simulation interface services for each module in the project development process. It is simple, easy to use, fast and convenient, and has the characteristics of maintainability and scalability. It can reduce the inefficiencies such as personnel constraints, mutual dependence and waiting caused by various factors in actual development scenarios. When the back-end personnel cannot provide interface support, the front-end personnel's workflow will not be affected, thereby improving software development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 This is a flowchart of a method for simulating background CRUD interface services based on node according to an embodiment of the present invention;
[0019] Figure 2 The figure is a block diagram of an electronic device according to an embodiment of the present invention.
[0020] Description of reference numerals:
[0021] 110. Processor;
[0022] 120. Memory. DETAILED DESCRIPTION
[0023] In related technologies, with the mainstream trend of the macro-economic downturn, enterprises need to streamline mechanisms to improve efficiency. However, the streamlining of personnel and the improvement of efficiency always seem to contradict each other. On the other hand, the business needs of enterprises are also gradually increasing. Some complex and difficult needs are bound to be tight on time and heavy on tasks, which forms another contradiction between streamlining and efficiency. Today's front-end technology is an era of componentization, modularization, and engineering. The rapid development of front-end technology and frameworks requires front-end personnel to have back-end development ideas and master basic full-stack development capabilities for current front-end development practitioners.
[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0025] Combine the following Figure 1 and Figure 2 , describing an embodiment of the present invention.
[0026] like Figure 1 As shown, according to an embodiment of the present invention, on the one hand, a method for simulating a background CRUD interface service based on a node is provided, comprising the following steps:
[0027] Step S101: Create a visualization project table according to the local database.
[0028] Step S103: Encapsulate the routing modular request service based on the visualized project table and the express module of nodejs to obtain the access path of the crud interface.
[0029] In this embodiment, you can use visualization tool software such as sqlyog to create a new table goods for the local MySQL service database. The names of the fields in the goods table are based on the project business requirements. The local MySQL service creates libraries and tables, and uses the local library to simulate the remote real library. This method has the same convenient advantages as the real library, which is easy to modify and maintain.
[0030] The modular development of nodejs server routing is the core code part of the present invention. The express server of nodejs is used to implement the CRUD basic interface code writing of different modules of the project, and the common configurations between different modules are extracted into a unified configuration file under the config package. The front-end personnel only need to make simple configurations, and the simulated services can respond and run quickly, thereby reducing the time loss in the R&D joint debugging stage, shielding the waiting bottleneck of resource dependence between personnel, and being able to ensure cost and increase efficiency, and complete the software delivery process on time, with quality and quantity guaranteed.
[0031] Furthermore, the above step S103 encapsulates the routing modular request service based on the visualized project table and the express module of nodejs to obtain the access path of the crud interface, which specifically includes the following steps:
[0032] Step S1031: modify the corresponding table name in each interface code based on the visualization project table.
[0033] Step S1033: In the main entry file index.js, introduce a routing module based on the visual project table.
[0034] Step S1035: modify the database configuration file db.config.js according to the routing module based on the visual project table, configure the connection and basic information of the local database, and obtain the access path of the CRUD interface.
[0035] In this embodiment, the access path of the CRUD interface can be obtained through basic data support, modular development of nodejs server routing and configuration of js configuration files. The basic data support is the local MySQL database environment, which builds the MySQL service locally and quickly builds tables with visual tools. Modify the js code logic, copy the node routing module userRouter.js file and rename it, for example, goodsRouter.js. For the modular routing file js code of node, you only need to make a simple copy and rename the interface name and sql table name. After the system service is started, the CRUD supporting interface of the local library local table can be automatically generated, which is convenient, easy to use, compact and lightweight.
[0036] In the main entry file index.js, introduce the new product routing module goodsRouter.js: constgoodsRouter = require('. / router / goodsRouter'); app.use(' / goods',goodsRouter).
[0037] Through the code configuration file, only simple modifications are needed to take effect quickly, and it has the advantages of easy pluggability and expansion during transplantation.
[0038] Furthermore, in step S1031, the corresponding table name in each interface code is modified based on the visualization project table, which specifically includes the following steps:
[0039] Step S10311: Copy the userRouter.js file of the node routing module, where the node routing module has four interfaces.
[0040] Step S10313: Modify the names of the four interfaces to table names respectively.
[0041] Among them, there are four basic interfaces in the node routing module, and then modify the corresponding table name in each interface code respectively.
[0042] Furthermore, the four interfaces include: an interface for querying a piece of data, an interface for querying all data, an interface for inserting a piece of data, and an interface for updating data.
[0043] In this embodiment, the interface names of the four interfaces are modified respectively as follows: interface for querying a certain piece of data (modifying the interface name / getUser to / getGoods), interface for querying all data (modifying the interface name / getUserList to / getGoodsList), interface for inserting a piece of data (modifying the interface name / addUser to / addGoods), and interface for updating data (modifying the interface name / updateUser to / updateGoods).
[0044] Modify the database configuration file db.config.js and configure the local MySQL connection URL, user, password and basic database information.
[0045] Finally, start the service. By default, port 3001 is enabled locally:
[0046] Install nodemon dependencies globally and run the command line:
[0047] nodemon. / index.js
[0048] The final access path of the CRUD interface is:
[0049] / goods / getGoods
[0050] / goods / getGoodsList
[0051] / goods / addGoods
[0052] / goods / updateGoods.
[0053] Furthermore, the method for simulating the background CRUD interface service based on the node also includes: customizing, extending and secondary developing the interface code according to business needs.
[0054] In this embodiment, although the process is fixed, the simulated module interfaces still have the characteristics of scalability and maintainability. Front-end developers can customize, expand and redevelop the modular routing code according to business needs. For example, not only can they implement the CRUD interface, but they can also install the Node-based Exceljs plug-in to add support for Excel file download and export. It is flexible and convenient, and the interface is easy to expand and maintain.
[0055] Optionally, open port 3001 service locally.
[0056] The present invention is based on the node environment, the amount of code is actually very small, and it is a truly lightweight local background service simulation system. It only needs to occupy one port 3001 to simulate all the CRUD interfaces of the entire project.
[0057] Furthermore, the method for simulating the background CRUD interface service based on Node also includes: using EJS template to add HTML page to achieve dynamic rendering.
[0058] In this embodiment, the functions can be further expanded iteratively in the future. This invention is worth further exploring and studying in the future, and there is room for iterative expansion. For example, by using ejs template technology, dynamic rendering support for html pages can be added to the system.
[0059] The method for simulating the background CRUD interface service based on node also includes: installing an exceljs plug-in based on node to realize file export.
[0060] When the project requires Excel file export, you can also install the node-based Exceljs plug-in support for the platform, so that you can not only implement the CRUD class interface, but also implement other types of simulation interfaces such as file export.
[0061] In the process of software development, the most time-consuming interface joint debugging and docking process provides a general, simple and lightweight solution with high availability features, especially for medium and even large projects with tight deadlines and heavy tasks. It can reduce development time and completely block the disadvantages of interface joint debugging that depends on resources from each other or even cannot be deadlocked and stopped due to insufficient resources. While providing convenience for developers, it can save the manpower and financial resources of the project team invisibly, improve the development speed, and also reduce the development cost.
[0062] The present invention encapsulates the routing modular request service based on the express module of nodejs and relies on the mysql environment installed locally on the computer. Only simple code modification and configuration are required to simulate and start the CRUD interface service on the local computer of the front-end personnel.
[0063] When the interface joint debugging of a certain function of a certain module of the project is carried out, the front-end personnel first create a new table in the local database of the project with visualization tools such as sqlyog, and then copy the express routing file in the code package and perform simple configuration and modification. The main entry file is started in the node command line mode, and the creation of a series of CRUD interfaces related to the module can be quickly completed. With the local CRUD simulation interface, the front-end personnel are relatively at ease and get twice the result with half the effort when the interface is joint debugged. In addition, the present invention also fully supports the front-end personnel to flexibly expand the interface according to the specific logic of the business, and has maintainability and scalability. In fact, in the actual software development scenario, the work links of multi-person collaborative docking properties, such as interface joint debugging development, are often relatively time-consuming and laborious. First, the interface may be fragmented and numerous, and the second is that the differentiated details and configurations of the interfaces of different modules of the project often need to be considered in advance. When the project schedule is tight and the task is heavy, both the front-end personnel and the back-end personnel are often not considered carefully, resulting in the interface joint debugging progress being slower than expected, which may affect the deadline delivery in severe cases. On the other hand, if an emergency occurs, such as when the development team is short of staff or even funds are tight, and the backend engineers are too busy to take care of multiple projects at the same time, the interfaces cannot usually be provided to the front-end personnel in a timely manner. At this time, if a certain interface is very important in business logic and will affect the global business logic, the front-end personnel can only stop development and wait for the progress of the backend, causing a deadlock in the development process. This is by no means an exaggeration.
[0064] In the process of interface debugging, the interfaces of most modules in most projects are essentially CRUD. When there is no background support, front-end personnel can simulate the necessary background interface implementation by themselves through simple copy and paste or even simple code configuration, which is bound to save a lot of valuable time in the interface debugging process.
[0065] Although the present invention is a simulation interface, it has a high degree of simulation. You only need to follow a few fixed steps, copy and modify simple codes, and do simple basic configuration to quickly build most of the CRUD interfaces that simulate actual projects. For the interface joint debugging process of front-end personnel, the effect is almost the same as that of real back-end interfaces such as Java.
[0066] like Figure 2 As shown, according to an embodiment of the present invention, on the other hand, an electronic device is provided, including: at least one processor 110; a memory 120 communicatively connected to the at least one processor, wherein the memory 120 stores instructions executable by the at least one processor 110, and the instructions are executed by the at least one processor 110, so that the at least one processor 110 can perform the following steps:
[0067] Step S101: Create a visualization project table according to the local database.
[0068] Step S103: Encapsulate the routing modular request service based on the visualized project table and the express module of nodejs to obtain the access path of the crud interface.
[0069] According to an embodiment of the present invention, on the other hand, a storage medium is provided, storing a computer program, which implements any one of the methods of simulating background CRUD interface services based on node when executed by a processor.
[0070] The computer executes the instructions to perform the following steps:
[0071] Step S101: Create a visualization project table according to the local database.
[0072] Step S103: Encapsulate the routing modular request service based on the visualized project table and the express module of nodejs to obtain the access path of the crud interface.
[0073] In general, program modules include routines, programs, libraries, objects, classes, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The functions of program modules can be combined or separated between program modules as needed in various embodiments. The machine executable instructions of program modules can be executed in local or distributed devices. In distributed devices, program modules can be located in both local storage media and remote storage media.
[0074] The program code for executing the disclosed method can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer or other programmable data processing device so that the program code enables the function / operation specified in the flow chart and / or block diagram to be realized when the program code is executed by the processor or controller. The program code can be executed completely on the machine, partially on the machine, as an independent software package, partially on the machine and partially on a remote machine, or completely on a remote machine or server.
[0075] The above program code can be implemented on a machine-readable medium, which can be any tangible medium that can contain or store a program used by or in conjunction with an instruction execution system, device or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium can include, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device or device, or any suitable combination of the foregoing. More specific examples of machine-readable storage media will include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. The various embodiments in this specification are described in a progressive manner, and the same and similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the apparatus, device, and non-volatile computer storage medium, 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.
[0076] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A method for simulating background CRUD interface service based on node, characterized in that: include: Create a visual project table based on the local database; Based on the visual project table and the express module of nodejs, the routing modular request service is encapsulated to obtain the access path of the crud interface.
2. The method for simulating background CRUD interface service based on node according to claim 1 is characterized in that: Based on the visual project table and the express module of nodejs, the routing modular request service is encapsulated to obtain the access path of the crud interface, which specifically includes: Modify the corresponding table name in each interface code based on the visualization project table; In the main entry file index.js, introduce the routing module based on the visual project table; The database configuration file db.config.js is modified according to the routing module based on the visual project table, the connection and basic information of the local database are configured, and the access path of the CRUD interface is obtained.
3. The method for simulating background CRUD interface service based on node according to claim 2 is characterized in that: Modify the corresponding table name in each interface code based on the visualization project table, specifically including: Copy the userRouter.js file of the node routing module, where the node routing module has four interfaces; The names of the four interfaces are respectively modified to table names.
4. The method for simulating background CRUD interface service based on node according to claim 3 is characterized in that: The four interfaces include: an interface for querying a piece of data, an interface for querying all data, an interface for inserting a piece of data, and an interface for updating data.
5. The method for simulating background CRUD interface service based on node according to any one of claims 1 to 4, characterized in that: Also includes: The interface code is customized, expanded and redeveloped according to business needs.
6. The method for simulating background CRUD interface service based on node according to any one of claims 1 to 4, characterized in that: Open port 3001 service locally.
7. The method for simulating background CRUD interface service based on node according to any one of claims 1 to 4, characterized in that: Also includes: Use ejs template to add html page to achieve dynamic rendering.
8. The method for simulating background CRUD interface service based on node according to any one of claims 1 to 4, characterized in that: Also includes: Install the node-based exceljs plug-in to realize file export.
9. An electronic device, characterized in that: include: at least one processor (110); a memory (120) communicatively coupled to the at least one processor (110); The memory (120) stores instructions executable by the at least one processor (110), and the instructions are executed by the at least one processor (110) to enable the at least one processor (110) to: Create a visual project table based on the local database; Based on the visual project table and the express module of nodejs, the routing modular request service is encapsulated to obtain the access path of the crud interface.
10. A storage medium, characterized in that: A computer program is stored, and when the computer program is executed by a processor, the method for simulating a background CRUD interface service based on a node as described in any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Node.js-based database request modular processing method and device and storage medium
CN113467765A
Application interface development method and device, equipment and storage medium
CN115904325A