A data processing method, apparatus, and storage medium

By generating a directory structure hierarchy and parsing the interface definition file to obtain service and interface attribute information, and then generating framework code files based on this information and moving them to the target directory, the problem of low efficiency in manually integrating multiple Proto files in existing technologies is solved, thus improving development efficiency and accuracy.

CN115202663BActive Publication Date: 2026-05-26TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2021-04-14
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

In existing technologies, when generating framework code from a single Proto file, multiple Proto files need to be manually integrated into the service framework one by one, which leads to low operational efficiency and is prone to errors, thus affecting development efficiency.

Method used

By reading the preset framework template file and generating the directory structure hierarchy, multiple interface definition files are parsed in a loop to obtain service information and interface attribute information. Based on this information and the preset code template file, the framework code file is generated and moved to the corresponding target directory.

Benefits of technology

This avoids the need to generate framework code from multiple Proto files one by one, reducing the error rate of manual integration and improving development efficiency and standardization of engineering development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115202663B_ABST
    Figure CN115202663B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a data processing method, apparatus, and storage medium. By reading a preset framework template file and decompressing it, a directory structure hierarchy is generated; a file list of multiple interface definition files is obtained, and the interface definition files are cyclically parsed according to the file list to obtain the first abstract syntax trees of the multiple interface definition files; service information and interface attribute information in the interface definition files are obtained according to the first abstract syntax trees; framework code files are generated based on the service information, interface attribute information, and a preset code template file, and the framework code files are moved to the corresponding target directories in the directory structure hierarchy. In this way, the operation of generating framework code files multiple times for multiple interface definition files is avoided, and the development efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and more specifically to a data processing method, apparatus, and storage medium. Background Technology

[0002] Protobuf (Google Protocol Buffers) is a high-efficiency protocol data exchange format library provided by Google. It generates cross-language code by defining data structures and service interfaces. Scaffolding tools are project generation technologies supported by various tools. During product development, when different teams need to develop features, to ensure consistency in code structure and format and reduce coding workload, scaffolding tools and Protobuf interfaces can define language files (Proto files) to uniformly generate framework code files. Developers then use these framework code files to complete the development of various functions, thereby improving development speed.

[0003] When defining service interfaces, developers often need to define multiple proto files. However, in current technology, framework code can only be generated from a single proto file. In this case, the framework code generated from each proto file needs to be manually integrated into a single service framework. This manual integration operation is inefficient and prone to errors, which affects the improvement of development efficiency. Summary of the Invention

[0004] This application provides a data processing method, apparatus, and storage medium. These can improve the development efficiency of product development projects.

[0005] A data processing method, comprising:

[0006] Read the preset framework template file and decompress it to generate a directory structure hierarchy;

[0007] Obtain a file list of multiple interface definition files, and perform loop parsing of the interface definition files according to the file list to obtain the first abstract syntax tree of the multiple interface definition files;

[0008] The service information and interface attribute information in the interface definition file are obtained based on the first abstract syntax tree;

[0009] Based on the service information, the interface attribute information, and the preset code template file, a framework code file is generated, and the framework code file is moved to the corresponding target directory in the directory structure hierarchy.

[0010] Accordingly, embodiments of this application provide a data processing apparatus, including:

[0011] The decompression unit is used to read and decompress the preset framework template file, generating a directory structure hierarchy;

[0012] The parsing unit is used to obtain a file list of multiple interface definition files, and to perform loop parsing of the interface definition files according to the file list to obtain a first abstract syntax tree of multiple interface definition files;

[0013] The first acquisition unit is used to acquire service information and interface attribute information from the interface definition file according to the first abstract syntax tree;

[0014] The first generation unit is used to generate a framework code file based on the service information, the interface attribute information, and the preset code template file, and move the framework code file to the corresponding target directory in the directory structure hierarchy.

[0015] In one embodiment, the parsing unit includes:

[0016] The reading subunit is used to cyclically read character data from multiple interface definition files in the file list, perform part-of-speech analysis on the character data, and generate tag data corresponding to the character data.

[0017] A sub-unit is constructed to perform syntax analysis on the marked data and to construct a first abstract syntax tree for multiple interface definition files based on the marked data.

[0018] In one embodiment, the first generating unit includes:

[0019] The first acquisition subunit is used to acquire a preset template code file;

[0020] A sub-unit is generated to replace the corresponding variable information in the preset template code file according to the service information and the interface attribute information, and to generate a framework code file.

[0021] In one embodiment, the first generating unit includes:

[0022] A sub-unit is configured to set the priority of the framework code file;

[0023] The first moving subunit is used to move the framework code file to the target directory corresponding to the priority level of the framework code file.

[0024] In one embodiment, the first generating unit includes:

[0025] A tagging subunit is used to tag the framework code file with tag information;

[0026] The second moving subunit is used to move the framework code file to the target directory corresponding to the tag information according to the tag information of the framework code file.

[0027] In one embodiment, the data processing apparatus further includes:

[0028] Specify unit, used to specify the file paths of preset framework template files, interface definition files, preset code template files, and structured query language script files via command-line tools.

[0029] In one embodiment, the data processing apparatus further includes:

[0030] The second acquisition unit is used to acquire and parse the structured query language script file according to the file path of the structured query language script file to obtain data definition language information, wherein the data definition language information includes table information, field information and type information;

[0031] The third acquisition unit is used to acquire the database access object layer code template file in the preset code template file;

[0032] The second generation unit is used to generate a database access object layer code file based on the data definition language information and the database access object layer code template file.

[0033] The moving unit is used to move the database access object layer code file to the database directory in the directory structure hierarchy.

[0034] In one embodiment, the second acquisition unit includes:

