CN117874112A - Method for realizing dynamic interface configuration - Google Patents

Method for realizing dynamic interface configuration Download PDF

Info

Publication number
CN117874112A
CN117874112A CN202410027840.0A CN202410027840A CN117874112A CN 117874112 A CN117874112 A CN 117874112A CN 202410027840 A CN202410027840 A CN 202410027840A CN 117874112 A CN117874112 A CN 117874112A
Authority
CN
China
Prior art keywords
configuration
sql
data
group
data table
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
CN202410027840.0A
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.)
Huaneng Dingbian New Energy Electricity Generating Co ltd
Beijing Huaneng Xinrui Control Technology Co Ltd
Original Assignee
Huaneng Dingbian New Energy Electricity Generating Co ltd
Beijing Huaneng Xinrui Control 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 Huaneng Dingbian New Energy Electricity Generating Co ltd, Beijing Huaneng Xinrui Control Technology Co Ltd filed Critical Huaneng Dingbian New Energy Electricity Generating Co ltd
Priority to CN202410027840.0A priority Critical patent/CN117874112A/en
Publication of CN117874112A publication Critical patent/CN117874112A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/25Integrating or interfacing systems involving database management systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/21Design, administration or maintenance of databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method for realizing dynamic interface configuration, which comprises the following steps of; creating a configuration group table in the platform; configuring a corresponding SQL data table; associating the configuration group table with an SQL data table; converting the configuration group table and the SQL data table into Map sets respectively; receiving a call request of a call interface, analyzing a path and checking; after successful calibration, acquiring and judging a data source of the SQL data table, and loading related drivers according to the data source; and outputting the result in the unified format. The method for realizing dynamic interface configuration reduces the redundancy and complexity of interfaces and reduces the maintenance and development cost under the condition of great significance.

Description

