Data dictionary mapping method and device based on annotation, electronic equipment and medium
By using annotation-based data dictionary mapping method in Spring Boot, the code redundancy and maintenance difficulties in data dictionary mapping in Java Web development are solved, and automatic mapping is realized and development efficiency and maintainability are improved.
Patent Information
- Application Number
- CN202411912574.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-24
- Publication Date
- 2025-04-15
AI Technical Summary
In Java Web development, traditional methods used for mapping data dictionaries have problems such as code redundancy, maintenance difficulties, cumbersome configuration and performance losses.
A data dictionary mapping method based on annotation is provided. Through the data query request obtained by the query interface in the Spring Boot framework, it determines whether the interface annotation is carried, determines the data structure type of the data query request in the data dictionary, and automatically maps the dictionary value based on the attribute annotation in the identification attribute.
This method can automatically map dictionary values of fields in Spring Boot architecture applications, improve development efficiency and maintainability of code, and supports dynamic expansion of dictionary types without modifying business code.
Smart Images

Figure CN119829583A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to an annotation-based data dictionary mapping method, device, electronic device and medium. Background Art
[0002] In Java Web development, it is often necessary to deal with the mapping problem of the data dictionary, that is, to automatically convert the code in the database into the corresponding display name. Traditional methods usually require hard coding in the code or using a large number of if-else statements, which not only makes the code redundant but also difficult to maintain. In the prior art, although it can be achieved through configuration files or AOP (aspect-oriented programming) and other technologies, there are still problems such as cumbersome configuration and performance loss. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide an annotation-based data dictionary mapping method to solve the above-mentioned problems existing in the prior art, and to realize automatic mapping of dictionary values of fields in Spring Boot architecture applications, thereby improving development efficiency and code maintainability.
[0004] In a first aspect, a data dictionary mapping method based on annotations is provided, which may include:
[0005] Determine whether the data query request obtained through the query interface in the Spring Boot framework carries the interface annotation;
[0006] If yes, the data query request is processed to determine the data structure type of the data that the data query request queries in the data dictionary; the data structure types include: paging query, single data query, list query and tree structure query;
[0007] Based on the data structure type, the data query request is processed to determine at least one return identifier and an identifier attribute corresponding to the return identifier;
[0008] If the identification attribute includes an attribute annotation, the target data corresponding to the returned identification is determined according to the correspondence between different identifications and different data in the data dictionary.
[0009] In a possible implementation, determining the data structure type of the data that the data query request queries in the data dictionary includes:
[0010] Based on the data query request, the mybatis-plus method is used to perform data query in the data dictionary;
[0011] Use the instanceof method to determine the data structure type of the query data in the data dictionary.
[0012] In a possible implementation, after determining the data structure type of the query data in the data dictionary, the method further includes:
[0013] If the data structure type is a paged query, a list query or a tree structure query, then based on the data query request, an iterative query is performed in the data dictionary to determine at least one return identifier and an identifier attribute corresponding to the return identifier.
[0014] In a possible implementation, determining at least one return identifier and an identifier attribute corresponding to the return identifier includes:
[0015] The eachField method is adopted to traverse all fields in the data dictionary based on the data query request and the data structure type to obtain the return identifier of the JSON structure and the identifier attribute corresponding to the return identifier.
[0016] In a possible implementation, determining the target mapping data corresponding to the return identifier according to the correspondence between different data and mapping data in the data dictionary includes:
[0017] The translateDicValue method is adopted to process the return identifier based on the correspondence between different data in the data dictionary and the mapping data to obtain the target mapping data, and to construct a correspondence between the target mapping data and the return identifier of the JSON structure.
[0018] In a possible implementation, the attribute annotation is based on Dict annotation.
[0019] In a possible implementation, the interface annotation is a QueryDict annotation.
[0020] In a second aspect, a data dictionary mapping device based on annotations is provided, which may include:
[0021] A determination unit, used to determine whether a data query request obtained through a query interface in a Spring Boot framework carries an interface annotation;
[0022] A processing unit, for processing the data query request if yes, and determining the data structure type of the data that the data query request queries in the data dictionary; the data structure types include: paging query, single data query, list query and tree structure query;
[0023] and, based on the data structure type, processing the data query request to determine at least one return identifier and an identifier attribute corresponding to the return identifier;
[0024] The determining unit is further configured to determine the target data corresponding to the returned identifier according to the correspondence between different identifiers and different data in the data dictionary if the identifier attribute includes an attribute annotation.
[0025] In a third aspect, an electronic device is provided, the electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0026] Memory, used to store computer programs;
[0027] The processor is used to implement any method step described in the first aspect when executing the program stored in the memory.
[0028] In a fourth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any method step described in the first aspect is implemented.
[0029] The present application provides a data dictionary mapping method based on annotations, the method comprising: determining whether a data query request obtained through a query interface in a SpringBoot framework carries an interface annotation; if so, processing the data query request to determine the data structure type of the data query request in the data dictionary; the data structure types include: paging query, single data query, list query, and tree structure query; based on the data structure type, processing the data query request to determine at least one return identifier and an identifier attribute corresponding to the return identifier; if the identifier attribute includes an attribute annotation, determining the target data corresponding to the return identifier according to the correspondence between different identifiers and different data in the data dictionary. The method can automatically implement dictionary mapping through annotations, reduce the amount of manual coding, and thus improve development efficiency; by separating the dictionary mapping relationship from the business code, it is convenient for centralized management and maintenance, thereby enhancing the maintainability of the code; the method supports dynamic expansion of dictionary types, and can adapt to new requirements without modifying the business code, thereby improving system flexibility. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0031] Figure 1 A system architecture diagram for an annotation-based data dictionary mapping method provided in an embodiment of the present application;
[0032] Figure 2 A flowchart of a data dictionary mapping method based on annotations provided in an embodiment of the present application;
[0033] Figure 3 A schematic diagram of the structure of an annotation-based data dictionary mapping device provided in an embodiment of the present application;
[0034] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] 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 only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments of 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.
[0036] The annotation-based data dictionary mapping method provided in the embodiment of the present application can be applied to Figure 1 In the system architecture shown in Figure 1 As shown, the system may include: a server and a terminal. The server may be a physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal may be a user equipment (UE) such as a mobile phone, smart phone, laptop, digital broadcast receiver, personal digital assistant (PDA), tablet computer (PAD), handheld device, vehicle-mounted device, wearable device, computing device or other processing device connected to a wireless modem, mobile station (MS), mobile terminal, etc. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in this application.
[0037] The terminal is used to obtain a data query request and send the data query request to the server.
[0038] The server is used to receive data query requests and execute an annotation-based data dictionary mapping method provided by the present application.
[0039] In Java Web development, it is often necessary to deal with the mapping problem of the data dictionary, that is, to automatically convert the code in the database into the corresponding display name. Traditional methods usually require hard coding in the code or using a large number of if-else statements, which not only makes the code redundant but also difficult to maintain. In the prior art, although it can be achieved through configuration files or AOP (aspect-oriented programming) and other technologies, there are still problems such as cumbersome configuration and performance loss.
[0040] Therefore, the present application provides an annotation-based data dictionary mapping method to solve the above-mentioned problems existing in the prior art, and can realize automatic mapping of dictionary values of fields in Spring Boot architecture applications, thereby improving development efficiency and code maintainability.
[0041] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.
[0042] Figure 2 A flowchart of a data dictionary mapping method based on annotations provided in an embodiment of the present application. Figure 2 As shown, the method may include:
[0043] Step S210: Determine whether the data query request obtained through the query interface in the Spring Boot framework carries an interface annotation.
[0044] Specifically, before executing step S210, the method may further include:
[0045] Define an annotation @Dict to identify the field that needs dictionary mapping; this annotation is added to the field;
[0046] The annotation contains necessary attributes, such as dictionary code (dictCode), table fields (dictText), and table name (dictTable).
[0047] The dictionary code is used for conditional judgment, the table name is used for querying other tables, and the table field indicates the fields that need to be returned in other tables. dicText and dictTable have default values, which can be omitted when used. If not, the dictionary table will be queried, and if values are passed, other tables will be queried. The process can be understood as follows: when there are multiple tables, when dicText and dictTable are the default values, the dictionary table corresponding to the data dictionary is queried; when there are specific values of dicText and dictTable, the data table corresponding to the specific values of dicText and dictTable is queried.
[0048] Define an interface annotation, that is, the @QueryDict annotation. This annotation has no attributes and is only used as an identifier for dictionary query.
[0049] In other words, write an AOP aspect to intercept fields that need to be mapped to dictionaries and automatically perform mapping when accessing these fields. At this time, the interface annotation is used in the aspect, and after using the interface annotation, this aspect will be entered.
[0050] Step S210 specifically includes: the client sends a data query request, and obtains the data query request through the query interface of the Spring Boot framework configured in the server.
[0051] Determine whether the data query request carries interface annotations;
[0052] If not, a prompt message is issued indicating that the data query request cannot be processed.
[0053] If yes, the data query request is processed to determine the data structure type of the data that the data query request queries in the data dictionary;
[0054] Among them, the data structure types include: paging query, single data query, list query and tree structure query.
[0055] Furthermore, based on the data query request, the mybatis-plus method is used to query data in the data dictionary;
[0056] Use the instanceof method to determine the data structure type of the query data in the data dictionary.
[0057] The process can be understood as: using the instanceof method to distinguish the data structure type, whether it is an IPage type can determine whether it is a paging query (because the query is implemented through mybatis-plus here), if it is a paging query, then iterate. That is, when the data structure type is a paging query, list query or tree structure query, iterate the query in the data dictionary based on the data query request.
[0058] Step S220: Based on the data structure type, the data query request is processed to determine at least one return identifier and an identifier attribute corresponding to the return identifier, and according to the attribute annotation of the identifier attribute, the target data corresponding to the return identifier is determined.
[0059] Specifically, the eachField method is used to traverse all fields in the data dictionary based on the data query request and the data structure type to obtain the return identifier of the JSON structure and the identifier attribute corresponding to the return identifier.
[0060] If the identification attribute does not include the attribute annotation, a prompt message is issued indicating that the data query request cannot be processed.
[0061] If the identifier attribute includes an attribute annotation, the target data corresponding to the return identifier is determined based on the correspondence between different identifiers and different data in the data dictionary. Specifically, the translateDicValue method is used to process the return identifier based on the correspondence between different data and mapping data in the data dictionary to obtain the target mapping data, and to construct the correspondence between the target mapping data and the return identifier of the JSON structure.
[0062] In layman's terms, use the instanceof method to distinguish the data structure type. If it is an IPage type, you can determine whether it is a paging query (because the query is implemented through mybatis-plus here). If it is a paging query, then iterate, and then call the eachField method to perform the next step of judgment and change operations. The same operation applies to other operations. The eachField method actually redefines a json, and then directly adds the original result return data to it, and then obtains each attribute of the return data. If this attribute is annotated with @Dict, use the translateDicValue method to perform dictionary translation (which can be achieved by querying the database or by querying enumeration.), and then add the translated data to the previously defined json.
[0063] Redefining a JSON means creating a new empty dictionary to store the processed data. Copy all the key-value pairs in the original result data (which may be another dictionary or similar structure) to the newly created dictionary. After that, copy all the key-value pairs in the original result data (which may be another dictionary or similar structure) to the newly created dictionary. Iterate each key (i.e. attribute name) in this new dictionary, and for each attribute, check whether it is marked with the @Dict annotation. This usually means that the value of the attribute is an identifier or code that needs to be translated or mapped, such as a foreign key or enumeration value. If an attribute does have the @Dict annotation, then call the translateDicValue method to find and replace the value of the attribute. This method may find the corresponding text description by querying a database table, or map it according to a predefined enumeration list. Finally, store the translated new value back to the corresponding position in the new dictionary.
[0064] In some embodiments, in the back-end development of the electronic signature project, there are many cases where the returned values (return identifiers) are all dictionary values. The first is that there are drop-down boxes in many forms. In order not to hard-code them in the front end and to facilitate modification, a data dictionary is used. When returning data, the back-end developers need to let the front end get the data and use it directly, instead of asking the front end to request dictionary table conversion.
[0065] Secondly, the database table stores the creator's ID, and the name of the creator is required when returning. Backend developers should not query the table for only one field, but use annotations to directly query the required value.
[0066] There is a seal table in the electronic signature project, which records the seal information. Among them, the seal type code, seal creation method, seal mode code, and seal color code are all dictionary codes, and the front end needs the values of these codes; and the seal table only contains the creator's ID, and the front end needs to display the creator's name.
[0067] In the seal entity class, a @Dict annotation is added to the sealType, createType, sealModel, sealColour and createUserId attributes.
[0068] In some embodiments, the mapping rules can be flexibly configured, especially the implementation of dynamic mapping rules, which is the key to improving the flexibility and adaptability of the system. It allows the system to adjust the mapping logic according to different environment variables or contextual factors, so as to better meet diverse business needs. Specifically, the specific behavior of certain mapping rules is determined by reading environment variables. For example, detailed logging can be enabled in a development environment and disabled in a production environment to improve performance. Specifically, environment variables are loaded using configuration files (such as YAML, JSON) or environment variable management systems (such as Spring Boot's @Value annotation or Python's os.environ), and different logic is executed in the mapping code based on these variables. The mapping rules can be automatically adjusted according to the current application context. This may involve factors such as user roles, device types, and geographic locations. Implementation method:
[0069] Use a dependency injection framework such as Spring's @Autowired to obtain contextual information.
[0070] Introduce the strategy pattern in the mapping class to select different mapping algorithms according to the context.
[0071] Use AOP (Aspect Oriented Programming) technology to dynamically change mapping rules before and after method calls.
[0072] The mapping rules are stored in an external configurable place, such as a database table, cache service, or a dedicated configuration center (such as Apollo, Nacos). This allows the mapping rules to be updated without restarting the application.
[0073] Implementation:
[0074] Create a mapping rule service layer that is responsible for loading the latest mapping rules from the configuration source.
[0075] Cache these rules and maintain the latest version in memory, reducing frequent access to external resources.
[0076] An API interface is provided so that administrators can modify mapping rules in real time.
[0077] Using metadata to guide the mapping process instead of hard-coding the mapping logic makes the mapping more general and can handle a wider variety of data sources without changing the core code.
[0078] Implementation:
[0079] Define a standard metadata format to describe the relationship between data sources and target models.
[0080] Write a parser to build the mapping path based on the metadata.
[0081] Supports hot loading of metadata, allowing mapping rules to be dynamically added or modified at runtime.
[0082] The ability to flexibly configure and dynamically adjust mapping rules in this way greatly enhances the adaptability and scalability of the system.
[0083] The present application provides a data dictionary mapping method based on annotations, the method comprising: determining whether a data query request obtained through a query interface in a SpringBoot framework carries an interface annotation; if so, processing the data query request to determine the data structure type of the data query request in the data dictionary; the data structure types include: paging query, single data query, list query, and tree structure query; based on the data structure type, processing the data query request to determine at least one return identifier and an identifier attribute corresponding to the return identifier; if the identifier attribute includes an attribute annotation, determining the target data corresponding to the return identifier according to the correspondence between different identifiers and different data in the data dictionary. The method can automatically implement dictionary mapping through annotations, reduce the amount of manual coding, and thus improve development efficiency; by separating the dictionary mapping relationship from the business code, it is convenient for centralized management and maintenance, thereby enhancing the maintainability of the code; the method supports dynamic expansion of dictionary types, and can adapt to new requirements without modifying the business code, thereby improving system flexibility.
[0084] Corresponding to the above method, the embodiment of the present application also provides a data dictionary mapping device based on annotations, such as Figure 3 As shown, the device comprises:
[0085] A determination unit 310 is used to determine whether a data query request obtained through a query interface in a Spring Boot framework carries an interface annotation;
[0086] The processing unit 320 is used to process the data query request and determine the data structure type of the data in the data dictionary that the data query request queries; the data structure type includes: paging query, single data query, list query and tree structure query;
[0087] and, based on the data structure type, processing the data query request to determine at least one return identifier and an identifier attribute corresponding to the return identifier;
[0088] The determining unit 310 is further configured to determine the target data corresponding to the returned identifier according to the correspondence between different identifiers and different data in the data dictionary if the identifier attribute includes an attribute annotation.
[0089] The functions of each functional unit of an annotation-based data dictionary mapping device provided in the above embodiment of the present application can be realized through the above method steps. Therefore, the specific working process and beneficial effects of each unit in an annotation-based data dictionary mapping device provided in the embodiment of the present application will not be repeated here.
[0090] The present application also provides an electronic device, such as Figure 4 As shown, it includes a processor 410 , a communication interface 420 , a memory 430 and a communication bus 440 , wherein the processor 410 , the communication interface 420 , and the memory 430 communicate with each other via the communication bus 440 .
[0091] Memory 430, for storing computer programs;
[0092] The processor 410 is used to execute the program stored in the memory 430 to implement the following steps:
[0093] Determine whether the data query request obtained through the query interface in the Spring Boot framework carries the interface annotation;
[0094] If yes, the data query request is processed to determine the data structure type of the data that the data query request queries in the data dictionary; the data structure types include: paging query, single data query, list query and tree structure query;
[0095] Based on the data structure type, the data query request is processed to determine at least one return identifier and an identifier attribute corresponding to the return identifier;
[0096] If the identification attribute includes an attribute annotation, the target data corresponding to the returned identification is determined according to the correspondence between different identifications and different data in the data dictionary.
[0097] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0098] The communication interface is used for communication between the above electronic device and other devices.
[0099] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0100] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0101] The implementation methods and beneficial effects of the components of the electronic device in the above embodiments to solve the problems can be seen in Figure 2 The various steps in the illustrated embodiment are implemented, therefore, the specific working process and beneficial effects of the electronic device provided by the embodiment of the present application are not repeated here.
[0102] In another embodiment provided in the present application, a computer-readable storage medium is also provided, which stores instructions. When the computer-readable storage medium is executed on a computer, the computer executes an annotation-based data dictionary mapping method described in any of the above embodiments.
[0103] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute an annotation-based data dictionary mapping method described in any one of the above embodiments.
[0104] Those skilled in the art will appreciate that the embodiments in the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt a complete hardware embodiment, a complete software embodiment, or a form of an embodiment combining software and hardware. Moreover, the present application may adopt a form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0105] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0106] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0107] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0108] Unless otherwise defined, the technical terms or scientific terms used in this application should be understood by people with ordinary skills in the field to which the present invention belongs. "First", "second" and similar words used in this application do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect", "couple" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0109] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they are aware of the basic creative concepts. Therefore, the present application embodiments are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application embodiments.
[0110] Obviously, those skilled in the art can make various changes and modifications to the embodiments in the present application without departing from the spirit and scope of the embodiments in the present application. Thus, if these modifications and variations of the embodiments in the present application are within the scope of the embodiments in the present application and their equivalents, the embodiments in the present application are also intended to include these modifications and variations.
Claims
1. A data dictionary mapping method based on annotations, characterized in that: The method comprises: Determine whether the data query request obtained through the query interface in the Spring Boot framework carries the interface annotation; If yes, the data query request is processed to determine the data structure type of the data that the data query request queries in the data dictionary; the data structure types include: paging query, single data query, list query and tree structure query; Based on the data structure type, the data query request is processed to determine at least one return identifier and an identifier attribute corresponding to the return identifier; If the identification attribute includes an attribute annotation, the target data corresponding to the returned identification is determined according to the correspondence between different identifications and different data in the data dictionary.
2. The method according to claim 1, characterized in that Determining the data structure type of the data that the data query request queries in the data dictionary includes: Based on the data query request, the mybatis-plus method is used to perform data query in the data dictionary; Use the instanceof method to determine the data structure type of the query data in the data dictionary.
3. The method according to claim 2, characterized in that After determining the data structure type of the query data in the data dictionary, the method further includes: If the data structure type is a paged query, a list query or a tree structure query, then based on the data query request, an iterative query is performed in the data dictionary to determine at least one return identifier and an identifier attribute corresponding to the return identifier.
4. The method according to claim 3, characterized in that Determining at least one return identifier and an identifier attribute corresponding to the return identifier includes: The eachField method is adopted to traverse all fields in the data dictionary based on the data query request and the data structure type to obtain the return identifier of the JSON structure and the identifier attribute corresponding to the return identifier.
5. The method according to claim 4, characterized in that Determining the target mapping data corresponding to the return identifier according to the correspondence between different data and mapping data in the data dictionary includes: The translateDicValue method is used to process the return identifier based on the correspondence between different data in the data dictionary and the mapping data to obtain the target mapping data, and to construct a correspondence between the target mapping data and the return identifier of the JSON structure.
6. The method according to claim 1, characterized in that The attribute annotation is based on Dict annotation.
7. The method according to claim 1, characterized in that The interface annotation is the QueryDict annotation.
8. A data dictionary mapping device based on annotations, characterized in that: The device comprises: A determination unit, used to determine whether a data query request obtained through a query interface in a Spring Boot framework carries an interface annotation; A processing unit, for processing the data query request if yes, and determining the data structure type of the data that the data query request queries in the data dictionary; the data structure types include: paging query, single data query, list query and tree structure query; and, based on the data structure type, processing the data query request to determine at least one return identifier and an identifier attribute corresponding to the return identifier; The determining unit is further configured to determine the target data corresponding to the returned identifier according to the correspondence between different identifiers and different data in the data dictionary if the identifier attribute includes an attribute annotation.
9. An electronic device, characterized in that: The electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Data processing method and device
CN120256479A
Data processing method and device
CN120256479B