[0035] The second acquisition subunit is used to acquire and parse the structured query language script file to obtain the second abstract syntax tree of the structured query language script file;

[0036] The third acquisition subunit is used to acquire the data definition language information of the structured query language script file based on the second abstract syntax tree.

[0037] Furthermore, embodiments of this application also provide a storage medium storing a plurality of instructions adapted for loading by a processor to execute steps in any of the data processing methods provided in embodiments of this application.

[0038] Furthermore, this application also provides a computer device, including a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to implement the data processing method provided in this application.

[0039] This application also provides a computer program product or computer program, which includes computer instructions stored in a storage medium. A processor of a computer device reads the computer instructions from the storage medium and executes the computer instructions, causing the computer device to perform the steps in the data processing method provided in this application.

[0040] This embodiment of the application reads and decompresses a preset framework template file to generate a directory structure hierarchy; obtains a file list of multiple interface definition files; parses the interface definition files iteratively based on the file list to obtain a first abstract syntax tree (AST) for the multiple interface definition files; obtains service information and interface attribute information from the interface definition files based on the first AST; generates framework code files based on the service information, interface attribute information, and the preset code template file; and moves the framework code files to the corresponding target directories in the directory structure hierarchy. In this way, by decompressing the preset framework template file to generate a directory structure hierarchy, and iteratively parsing multiple interface definition files to obtain service information and interface attribute information, and then generating framework code files based on the service information, interface attribute information, and the preset code template file, and moving the generated framework code files to the corresponding target directories in the directory structure hierarchy, the process avoids generating framework code for each of the multiple interface definition files individually, thus improving development efficiency. Attached Figure Description

[0041] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0042] Figure 1 This is a schematic diagram illustrating an implementation scenario of a data processing method provided in an embodiment of this application;

[0043] Figure 2 This is a flowchart illustrating a data processing method provided in an embodiment of this application;

[0044] Figure 3 This is a schematic flowchart of a data processing method provided in an embodiment of this application;

[0045] Figure 4 This is another schematic flowchart of a data processing method provided in an embodiment of this application;

[0046] Figure 5 This is a schematic diagram of the structure of the data processing apparatus provided in the embodiments of this application;

[0047] Figure 6 This is a schematic diagram of the structure of the computer device provided in the embodiments of this application. Detailed Implementation

[0048] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0049] This application provides a data processing method, apparatus, and storage medium. The data processing apparatus can be integrated into a computer device, which may be a server or a terminal, etc.

[0050] For better illustration of the embodiments of this application, please refer to the following terms:

[0051] Scaffolding: A metaprogramming approach for building database-enabled software applications. Scaffolding is a project generation technique supported by various tools, where programmers write specifications describing how to use the application's database. The compiler uses these specifications to generate code that the application can use to create, read, update, and delete database entries, effectively treating templates as "scaffolding" for building more robust applications.

[0052] Framework: A framework is a reusable design for the entire or part of a system, manifested as a set of abstract components and the methods by which component instances interact; another definition considers a framework as the application skeleton that can be customized by application developers. A framework is a reusable design component that defines the application's architecture, clarifies the dependencies, responsibility allocation, and control flow between the entire design and collaborating components, and is manifested as a set of abstract classes and the methods by which their instances collaborate.

[0053] Command-line tools, also known as command-line interfaces (CLI), were the most widely used user interfaces before the widespread adoption of graphical user interfaces. They typically do not support a mouse; users input commands via the keyboard, and the computer receives and executes these commands. They can also be called code generation tools.

[0054] Protobuf: short for Protocol Buffers, is a data description language developed by Google. Similar to Extensible Markup Language (XML), it can serialize structured data and can be used for data storage, communication protocols, and other applications.

[0055] Abstract Syntax Tree (AST): In computer science, an Abstract Syntax Tree (AST), or simply a syntax tree, is an abstract representation of the syntactic structure of source code. It represents the syntactic structure of a programming language in a tree-like structure, where each node in the tree represents a structure within the source code.

[0056] RPC: Remote Procedure Call (RPC) is a protocol that allows a program to request services from another program on a network. In RPC, the program making the request is the client program, and the program providing the service is the server. RPC is a widely used technology to support distributed applications (applications whose components are distributed across different computers). The main purpose of RPC is to provide a way for components to communicate with each other, enabling them to make requests to each other and exchange the results of those requests.

[0057] SQL: Structured Query Language (SQL) is a special-purpose programming language, a database query and programming language used to access, query, update, and manage relational database systems.

[0058] DDL: Database Schema Definition Language (DDL), also known as Data Definition Language, is a type of SQL language used to describe real-world entities to be stored in a database.

[0059] DAO (Data Access Object) is an object-oriented database interface that exposes the Microsoft Jet database engine and allows Visual Basic (VB, a general-purpose object-based programming language developed by Microsoft, which is a structured, modular, object-oriented, event-driven visual programming language with an accompanying development environment) to directly connect to Access (a relational database management system released by Microsoft) tables via Open Database Connectivity (ODBC) as if connecting directly to any other database. DAOs are best suited for single-system applications or small-scale local distribution.

[0060] Please see Figure 1 Taking the integration of data processing devices into computer equipment as an example, Figure 1 This is a schematic diagram illustrating the implementation environment of the data processing method provided in this application embodiment, including server A and terminal B. Server A can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN) services, and big data and artificial intelligence platforms. Server A can read and decompress a preset framework template file to generate a directory structure hierarchy; obtain a file list of multiple interface definition files, and perform iterative parsing of the interface definition files according to the file list to obtain a first abstract syntax tree of multiple interface definition files; obtain service information and interface attribute information from the interface definition files according to the first abstract syntax tree; generate a framework code file based on the service information, interface attribute information, and preset code template file, and move the framework code file to the corresponding target directory in the directory structure hierarchy.