Method for realizing dynamic interface configuration
Technical Field
The present invention relates to the field of data maintenance, and in particular, to a method for implementing dynamic interface configuration.
Background
With the development of technology and the advancement of society, enterprises face rapidly changing market environments and constantly changing business demands. Static interfaces cannot flexibly accommodate such changes, while dynamic interfaces allow interfaces to be dynamically created, modified, and deleted according to actual needs. The dynamic interface can dynamically return corresponding data results according to different data requirements, and helps developers to realize data-driven development. Scalability and flexibility of the system: for large systems or long-standing systems, the demand tends to vary over time. To ensure scalability and flexibility of the system, the dynamic interfaces may dynamically add, modify, or delete interfaces according to changes in demand, thereby meeting the expansion and change demands of the system.
As business continues to expand, data needs to be returned, plus more interfacing companies. When the service demand changes, the interface needs to be redesigned and realized, which may cause complicated adjustment and modification processes of the interface, and secondly, cause redundancy and complexity of the interface to be higher, contain a large number of parameters and return values, and increase the difficulty of maintenance and development of the interface. Resulting in a relatively slow development process. At the same time, interfaces are difficult to dynamically adjust, and when the requirements change, redesign and implementation may be required, which limits the ability to quickly iterate and develop agilely.
Disclosure of Invention
Based on the technical defects, the invention provides a method for realizing dynamic interface configuration, and the problems in the prior art are solved by returning data through a dynamic interface mode.
The invention provides a method for realizing dynamic interface configuration, which comprises the following steps of; creating a configuration group table in the platform, wherein each group in the configuration group table corresponds to one client, and each client corresponds to a code corresponding to the calling interface; configuring a corresponding SQL data table, wherein the SQL data table is provided with input participation parameters and output participation parameters, and comprises paths corresponding to the codes and data sources; associating the configuration group table with an SQL data table, namely, the SQL data table is provided with the IDs of groups in the configuration group table; converting the configuration group table and the SQL data table into Map sets respectively; receiving a call request of a call interface, analyzing a path and checking; after successful calibration, acquiring and judging a data source of the SQL data table, and loading related drivers according to the data source; and outputting the result in the unified format.
In one embodiment of the invention, the path of the SQL data table comprises list, getPlants.
In an embodiment of the present invention, the method for implementing dynamic interface configuration further includes a data timing update step, including acquiring newly added and modified data of the SQL data table configuration group table in real time, and updating in time.
In an embodiment of the present invention, in the Map set of the configuration group table, key is a unique code within the group, and the code includes common, tpriGroup.
In an embodiment of the present invention, a path in the configuration group table and the SQL configuration table, which are defined, is attached to a call request of the call interface, where the path includes a request parameter in a request body in the call request, and the request parameter has a current value and an identifier that whether the current parameter is enabled or not.
In an embodiment of the present invention, in the step of analyzing the path and checking, the data of the current group in the Map set of the configuration group table is obtained by calling the request parameter in the request body, if the current group exists in the configuration group table, the ID of the current group is obtained, and if not, the error information is returned.
In an embodiment of the present invention, in the step of analyzing and checking paths, further includes obtaining data in the Map set of the corresponding SQL data table through the ID of the current group and the path in the call request of the call interface, if the data in the Map set of the corresponding SQL data table exists, obtaining the SQL data table corresponding to the current group, and if the data in the Map set of the corresponding SQL data table does not exist, feeding back the error information.
In an embodiment of the present invention, in the step of analyzing the path and checking, the request parameter is circularly determined, the request parameter sent by the call request is determined not to be null, the illegal keyword is determined, and the delete, update, insert keyword is entered.
In one embodiment of the present invention, in the step of obtaining and determining the data sources of the SQL data table, it is determined which data source to use, thereby loading the relevant Jdbc connection to connect the database, and executing the SQL operation, wherein the database comprises mysql and clickhouse.
In an embodiment of the present invention, the step of outputting the result in the unified format includes putting the queried result into a List < Map < String, object > > set, and outputting the current query result.
The beneficial effects are that:
the method for realizing the dynamic interface configuration of the invention returns data in a dynamic interface mode. Interfaces can be dynamically created, modified and deleted according to actual requirements to accommodate changing business requirements. When the service demand changes, only the dynamic interface needs to be correspondingly adjusted, and the static interface does not need to be redesigned and realized. The method can return required data and fields according to specific requirements, reduces redundancy and complexity of interfaces, and reduces maintenance and development costs under the condition of great significance.
Drawings
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
Fig. 1 is a flowchart illustrating steps of a method for implementing dynamic interface configuration according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all embodiments of the invention.
All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention. It should be noted that, if a directional indication (such as up, down, left, right, front, and rear … …) is referred to in the embodiment of the present invention, the directional indication is merely used to explain a relative positional relationship, a movement condition, and the like between the components in a specific posture (shown in the drawings), and if the specific posture is changed, the directional indication is correspondingly changed.
In addition, if there is a description of "first", "second", etc. in the embodiments of the present invention, the description of "first", "second", etc. is for descriptive purposes only and is not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions of the embodiments may be combined with each other, but it is necessary to base that the technical solutions can be realized by those skilled in the art, and when the technical solutions are contradictory or cannot be realized, the combination of the technical solutions should be considered to be absent and not within the scope of protection claimed in the present invention.
As shown in fig. 1, the present embodiment provides a method for implementing dynamic interface configuration, including the following steps;
a table of configuration groups is created in the platform, each group in the table of configuration groups being a corresponding one of the clients, each client corresponding to a code corresponding to the call interface. In some embodiments, the group concept is similar to a company, with the entire company's interface under the current group. The purpose of the group table is to distinguish between companies, e.g. company a represents a group, company B also represents a group, and so on. The configuration group table has an intra-group unique code, e.g., common, tpriGroup, baseGroup, which is also a received path parameter that is used to distinguish which interfaces of the company are actually invoked.
Configuring a corresponding SQL data table, wherein the SQL data table is provided with input participation parameters and output participation parameters, and comprises paths corresponding to the codes and data sources; the path of the SQL data table includes list, getPlants.
SQL data tables are structured objects for storing data, consisting of a series of columns and rows, similar to spreadsheets. SQL statement classification. (1) The data definition language (Data Definition Language, DDL) is used to create or delete objects such as databases for storing data and tables in the databases. Including CREATE, DROP, ALTER. (2) A data manipulation language (Data Manipulation Language, DML) is used to query or alter records in a table. Including SELECT, INSERT, UPDATE, DELETE. (3) The data control language (Data Control Language, DCL) is used to confirm or cancel changes made to the data in the database.
For example: the SQL data table may be expressed in the following format:
REATE TABLE < Table name > (< column name 1> < data type > < column required constraint >, < column name 2> < data type > < column required constraint >);
CREATE TABLE product(product_id CHAR(4)NOT NULL
,product_name VARCHAR(100)NOT NULL
,product_type VARCHAR(32)NOT NULL
,sale_price INTEGER,purchase_price INTEGER
,regist_date DATE
,PRIMARY KEY(product_id))。
the SQL configuration table is used for storing SQL sentences, the current SQL configuration table has group Ids in it, and is used for distinguishing which group the SQL corresponding to the current group belongs to, and the current SQL configuration table also has SQL paths, such as list, getPlants and the like.
And associating the configuration group table with an SQL data table, namely, the SQL data table is provided with the IDs of the groups in the configuration group table. In this step, the IDs of the groups in the configuration group table are used as specific parameters of the SQL data table and as specific associated features.
The configuration group table and the SQL data table are each converted into a Map set. Map is a set of key-value pairs (key-value), each element in the Map set containing a key object and a value object. Wherein the key object does not allow repetition, and the value object may be repeated, and the value object may also be of the Map type, as may the elements in the array. The Map interface has two main implementation classes: hashMap class and TreeMap class. The HashMap class accesses the key objects according to a hash algorithm, and the TreeMap class can sort the key objects.
In some embodiments, in the Map set of the configuration group table, keys are unique codes within the group, including common, tpriGroup. One code of the configuration group table corresponds to data in a plurality of SQL configuration tables and belongs to one-to-many relations. The request path is exemplified by http:// ip (ip address) +port/common/list, a request path under a group in the SQL configuration table is unique, a group in the configuration group is also unique, and the Map set key of the SQL configuration table is also unique and is also unique. Receiving a call request of a call interface, analyzing a path and checking; and the call request of the call interface is attached with paths in the defined configuration group table and the SQL configuration table, wherein the paths comprise request parameters in a request body in the call request, current values in the request parameters and identification whether the current parameters are enabled or not.
The request parameter, for example, the planid=15, is sent along with the request body (body), for accurate matching, the parameter in the current group+path unique data in the SQL configuration table is converted into a Map set, the key of the Map set is the parameter name, the value is the information of the current request parameter, the information of the request parameter has the current value, and the current request parameter is identified as to whether the current request parameter is enabled or not. Judging whether the identifier is in an enabling state, if so, performing parameter matching, and after the platid matching is successful, assigning a value 15 of a request parameter to a value of the platid of the current SQL configuration, so that the SQL statement and the request parameter are matched.
And after the verification is successful, acquiring and judging a data source of the SQL data table, and loading related drivers according to the data source. In some embodiments, in the step of analyzing the path and checking, the method includes obtaining data of a current group in the Map set of the configuration group table by calling a request parameter in a request body, if the current group exists in the configuration group table, obtaining an ID of the current group, and if the current group does not exist, returning an error message. In the step of analyzing and checking the path, the method further comprises the step of acquiring data in the Map set of the corresponding SQL data table through the ID of the current group and the path in the call request of the call interface, acquiring the corresponding SQL data table if the data in the Map set of the corresponding SQL data table exists, and feeding back error information if the data in the Map set of the corresponding SQL data table does not exist. In some embodiments, in the step of analyzing the path and checking, the request parameter is circularly judged, the request parameter sent by the call request is judged not to be empty, the illegal keyword is judged, the delete, update, insert keyword is input, and the current operation can only be used for inquiring and cannot be used for adding or deleting the target data.
In the step of acquiring and judging the data sources of the SQL data table, the method comprises the step of judging which data source is used so as to load the related Jdbc connection to connect a database, and executing SQL operation, wherein the database comprises mysql and clickhouse, and is suitable for SQL query.
Jdbc (Java database connection) is an API in the Java language that is used to connect and operate relational databases. Using JDBC we can access various databases by writing Java code, including MySQL, oracle, SQL Server, etc. JDBC technology and its application in database development will be described herein. JDBC working principle JDBC is a Java-based standard interface that provides a set of interfaces and classes that allow Java applications to interact with various databases.
The working principle of JDBC is as follows:
1. loading a database driver: before JDBC is used, the corresponding database driver needs to be loaded, and the drivers used by different databases are different. Typically, we need to add the jar file of the driver to the class path of the item and load the driver in code using the class.
2. Connection database: the database is connected using a drivermnager class, which provides a set of methods to obtain database connections. The concatenated string is typically composed of three parts: protocol, hostname and database name.
3. Executing SQL sentences: after the Connection is successful, a state or preporedstate object can be created through the Connection object for executing the SQL Statement. State supports static SQL statements, while preparedstate supports dynamic SQL statements. After executing the SQL statement, the query result can be obtained through the ResultSet object.
4. Closing the connection: after the database operation is completed, the Connection, statement and ResultSet objects must be closed, freeing up resources.
And outputting the result in the unified format. The step of outputting the results in the unified format comprises the step of putting the queried results into a List < Map < String, object > > set and outputting the current query results. The key of the current Map set is the field name of the query structure, the Value is the Value corresponding to the field, and the current query result is returned, so that a new interface is not required to be written and designed, and the timely service requirement is realized.
The method for realizing the dynamic interface configuration also comprises a data timing updating step, which comprises the steps of acquiring the newly-added and modified data of the SQL data table and the configuration group table in real time and updating in time. When the data loading task is executed, the step is executed at regular time and is used for receiving whether the SQL data table or the configuration group table information is newly added and modified, if yes, the updating is carried out in time, thereby achieving the automation, avoiding the operation of personnel and waiting for the re-refreshing of the regular task.
The foregoing is a further detailed description of the invention in connection with the preferred embodiments, and it is not intended that the invention be limited to the specific embodiments described. It should be understood by those skilled in the art that several simple deductions or substitutions may be made without departing from the spirit of the present invention, and the present invention is not limited to the above-described embodiments.

