Unified enumeration management method and device based on interface constraint, equipment and medium
Through the unified management of enumeration objects based on interface constraints, the problem of redundant code and maintenance difficulties in enumeration management is solved, centralized management and rapid access of enumeration data are realized, and project development efficiency is improved.
Patent Information
- Application Number
- CN202411181833.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-11-29
AI Technical Summary
In the prior art, enumeration management has problems with redundant code and maintenance difficulties, resulting in low efficiency of enumeration management and prone to omissions and omissions, which increases the risk of project development.
Through an interface constraint-based method, enumeration objects are managed uniformly, and the database is used for matching search and storage, avoiding repeated definitions, and centralized management and fast access to enumerations are achieved.
Reduce the human operation error rate, ensure the consistency of enumeration data, avoid duplicate development, and improve the efficiency of enumeration management and project development.
Smart Images

Figure CN119046327A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to an enumeration unified management method, device, equipment and medium based on interface constraints. Background Art
[0002] There are various code tables in the current contract field, but these code tables are generally stored in different storage units according to needs, and the functions of different code tables are also different.
[0003] Due to the large number of usage scenarios of code tables, the enumeration management in the code table is relatively chaotic, which not only generates a large amount of redundant code in the project, but also is not conducive to later maintenance. Especially when the enumeration needs to be maintained, it often leads to omissions or incomplete considerations due to the scattered code, which increases the probability of defects and reduces the efficiency of project development.
[0004] Therefore, how to improve the efficiency of enumeration management has become a technical problem that needs to be solved urgently. Summary of the invention
[0005] The present application provides an interface constraint-based enumeration unified management method, apparatus, device and medium, aiming to improve the efficiency of enumeration management.
[0006] In a first aspect, the present application provides an enumeration unified management method based on interface constraints, the enumeration unified management method based on interface constraints comprising the following steps:
[0007] Based on the enumeration acquisition request sent by the requester, the enumeration name of the enumeration object is obtained;
[0008] Based on the enumeration name, matching and searching the enumeration object in the first database through the enumeration constraint interface;
[0009] When the enumeration object is matched in the first database, the enumeration object is sent to the requester based on a preset data format to respond to the enumeration acquisition request sent by the requester.
[0010] In a second aspect, the present application further provides an enumeration unified management device based on interface constraints, the enumeration unified management device based on interface constraints comprising:
[0011] An enumeration name acquisition module, used to acquire the enumeration name of the enumeration object based on the enumeration acquisition request sent by the requester;
[0012] An enumeration search module, used for matching and searching enumeration objects in a first database through an enumeration constraint interface based on the enumeration name;
[0013] The enumeration sending module is used to send the enumeration object to the requester based on a preset data format when the enumeration object is matched in the first database, so as to respond to the enumeration acquisition request sent by the requester.
[0014] In a third aspect, the present application also provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the above-mentioned interface constraint-based enumeration unified management method are implemented.
[0015] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, wherein when the computer program is executed by a processor, the steps of the above-mentioned enumeration unified management method based on interface constraints are implemented.
[0016] The present application provides a method, device, computer equipment and storage medium for unified management of enumeration based on interface constraints. The method of the present application includes obtaining the enumeration name of the enumeration object based on the enumeration acquisition request sent by the requester; matching and searching the enumeration object in the first database through the enumeration constraint interface based on the enumeration name; when the enumeration object is matched in the first database, the enumeration object is sent to the requester based on the preset data format to respond to the enumeration acquisition request sent by the requester. In the above manner, the present application uniformly stores the enumeration object through the first database, which can realize the centralized management of enumeration, avoid the repeated definition of the same enumeration, and reduce redundant code. When the requester sends the enumeration acquisition request, according to the enumeration name, the matching enumeration object is searched in the first database through the enumeration constraint interface, and according to the preset data format, the enumeration object is sent to the requester, realizing the unified management of enumeration, reducing the error rate of human operation, and realizing the rapid access and call of enumeration data. Through unified management, the consistency of enumeration data in the whole system can be ensured, repeated development can be avoided, and the efficiency of enumeration management and project development can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1 A flowchart of a first embodiment of an enumeration unified management method based on interface constraints provided by the present application;
[0019] Figure 2A flowchart of a specific example of the enumeration query process provided in an embodiment of the present application;
[0020] Figure 3 A flowchart of a second embodiment of an enumeration unified management method based on interface constraints provided by the present application;
[0021] Figure 4 It is a structural diagram of a first embodiment of an enumeration unified management device based on interface constraints provided by the present application;
[0022] Figure 5 It is a schematic block diagram of the structure of a computer device provided in an embodiment of the present application.
[0023] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0025] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0026] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0027] Please refer to Figure 1 , Figure 1 A flowchart of a first embodiment of an enumeration unified management method based on interface constraints provided by the present application.
[0028] like Figure 1 As shown, the interface constraint-based enumeration unified management method includes steps S101 to S103.
[0029] S101, based on the enumeration acquisition request sent by the requester, obtaining the enumeration name of the enumeration object;
[0030] In one embodiment, an enumeration is a data type that consists of a set of predefined constant values, which are called enumeration members or enumeration items.
[0031] In one embodiment, an enumeration acquisition request refers to a request by a client to a server or a service to obtain the names and values of all enumeration types in programming. The enumeration acquisition request can be applied to scenarios such as WebAPI (Application Programming Interface) calls, database queries, and configuration file reading.
[0032] Generally, the enumeration request may include the request type, request path, request parameters, authentication information, and other metadata.
[0033] Exemplarily, depending on the design of the API, the request type may be GFT or POST. The request path may include the path of the API endpoint or service. The request parameters may include the enumerated type name, the attributes to be returned (such as name, value, etc.). The authentication information may include an API key, token, or other authentication information. Other metadata may include request headers, version numbers, etc.
[0034] In one embodiment, the enumeration name of an enumeration object generally refers to the names of the individual members defined in the enumeration type. These names are part of the enumeration type and are explicitly specified in the definition of the enumeration.
[0035] S102, based on the enumeration name, matching and searching for enumeration objects in a first database through an enumeration constraint interface;
[0036] In one embodiment, if Figure 2 As shown, after receiving the enumeration acquisition request initiated by the requester, the enumeration name is first converted into a unified format (such as uppercase) to facilitate matching. Then the enumeration object is searched in the first database. If it is found, the enumeration value is converted into a unified model list and returned to the requester, otherwise the search continues.
[0037] Furthermore, based on the unified format, the enumeration name of the enumeration object is converted into a format that matches the first database.
[0038] In one embodiment, after receiving the enumeration acquisition request, the server can convert the enumeration name of the enumeration object into a format type that matches the first database, that is, standardize the enumeration name of the enumeration object to facilitate more accurate and faster search for the enumeration object in the first database.
[0039] Exemplarily, the enumeration names may be uniformly converted into uppercase.
[0040] In one embodiment, if the database storing the enumeration objects has a specific naming rule or format requirement, the enumeration names of the enumeration objects are converted into a unified format according to the naming rule or format requirement of the database.
[0041] Preferably, the first database can be a local cache. Because the enumeration data is usually not large, it can be easily processed using the local cache, and the delay caused by accessing Redis (RemoteDictionaryServer, remote dictionary service) through the network can be avoided, and the deployment can be simplified without configuring and maintaining Redis instances. At the same time, the access speed of the local cache is faster than that of the remote database, and the enumeration object can be quickly requested and called.
[0042] In one embodiment, the local cache can use a hash table, a dictionary or a custom cache class as a memory data structure, and then serialize the enumeration data of the enumeration object and store it in the local cache, and then load it when needed. Generally, if the application has used a local database (such as SQLite), the local database can be used to store the enumeration data.
[0043] Optionally, the first database may also be Redis. Redis is a memory-based data storage system that supports multiple types of data structures, such as strings, hashes, lists, sets, etc., and is very suitable for caching enumeration data.
[0044] In one embodiment, when Redis is used as the first database, it is necessary to configure the connection of the Redis server to ensure that the application that needs to use the enumeration object can connect to the Redis instance. In Redis, a unique key needs to be defined for each enumeration type, for example, the name of the enumeration object can be used as the key. The enumeration name can be serialized into a string or JSON (JavaScript Object Notation) format for storage in Redis.
[0045] For example, you can use Redis's SET command or HSET command to store the enumeration name in Redis. If you use the SET command, you can store the serialized string directly; if you use HSET, you can store each enumeration name as a field in a hash table. When the enumeration name is needed, use the GET or HGETALL command to retrieve it from Redis.
[0046] In this embodiment, the first database can be a local cache or a Redis. In the local cache mode, data is stored in the memory of the application or the local file system, and no network communication is required; in the Redis mode, data is stored in a remote Redis server, and data exchange is required over the network. However, the cache of each instance in the local cache is independent, and data is not shared between different instances; while Redis can be used as a shared cache between multiple application instances to achieve centralized management and sharing of data. Both can be applied to different application scenarios. Therefore, according to actual application requirements, you can choose to use a local cache, Redis or other data storage structure as the first database to store the enumeration data of the enumeration object.
[0047] Furthermore, when the enumeration object does not exist in the first database, the enumeration object is matched and searched in the second database specified by the project based on the enumeration name; when the enumeration object is matched in the project enumeration directory, the enumeration object is stored in the first database based on the reflection mechanism, and the enumeration object is sent to the requesting party based on the preset data format.
[0048] In one embodiment, the second database may be an enumerated catalog of project specifications.
[0049] In one embodiment, if Figure 2 As shown, when the enumeration object is not searched in the first database, the second database is searched for matching and the enumeration object. If the enumeration object is searched for matching in the second database, the reflection mechanism is used to load the enumeration data of the enumeration object from the second database into the JVM (Java Virtual Machine) and synchronize it to the first database. Then, a matching search is performed in the first database according to the enumeration name, and the enumeration value of the matched enumeration object is converted into a preset data format and returned to the requesting party.
[0050] Among them, JVM (Java Virtual Machine) is a concept of an abstract computer that provides a platform-independent execution environment for Java programs. The main function of JVM is to allow Java programs to be written once and then run on any platform that provides JVM. JVM runs on top of the operating system and has no direct interaction with the hardware.
[0051] Generally, JVM includes class loader, bytecode verifier, interpreter, just-in-time compiler, runtime data area and garbage collector. Among them, class loader is responsible for loading class files, and converting them into classes represented inside JVM (such as enumeration classes provided in embodiments of the present application), and ensuring that each class is only loaded once. After the class is loaded into JVM, the bytecode verifier will check whether the loaded class files meet the internal specifications of JVM to ensure that they will not damage the operating environment of JVM. The interpreter interprets and executes the bytecode line by line. The just-in-time compiler compiles the bytecode into local machine code to improve the execution efficiency of the program. The runtime data area is the memory area used by JVM when executing Java programs, and this area includes heap (Heap), stack (Stack), method area (Method Area), program counter (Program Counter) etc. JVM automatically manages memory, and when an object is no longer used, the garbage collector will automatically reclaim the memory occupied by these objects.
[0052] In one embodiment, the reflection mechanism is a powerful feature in the Java language that allows a program to access, inspect, and modify its own structures, such as classes, interfaces, fields (member variables), and methods, at runtime. This ability enables Java programs to dynamically load, explore, and use code that is completely unknown at compile time.
[0053] For example, the reflection mechanism can be used to construct any enumeration object at runtime. Even if the enumeration name of the enumeration object is unknown at compile time, the enumeration object can be created through the reflection mechanism. When running the reflection mechanism, the information of the enumeration object can also be obtained, such as the enumeration name, modifiers, fields, methods, etc. of the enumeration object. At the same time, the reflection mechanism can also call methods of any object, modify the value of private fields, and operate complex types such as data and collections.
[0054] Furthermore, when the enumeration object does not exist in the project enumeration directory, a third database is obtained; based on the enumeration name, the enumeration object is matched and searched in the third database; when the enumeration object is matched in the third database, based on the reflection mechanism, the enumeration object is stored in the first database, and based on the preset data format, the enumeration object is sent to the requesting party.
[0055] In one embodiment, the third database may be an external engineering jar package specifically used to store enumerations.
[0056] In one embodiment, if Figure 2 As shown, if the enumeration object is not found in the second database, the third database is loaded and the enumeration object is matched and searched in the third database.
[0057] In one embodiment, if an enumeration object is searched and matched in the third database, the enumeration data of the enumeration object is loaded and stored from the third database into the first database by using the reflection mechanism. Then, a matching search is performed in the first database according to the enumeration name, and the enumeration value of the matched enumeration object is converted into a preset data format and returned to the requesting party.
[0058] In one embodiment, if the first database, the second database, and the third database do not match the enumeration object in the request, null is returned, indicating that the enumeration object does not exist.
[0059] S103: When the enumeration object is matched in the first database, the enumeration object is sent to the requesting party based on a preset data format to respond to the enumeration acquisition request sent by the requesting party.
[0060] In one embodiment, when the requested enumeration objects are matched in the first database, these enumeration objects are sent back to the requesting party in a preset data format.
[0061] In one embodiment, the enumerated data matching the request is retrieved from the first database through a query operation, such as using a GET command in Redis or directly accessing a data structure in a local cache.
[0062] In one embodiment, after an enumeration object matching the enumeration acquisition request is found, the retrieved data is formatted into a preset data format. For example, data serialization can be used to convert the format of the enumeration object, such as into JSON or XML format.
[0063] Furthermore, when the requester is a front-end requester, the enumeration object is converted into an enumeration list format, and the enumeration object in the enumeration list format is sent to the front-end requester. When the requester is a back-end requester, the enumeration value of the enumeration object is sent to the back-end requester.
[0064] In one embodiment, the preset data format may include data formats such as an enumeration list format and an enumeration value format.
[0065] In one embodiment, if an enumeration object is matched, it is also necessary to determine whether the enumeration acquisition request comes from the front end or the back end internal call, so as to return enumeration data in different formats according to different requesting parties, thereby improving data availability and facilitating subsequent processing.
[0066] In one embodiment, the source of the enumeration acquisition request can be identified by checking a specific field (such as X-Caller) in the HTTP request header, or by using the context information of the request.
[0067] In one embodiment, if the requester is a front-end requester, the enumeration object is sent to the front-end requester in an enumeration list format to facilitate front-end rendering. The enumeration list format generally includes the name and value of the enumeration object to facilitate the front-end framework or library to render UI components such as lists and drop-down menus.
[0068] In one embodiment, if the requester is a backend requester, i.e., an internal call from the backend, a key-value pair of the enumeration object is returned to the backend requester, so that the backend can map the enumeration data. The key-value pair format facilitates data processing and mapping by the backend service, such as using the enumeration value as a control flow condition in the business logic.
[0069] In this embodiment, returning data in different formats can improve the availability of data, so that both the front-end and the back-end can receive and process data in a way that best suits their needs. For the front-end, the list format makes data easy to display and user interaction. For the back-end, the key-value pair format makes data easy to perform logical processing and data mapping within the service.
[0070] This embodiment provides a method for unified management of enumerations based on interface constraints. The method of this application can realize centralized management of enumerations by uniformly storing enumeration objects through a first database, avoids repeated definition of the same enumeration, and reduces redundant code. When the requester sends an enumeration acquisition request, the matching enumeration object is searched in the first database through the enumeration constraint interface according to the enumeration name, and the enumeration object is sent to the requester according to the preset data format, so as to realize unified management of enumerations, reduce the error rate of human operation, and realize fast access and call of enumeration data. Through unified management, the consistency of enumeration data in the entire system can be ensured, repeated development can be avoided, and the efficiency of enumeration management and project development can be improved.
[0071] Please refer to Figure 3 , Figure 3 A flowchart of a second embodiment of an enumeration unified management method based on interface constraints provided by the present application.
[0072] In this embodiment, Figure 3 As shown, based on the above Figure 1 In the illustrated embodiment, the method further includes steps S201 to S203.
[0073] S201. Create an enumeration constraint interface based on at least one constraint field;
[0074] In one embodiment, the constraint field may include fields such as a code, a simple description, a detailed description, and an English description.
[0075] In one embodiment, when creating an enumeration constraint interface, the functions that the enumeration constraint interface needs to support may be determined, such as adding, querying, updating, and deleting enumeration objects, etc. Then, it is determined which fields are constraint fields that the enumeration object must comply with, such as code, simple description, detailed description, and English description, etc. The input parameters of the interface are designed to ensure that the necessary information can be received to create or modify the enumeration object, and the business logic of the enumeration constraint interface is edited to ensure that an enumeration object that meets the constraints can be created according to the input parameters.
[0076] S202: Based on the constraint field, define constraints on at least one enumeration object to obtain the enumeration object in a unified definition format;
[0077] In one embodiment, an enumeration class is created according to the interface specification of the enumeration constraint interface, including all constraint fields. The interface definition method is implemented in the enumeration class to ensure that the enumeration object can be managed. According to the actual application requirements, specific enumeration objects are defined to ensure that each enumeration object meets the requirements of the constraint field.
[0078] S203: Based on the first database, store the enumeration objects in a uniform definition format, so as to search the first database for the enumeration objects matching the enumeration name through the enumeration constraint interface.
[0079] In one embodiment, when the enumeration objects in the uniform definition format are stored in the first database, it is necessary to design the database table structure of the first database to ensure that the first database can store the enumeration objects in the uniform definition format.
[0080] In one embodiment, code may be written to store the enumeration object in a database and ensure the consistency and integrity of the data. For example, the add Enum To Database method may be implemented to store the enumeration object in the Enum Table table.
[0081] In one embodiment, code may be written to retrieve an enumeration object matching the enumeration name from the first database through the enumeration constraint interface, for example, a get Enum From Database method may be implemented to retrieve an enumeration object from the EnumTable table according to the enumeration name.
[0082] In one embodiment, generics can be used to provide a unified enumeration operation entry, which allows front-end and back-end developers to obtain or operate enumeration data through simple interface calls. The input parameter only requires an enumeration name, which can be provided to both the front-end and the back-end.
[0083] In one embodiment, a generic interface is created, which defines basic methods of enumeration operations, such as obtaining enumeration values, adding enumerations, etc. The generic interface can be a general interface so that it can be applied to different types of enumerations.
[0084] In one embodiment, based on the generic interface, a generic class can be implemented, and the generic class uses generic parameters to handle different types of enumerations. The methods in the class can handle the creation, retrieval, update and deletion of enumeration objects.
[0085] For example, according to actual needs, if the front end needs to add a drop-down box and the enumeration data is provided by the back end, consider defining an enumeration object and then creating the enumeration constraint interface defined above. The enumeration constraint interface can be used to implement unified management of subsequent related actions on the enumeration object (such as calling, deleting, modifying, etc.).
[0086] This embodiment unifies the enumeration management function. When adding an enumeration object, you only need to create an enumeration constraint interface. Whether it is used by the front-end or the back-end, you can get the same model structure (a list on the front end and a key-value pair on the back end) by querying the enumeration name through the unified access entry of the enumeration. The user does not need to care about the specific fields defined by the enumeration object, nor does he need to care about the path defined by the enumeration object. In particular, when the content of the enumeration needs to be added or reduced in the later stage, you only need to modify the specific enumeration. For the user, it can achieve imperceptible iteration, which reduces the development workload and improves the development efficiency to a certain extent.
[0087] See also Figure 4 , Figure 4 It is a structural diagram of a first embodiment of an enumeration unified management device based on interface constraints provided by the present application. The enumeration unified management device based on interface constraints is used to execute the aforementioned enumeration unified management method based on interface constraints.
[0088] like Figure 4 As shown, the interface constraint-based enumeration unified management device 300 includes: a data acquisition module 301 , an abnormal data screening module 302 , a fault coefficient calculation module 303 and a fault type determination module 304 .
[0089] The enumeration name acquisition module 301 is used to acquire the enumeration name of the enumeration object based on the enumeration acquisition request sent by the requester;
[0090] An enumeration search module 302 is used to match and search for enumeration objects in a first database through an enumeration constraint interface based on the enumeration name;
[0091] The enumeration sending module 303 is used to send the enumeration object to the requester based on a preset data format when the enumeration object is matched in the first database, so as to respond to the enumeration acquisition request sent by the requester.
[0092] In one embodiment, the interface constraint-based enumeration unified management device 300 further includes an enumeration name unification module, including:
[0093] The format conversion unit is used to perform format conversion on the enumeration name of the enumeration object based on a unified format, so as to convert the enumeration name of the enumeration object into a name format matching the first database.
[0094] In one embodiment, the interface constraint-based enumeration unified management device 300 further includes an enumeration second search module, and the enumeration second search module includes:
[0095] An enumeration second search unit, configured to, when the enumeration object does not exist in the first database, search for the enumeration object in a second database specified by the project based on the enumeration name;
[0096] The enumeration first loading unit is used to store the enumeration object in the first database based on the reflection mechanism when the enumeration object is matched in the project enumeration directory, and send the enumeration object to the requesting party based on the preset data format.
[0097] In one embodiment, the enumerating the second search module further comprises:
[0098] A third database acquisition unit, configured to acquire a third database when the enumeration object does not exist in the item enumeration directory;
[0099] An enumeration third search unit is used to match and search the enumeration object in the third database based on the enumeration name;
[0100] The enumeration second loading unit is used to store the enumeration object in the first database based on a reflection mechanism when the enumeration object is matched in the third database, and send the enumeration object to the requesting party based on the preset data format.
[0101] In one embodiment, the enumeration sending module 303 includes:
[0102] The front-end request response unit is used to convert the enumeration object into an enumeration list format when the requester is a front-end requester, and send the enumeration object in the enumeration list format to the front-end requester.
[0103] In one embodiment, the enumeration sending module 303 further includes:
[0104] The backend request response unit is used to send the enumeration value of the enumeration object to the backend requester when the requester is a backend requester.
[0105] In one embodiment, the interface constraint-based enumeration unified management device 300 further includes an enumeration constraint definition module, including:
[0106] An interface creation unit, used to create an enumeration constraint interface based on at least one constraint field;
[0107] An enumeration unified definition unit, used to define constraints on at least one enumeration object based on the constraint field to obtain the enumeration object in a unified definition format;
[0108] The enumeration storage unit is used to store the enumeration objects in a uniform definition format based on the first database, so as to search the first database for the enumeration objects matching the enumeration name through the enumeration constraint interface.
[0109] It should be noted that technical personnel in the relevant field can clearly understand that, for the convenience and conciseness of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned embodiment of the enumeration unified management method based on interface constraints, and will not be repeated here.
[0110] The apparatus provided in the above embodiment may be implemented in the form of a computer program. The computer program may be Figure 5 Runs on the computer device shown.
[0111] See also Figure 5 , Figure 5 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server.
[0112] See also Figure 5 The computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.
[0113] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any one of the enumeration unified management methods based on interface constraints.
[0114] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0115] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any one of the enumeration unified management methods based on interface constraints.
[0116] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0117] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0118] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:
[0119] Based on the enumeration acquisition request sent by the requester, the enumeration name of the enumeration object is obtained;
[0120] Based on the enumeration name, matching and searching the enumeration object in the first database through the enumeration constraint interface;
[0121] When the enumeration object is matched in the first database, the enumeration object is sent to the requester based on a preset data format to respond to the enumeration acquisition request sent by the requester.
[0122] In one embodiment, before implementing the matching and searching for enumeration objects in the first database based on the enumeration name through the enumeration constraint interface, the processor is further configured to implement:
[0123] Based on the unified format, format conversion is performed on the enumeration name of the enumeration object to convert the enumeration name of the enumeration object into a name format that matches the first database.
[0124] In one embodiment, after implementing the matching and searching for enumeration objects in the first database through the enumeration constraint interface based on the enumeration name, the processor is further configured to implement:
[0125] When the enumeration object does not exist in the first database, based on the enumeration name, matching and searching for the enumeration object in a second database specified by the project;
[0126] When the enumeration object is matched in the item enumeration directory, the enumeration object is stored in the first database based on a reflection mechanism, and the enumeration object is sent to the requesting party based on the preset data format.
[0127] In one embodiment, after implementing the matching and searching for the enumeration object in a second database specified by the project based on the enumeration name, the processor is further configured to implement:
[0128] When the enumeration object does not exist in the item enumeration directory, acquiring a third database;
[0129] Based on the enumeration name, matching and searching the enumeration object in the third database;
[0130] When the enumeration object is matched in the third database, the enumeration object is stored in the first database based on a reflection mechanism, and the enumeration object is sent to the requesting party based on the preset data format.
[0131] In one embodiment, when the processor implements the sending of the enumeration object to the requesting party based on the preset data format, it is configured to implement:
[0132] When the requester is a front-end requester, the enumeration object is converted into an enumeration list format, and the enumeration object in the enumeration list format is sent to the front-end requester.
[0133] In one embodiment, when the processor implements sending the enumeration object to the requesting party based on a preset data format, the processor is further configured to implement:
[0134] When the requester is a backend requester, the enumeration value of the enumeration object is sent to the backend requester.
[0135] In one embodiment, before implementing the acquisition of the enumeration name of the enumeration object based on the enumeration acquisition request sent by the requester, the processor is further used to implement:
[0136] Based on at least one constraint field, create an enumeration constraint interface;
[0137] Based on the constraint field, define constraints on at least one enumeration object to obtain the enumeration object in a unified definition format;
[0138] Based on the first database, the enumeration objects in a uniform definition format are stored, so that the enumeration objects matching the enumeration name can be searched in the first database through the enumeration constraint interface.
[0139] A computer-readable storage medium is also provided in an embodiment of the present application, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the processor executes the program instructions to implement any one of the interface constraint-based enumeration unified management methods provided in the embodiments of the present application.
[0140] The computer-readable storage medium may be an internal storage unit of the computer device described in the above embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (SmartMediaCard, SMC), a secure digital (SecureDigital, SD) card, a flash card (FlashCard), etc. equipped on the computer device.
[0141] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for unified enumeration management based on interface constraints, characterized in that: The method comprises: Based on the enumeration acquisition request sent by the requester, the enumeration name of the enumeration object is obtained; Based on the enumeration name, matching and searching the enumeration object in the first database through the enumeration constraint interface; When the enumeration object is matched in the first database, the enumeration object is sent to the requester based on a preset data format to respond to the enumeration acquisition request sent by the requester.
2. The method for unified management of enumeration based on interface constraints according to claim 1, characterized in that: Before matching and searching the enumeration object in the first database through the enumeration constraint interface based on the enumeration name, the method further includes: Based on the unified format, format conversion is performed on the enumeration name of the enumeration object to convert the enumeration name of the enumeration object into a name format that matches the first database.
3. The method for unified management of enumeration based on interface constraints according to claim 1, characterized in that: After matching and searching the enumeration object in the first database through the enumeration constraint interface based on the enumeration name, the method further includes: When the enumeration object does not exist in the first database, based on the enumeration name, matching and searching for the enumeration object in a second database specified by the project; When the enumeration object is matched in the item enumeration directory, the enumeration object is stored in the first database based on a reflection mechanism, and the enumeration object is sent to the requesting party based on the preset data format.
4. The method for unified management of enumeration based on interface constraints according to claim 3 is characterized in that: After matching and searching the enumeration object in a second database specified by the project based on the enumeration name, the method further includes: When the enumeration object does not exist in the item enumeration directory, acquiring a third database; Based on the enumeration name, matching and searching the enumeration object in the third database; When the enumeration object is matched in the third database, the enumeration object is stored in the first database based on a reflection mechanism, and the enumeration object is sent to the requesting party based on the preset data format.
5. The interface constraint-based enumeration unified management method according to claim 1, characterized in that: The sending the enumeration object to the requesting party based on a preset data format includes: When the requester is a front-end requester, the enumeration object is converted into an enumeration list format, and the enumeration object in the enumeration list format is sent to the front-end requester.
6. The method for unified management of enumeration based on interface constraints according to claim 1, characterized in that: The sending the enumeration object to the requesting party based on a preset data format further includes: When the requester is a backend requester, the enumeration value of the enumeration object is sent to the backend requester.
7. The method for unified management of enumeration based on interface constraints according to claim 1, characterized in that: Before obtaining the enumeration name of the enumeration object based on the enumeration acquisition request sent by the requester, the method further includes: Based on at least one constraint field, creating the enumeration constraint interface; Based on the constraint field, define constraints on at least one enumeration object to obtain the enumeration object in a unified definition format; Based on the first database, the enumeration objects in a uniform definition format are stored, so that the enumeration objects matching the enumeration name can be searched in the first database through the enumeration constraint interface.
8. An enumeration unified management device based on interface constraints, characterized in that: The interface constraint-based enumeration unified management device comprises: An enumeration name acquisition module, used to acquire the enumeration name of the enumeration object based on the enumeration acquisition request sent by the requester; An enumeration search module, used for matching and searching enumeration objects in a first database through an enumeration constraint interface based on the enumeration name; The enumeration sending module is used to send the enumeration object to the requester based on a preset data format when the enumeration object is matched in the first database, so as to respond to the enumeration acquisition request sent by the requester.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, the steps of the enumeration unified management method based on interface constraints as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the enumeration unified management method based on interface constraints as claimed in any one of claims 1 to 7 are implemented.