[0061] Terminal B can be any computer device capable of data input, such as a smartphone, tablet, laptop, or desktop computer, but is not limited to these. Terminal B and server A can be directly or indirectly connected via wired or wireless communication. Server A can receive data uploaded by terminal B to perform corresponding data processing operations; this application does not impose any restrictions on this.

[0062] It should be noted that, Figure 1 The illustrated implementation environment scenario of the data processing method is merely an example. The implementation environment scenario of the data processing method described in this application embodiment is for the purpose of more clearly illustrating the technical solution of this application embodiment and does not constitute a limitation on the technical solution provided in this application embodiment. Those skilled in the art will understand that with the evolution of data processing and the emergence of new business scenarios, the technical solution provided in this application is also applicable to similar technical problems.

[0063] The following sections provide detailed descriptions of each example. It should be noted that the order in which the embodiments are described is not intended to limit the preferred order of the embodiments.

[0064] This embodiment will be described from the perspective of a data processing device, which can be integrated into a computer device, which can be a server or a terminal, and this application does not impose any restrictions here.

[0065] Please see Figure 2 , Figure 2 This is a flowchart illustrating the data processing method provided in an embodiment of this application. The data processing method includes:

[0066] In step 101, the preset framework template file is read and decompressed to generate a directory structure hierarchy.

[0067] In product development, different teams typically collaborate to develop product features. However, different teams, different feature developers, or different developers may have different coding habits or need to use different language environments. Therefore, to ensure consistency in code structure and format and reduce the workload of coding, scaffolding tools and Protobuf interface definition language files (Proto files) can be used to uniformly generate framework code files. These framework code files include service definition interface information and encapsulation of some highly repetitive code. Developers can then code based on these framework code files to complete the development of various features, thereby improving development speed.

[0068] A service is a function call provided by a lower layer to an adjacent upper layer. It refers to an application, routine, or process that performs a specific function to support other programs. A service provides a series of interfaces to implement the corresponding functions. An interface is a connection point for exchanging information between two adjacent layers within the same node; it is the entry point for the upper layer to use the lower layer's service. A service may consist of multiple modules, and each module typically defines a Proto file. Therefore, when defining interfaces, i.e., when defining service interfaces, developers usually need to define multiple Proto files. However, in current technology, only a single Proto file can generate the framework code file. In this case, developers need to manually generate framework code files from multiple Proto files one by one and manually integrate all the generated framework code files into a single service framework. This manual integration operation is inefficient, error-prone, and hinders development efficiency.

[0069] To address the above issues, this application provides a data processing method. This method involves decompressing a preset framework template file to generate a directory structure hierarchy, and then iteratively parsing multiple Proto files. Based on the parsed data and the preset code template file, a framework code file is generated. This generated framework code file is then moved to the corresponding target directory within the directory structure hierarchy, thereby generating the framework for the product development project. This avoids the need to generate framework code files from multiple Proto files individually, as is required in existing technologies. Furthermore, it reduces the process of integrating all generated framework code files into a single service framework, lowering the error rate of manual operations and thus improving project development efficiency. Please refer to the following steps for the specific implementation process.

[0070] To unify the generation of framework code files from multiple Proto files within a custom directory hierarchy, a custom framework template file can be used. This is achieved by obtaining a preset framework template file, reading and decompressing it, and then generating the directory structure hierarchy. In one embodiment, the path to the preset framework template file can be specified using the scaffolding's command-line tool. The command-line tool can also specify the paths to other files needed for framework generation, such as multiple interface definition files (Proto files), the path to the preset code template file for generating framework code files, and the service port. Furthermore, the command-line tool can be configured with parameters to achieve specific functions. For example, parameters can be set to generate only PB files, which are executable binary files compiled from the interface definition files. After specifying the files and setting the parameters using the command-line tool, the preset framework template file can be located at the specified path, read, and decompressed to generate the directory structure hierarchy.

[0071] The preset framework template file is a compressed file containing a tree-like directory structure organized according to the project's directory hierarchy. It defines the directory hierarchy of the framework to be generated and can be customized by developers according to project requirements. In one embodiment, the generated directory structure can be moved to a designated folder. After generating the product development project framework, the framework can be packaged according to the directory hierarchy generated by the preset framework template file to obtain a compressed file containing the project framework.

[0072] In step 102, a file list of multiple interface definition files is obtained, and the interface definition files are parsed in a loop according to the file list to obtain the first abstract syntax tree of multiple interface definition files.

[0073] To simultaneously generate framework code files from multiple interface definition files and integrate them into a single framework, a command-line tool can be used to specify the paths to multiple interface definition files. This allows obtaining a list of these files and then iteratively parsing them. Each interface definition file defines service interfaces and messages. These service interfaces can be RPC interfaces or Hypertext Transfer Protocol (HTTP) interfaces, among others. Messages serve as a message transmission channel, containing structured data. The message defines the data structure, including data types, field names, field rules, field unique identifiers, default values, and other interface parameter information. Therefore, when calling the interfaces defined in the interface definition files, data can be transmitted through the interfaces in the format defined in the files.

[0074] To facilitate the reading of code data from multiple interface definition files, an abstract syntax tree (AST) parser can be used to iteratively parse these files. This involves part-of-speech tagging (PTS), also known as scanning, which converts all words or characters in the interface definition files into tokens according to predetermined rules. Simultaneously, it removes whitespace, comments, etc., ultimately segmenting the code data from the entire interface definition file into a token list, generating corresponding token data. Next, syntactic analysis is performed on this token data, converting the token list from the lexical analysis into a tree structure. The AST parser also verifies the syntax and removes unnecessary tokens, such as incomplete parentheses. This process yields the first abstract syntax tree (AST) of the multiple interface definition files. Each node in the first AST represents a syntactic structure in the program code; for example, packages, types, modifiers, operators, interfaces, and return values ​​can all be syntactic structures.