Claims (10)

1. A method for implementing dynamic interface configuration, comprising the steps of;
creating a configuration group table in the platform, wherein each group in the configuration group table corresponds to one client, and each client corresponds to a code corresponding to the calling interface;
configuring a corresponding SQL data table, wherein the SQL data table is provided with input participation parameters and output participation parameters, and comprises paths corresponding to the codes and data sources;
associating the configuration group table with an SQL data table, namely, the SQL data table is provided with the IDs of groups in the configuration group table;
converting the configuration group table and the SQL data table into Map sets respectively;
receiving a call request of a call interface, analyzing a path and checking;
after successful calibration, acquiring and judging a data source of the SQL data table, and loading related drivers according to the data source; and outputting the result in the unified format.
2. The method of implementing dynamic interface configuration of claim 1, wherein the path of the SQL data table comprises list, getPlants.
3. The method of claim 1, further comprising a data timing update step comprising obtaining the newly added and modified data of the SQL data table configuration group table in real time and updating in time.
4. The method of implementing dynamic interface configuration of claim 1, wherein in the Map set of the configuration group table, keys are unique codes within a group, the codes comprising common, tpriGroup.
5. The method according to claim 1, wherein the paths in the configuration group table and the SQL configuration table are attached to the call request of the call interface, and the paths include a request parameter in a request body in the call request, a current value in the request parameter, and an identification of whether the current parameter is enabled.
6. The method according to claim 1, wherein the step of analyzing the path and checking includes obtaining data of a current group in the Map set of the configuration group table by calling a request parameter in a request body in the request, obtaining an ID of the current group if the current group exists in the configuration group table, and returning an error message if the current group does not exist.
7. The method for implementing dynamic interface configuration according to claim 6, further comprising obtaining data in Map set of the corresponding SQL data table through the ID of the current group and the path in the call request of the call interface in the step of analyzing and checking paths, if the data in Map set of the corresponding SQL data table exists, obtaining the corresponding SQL data table of the current group, and if the data in Map set of the corresponding SQL data table does not exist, feeding back error information.
8. The method for implementing dynamic interface configuration according to claim 7, wherein in the step of analyzing and checking paths, loop judgment is performed on the request parameters, it is judged that the request parameters sent by the call request are not null, illegal keywords are judged, and delete, update, insert keywords are entered.
9. The method of implementing dynamic interface configuration of claim 1, wherein in the step of obtaining and determining data sources of the SQL data table, it is determined which data source to use to load the relevant Jdbc connection to connect to a database, the database comprising mysql and clickhouse, to perform the SQL operation.
10. The method for implementing dynamic interface configuration according to claim 1, wherein in the step of outputting the result in the unified format, the method comprises putting the queried result into a List < Map < String, object > > set and outputting the current query result.
CN202410027840.0A 2024-01-09 2024-01-09 Method for realizing dynamic interface configuration Pending CN117874112A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410027840.0A CN117874112A (en) 2024-01-09 2024-01-09 Method for realizing dynamic interface configuration

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410027840.0A CN117874112A (en) 2024-01-09 2024-01-09 Method for realizing dynamic interface configuration

