[go: up one dir, main page]

CN111522849A - Database dynamic access method, server and storage medium - Google Patents

Database dynamic access method, server and storage medium Download PDF

Info

Publication number
CN111522849A
CN111522849A CN202010324603.2A CN202010324603A CN111522849A CN 111522849 A CN111522849 A CN 111522849A CN 202010324603 A CN202010324603 A CN 202010324603A CN 111522849 A CN111522849 A CN 111522849A
Authority
CN
China
Prior art keywords
database
access
dynamic
user
access request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010324603.2A
Other languages
Chinese (zh)
Inventor
林陆锐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Chunchan Intelligent Information Technology Co ltd
Original Assignee
Shenzhen Chunchan Intelligent Information Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Chunchan Intelligent Information Technology Co ltd filed Critical Shenzhen Chunchan Intelligent Information Technology Co ltd
Priority to CN202010324603.2A priority Critical patent/CN111522849A/en
Publication of CN111522849A publication Critical patent/CN111522849A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Bioethics (AREA)
  • Software Systems (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a database dynamic access method, a server and a storage medium, wherein the method comprises the following steps: receiving an access request generated by a user trigger front end, wherein the access request comprises interface parameters; generating a dynamic function according to the access request, and performing data processing on a database of the server according to the dynamic function to generate a processing result; the front end can directly send an access request to the server end without passing through a back end application, interface parameters or the access request do not need to be modified correspondingly according to the type of the database, and after the server receives the access request, execution functions respectively corresponding to different databases can be dynamically generated according to the corresponding type of the database and a data operation request of a user, so that the operation processing of the database table is realized, and the back end requirement in the using process of the database can be reduced.

Description

Database dynamic access method, server and storage medium
Technical Field
The present invention relates to the field of database technologies, and in particular, to a database dynamic access method, a server, and a storage medium.
Background
In the process of performing operations such as adding, deleting, modifying, checking and the like on a database by the existing front-end application, an access request sent by the front end needs to be acquired by the back end, and a corresponding database interface needs to be called to operate the database after the access request is analyzed. Therefore, in order to realize convenient visualization operation of the front-end application, a corresponding interface code needs to be added in the back-end program to realize access operation of the front-end to the database. Moreover, when the front end needs to access different databases, developers are also required to perform adaptive interface coding on the different databases, so that the dependence on the back-end developers is greatly increased. When the development task of the back-end developer is difficult or the number of the personnel is insufficient, the on-line and the updating of the front-end application are influenced.
Disclosure of Invention
The invention mainly aims to provide a database dynamic access method, a server and a storage medium, and aims to solve the problem that a developer needs to perform interface compilation on a back end when a front end accesses a database.
In order to achieve the above object, the present invention provides a dynamic database access method, which is applied to a server, and comprises the following steps:
receiving an access request generated by a user trigger front end, wherein the access request comprises interface parameters;
generating a dynamic function according to the access request, and performing data processing on a database of the server according to the dynamic function to generate a processing result;
and returning the processing result to the front end.
Optionally, the step of generating a dynamic function according to the access request includes:
determining a request mode and a database resource object according to the interface parameters in the access request;
and dynamically generating a dynamic function for performing corresponding operation on the database resource object according to the request mode and the database resource object.
Optionally, the step of performing data processing on the database of the server according to the dynamic function includes:
dynamically loading the encapsulation class corresponding to the dynamic function by adopting a reflection mechanism;
and carrying out data processing on the database of the server according to the encapsulation class and the dynamic function.
Optionally, the step of receiving the access request generated by the user-triggered front end includes:
and receiving an access request which is generated by the front end according to a preset interface specification and contains a request mode and a database resource object after the front end is triggered by a user.
Optionally, before the step of generating a dynamic function according to the access request, the method further includes:
judging whether the front end has the access authority of the database or not according to the access request;
when the front end has the access right of the database, executing the following steps: generating a dynamic function according to the access request;
and when the front end does not have the access right of the database, returning a prompt of insufficient right to the front end.
Optionally, the step of determining whether the front end has the access right of the database according to the access request includes:
determining the user information of the front end according to the access request;
acquiring a preset user authority table, and judging whether the front end has an access authority or not according to the user authority table and the user information;
when the user information exists in the user authority table, determining that the front end has the access authority;
and when the user information does not exist in the user authority table, determining that the front end does not have the access authority.
Optionally, the step of obtaining a preset user permission table and determining whether the front end has an access permission according to the user permission table and the user information further includes:
determining a request mode of the front end according to the interface parameters in the access request;
and acquiring a preset user authority table, and judging whether the front-end user has the access authority of the request mode according to the user authority table.
Optionally, before the step of receiving the access request generated by the user-triggered front end, the method further includes:
and adding a preset field when a table is built in the database, wherein the preset field is used for realizing data processing of the dynamic function.
In addition, to achieve the above object, the present invention further provides a server, which includes a memory, a processor, and a database dynamic access program stored in the memory and operable on the processor, wherein: the database dynamic access program, when executed by the processor, implements the steps of the database dynamic access method described above.
In addition, to achieve the above object, the present invention further provides a computer readable storage medium, on which a database dynamic access program is stored, and the database dynamic access program, when executed by a processor, implements the steps of the database dynamic access method as described above.
According to the dynamic database access method, the server and the storage medium provided by the embodiment of the invention, the front end is triggered by a user to generate the access request comprising the interface parameters, the interface parameters correspond to the database table operation, after the front end sends the access request to the server, the server can analyze the access request to obtain the corresponding interface parameters, dynamically generate the interface parameters into the execution function capable of performing the data operation on the database according to the preset dynamic function generation rule, and connect the execution function with the database to perform the operation processing on the data. And generating a corresponding processing result after the processing is finished and returning the processing result to the front end to prompt the user. After receiving the trigger operation of the user, the front end can directly send the access request to a server which is connected with the database and can communicate with the outside according to the trigger operation, and the server directly generates an executable database dynamic function according to the interface parameters carried in the access request and processes the database. The method is different from the prior art that a developer at the back end compiles codes according to different database types and then gives out interface names which can be called, and the front end generates access requests according to the interface names given by the back end.
Drawings
FIG. 1 is a schematic diagram of an apparatus in a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a first embodiment of a dynamic database access method according to the present invention;
FIG. 3 is a flowchart illustrating a second embodiment of a dynamic database access method according to the present invention;
FIG. 4 is a flowchart illustrating a third embodiment of a database dynamic access method according to the present invention;
FIG. 5 is a flowchart illustrating a fourth embodiment of a database dynamic access method according to the present invention;
fig. 6 is a flowchart illustrating a fifth embodiment of a dynamic database access method according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, fig. 1 is a schematic device structure diagram of a hardware operating environment according to an embodiment of the present invention.
The terminal is a server, and the server is provided with a packet body required for receiving an access request, generating a dynamic function and operating a database, such as a default server startup packet, an application program main configuration file, a database connection configuration file, a dynamic query dependency packet, a query structure asynchronous IO dependency packet, a dynamic entity injection dependency packet, a linux system dependency packet installation script and the like.
As shown in fig. 1, the terminal may include: a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), a standard wired interface, a wireless interface, and the like. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Optionally, the terminal may further include a camera, a Radio Frequency (RF) circuit, a sensor, an audio circuit, a WiFi module, and the like. Of course, the hardware device may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, and so on, which are not described herein again.
Those skilled in the art will appreciate that the terminal structure shown in fig. 1 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, the memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a database dynamic access program.
In the terminal shown in fig. 1, the network interface 1004 is mainly used for connecting a front-end application and performing data communication with the front-end application; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and the processor 1001 may be configured to call the database dynamic access program stored in the memory 1005 and perform the following operations:
receiving an access request generated by a user trigger front end, wherein the access request comprises interface parameters;
generating a dynamic function according to the access request, and performing data processing on a database of the server according to the dynamic function to generate a processing result;
and returning the processing result to the front end.
Further, the processor 1001 may call a database dynamic access program stored in the memory 1005, and also perform the following operations:
determining a request mode and a database resource object according to the interface parameters in the access request;
and dynamically generating a dynamic function for performing corresponding operation on the database resource object according to the request mode and the database resource object.
Further, the processor 1001 may call a database dynamic access program stored in the memory 1005, and also perform the following operations:
dynamically loading the encapsulation class corresponding to the dynamic function by adopting a reflection mechanism;
and carrying out data processing on the database of the server according to the encapsulation class and the dynamic function.
Further, the processor 1001 may call a database dynamic access program stored in the memory 1005, and also perform the following operations:
and receiving an access request which is generated by the front end according to a preset interface specification and contains a request mode and a database resource object after the front end is triggered by a user.
Further, the processor 1001 may call a database dynamic access program stored in the memory 1005, and also perform the following operations:
judging whether the front end has the access authority of the database or not according to the access request;
when the front end has the access right of the database, generating a dynamic function according to the access request;
and when the front end does not have the access right of the database, returning a prompt of insufficient right to the front end.
Further, the processor 1001 may call a database dynamic access program stored in the memory 1005, and also perform the following operations:
determining the user information of the front end according to the access request;
acquiring a preset user authority table, and judging whether the front end has an access authority or not according to the user authority table and the user information;
when the user information exists in the user authority table, determining that the front end has the access authority;
and when the user information does not exist in the user authority table, determining that the front end does not have the access authority.
Further, the processor 1001 may call a database dynamic access program stored in the memory 1005, and also perform the following operations:
determining a request mode of the front end according to the interface parameters in the access request;
and acquiring a preset user authority table, and judging whether the front-end user has the access authority of the request mode according to the user authority table.
Further, the processor 1001 may call a database dynamic access program stored in the memory 1005, and also perform the following operations:
and adding a preset field when a table is built in the database, wherein the preset field is used for realizing data processing of the dynamic function.
The specific embodiment of the application server of the present invention is basically the same as the following embodiments of the application database dynamic access method, and is not described herein again.
Referring to fig. 2, fig. 2 is a schematic flowchart of a first embodiment of a dynamic database access method according to the present invention, wherein the dynamic database access method includes the following steps:
step S10, receiving an access request generated by a user trigger front end, wherein the access request comprises interface parameters;
after receiving a relevant instruction triggered by a user, a front-end application or a front-end page can generate a corresponding access request according to the triggering instruction and send the access request to a server capable of being used for configuring a database. After receiving the access request, the server may parse the corresponding interface parameter from the access request. For example, when a user triggers a change, check, and cut operation on a database table, an access request including corresponding interface parameters may be sent to a server, and the server may determine, according to the interface parameters, a corresponding operation that the front end needs to execute and determine a name of a database table that needs to be operated.
Step S20, generating a dynamic function according to the access request, and performing data processing on the database of the server according to the dynamic function to generate a processing result;
after the server receives the access request sent by the front end, a corresponding dynamic function can be generated according to the interface parameters in the access request and the preset dynamic function generation rule, and the data processing of the database table connected with the server is realized by calling the dynamic function. After the data processing is performed on the database according to the access request of the front end, a corresponding processing result can be generated. For example, after the user triggers the instruction to acquire the user information, the front end may send an access request url including the interface parameters: https:// example. com/api/{ datasource }/{ table } GET;
in the url, https:// example.com is a domain name path of the server, api can be used as a partition point for distinguishing the path from the interface service in the url, { datasource }/{ table } GET, { datasource }, { table } is a database table name, and GET is a query/acquire/read instruction, that is, the url is data information for acquiring the database table name { datasource }, { table } from the server having the domain name https:// example.com. After receiving the url, the server can analyze the url to obtain interface parameters of data source, table and GET, and dynamically generate a query function for a table with a database table name of { data source }, { table }, and the server can connect with the database according to the generated query function and obtain data information of the { data source }, { table } table from the database.
Step S30, returning the processing result to the front end.
After the server determines the database table resources required to be operated and the corresponding operation mode according to the interface parameters in the access request and performs resource operation, the server can generate corresponding processing results according to the results of the resource operation and return the processing results to the front end to prompt the user. The server can return the corresponding processing result through XML, json or a status code. After receiving the processing result in the corresponding format, the front end can visualize and display the processing result to the user. For example, in an operation of creating new data or deleting original data by a user, the front end may display a creation success or a deletion success to the user after receiving a processing result, and when the user uses an operation of querying data, the front end may display data information acquired from the database, that is, a query result, to the user after receiving the processing result. It can be understood that the front end directly sends the access request to the server, the database can be directly and dynamically accessed through the server, the front end can realize the database access through the standardized interface provided by the server, and the database operation interface provided by the back end is not needed to be utilized, so that the back end development process is avoided. Namely, the method does not need the participation of the back-end personnel at all in the development process of the front-end project, does not need the support of the back-end application, and greatly reduces the dependence on the back-end personnel in the development process of the front-end project.
In this embodiment, a user triggers a front end to generate an access request including interface parameters, the interface parameters correspond to database table operations, after the front end sends the access request to a server, the server may perform parsing to obtain corresponding interface parameters, dynamically generate the interface parameters according to a preset dynamic function generation rule into an execution function capable of performing data operations on a database, and connect the execution function with the database to perform operation processing on data. And generating a corresponding processing result after the processing is finished and returning the processing result to the front end to prompt the user. After receiving the trigger operation of the user, the front end can directly send the access request to a server which is connected with the database and can communicate with the outside according to the trigger operation, and the server directly generates an executable database dynamic function according to the interface parameters carried in the access request and processes the database. Compared with the prior art in which a developer at the back end compiles codes according to different database types and then gives out interface names which can be called, and the front end generates access requests according to the interface names given by the back end, the method is different in that the front end can directly send the access requests containing interface parameters and directly send the access requests to the server end without the application at the back end, and the interface parameters or the access requests do not need to be changed according to the types of the databases.
Further, referring to fig. 3, fig. 3 is a flowchart illustrating a second embodiment of the database dynamic access method of the present invention, based on the embodiment shown in fig. 2, in step S20, a dynamic function is generated according to the access request, and data processing is performed on the database of the server according to the dynamic function, and the step of generating a processing result includes:
step S21, determining a request mode and a database resource object according to the interface parameters in the access request;
step S22, according to the request mode and database resource object, dynamically generating a dynamic function for performing corresponding operation on the database resource object;
and step S23, performing data processing on the database of the server according to the dynamic function to generate a processing result.
In this embodiment, the server may determine the interface parameter sent by the front end from the received access request url, and further determine the resource object and the request mode in the database. The database resource object may include a database table name, a primary key, a data source ID, a field name, an optional argument, a specifiable page number, etc., and the request manner may include GET, POST, PUT, and DELETE. The server can determine an operation processing mode for the database according to the acquired request mode and the database resource object. The following are illustrative:
1. URL: /api/{ datasource }/{ table }; the request mode comprises the following steps: PUT; POST parameters: { "field name": value "};
wherein, the { database } and the { table } are names of database tables, and the operation is to add the POST parameters into the database.
2. URL: /api/{ datasource }/{ table }/{ id }; the request mode comprises the following steps: DELETE;
wherein, { id } is a primary key, and the operation is to delete the data corresponding to the primary key in the database table.
3. URL: /api/{ datasource }/{ table }/{ id }; the request mode comprises the following steps: PUT; POST parameters: { "field name": value "};
the operation is the data which modifies the original data in the main key of the database table into POST parameters.
4. URL: /api/{ datasource }/{ table }; the request mode comprises the following steps: POST; POST parameters:
Figure BDA0002461637530000091
Figure BDA0002461637530000092
the POST parameters are query conditions, and the operation is to query in a database table according to the query conditions sent by the POST parameters.
5. URL: /api/{ datasource }/{ table }/count; the request mode comprises the following steps: POST; POST parameters: inquiring conditions;
the operation is to query the total number of data satisfying the conditions in the database according to the query conditions sent by the POST parameters.
6. URL: /api/{ datasource }/{ table }/exist; the request mode comprises the following steps: POST; POST parameters: inquiring conditions;
the operation is to inquire whether data meeting the inquiry condition exists in the database according to the inquiry condition sent by the POST parameter.
7. URL: /{ datasource }/join; the request mode comprises the following steps: POST; POST parameters: query conditions,
Figure BDA0002461637530000101
Figure BDA0002461637530000102
Wherein { datasource } is a data source ID, and joinTables represent a joint table query, which is data meeting query conditions for the joint table query.
8. URL: /{ datasource }/join/count; the request mode comprises the following steps: POST; POST parameters: inquiring conditions and linked list;
the operation is to count the data meeting the query condition in the link table.
9. URL: /api/{ datasource }/{ table }/{ id }; the request mode comprises the following steps: GET; POST parameters: none;
this operation is to query whether there is a corresponding primary key ID in the database.
10. URL: /{ datasource }/logic; the request mode comprises the following steps: POST; POST parameters:
{ "username": user name ",
password;
the operation is to perform login verification through the sent POST parameters.
11. URL: /{ datasource }/logout; the request mode comprises the following steps: GET;
the operation is a request logout.
12. URL: /api/{ datasource }/download/{ table }/{ field }/{ id }; the request mode comprises the following steps: GET;
the operation is to acquire the corresponding database resource object file, i.e. to download the database file.
13. URL: /api/{ datasource }/preview/{ table }/{ field }/{ id }/{ page }; the request mode comprises the following steps: GET;
wherein { page } is selectable parameter, and can specify page number, and the operation is to acquire a corresponding database resource object and preview the database resource object, and can be pictures, videos, presentations, portable documents, and the like.
14. URL: /api/{ datasource }/{ table }/{ field }/upload; the request mode comprises the following steps: POST;
wherein { field } is a field name, the POST parameter may include a form and a plurality of files, the operation is to store the plurality of files in a database, and the server may return a relative path of each file to the front end after executing the storage process.
15. URL: /api/{ datasource }/{ table }/update; the request mode comprises the following steps: POST; POST parameters:
Figure BDA0002461637530000111
Figure BDA0002461637530000112
the operation is that the data meeting the query condition in the database table is modified into the data in the POST parameter, namely batch query updating is carried out.
16. URL: /api/{ datasource }/{ table }/delete; the request mode comprises the following steps: POST; POST parameters:
[id1,id2,...];
this operation is to delete the data with the primary keys id1, id2.
It can be understood that the server may also implement operations such as EXCEL export, cross-table query export EXCEL, new addition and return of a specified main key, video playing, EXCEL import, and the like according to a request manner and a database resource object combination manner, which are not described herein in detail.
The server can determine a specific operation mode according to the combination of the request mode and the database resource object in the access request, generate a corresponding dynamic function according to the type of the database connected with the server, and implement corresponding operation on the database by executing the dynamic function. The front end only needs to provide the database resource objects and the request modes needing to be operated in the access request, and does not need to know the database type of the server end, so that the problem that database data cannot be flexibly called through the front end due to unfamiliarity of technical personnel at the front end in the field of databases is avoided, different interface compiling aiming at the database type by rear-end developers can be omitted, the butt joint of the front end and the rear end is reduced, and the technical personnel at the rear end are liberated.
Further, referring to fig. 4, fig. 4 is a flowchart illustrating a third embodiment of the database dynamic access method of the present invention, based on the embodiment shown in fig. 3, in step S23, the step of performing data processing on the database of the server according to the dynamic function, and generating a processing result includes:
step S231, dynamically loading the packaging class corresponding to the dynamic function by adopting a reflection mechanism;
step S232, data processing is carried out on the database of the server according to the packaging class and the dynamic function.
In this embodiment, after determining the database operation mode specified by the user according to the request mode in the interface parameter and the database resource object, the server may generate a corresponding dynamic function according to the operation mode, and when loading the dynamic function, the server may dynamically load, through a reflection mechanism, a corresponding package class required for executing the dynamic function, and execute the dynamic function according to the loaded package class, so as to perform corresponding data processing on the database connected to the server. The required encapsulation class is loaded in the process of executing the dynamic function, so that the load of the server in normal operation can be effectively reduced, the source code does not need to be modified for compiling in the process of operating different dynamic functions, and the flexibility of processing data by the server is improved.
Further, referring to fig. 5, fig. 5 is a flowchart illustrating a fourth embodiment of the database dynamic access method of the present invention, based on the embodiment shown in fig. 3, in step S10, the step of receiving an access request generated by a user-triggered front end, where the step of receiving the access request includes an interface parameter includes:
step S11, receiving an access request containing a request mode and a database resource object generated by the front end according to a preset interface specification after the front end is triggered by a user, where the interface parameter includes the request mode and the database resource object.
In this embodiment, after being triggered by a user, the front end may generate an access request url including a request mode and a database resource object according to a preset interface specification, where the interface specification may be a Restful API interface specification, that is, a noun complex form is used to define a database resource object, and a verb is used to define a request mode to perform data operation on a database. For example:
GET http:// localhost:8080/api/user (query user)
POST http:// localhost:8080/api/user (New user)
PUT http:// localhost:8080/api/user (update user)
DELETE http:// localhost:8080/api/user (DELETE user);
through Restful API interface specifications, technicians at different front ends can unify interface parameter specifications in access requests, a server can dynamically generate an execution function according to received interface parameters meeting the interface specifications, and data processing is performed on a database, so that the server and the front end are separated, namely the front end expression mode can be any front end language (android, ios, html5 and the like).
Further, referring to fig. 6, fig. 6 is a schematic flowchart of a fifth embodiment of the dynamic database access method of the present invention, based on the embodiment shown in fig. 2, before the step of generating a dynamic function according to the access request, the step S20 further includes:
step S40, judging whether the front end has the access authority of the database according to the access request;
when the front end has the access right of the database, executing step S20: generating a dynamic function according to the access request;
and step S50, when the front end does not have the access right of the database, returning a prompt of insufficient right to the front end.
In this embodiment, since there is a security problem in the transmission process in a manner that the front end sends the access request to enable the server to operate the database, the server needs to determine whether the front end sending the access request has the access right of the database after receiving the access request generated by the front end. After the front end is subjected to access authority verification, if the front end has the access authority, the server can dynamically generate an execution function according to the received access request, and if the front end does not have the access authority, the server directly returns a prompt that the authority is insufficient and the operation cannot be performed like the front end, so that the operation times of the server are reduced, the operation load of the server is reduced, and the safety of the front end operating the database through the access request is improved.
Further, in a sixth embodiment of the database dynamic access method according to the present invention, based on the embodiment shown in fig. 6, in step S40, the step of determining whether the front end has the access right of the database according to the access request further includes:
step S41, determining the user information of the front end according to the access request;
step S42, obtaining a preset user authority table, and judging whether the front end has an access authority or not according to the user authority table and the user information;
step S43, when the user information exists in the user authority table, determining that the front end has the access authority;
step S44, when the user information does not exist in the user right table, determining that the front end does not have access right.
In this embodiment, the server may obtain, according to the received access request, user information of a front end that sends the access request, and query the user information from a pre-stored user permission table to determine whether the front end has an access permission. After the server inquires the user information of the user from the user authority table, the front end can be determined to have the access authority, otherwise, the front end does not have the access authority. The verification of the access authority can be realized according to the user information of the front end so as to protect the data in the database from illegal operation.
Further, in a seventh embodiment of the database dynamic access method according to the present invention, based on the sixth embodiment, the step S42 of obtaining a preset user permission table, and determining whether the front end has an access permission according to the user permission table and the user information further includes:
step S421, determining the request mode of the front end according to the interface parameter in the access request;
step S422, a preset user authority table is obtained, and whether the front-end user has the access authority of the request mode or not is judged according to the user authority table.
In this embodiment, the server may set different access permissions for different database operations, for example, the number of users having data query permissions may be set to be higher than the number of users having data addition, deletion, and modification permissions, so as to ensure stability of database data. After determining the request mode of the front end according to the interface parameters in the access request of the front end, the server can judge whether the user sending the access request has the access authority of the request mode from a preset user authority table. When a user requests to inquire data, the server can detect whether the user has inquiry authority or not, and return inquiry data when the user has the inquiry authority; when the user requests to delete the data but does not have the deletion right, the server can not execute the deletion operation and return a prompt of insufficient right. Different access authorities are set for different database operations, and the flexibility of database data operations can be improved on the premise of guaranteeing the safety of database data.
Further, in an eighth embodiment of the database dynamic access method according to the present invention, based on the embodiments shown in fig. 2 to 6, in step S10, the step of receiving an access request generated by a user-triggered front end, where the step of receiving the access request includes interface parameters further includes:
and step S70, adding a preset field when building a table in the database, wherein the preset field is used for realizing data processing of the dynamic function.
In this embodiment, in order to generate a dynamic function, the server needs to add a corresponding preset field when building a table in the database, so as to implement data processing functions such as dynamic query. Specifically, the server may add fields such as creator path, creation time, modification time, creator, group ID, role ID, etc. to the table to facilitate dynamic querying.
In addition, the invention also provides a computer readable storage medium, on which the database dynamic access program is stored. The computer-readable storage medium may be the Memory 20 in the terminal in fig. 1, and may also be at least one of a ROM (Read-only Memory)/RAM (Random Access Memory), a magnetic disk, and an optical disk, where the computer-readable storage medium includes several instructions to enable a terminal device (which may be a smart television, a mobile phone, a computer, a server, or a network device) having a processor to execute the database dynamic Access method according to the embodiments of the present invention.
It is to be understood that throughout the description of the present specification, reference to the term "one embodiment", "another embodiment", "other embodiments", or "first through nth embodiments", etc., is intended to mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A dynamic database access method is applied to a server and is characterized by comprising the following steps:
receiving an access request generated by a user trigger front end, wherein the access request comprises interface parameters;
generating a dynamic function according to the access request, and performing data processing on a database of the server according to the dynamic function to generate a processing result;
and returning the processing result to the front end.
2. The dynamic database access method of claim 1, wherein the step of generating a dynamic function based on the access request comprises:
determining a request mode and a database resource object according to the interface parameters in the access request;
and dynamically generating a dynamic function for performing corresponding operation on the database resource object according to the request mode and the database resource object.
3. The dynamic database access method according to claim 2, wherein the step of processing the database of the server according to the dynamic function comprises:
dynamically loading the encapsulation class corresponding to the dynamic function by adopting a reflection mechanism;
and carrying out data processing on the database of the server according to the encapsulation class and the dynamic function.
4. The dynamic database access method of claim 2, wherein the step of receiving a user-triggered front-end generated access request comprises:
and receiving an access request which is generated by the front end according to a preset interface specification and contains a request mode and a database resource object after the front end is triggered by a user.
5. The dynamic database access method of claim 1, wherein the step of generating a dynamic function based on the access request is preceded by the step of:
judging whether the front end has the access authority of the database or not according to the access request;
when the front end has the access right of the database, executing the following steps: generating a dynamic function according to the access request;
and when the front end does not have the access right of the database, returning a prompt of insufficient right to the front end.
6. The dynamic database access method of claim 5, wherein the step of determining whether the front end has the access right of the database according to the access request comprises:
determining the user information of the front end according to the access request;
acquiring a preset user authority table, and judging whether the front end has an access authority or not according to the user authority table and the user information;
when the user information exists in the user authority table, determining that the front end has the access authority;
and when the user information does not exist in the user authority table, determining that the front end does not have the access authority.
7. The dynamic database access method of claim 6, wherein the step of obtaining a preset user authority table and determining whether the front end has an access authority according to the user authority table and the user information further comprises:
determining a request mode of the front end according to the interface parameters in the access request;
and acquiring a preset user authority table, and judging whether the front-end user has the access authority of the request mode according to the user authority table.
8. The dynamic database access method according to any one of claims 1 to 7, wherein the step of receiving a user-triggered front-end generated access request is preceded by the steps of:
and adding a preset field when a table is built in the database, wherein the preset field is used for realizing data processing of the dynamic function.
9. A server, comprising a memory, a processor, and a database dynamic access program stored on the memory and executable on the processor, wherein: the database dynamic access program when executed by the processor implements the steps of the database dynamic access method of any of claims 1 to 8.
10. A computer-readable storage medium, having a database dynamic access program stored thereon, which when executed by a processor implements the steps of the database dynamic access method of any one of claims 1 to 8.
CN202010324603.2A 2020-04-22 2020-04-22 Database dynamic access method, server and storage medium Pending CN111522849A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010324603.2A CN111522849A (en) 2020-04-22 2020-04-22 Database dynamic access method, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010324603.2A CN111522849A (en) 2020-04-22 2020-04-22 Database dynamic access method, server and storage medium

Publications (1)

Publication Number Publication Date
CN111522849A true CN111522849A (en) 2020-08-11

Family

ID=71910632

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010324603.2A Pending CN111522849A (en) 2020-04-22 2020-04-22 Database dynamic access method, server and storage medium

Country Status (1)

Country Link
CN (1) CN111522849A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111949719A (en) * 2020-08-20 2020-11-17 深圳天顺智慧能源科技有限公司 Method and device for realizing configuration tool of power system and related components
CN112711628A (en) * 2020-12-30 2021-04-27 北京楚梵基业科技有限公司 Data interaction method, device and central station
CN112822284A (en) * 2021-01-22 2021-05-18 平安壹钱包电子商务有限公司 Data processing method and device based on dynamic proxy and computer equipment
CN113064878A (en) * 2021-03-03 2021-07-02 深圳市科陆电子科技股份有限公司 High concurrent access system, method and storage medium for database records based on MQTT
CN115714818A (en) * 2021-08-20 2023-02-24 北京小米移动软件有限公司 Data processing method and device, server and storage medium
CN116208668A (en) * 2023-05-05 2023-06-02 北京零壹视界科技有限公司 Data caching method, device, equipment and medium based on content distribution network

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4937743A (en) * 1987-09-10 1990-06-26 Intellimed Corporation Method and system for scheduling, monitoring and dynamically managing resources
CN105335432A (en) * 2014-08-11 2016-02-17 无锡华润微电子有限公司 Oracle database access method
CN105553733A (en) * 2015-12-23 2016-05-04 北京安托软件技术有限公司 Resource monitoring and management system
CN106257460A (en) * 2016-08-24 2016-12-28 天津天大求实电力新技术股份有限公司 Data base's general-purpose accessing implementation method for micro-capacitance sensor monitoring system
CN109032797A (en) * 2018-07-18 2018-12-18 上海恺英网络科技有限公司 For providing the method and apparatus of web page access

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4937743A (en) * 1987-09-10 1990-06-26 Intellimed Corporation Method and system for scheduling, monitoring and dynamically managing resources
CN105335432A (en) * 2014-08-11 2016-02-17 无锡华润微电子有限公司 Oracle database access method
CN105553733A (en) * 2015-12-23 2016-05-04 北京安托软件技术有限公司 Resource monitoring and management system
CN106257460A (en) * 2016-08-24 2016-12-28 天津天大求实电力新技术股份有限公司 Data base's general-purpose accessing implementation method for micro-capacitance sensor monitoring system
CN109032797A (en) * 2018-07-18 2018-12-18 上海恺英网络科技有限公司 For providing the method and apparatus of web page access

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
金玉明: "《精通SQL Server 2008完全自学手册》", 中国铁道出版社, pages: 264 - 265 *

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111949719A (en) * 2020-08-20 2020-11-17 深圳天顺智慧能源科技有限公司 Method and device for realizing configuration tool of power system and related components
CN111949719B (en) * 2020-08-20 2024-05-07 深圳天顺智慧能源科技有限公司 Method and device for realizing configuration tool of power system and related components
CN112711628A (en) * 2020-12-30 2021-04-27 北京楚梵基业科技有限公司 Data interaction method, device and central station
CN112822284A (en) * 2021-01-22 2021-05-18 平安壹钱包电子商务有限公司 Data processing method and device based on dynamic proxy and computer equipment
CN113064878A (en) * 2021-03-03 2021-07-02 深圳市科陆电子科技股份有限公司 High concurrent access system, method and storage medium for database records based on MQTT
CN115714818A (en) * 2021-08-20 2023-02-24 北京小米移动软件有限公司 Data processing method and device, server and storage medium
CN116208668A (en) * 2023-05-05 2023-06-02 北京零壹视界科技有限公司 Data caching method, device, equipment and medium based on content distribution network

Similar Documents

Publication Publication Date Title
CN111522849A (en) Database dynamic access method, server and storage medium
US9317681B2 (en) Information processing apparatus, information processing method, and computer program product
US8136095B2 (en) Relations in fuzzing data
CN110941779B (en) Page loading method and device, storage medium and electronic equipment
US11882154B2 (en) Template representation of security resources
CN110083338B (en) Service system based on intelligent gateway
CN111026669A (en) Test log management method, test log management device and storage medium
CN111767109A (en) H5 page display method, device and readable storage medium based on terminal application
CN111124544A (en) Interface display method and device, electronic equipment and storage medium
CN112214714A (en) Request processing method, device and equipment based on configuration file and storage medium
CN110266792B (en) Address translation method, address translation device, address translation equipment and computer-readable storage medium
WO2021093672A1 (en) Method for embedding external system, workflow system, device and computer readable storage medium
CN115002548B (en) Television platform application interface calling method and device, terminal equipment and storage medium
CN109918112B (en) Game hot update method, device and storage medium
CN112925589A (en) Calling method and device of expansion interface
WO2024239757A1 (en) Sub-application running method and apparatus, and computer device and storage medium
CN115525305A (en) Data processing method, application starting method, device, computer equipment and storage medium
CN112836189A (en) Third-party application access method, terminal and computer-readable storage medium
CN113791795A (en) Plug-in installation method, device, system, equipment and storage medium
CN113746941B (en) Method, device and storage medium for removing restriction of third-party cookie
KR102258241B1 (en) Server side data component for support of development and management and method for perform the data component
CN112367394A (en) Large-screen cloud disk data request method, intelligent large-screen terminal and readable storage medium
CN113722538B (en) Interface dynamic rendering method and device
CN110247966B (en) Kernel creation method, smart television and computer-readable storage medium
CN117608677B (en) Plug-in generation method, cloud service system and service access method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200811