[0075] In step 103, the service information and interface attribute information in the interface definition file are obtained according to the first abstract syntax tree.

[0076] In order to generate framework code files, after parsing and constructing a first abstract syntax tree of multiple interface definition files, the service information and interface attribute information of the interface definition files are obtained by reading the first abstract syntax tree of the multiple interface definition files. The service information includes information such as service name, and the interface attribute information includes interface name defined in the interface definition file and interface parameter information such as data type, field name, and field rules defined in the data structure. Based on the information obtained above, the operation of generating framework code files is performed.

[0077] In step 104, a framework code file is generated based on service information, interface attribute information, and a preset code template file, and the framework code file is moved to the corresponding target directory in the directory structure hierarchy.

[0078] After obtaining the service information and interface attribute information from the interface definition file, in order to generate custom framework code files, a preset template code file can be obtained through a command-line tool at a specified path. The corresponding variable information in this preset template code file is then replaced with the obtained service and interface attribute information, thereby generating the corresponding framework code file. Subsequently, when developers call the interface in the framework code file through the framework, data will be transmitted within that interface in the format defined in the interface attribute information. The preset code template file serves as the template for generating the framework code file; there can be multiple preset code template files, and correspondingly, multiple framework code files will be generated.

[0079] In one embodiment, the generated framework code files can be prioritized. For example, the priority of the framework code files can be set according to their importance, that is, some important framework code files can be assigned a higher priority level, and some relatively less important framework code files can be assigned a lower priority level. Alternatively, the usage frequency of the framework code files can be accumulated, and the framework code files used the most frequently can be assigned the highest priority level, and the framework code files used the least frequently can be assigned the lowest priority level. The priority of the framework code files can also be set according to their usage time, with the most recently used framework code files assigned the highest priority level and the framework code files that have not been used for the longest time assigned the lowest priority level, and so on. Based on the priority level of the framework code file, it can be moved to the target directory corresponding to that level, so that developers can maintain and quickly retrieve the more important framework code files.

[0080] In one embodiment, framework code files can be tagged with information such as the corresponding layer in the framework, such as the service layer, controller layer, database access object layer (DAO layer), and user layer (user layer, which is used to manage user-related code), the name of the development team, the language type before format conversion, or the category of the implemented functional modules, etc. Based on the tag information of the framework code file, the framework code file is moved to the target directory corresponding to the tag information, so that developers can quickly manage and obtain framework code files with different tags.

[0081] In one embodiment, to enable database access via the framework and perform operations such as adding, deleting, modifying, and querying, a Structured Query Language (SCL) script file can be used to define the corresponding database structure and operation methods. Then, based on the database structure and operation methods defined in the SCL script file, a corresponding database access object layer (DAPI) code file is generated using a database access object layer code template file. Developers can then access the database by calling this DAPI code file. This database access object layer code template file is a template for the generated DAPI code file, containing encapsulations of basic code and information on variables that need to be replaced. Specifically, the path to the Structured Query Language (SCL) script file can be specified in the scaffolding's command-line tool. Based on this path, the SCL script file is retrieved and parsed, resulting in a second abstract syntax tree (BLS). From this BLS, the Data Definition Language (DDL) information is obtained, including table, field, and type information. This includes table name, field name, field type, and field length, corresponding to the database structure and operation methods defined in the DDL. This leads to the acquisition of the Database Access Object Layer (DAL) code template file within the pre-defined code template file. Based on the DDL information and the DAL code template file, a DAL code file is generated and moved to the database directory within the directory structure. This allows developers to access the database using the DAL code file within the framework.

[0082] As described above, this embodiment of the application generates a directory structure hierarchy by reading and decompressing a preset framework template file; obtains a file list of multiple interface definition files; parses the interface definition files iteratively based on the file list to obtain a first abstract syntax tree (AST) for the multiple interface definition files; obtains service information and interface attribute information from the interface definition files based on the first AST; generates a framework code file based on the service information, interface attribute information, and the preset code template file; and moves the framework code file to the corresponding target directory in the directory structure hierarchy. Thus, by decompressing the preset framework template file to generate a directory structure hierarchy, and iteratively parsing multiple interface definition files to obtain service information and interface attribute information, and then generating a framework code file based on the service information, interface attribute information, and the preset code template file, and moving the generated framework code file to the corresponding target directory in the directory structure hierarchy, this avoids generating framework code for each of the multiple interface definition files individually, thereby improving development efficiency while enhancing the standardization of engineering development.

[0083] Based on the method described in the above embodiments, the following examples will provide further detailed explanations.

[0084] In this embodiment, the data processing device will be described using an example of its integration into a computer device. The data processing method uses a server as the execution entity, and is specifically described using the generation of database access object layer code files as an example. For details, please refer to... Figure 3 , Figure 3 This is a schematic diagram illustrating the specific process of a data processing method provided in an embodiment of this application.

[0085] For a better description of the embodiments of this application, please refer to the following: Figure 3 and Figure 4 .like Figure 4 As shown, Figure 4 Another flowchart illustrating the data processing method provided in this application embodiment. The specific process is as follows:

[0086] In step 201, the server specifies the file paths of the preset framework template file, interface definition file, preset code template file, and structured query language script file through the command line tool, reads the preset framework template file and decompresses it to generate a directory structure hierarchy.