Publications (1)

Publication Number Publication Date
CN117874112A true CN117874112A (en) 2024-04-12

Family

ID=90586251

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410027840.0A Pending CN117874112A (en) 2024-01-09 2024-01-09 Method for realizing dynamic interface configuration

Country Status (1)

Country Link
CN (1) CN117874112A (en)

Similar Documents

Publication Publication Date Title
US11907247B2 (en) Metadata hub for metadata models of database objects
US6484180B1 (en) Accessing domain object data stored in a relational database system
US7111013B2 (en) Object graph editing context and methods of use
US5806074A (en) Configurable conflict resolution in a computer implemented distributed database
KR101083488B1 (en) Impact analysis in an object model
US8108367B2 (en) Constraints with hidden rows in a database
US9218409B2 (en) Method for generating and using a reusable custom-defined nestable compound data type as database qualifiers
US20110125705A1 (en) Auto-generation of code for performing a transform in an extract, transform, and load process
US9229971B2 (en) Matching data based on numeric difference
US20080046501A1 (en) Managing uneven authorizations in a computer data exchange
KR20060045622A (en) Extraction, transformation and loading designer module of a computerized financial system
US10445675B2 (en) Confirming enforcement of business rules specified in a data access tier of a multi-tier application
US20150278300A1 (en) Query translation for searching complex structures of objects
US11561976B1 (en) System and method for facilitating metadata identification and import
US6820268B2 (en) Method for associating data bearing objects with user interface objects
CN113760947A (en) Data center, data processing method, device, equipment and storage medium
JP2006524376A (en) Generic database schema
CN110399386B (en) Presto-based SQL UPDATE method and control system
US20240119069A1 (en) Model-based determination of change impact for groups of diverse data objects
CN117874112A (en) Method for realizing dynamic interface configuration
US20200364725A1 (en) Regulatory category assignment via machine learning
US11940951B2 (en) Identification and import of metadata for extensions to database artefacts
CN110647518B (en) Data source fusion calculation method, component and device
US11372843B2 (en) Function-based indexes in database systems
US20240232186A9 (en) Virtual access to parameterized data objects

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