[0087] When generating the framework for a product development project, it is necessary to specify the files required for framework generation so that the server can obtain the specified files through the command-line tool in the scaffolding to generate the framework. Specifically, the server can specify the file paths of the preset framework template file, interface definition file, preset code template file, and structured query language script file required for framework generation through the command-line tool. The preset framework template file is used to generate the project's directory structure hierarchy and can be customized according to the developers' ideas or the needs of the product development project. The interface definition file is used to define the service interfaces required by the project, and multiple interface definition files can exist. The preset code template file is used to combine with the interface definition files to generate the framework code file, and is a template for the framework code file generated by a data processing method provided in this application embodiment; it can also be customized according to the needs of the product development project. The structured query language (SQL) script file is used to define the database structure and operation methods, etc. Based on the structured query language script file and the corresponding template, a database access object layer code file is generated so that developers can access the database through the framework. Thus, by specifying the path of the preset framework template file, the preset framework template file is obtained, read, and decompressed to generate the directory structure hierarchy of the product development project. The directory structure includes a target directory and a database directory. The database directory can be used to store database access object layer code files, and the target directory can be used to store framework code files. Both the target directory and the database directory can have multiple subdirectories, which are not limited here.

[0088] In step 202, the server obtains a file list of multiple interface definition files, reads the character data of multiple interface definition files in the file list in a loop, performs part-of-speech analysis on the character data, generates the tag data corresponding to the character data, performs syntax analysis on the tag data, and constructs the first abstract syntax tree of multiple interface definition files based on the tag data.

[0089] To generate the framework code files, the server can obtain a list of multiple interface definition files by specifying the path to the interface definition files using a command-line tool. It then iteratively reads the character data from these interface definition files, specifically reading the interfaces and data structures defined within them. To facilitate the program's reading of the code data from these multiple interface definition files, an abstract syntax tree (AST) parser is used. Specifically, part-of-speech tagging is performed on the character data, converting all words or characters in the interface definition files into tokens according to predetermined rules. Simultaneously, whitespace, comments, and other data are removed, dividing the entire character data into a token list (a one-dimensional array). This generates the corresponding token data. Next, syntax analysis is performed on this token data, converting the token list obtained from lexical analysis into a tree structure. The AST parser also verifies the syntax and removes unnecessary tokens, such as incomplete parentheses. Based on this token data, the first AST of the multiple interface definition files is constructed, thus obtaining the first AST of the multiple interface definition files.

[0090] In step 203, the server obtains the service information and interface attribute information in the interface definition file based on the first abstract syntax tree, obtains the preset template code file, replaces the corresponding variable information in the preset template code file with the service information and the interface attribute information, and generates the framework code file.

[0091] After obtaining the first abstract syntax tree (AST) of multiple interface definition files that are easy for the program to read, the first AST of multiple interface definition files is read to obtain the service information and interface attribute information in the interface definition files. The service information includes information such as the service name, and the interface attribute information includes the interface name defined in the interface definition file, as well as interface parameter information such as data types, field names, and field rules defined in the data structure. Simultaneously, a preset template code file can be obtained by specifying the path in the command-line tool. The corresponding variable information in this preset template code file is replaced according to the obtained service information and interface attribute information. That is, the interfaces and related data structures defined in the multiple interface definition files are replaced in this preset template code file, thereby generating the corresponding framework code file. It should be noted that this preset template code file may contain a database access object layer code template file, but no operations are performed on the database access object layer code template file in this step. Therefore, when developers call the interfaces in the framework code file through the framework, the data will be transmitted in the interface according to the format defined in the interface parameter information.

[0092] In step 204, the server sets the priority of the framework code file and moves it to the target directory corresponding to the priority level.

[0093] After generating the framework code files, they can be moved to the corresponding target directory within the directory structure hierarchy generated by the framework template files. Specifically, the generated framework code files can be prioritized. For example, they can be prioritized based on their importance, assigning higher priority to more important files and lower priority to less important ones. Alternatively, they can be prioritized based on usage frequency, assigning the highest priority to the most frequently used files and the lowest priority to the least frequently used files. They can also be prioritized based on usage time, assigning the highest priority to the most recently used files and the lowest priority to the least used files, and so on. Based on the priority level, each framework code file is moved to the corresponding target directory, allowing developers to easily maintain and quickly access the highest priority framework code files.

[0094] In one embodiment, the framework code file can be tagged with information such as the corresponding layer in the framework, such as the service layer, controller layer, database access object layer (DAO layer), and user layer, the name of the development team, the language type before format conversion, or the category of the implemented functional modules, etc. Based on the tag information of the framework code file, the framework code file is moved to the target directory corresponding to the tag information, so that developers can quickly manage and obtain framework code files with different tags.

[0095] In step 205, the server obtains the structured query language script file according to the file path of the structured query language script file, parses it to obtain the second abstract syntax tree of the structured query language script file, and obtains the data definition language information of the structured query language script file according to the second abstract syntax tree.

[0096] In product development, database access is generally required. Accordingly, for the product development project framework, the code that operates on the database can be encapsulated into a database access object layer (DAPI) framework code file, i.e., a DAPI code file. This allows developers to perform operations such as adding, deleting, modifying, and querying data from the database based on the framework. Furthermore, developers can continue coding on top of the DAPI code file, reducing repetitive writing of database access-related code and decreasing workload. Specifically, the corresponding database interface can be defined using a Structured Query Language (SCL) script file. This SCL script file can be written using the DDL language in SQL, defining the database structure and database operation methods. These operation methods can include creation, modification, deletion, and query operations. Based on the database structure and operation methods defined in the DDL language of the SCL script file, and the corresponding template file, the corresponding DAPI code file is generated. Developers can then call the generated DAPI code file to access the database.

[0097] The server can retrieve and parse the Structured Query Language (SCL) script file based on the file path specified by the command-line tool, thereby obtaining a second abstract syntax tree (AST) for the SCL script file. In one embodiment, the SCL script file can be parsed using an SQL language abstract syntax tree parser. This involves performing part-of-speech tagging on the DDL code data within the SCL script file, converting all words or characters in the SCL script file into tokens according to predetermined rules. Simultaneously, whitespace, comments, and other data are removed from the character data, thus segmenting the code data of the entire SCL script file into a token list. This generates token data corresponding to the code data. Next, syntactic analysis can be performed on this token data, converting the token list obtained from lexical analysis into a tree structure. The second abstract syntax tree is then constructed based on the token data of the SCL script file.

[0098] The second abstract syntax tree obtained from the structured query language script file is read, and the data definition language information defined in the structured query language script file is obtained based on the second abstract syntax tree. The data definition language information includes table information, field information, and type information, such as table name, field name, field type, and field length. In other words, it is the information corresponding to the database structure and database operation methods defined in the DDL language in the structured query language script file.

[0099] In step 206, the server obtains the database access object layer code template file from the preset code template file, generates a database access object layer code file based on the data definition language information and the database access object layer code template file, and moves the database access object layer code file to the database directory in the directory structure hierarchy.

[0100] Specifically, the server obtains the database access object layer code template file from the preset code template file, replaces the corresponding variable information in the database access object layer code template file with the data definition language information obtained from the structured query language script file, generates a database access object layer code file after replacement, and moves the database access object layer code file to the database directory in the directory structure hierarchy. In this way, the server can access the database through the database access object layer code file in the framework.

[0101] In one embodiment, the generated database access object layer (DOL) code files can be prioritized. For example, the priority of the DOL code files can be set according to their importance, that is, some important DOL code files can be assigned a higher priority level, and some relatively less important DOL code files can be assigned a lower priority level. Alternatively, the usage frequency of the DOL code files can be accumulated, and the most frequently used DOL code files can be assigned the highest priority level, and the least frequently used DOL code files can be assigned the lowest priority level. The priority of the DOL code files can also be set according to their usage time, with the most recently used DOL code files assigned the highest priority level and the least used DOL code files assigned the lowest priority level, and so on. Based on the priority level of the DOL code file, it can be moved to the database directory corresponding to that priority level, so that developers can maintain and quickly retrieve the higher priority DOL code files.

[0102] In one embodiment, database access object layer code files can be tagged with information such as hierarchical information, language type before format conversion, or functional module category. Based on the tag information, the database access object layer code file is moved to the database directory corresponding to the tag information, so that developers can quickly manage and retrieve database access object layer code files with different tags.

[0103] As described above, in this embodiment, the server specifies the file paths of a preset framework template file, an interface definition file, a preset code template file, and a structured query language script file via a command-line tool. The server reads and decompresses the preset framework template file to generate a directory structure hierarchy. The server obtains a file list of multiple interface definition files, iteratively reads the character data from these files, performs part-of-speech analysis on the character data to generate corresponding tag data, performs syntactic analysis on the tag data, and constructs a first abstract syntax tree for the multiple interface definition files based on the tag data. The server then obtains the service information and interface attribute information from the interface definition files based on the first abstract syntax tree, obtains the preset template code file, and replaces the preset template code file with the service information and interface attribute information. The server generates a framework code file based on the corresponding variable information. It then prioritizes this framework code file and moves it to the target directory corresponding to that priority level. Next, the server retrieves and parses the Structured Query Language (SML) script file based on its file path, obtaining its second abstract syntax tree. Based on this second abstract syntax tree, it retrieves the data definition language (DML) information for the SML script file. Finally, the server retrieves the database access object (DOO) layer code template file from the preset code template file, generates a DOOML code file based on the DML information and the DOOML code template file, and moves this DOOML code file to the database directory within the directory structure hierarchy. Therefore, by decompressing the preset framework template file to generate a directory structure hierarchy, and cyclically parsing multiple interface definition files to obtain service information and interface attribute information from the interface definition files, framework code files are generated based on the service information, interface attribute information, and preset code template files. The generated framework code files are then moved to the corresponding target directories in the directory structure hierarchy. Simultaneously, the structured query language script file is obtained and parsed to obtain the second abstract syntax tree of the structured query language script file. Based on the second abstract syntax tree, the data definition language information of the structured query language script file is obtained. Based on the data definition language information and the database access object layer code template file, database access object layer code files are generated. This enables developers to access data through the framework, thereby generating a unified framework and avoiding the need to generate framework code for each of the multiple interface definition files individually. This improves the standardization of engineering development and increases development efficiency.

[0104] To better implement the above methods, embodiments of the present invention also provide a data processing apparatus that can be integrated into a computer device, which can be a server.

[0105] For example, such as Figure 5 The diagram shown is a structural schematic of a data processing device provided in an embodiment of this application. The data processing device may include a decompression unit 301, a parsing unit 302, a first acquisition unit 303, and a first generation unit 304, as follows:

[0106] The decompression unit 301 is used to read and decompress the preset framework template file to generate a directory structure hierarchy.

[0107] Parsing unit 302 is used to obtain a file list of multiple interface definition files, and to perform loop parsing of the interface definition files according to the file list to obtain the first abstract syntax tree of multiple interface definition files;

[0108] The first acquisition unit 303 is used to acquire service information and interface attribute information from the interface definition file according to the first abstract syntax tree.

[0109] The first generation unit 304 is used to generate a framework code file based on the service information, the interface attribute information and the preset code template file, and move the framework code file to the corresponding target directory in the directory structure hierarchy.

[0110] In one embodiment, the parsing unit 302 includes:

[0111] The reading subunit is used to read character data from multiple interface definition files in the file list in a loop, perform part-of-speech analysis on the character data, and generate tag data corresponding to the character data.

[0112] A sub-unit is constructed to perform syntax analysis on the marked data, and the first abstract syntax tree of multiple interface definition files is constructed based on the marked data.

[0113] In one embodiment, the first generation unit 304 includes:

[0114] The first acquisition subunit is used to acquire a preset template code file;

[0115] The generation sub-unit is used to replace the corresponding variable information in the preset template code file based on the service information and the interface attribute information, and generate the framework code file.

[0116] In one embodiment, the first generation unit 304 includes:

[0117] Define a sub-unit to set the priority of the framework code file;

[0118] The first move subunit is used to move the framework code file to the target directory corresponding to the priority level of the framework code file.

[0119] In one embodiment, the first generation unit 304 includes:

[0120] The tagging subunit is used to tag the code file of this framework with tag information;

[0121] The second moving subunit is used to move the framework code file to the target directory corresponding to the tag information, based on the tag information of the framework code file.

[0122] In one embodiment, the data processing apparatus further includes:

[0123] Specify unit, used to specify the file paths of preset framework template files, interface definition files, preset code template files, and structured query language script files via command-line tools.

[0124] In one embodiment, the data processing apparatus further includes:

[0125] The second acquisition unit is used to acquire the structured query language script file according to the file path of the structured query language script file and parse it to obtain data definition language information, which includes table information, field information and type information;

[0126] The third acquisition unit is used to acquire the database access object layer code template file in the preset code template file;

[0127] The second generation unit is used to generate a database access object layer code file based on the data definition language information and the database access object layer code template file.

[0128] The move unit is used to move the database access object layer code file to the database target directory in the directory structure hierarchy.

[0129] In one embodiment, the second acquisition unit includes:

[0130] The second acquisition subunit is used to acquire and parse the structured query language script file to obtain the second abstract syntax tree of the structured query language script file;

[0131] The third acquisition subunit is used to obtain the data definition language information of the structured query language script file based on the second abstract syntax tree.

[0132] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.

[0133] As described above, in this embodiment, the decompression unit 301 reads and decompresses a preset framework template file to generate a directory structure hierarchy; the parsing unit 302 obtains a file list of multiple interface definition files, and performs iterative parsing of the interface definition files according to the file list to obtain a first abstract syntax tree of the multiple interface definition files; the first acquisition unit 303 obtains service information and interface attribute information from the interface definition files according to the first abstract syntax tree; and the first generation unit 304 generates a framework code file based on the service information, interface attribute information, and the preset code template file, and moves the framework code file to the corresponding target directory in the directory structure hierarchy. Thus, by decompressing the preset framework template file to generate a directory structure hierarchy, and iteratively parsing multiple interface definition files to obtain service information and interface attribute information from the interface definition files, and then generating a framework code file based on the service information, interface attribute information, and the preset code template file, and moving the generated framework code file to the corresponding target directory in the directory structure hierarchy, the generation of framework code for each of the multiple interface definition files is avoided, improving development efficiency.

[0134] This application also provides a computer device, such as... Figure 6 As shown, it illustrates a structural diagram of a computer device involved in an embodiment of this application. This computer device may be a server, specifically:

[0135] The computer device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will understand that... Figure 6 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

[0136] The processor 401 is the control center of the computer device. It connects various parts of the computer device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 402, and by calling data stored in the memory 402, it performs various functions of the computer device and processes data, thereby performing overall detection of the computer device. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 401.

[0137] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.

[0138] The computer device also includes a power supply 403 that supplies power to the various components. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 403 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0139] The computer device may also include an input unit 404, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0140] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 401 in the computer device loads the executable files corresponding to the processes of one or more applications into the memory 402 according to the following instructions, and the processor 401 runs the applications stored in the memory 402 to realize various functions, as follows:

[0141] Read and decompress the preset framework template file to generate a directory structure hierarchy; obtain a file list of multiple interface definition files, and parse the interface definition files in a loop according to the file list to obtain the first abstract syntax tree of multiple interface definition files; obtain the service information and interface attribute information in the interface definition files according to the first abstract syntax tree; generate the framework code file based on the service information, interface attribute information and preset code template file, and move the framework code file to the corresponding target directory in the directory structure hierarchy.

[0142] The specific implementation of each of the above operations can be found in the preceding embodiments, and will not be repeated here. It should be noted that the computer device provided in this application embodiment and the data processing method in the above embodiments belong to the same concept, and its specific implementation process can be found in the above method embodiments, and will not be repeated here.

[0143] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.

[0144] Therefore, embodiments of this application provide a storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the data processing methods provided in embodiments of this application. For example, the instructions can execute the following steps:

[0145] Read and decompress the preset framework template file to generate a directory structure hierarchy; obtain a file list of multiple interface definition files, and parse the interface definition files in a loop according to the file list to obtain the first abstract syntax tree of multiple interface definition files; obtain the service information and interface attribute information in the interface definition files according to the first abstract syntax tree; generate the framework code file based on the service information, interface attribute information and preset code template file, and move the framework code file to the corresponding target directory in the directory structure hierarchy.

[0146] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0147] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0148] Since the instructions stored in the storage medium can execute the steps of any of the data processing methods provided in the embodiments of this application, the beneficial effects that any of the data processing methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.

[0149] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the various optional implementations of the above embodiments.

[0150] The data processing method, apparatus, and storage medium provided in the embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A data processing method, characterized in that, include: Read the preset framework template file and decompress it to generate a directory structure hierarchy; Obtain a file list of multiple interface definition files, and perform loop parsing of the interface definition files according to the file list to obtain the first abstract syntax tree of the multiple interface definition files; The service information and interface attribute information in the interface definition file are obtained based on the first abstract syntax tree; The process of generating a framework code file based on the service information, the interface attribute information, and the preset code template file includes: obtaining the preset template code file; replacing the corresponding variable information in the preset template code file according to the service information and the interface attribute information, and generating the framework code file. Move the framework code files to the corresponding target directory in the directory structure hierarchy.

2. The data processing method as described in claim 1, characterized in that, The step of iteratively parsing the interface definition files according to the file list to obtain a first abstract syntax tree of multiple interface definition files includes: The character data of multiple interface definition files in the file list is read in a loop, the character data is analyzed by part-of-speech tagging, and the tag data corresponding to the character data is generated. The tagged data is subjected to syntactic analysis, and a first abstract syntax tree is constructed based on the tagged data for multiple interface definition files.

3. The data processing method as described in claim 1, characterized in that, Moving the framework code file to the corresponding target directory in the directory structure hierarchy includes: Priority settings are applied to the framework code files; Based on the priority level of the framework code file, move the framework code file to the target directory corresponding to that priority level.

4. The data processing method as described in claim 1, characterized in that, Moving the framework code file to the corresponding target directory in the directory structure hierarchy includes: Tag information is added to the framework code file; Based on the tag information of the framework code file, move the framework code file to the target directory corresponding to the tag information.

5. The data processing method as described in claim 1, characterized in that, Before reading and decompressing the preset framework template file and generating the directory structure hierarchy, the process also includes: Specify the file paths for the preset framework template file, interface definition file, preset code template file, and structured query language script file using the command-line tool.

6. The data processing method as described in claim 5, characterized in that, The method further includes: Based on the file path of the structured query language script file, the structured query language script file is obtained and parsed to obtain data definition language information, which includes table information, field information and type information; Obtain the database access object layer code template file from the preset code template file; Based on the data definition language information and the database access object layer code template file, a database access object layer code file is generated to enable access to the database through the database access object layer code file; Move the database access object layer code file to the database directory in the directory structure hierarchy.

7. The data processing method as described in claim 6, characterized in that, The process of obtaining and parsing the structured query language script file to obtain data definition language information includes: Obtain the structured query language script file and parse it to obtain the second abstract syntax tree of the structured query language script file; The data definition language information of the structured query language script file is obtained based on the second abstract syntax tree.

8. A data processing apparatus, characterized in that, Also includes: The decompression unit is used to read and decompress the preset framework template file, generating a directory structure hierarchy; The parsing unit is used to obtain a file list of multiple interface definition files, and to perform loop parsing of the interface definition files according to the file list to obtain a first abstract syntax tree of multiple interface definition files; The first acquisition unit is used to acquire service information and interface attribute information from the interface definition file according to the first abstract syntax tree; The first generation unit is used to generate a framework code file based on the service information, the interface attribute information and the preset code template file, and move the framework code file to the corresponding target directory in the directory structure hierarchy; The first generation unit includes: The first acquisition subunit is used to acquire a preset template code file; A sub-unit is generated to replace the corresponding variable information in the preset template code file according to the service information and the interface attribute information, and to generate a framework code file.

9. The data processing apparatus as described in claim 8, characterized in that, The parsing unit includes: The reading subunit is used to cyclically read character data from multiple interface definition files in the file list, perform part-of-speech analysis on the character data, and generate tag data corresponding to the character data. A sub-unit is constructed to perform syntax analysis on the marked data and to construct a first abstract syntax tree for multiple interface definition files based on the marked data.

10. The data processing apparatus as claimed in claim 8, characterized in that, The first generation unit includes: A sub-unit is configured to set the priority of the framework code file; The first moving subunit is used to move the framework code file to the target directory corresponding to the priority level of the framework code file.

11. The data processing apparatus as claimed in claim 8, characterized in that, The first generation unit includes: A tagging subunit is used to tag the framework code file with tag information; The second moving subunit is used to move the framework code file to the target directory corresponding to the tag information according to the tag information of the framework code file.

12. The data processing apparatus as described in claim 8, characterized in that, The data processing device further includes: Specify unit, used to specify the file paths of preset framework template files, interface definition files, preset code template files, and structured query language script files via command-line tools.

13. The data processing apparatus as claimed in claim 12, characterized in that, The data processing device further includes: The second acquisition unit is used to acquire and parse the structured query language script file according to the file path of the structured query language script file to obtain data definition language information, wherein the data definition language information includes table information, field information and type information; The third acquisition unit is used to acquire the database access object layer code template file in the preset code template file; The second generation unit is used to generate a database access object layer code file based on the data definition language information and the database access object layer code template file. The moving unit is used to move the database access object layer code file to the database directory in the directory structure hierarchy.

14. The data processing apparatus as claimed in claim 13, characterized in that, The second acquisition unit includes: The second acquisition subunit is used to acquire and parse the structured query language script file to obtain the second abstract syntax tree of the structured query language script file; The third acquisition subunit is used to acquire the data definition language information of the structured query language script file based on the second abstract syntax tree.

15. A storage medium, characterized in that, The storage medium stores a plurality of instructions adapted for loading by a processor to execute the steps of the data processing method according to any one of claims 1 to 7.

16. A computer device, characterized in that, It includes a processor and a memory, the memory storing an application program, and the processor running the application program in the memory to implement the steps of the data processing method as described in any one of claims 1 to 7.

17. A computer program product, characterized in that, The computer program product includes computer instructions stored in a storage medium; the processor of the computer device reads the computer instructions from the storage medium and executes the computer instructions, causing the computer device to perform the steps of the data processing method as described in any one of claims 1 to 7.