System and method for automatically generating codes for data service of data-in-data platform and medium
Through the automated requirements analysis and code generation system, the problem of low efficiency in traditional data service development is solved, and efficient, standardized and secure data service code generation is achieved to adapt to the complex needs of the data middle platform.
Patent Information
- Application Number
- CN202510767588.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-10
- Publication Date
- 2025-09-23
AI Technical Summary
Traditional data service development relies on manual code writing, resulting in low development efficiency, long development cycles, high error rates and inconsistent code quality, making it difficult to meet the complex needs of the data middle platform.
The requirement parsing module is used to convert natural language requirements into structured information. Combined with the data model adaptation, code template management and interface testing modules, data service code is automatically generated and optimized, including text segmentation, semantic analysis, data model matching, code filling and automated testing.
It achieves efficient automation of data service development, shortens cycles, reduces error rates, improves code standardization and reliability, adapts to business changes, and ensures security.
Smart Images

Figure CN120687087A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and specifically to a system, method and medium for automatically generating code for data services in a data middle platform. Background Art
[0002] With the rapid development of big data technology, data middle platforms are playing an increasingly important role in enterprise data management and applications. These platforms aim to integrate internal and external data resources and provide unified data services for various business systems. However, the actual construction of data middle platforms presents numerous challenges in developing data services.
[0003] Traditional data service development typically relies on manual coding, requiring developers to manually write code for data querying, processing, and interface encapsulation based on diverse business requirements and data models. This approach suffers from low development efficiency, especially when faced with a large number of data service demands. This leads to long development cycles and difficulty in quickly responding to business changes. Furthermore, manually written code is prone to errors, resulting in inconsistent code quality and high maintenance costs. Furthermore, different developers often write in different coding styles, lacking unified standards, hindering team collaboration and code management.
[0004] While some code generation tools have emerged to address these issues, existing tools often have limited functionality and fail to fully meet the complex requirements of data service development in the data center. For example, some tools can only generate basic add, delete, modify, and query code based on simple data table structures, but lack support for complex data processing logic, multi-data source integration, data security control, and other functions.
[0005] To this end, we propose a system, method and medium for automatically generating code for data services in the data middle platform to solve the above problems. Summary of the Invention
[0006] In response to the deficiencies in the prior art, the present invention provides a system, method, and medium for automatically generating code for data services in a data middle platform, which solves the problems raised in the background technology.
[0007] To achieve the above objectives, the present invention is implemented through the following technical solutions: A system for automatically generating code for data services in a data center, comprising:
[0008] The demand analysis module is used to analyze the data service requirements input by users and convert the requirements described in natural language into structured information that can be processed by computers;
[0009] The data model adaptation module is used to adapt the corresponding data model according to the analyzed requirements and determine the data source and data processing logic;
[0010] The code template management module is used to store and manage various data service code templates, and select appropriate templates to generate code frameworks based on requirements and data models;
[0011] The code generation and optimization module is used to generate specific data service code based on the selected template and processing logic, and optimize the code;
[0012] The interface testing module is used to perform automated testing on the generated data service interface to verify the functional correctness and stability of the interface.
[0013] Preferably, the demand parsing module includes a text segmentation unit, a semantic analysis unit and a demand structuring unit; the text segmentation unit performs word segmentation processing on the demand text input by the user based on a bidirectional maximum matching algorithm, the semantic analysis unit uses a BERT model based on deep learning to analyze the semantic relationship between the words after word segmentation, and the demand structuring unit converts the result of the semantic analysis into a JSON format structured demand model containing the demand type, operation object and operation requirements.
[0014] Preferably, the data model adaptation module includes a data model retrieval unit, a data association analysis unit and a data processing logic generation unit; the data model retrieval unit calculates the similarity between the demand keywords and the data models in the data model library through the cosine similarity algorithm, and retrieves the data model that matches the demand, the data association analysis unit uses graph database technology to analyze the association relationship between multiple data models, and the data processing logic generation unit generates corresponding data processing logic based on the rule engine.
[0015] Preferably, the code template management module includes a template storage unit, a template classification unit and a template matching unit; the template storage unit stores different types of data service code templates in a Git version control system, the template classification unit classifies code templates according to three dimensions of data service function, technical architecture and programming language, and the template matching unit uses a multi-attribute decision algorithm to match the most suitable data service code template from the template library according to the demand analysis results and data model adaptation results.
[0016] Preferably, the code generation and optimization module includes a code filling unit, a code verification unit and a code optimization unit; the code filling unit uses template engine technology to fill specific parameters, data model information, etc. in the requirements into the selected code template, the code verification unit uses a static code analysis tool to perform syntax and logic verification on the generated code, and the code optimization unit optimizes the performance of the generated code based on a performance analysis tool by optimizing the database connection pool configuration, reconstructing the algorithm logic, etc.
[0017] Preferably, the interface testing module includes a test case generation unit, a test execution unit and a result analysis unit; the test case generation unit automatically generates interface test cases according to requirements and data models based on boundary value analysis and equivalence class partitioning method, the test execution unit executes test cases through an automated testing framework, calls the data service interface and obtains the interface return result, and the result analysis unit uses the assertion mechanism and exception capture technology to analyze the test execution results and determine whether the interface meets the requirements.
[0018] The present invention also discloses a method for automatically generating codes for data services of a data middle platform, which specifically includes the following steps:
[0019] Requirement parsing step: Receive data service requirements input by the user, segment the requirement text using a bidirectional maximum matching algorithm, analyze the semantic relationship of the segmented words using the deep learning-based BERT model, and convert the analysis results into a JSON-formatted structured requirement model that includes the requirement type, operation object, and operation requirements. The structured requirement model is then checked for integrity and rationality. If a requirement is detected to be missing key information or contains logical contradictions, the user is prompted to correct the requirement.
[0020] Data model adaptation steps: Based on the structured demand model, the cosine similarity algorithm is used to calculate the similarity between the demand keywords and the data models in the data model library. Matching data models are then searched for in the data model library. If multiple data models are involved, graph database technology is used to analyze the relationships between the models. The corresponding data processing logic is generated based on the rule engine. Based on historical data service calls and performance analysis results, the adapted data model is optimized by performing index optimization, field redundancy processing, and other optimization operations.
[0021] Code template selection steps: Based on the results of demand analysis and data model adaptation, a code template library is classified according to the three dimensions of data service function, technical architecture, and programming language. The appropriate code template is selected from the template library using a multi-attribute decision-making algorithm. The code template is regularly updated and maintained according to the evolution of software development technology and changes in enterprise code standards.
[0022] Code generation and optimization steps: Use template engine technology to fill the required parameters and data model information into the selected code template to generate preliminary code. Use static code analysis tools to verify the syntax and logic of the preliminary code. Use performance analysis tools to optimize the code performance by optimizing database connection pool configuration, refactoring algorithm logic, etc., and automatically generate corresponding code comments based on the generated code logic to improve code readability.
[0023] Interface testing steps: Generate interface test cases based on requirements and data models based on boundary value analysis and equivalence class partitioning methods, automatically build and configure the test environment, execute test cases through the automated testing framework, call the data service interface and obtain the interface return results, use the assertion mechanism and exception capture technology to analyze the test results, and judge the correctness and stability of the interface function.
[0024] Preferably, in the requirement parsing step, when the requirement text input by the user is ambiguous, the accurate requirement semantics are determined by presenting multiple possible semantic understanding options to the user and receiving the user's selection result.
[0025] Preferably, in the code generation and optimization step, the generated code is subjected to a security check, including detection and repair of security vulnerabilities such as SQL injection prevention and cross-site scripting attack prevention.
[0026] The present invention also discloses a medium for automatically generating code for data services of a data middle platform, wherein the medium stores a computer program. When the processor executes the requirement parsing step, the computer program specifically performs two-way maximum matching word segmentation on the requirement text, semantic analysis using the BERT model, structured requirement model verification and ambiguity processing operations; when executing the data model adaptation step, the computer program specifically performs data model similarity calculation, association relationship analysis, processing logic generation and model optimization operations; when executing the code template selection step, the computer program specifically performs template classification retrieval, matching and update operations; when executing the code generation and optimization step, the computer program specifically performs code filling, verification, optimization and annotation generation and security check operations; when executing the interface testing step, the computer program specifically performs test case generation, test environment construction, test execution and result analysis operations.
[0027] Beneficial effects
[0028] The present invention provides a system, method, and medium for automatically generating code for data services in a data middleware. Compared with the prior art, it has the following advantages:
[0029] (1) The system of the present invention uses the demand analysis module to quickly understand user needs, the data model adaptation module to accurately match data models, the code template management module to efficiently select templates, and the code generation and optimization module to automatically generate and optimize code, greatly reducing the time spent on manual code writing; the interface testing module automates the testing process, avoiding a large amount of manual testing work, and overall realizing efficient automation of the entire process of data service development, significantly shortening the development cycle.
[0030] (2) The present invention adopts a bidirectional maximum matching algorithm for word segmentation and a BERT model for semantic analysis to ensure accurate requirement analysis; a static code analysis tool verifies code syntax logic, a performance analysis tool optimizes code performance, and a code comment generation unit improves code readability; at the same time, a strict test case generation and execution mechanism ensures the standardization, stability, and reliability of the generated code from multiple aspects, reduces the error rate, and facilitates later maintenance.
[0031] (3) During the code generation and optimization steps, the code is subject to security checks such as SQL injection prevention and cross-site scripting attack prevention to effectively ensure the security of data services; the data model adaptation module optimizes the data model based on historical calls and performance, and the code template management module updates the template based on technological evolution and enterprise specifications, so that the system can flexibly adapt to business changes and technological development and meet the diverse needs of the data middle platform. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 is a system block diagram of the present invention;
[0033] Figure 2 This is a schematic diagram of the demand analysis module of the present invention;
[0034] Figure 3 This is a schematic diagram of the data model adaptation module of the present invention;
[0035] Figure 4 This is a schematic diagram of the code template management module of the present invention;
[0036] Figure 5 This is a schematic diagram of the code generation and optimization module of the present invention;
[0037] Figure 6 This is a schematic diagram of the interface test module of the present invention.
[0038] In the figure: 01, requirement analysis module; 02, data model adaptation module; 03, code template management module; 04, code generation and optimization module; 05, interface testing module; 011, text segmentation unit; 012, semantic analysis unit; 013, requirement structuring unit; 021, data model retrieval unit; 022, data association analysis unit; 023, data processing logic generation unit; 031, template storage unit; 032, template classification unit; 033, template matching unit; 041, code filling unit; 042, code verification unit; 043, code optimization unit; 051, test case generation unit; 052, test execution unit; 053, result analysis unit. DETAILED DESCRIPTION
[0039] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0040] The present invention provides three technical solutions, including the following embodiments:
[0041] Example 1
[0042] See also Figures 1-6 , a system, method, and medium for automatically generating code for data services in a data middle platform, including:
[0043] Demand parsing module 01 is used to parse the data service requirements input by users and convert the requirements described in natural language into structured information that can be processed by computers;
[0044] Data model adaptation module 02 is used to adapt the corresponding data model according to the analyzed requirements and determine the data source and data processing logic;
[0045] Code template management module 03 is used to store and manage various data service code templates, and select appropriate templates to generate code frameworks based on requirements and data models;
[0046] The code generation and optimization module 04 is used to generate specific data service codes based on the selected template and processing logic, and optimize the codes;
[0047] The interface testing module 05 is used to perform automated testing on the generated data service interface to verify the functional correctness and stability of the interface.
[0048] The requirement parsing module 01 includes a text segmentation unit 011, a semantic analysis unit 012 and a requirement structuring unit 013; the text segmentation unit 011 performs segmentation processing on the requirement text input by the user based on the bidirectional maximum matching algorithm, the semantic analysis unit 012 uses the BERT model based on deep learning to analyze the semantic relationship between the segmented words, and the requirement structuring unit 013 converts the results of the semantic analysis into a JSON format structured requirement model containing the requirement type, operation object and operation requirements.
[0049] At the hardware level, the demand analysis module 01 is deployed on a high-performance server in the enterprise data center. The server is equipped with a multi-core processor and large-capacity memory to ensure the efficient operation of natural language processing related algorithms.
[0050] Text segmentation unit 011 uses a bidirectional maximum matching algorithm to process the demand text. Taking Python as an example, the Jieba word segmentation library is used to implement the bidirectional maximum matching word segmentation function. In terms of code implementation, the user's input demand text is first read, such as "Generate an API interface for querying electronic product sales orders in South China in the past three months." Then, using the Jieba library's bidirectional word segmentation mode, the text is split into multiple words or phrases, such as "generate," "one," "for," "query," "South China," "past three months," "electronic products," "sales orders," and "API interface."
[0051] Semantic Analysis Unit 012 performs semantic understanding based on the BERT model. In practice, the pre-trained BERT model provided by HuggingFace is used to input the segmented word sequence into the model. The model learns and analyzes the semantic relationships between words to understand the core intent of the user's needs. For example, a user need might be to generate an API interface with query functionality for electronic product sales orders in South China over the past three months.
[0052] The Demand Structuring Unit 013 converts the semantic analysis results into a structured demand model in JSON format. Following established structural specifications, the demand information is organized into the following format: {"action":"Generate","type":"API Interface","function":"Query","regions":["South China"],"time":"Last Three Months","product":"Electronic Products","data":"Sales Order"}. The Demand Verification Unit verifies the generated structured demand model using pre-set completeness and plausibility rules, such as checking for missing key fields and correct time formats. If any issues are found, the user is immediately prompted to correct them.
[0053] The data model adaptation module 02 includes a data model retrieval unit 021, a data association analysis unit 022 and a data processing logic generation unit 023; the data model retrieval unit 021 calculates the similarity between the demand keywords and the data models in the data model library through the cosine similarity algorithm, and retrieves the data model that matches the demand. The data association analysis unit 022 uses graph database technology to analyze the association relationship between multiple data models. The data processing logic generation unit 023 generates corresponding data processing logic based on the rule engine.
[0054] The data model adaptation module 02 runs in the database server cluster environment of the enterprise data center to achieve efficient management and adaptation of massive data models.
[0055] The data model retrieval unit 021 searches the data model library. The data model library uses a relational database (such as MySQL) for storage. Each data model is represented as a table structure and records relevant metadata. During the search, the demand keywords are extracted and the Python Scikit-learn library is used to calculate the cosine similarity between the demand keywords and each data model in the data model library. For example, for the above demand, keywords such as "electronic product sales order" and "South China region" are extracted and similarity is calculated with the sales data models and regional data models in the data model library to select the data models with the highest similarity.
[0056] Data association analysis unit 022 comes into play when multiple data models are involved. Using Neo4j graph database technology, each data model is abstracted as a node in a graph, with the relationships between models as edges. Once the sales data model and the regional data model are determined to be relevant to the demand, a query statement in the graph database reveals that the two are associated via the regional ID field.
[0057] The data processing logic generation unit 023 generates data processing logic based on a rules engine (such as Drools). To meet the above requirements, the generated logic is as follows: Records with sales dates within the past three months and a region ID corresponding to South China are filtered from the sales data model, and field information related to electronic product sales orders is extracted. Simultaneously, the data model optimization unit uses SQL statements to optimize indexes in the adapted data model based on historical data service call logs and performance monitoring data. For example, a composite index is added to the sales data model's sales date and region ID fields.
[0058] The code template management module 03 includes a template storage unit 031, a template classification unit 032 and a template matching unit 033; the template storage unit 031 stores different types of data service code templates in the Git version control system, the template classification unit 032 classifies the code templates according to the three dimensions of data service function, technical architecture and programming language, and the template matching unit 033 uses a multi-attribute decision algorithm to match the most suitable data service code template from the template library according to the demand analysis results and data model adaptation results.
[0059] The code template management module 03 is deployed on a version control server (such as GitLab) to achieve efficient management and version control of code templates.
[0060] Template Storage Unit 031 uses the Git version control system to store code templates. Each template project is a Git repository containing different versions of code template files, as well as related documentation and configuration files. Template Classification Unit 032 categorizes templates based on data service functionality (e.g., query, statistics, writing), technical architecture (e.g., Spring Boot, Django), and programming language (e.g., Java, Python). These categories are stored in a folder hierarchy on GitLab.
[0061] The template matching unit 033 uses a multi-attribute decision-making algorithm (such as the TOPSIS algorithm) to select templates. During the calculation process, it comprehensively considers multiple attributes, such as the requirement type, data model characteristics, and performance requirements, to calculate a comprehensive score for each template and select the template with the highest score. For example, given the requirement for a Java API interface query, the Java Spring Boot-based RESTful API query template was selected. The template update unit regularly (e.g., weekly) reviews the template library and updates and maintains templates by comparing the latest technical specifications from the open source community with changes in internal enterprise code specifications.
[0062] The code generation and optimization module 04 includes a code filling unit 041, a code verification unit 042 and a code optimization unit 043; the code filling unit 041 uses template engine technology to fill the specific parameters, data model information, etc. in the requirements into the selected code template, the code verification unit 042 uses a static code analysis tool to perform syntax and logic verification on the generated code, and the code optimization unit 043 optimizes the performance of the generated code based on the performance analysis tool by optimizing the database connection pool configuration, reconstructing the algorithm logic, etc.
[0063] The code generation and optimization module 04 runs on the enterprise's development server and uses various development tools and frameworks to achieve code generation and optimization.
[0064] Code Filling Unit 041 utilizes Apache Velocity template engine technology. In practice, specific requirements parameters (such as region, time, and data fields) and data model information are populated into the selected code template according to the template engine's syntax rules. For example, using a Java code template, relevant information is added to the template's placeholders to generate preliminary Java code.
[0065] Code Verification Unit 042 uses the SonarQube static code analysis tool. The generated code is submitted to the SonarQube platform, which performs syntax checking, code complexity analysis, and potential logic error detection based on pre-set Java language specifications and Spring Boot framework requirements. If any issues are found, a detailed problem report is generated and fed back to the developer.
[0066] Code Optimization Unit 043 is based on the YourKit Java Profiler performance analysis tool. This tool monitors code performance and analyzes database query execution efficiency, memory usage, and other factors. Based on the analysis results, database queries are optimized, such as adjusting the SQL connection method and adding appropriate query conditions; adjusting the database connection pool configuration, setting appropriate parameters such as the maximum and minimum connection counts; and restructuring algorithm logic to reduce unnecessary loops and recursion, thereby lowering memory usage. Furthermore, the Code Comment Generation Unit uses JavaDoc to automatically generate corresponding code comments based on the code logic.
[0067] The interface test module 05 includes a test case generation unit 051, a test execution unit 052 and a result analysis unit 053; the test case generation unit 051 automatically generates interface test cases according to requirements and data models based on boundary value analysis and equivalence class partitioning methods, the test execution unit 052 executes test cases through the automated testing framework, calls the data service interface and obtains the interface return results, and the result analysis unit 053 uses the assertion mechanism and exception capture technology to analyze the test execution results and determine whether the interface meets the requirements.
[0068] The interface test module 05 is deployed on an independent test server to ensure the isolation and stability of the test environment.
[0069] Test case generation unit 051 generates test cases based on boundary value analysis and equivalence class partitioning. Using Python's pytest framework, a test case generation script is written. Based on the requirements above, it generates test cases for normal data input (e.g., entering a correct South China region ID and a time range within the past three months), boundary value data input (e.g., entering a start and end date within the past three months), and abnormal data input (e.g., entering an incorrect region ID format or a date outside the time range).
[0070] Test Environment Management Unit 052 uses Docker container technology to automatically build the test environment. A Docker Compose file is created to define the required database container (such as a MySQL container), server container (such as a Tomcat container), and network configuration. The test environment is launched with a single click by executing the Docker Compose command.
[0071] Test Execution Unit 053 uses Postman or JUnit automated testing frameworks to execute test cases. Generated test cases are imported into the test framework, calling the generated data service interface and obtaining the interface's return results. The Result Analysis Unit analyzes the test results using assertion mechanisms (such as the assert method in JUnit) and exception handling techniques (such as try-catch statements) to determine whether the interface meets requirements. If a test fails, detailed error information is recorded, including the error code returned by the interface, error message, and test case input parameters, and an error report is generated and provided to the developer.
[0072] Example 2
[0073] Based on Example 1, the present invention also discloses a method for automatically generating code for data services in a data center, which specifically includes the following steps:
[0074] Requirements parsing steps: Developers submit data service requirements through the web interface or API interface provided by the system. The system first uses Python's Jieba library to segment the requirement text based on the bidirectional maximum matching algorithm and decompose the text into a word sequence. Then, the word sequence is input into the BERT model pre-trained based on Hugging Face for semantic analysis to understand the core intent of the requirement. Then, according to the established JSON format specification, the semantic analysis results are converted into a structured requirement model. Finally, the structured requirement model is verified for integrity and rationality using the requirement verification unit based on preset verification rules. If the requirement is found to be ambiguous, the system will display multiple possible semantic understanding options to the user through the web interface, receive the user's selection results, and determine the accurate semantics of the requirement;
[0075] Data model adaptation steps: Based on the structured demand model, extract data model information from the data model library (MySQL database). Use Python's Scikit-learn library to calculate the cosine similarity between demand keywords and each data model in the data model library to screen out matching data models. When multiple data models are involved, use the Neo4j graph database to analyze the relationships between models and determine the data integration method. Use the Drools rule engine to generate the corresponding data processing logic. At the same time, based on historical data service calls and performance analysis results, use SQL statements to optimize indexes and handle field redundancy on the adapted data model to improve data processing performance.
[0076] Code template selection steps: Based on the requirements analysis and data model adaptation results, template information is obtained from the Git-based code template library. Templates are evaluated and selected using the TOPSIS multi-attribute decision-making algorithm based on a three-dimensional classification structure based on data service function, technical architecture, and programming language. Furthermore, the template library is regularly reviewed, and code templates are updated and maintained based on the evolution of software development technologies and changes in enterprise code standards to ensure their applicability and advancement.
[0077] Code generation and optimization steps: Using Apache Velocity template engine technology, fill the required parameters and data model information into the selected code template to generate preliminary code. Use the SonarQube static code analysis tool to perform syntax and logic verification on the preliminary code to check whether the code complies with programming language specifications and technical framework requirements. Based on the YourKit Java Profiler performance analysis tool, optimize the code performance, including optimizing database query statements, adjusting database connection pool configuration, and refactoring algorithm logic. Perform security checks on the generated code, using tools such as OWASP ZAP to detect and fix security vulnerabilities such as SQL injection and cross-site scripting attacks. Finally, use the JavaDoc tool to automatically generate code comments based on the code logic to improve the readability and maintainability of the code.
[0078] Interface testing steps: Use Python's pytest framework to generate interface test cases based on boundary value analysis and equivalence class partitioning. Define the database, server, and network environment required for testing using a Docker Compose file and automate the setup of the Docker container technology. Use Postman or JUnit automated testing frameworks to execute test cases, calling data service interfaces and obtaining the interface return results. Analyze test results using assertions and exception handling techniques to determine the correctness and stability of interface functionality. If any issues arise with the interface, generate detailed error reports based on the test results, including interface error information and test case input parameters, and provide feedback to developers for debugging and remediation.
[0079] In the requirement parsing step, when the requirement text entered by the user is ambiguous, the accurate requirement semantics is determined by presenting multiple possible semantic understanding options to the user and receiving the user's selection results.
[0080] During the code generation and optimization steps, the generated code is subject to security checks, including SQL injection prevention, cross-site scripting attack prevention, and other security vulnerability detection and repair.
[0081] Example 3
[0082] Based on Example 2, the present invention further discloses a medium for automatically generating code for data services in a data center. The computer-readable storage medium can be a storage device in a distributed file system (such as Ceph) in an enterprise data center or a hard disk array on a local server. The computer program stored in the storage medium is written in Java and uses Maven for project management and dependency management.
[0083] When an enterprise developer triggers the data service code generation task on the development platform, the server's processor reads the computer program from the storage medium. During execution, the program strictly follows the steps of the aforementioned data service automatic code generation method. In the requirements analysis step, relevant natural language processing libraries and algorithms are invoked to perform bidirectional maximum match word segmentation, BERT model semantic analysis, structured requirements model validation, and ambiguity resolution on the requirements text. In the data model adaptation step, database operation libraries and related algorithms are used to calculate data model similarity, analyze associations, generate processing logic, and optimize the model. In the code template selection step, version control tools and multi-attribute decision-making algorithms are used to perform template classification retrieval, matching, and updating. In the code generation and optimization step, template engines, code analysis tools, and performance optimization tools are used to perform code filling, validation, optimization, comment generation, and security checks. In the interface testing step, test frameworks and related technologies are used to generate test cases, set up the test environment, execute tests, and analyze results. Through the orderly execution of the computer program on the processor, data service code is automatically generated to meet the enterprise's data service development needs.
[0084] Meanwhile, the contents not described in detail in this specification belong to the prior art known to those skilled in the art.
[0085] The above embodiments of the invention are described in detail, but the contents are only preferred embodiments of the invention and should not be considered to limit the scope of the invention. All equivalent changes and improvements made within the scope of the invention should still fall within the scope of the invention.
Claims
1. A system for automatically generating codes for data services in a data center, characterized by: include: Demand parsing module (01), used to parse the data service requirements input by users and convert the requirements described in natural language into structured information that can be processed by computers; The data model adaptation module (02) is used to adapt the corresponding data model according to the analyzed requirements and determine the data source and data processing logic; Code template management module (03) is used to store and manage various data service code templates, and select appropriate templates to generate code frameworks based on requirements and data models; The code generation and optimization module (04) is used to generate specific data service codes based on the selected template and processing logic, and optimize the codes; The interface testing module (05) is used to automatically test the generated data service interface to verify the functional correctness and stability of the interface.
2. The system for automatically generating code for data services in a data middle platform according to claim 1, characterized in that: The demand parsing module (01) includes a text segmentation unit (011), a semantic analysis unit (012) and a demand structuring unit (013); the text segmentation unit (011) performs word segmentation processing on the demand text input by the user based on a bidirectional maximum matching algorithm, the semantic analysis unit (012) uses a BERT model based on deep learning to analyze the semantic relationship between the words after word segmentation, and the demand structuring unit (013) converts the result of the semantic analysis into a JSON format structured demand model including the demand type, operation object and operation requirements.
3. The system for automatically generating code for data services in a data middle platform according to claim 1, characterized in that: The data model adaptation module (02) includes a data model retrieval unit (021), a data association analysis unit (022) and a data processing logic generation unit (023); the data model retrieval unit (021) calculates the similarity between the demand keyword and the data model in the data model library through a cosine similarity algorithm, and retrieves the data model that matches the demand; the data association analysis unit (022) uses a graph database technology to analyze the association relationship between multiple data models; and the data processing logic generation unit (023) generates corresponding data processing logic based on a rule engine.
4. The system for automatically generating code for data services in a data middle platform according to claim 1, characterized in that: The code template management module (03) includes a template storage unit (031), a template classification unit (032) and a template matching unit (033); the template storage unit (031) stores different types of data service code templates in a Git version control system, the template classification unit (032) classifies code templates according to three dimensions: data service function, technical architecture and programming language, and the template matching unit (033) uses a multi-attribute decision algorithm to match the most suitable data service code template from a template library according to the demand analysis results and the data model adaptation results.
5. The system for automatically generating code for data services in a data middle platform according to claim 1, characterized in that: The code generation and optimization module (04) includes a code filling unit (041), a code verification unit (042) and a code optimization unit (043); the code filling unit (041) uses template engine technology to fill specific parameters, data model information, etc. in the requirements into the selected code template, the code verification unit (042) performs syntax and logic verification on the generated code through a static code analysis tool, and the code optimization unit (043) optimizes the performance of the generated code by optimizing the database connection pool configuration, reconstructing the algorithm logic, etc. based on the performance analysis tool.
6. The system for automatically generating code for data services in a data middle platform according to claim 1, characterized in that: The interface test module (05) comprises a test case generation unit (051), a test execution unit (052) and a result analysis unit (053); the test case generation unit (051) automatically generates interface test cases according to requirements and data models based on boundary value analysis and equivalence class partitioning methods; the test execution unit (052) executes the test cases through an automated testing framework, calls the data service interface and obtains the interface return result; the result analysis unit (053) uses an assertion mechanism and an exception capture technology to analyze the test execution result and determine whether the interface meets the requirements.
7. A method for automatically generating code for data services in a data center, characterized by: The specific steps include: Requirement parsing step: Receive data service requirements input by the user, segment the requirement text using a bidirectional maximum matching algorithm, analyze the semantic relationship of the segmented words using the deep learning-based BERT model, and convert the analysis results into a JSON-formatted structured requirement model that includes the requirement type, operation object, and operation requirements. The structured requirement model is then checked for integrity and rationality. If a requirement is detected to be missing key information or contains logical contradictions, the user is prompted to correct the requirement. Data model adaptation steps: Based on the structured demand model, the cosine similarity algorithm is used to calculate the similarity between the demand keywords and the data models in the data model library. Matching data models are then searched for in the data model library. If multiple data models are involved, graph database technology is used to analyze the relationships between the models. The corresponding data processing logic is generated based on the rule engine. Based on historical data service calls and performance analysis results, the adapted data model is optimized by performing index optimization, field redundancy processing, and other optimization operations. Code template selection steps: Based on the results of demand analysis and data model adaptation, a code template library is classified according to the three dimensions of data service function, technical architecture, and programming language. The appropriate code template is selected from the template library using a multi-attribute decision-making algorithm. The code template is regularly updated and maintained according to the evolution of software development technology and changes in enterprise code standards. Code generation and optimization steps: Use template engine technology to fill the required parameters and data model information into the selected code template to generate preliminary code. Use static code analysis tools to verify the syntax and logic of the preliminary code. Use performance analysis tools to optimize the code performance by optimizing database connection pool configuration, refactoring algorithm logic, etc., and automatically generate corresponding code comments based on the generated code logic to improve code readability. Interface testing steps: Generate interface test cases based on requirements and data models based on boundary value analysis and equivalence class partitioning methods, automatically build and configure the test environment, execute test cases through the automated testing framework, call the data service interface and obtain the interface return results, use the assertion mechanism and exception capture technology to analyze the test results, and judge the correctness and stability of the interface function.
8. The method for automatically generating code for data services of a data middle platform according to claim 7, characterized in that: In the requirement parsing step, when the requirement text input by the user is ambiguous, the accurate requirement semantics are determined by presenting multiple possible semantic understanding options to the user and receiving the user's selection result.
9. The method for automatically generating code for data services of a data middle platform according to claim 7, characterized in that: In the code generation and optimization step, the generated code is subjected to security checks, including detection and repair of security vulnerabilities such as SQL injection prevention and cross-site scripting attack prevention.
10. A medium for automatically generating codes for data services in a data middle platform, characterized by: The medium stores a computer program, which, when executed by a processor, implements the method for automatically generating code for data services according to any one of claims 7 to 9, wherein when executing the requirement parsing step, the method specifically performs bidirectional maximum matching word segmentation on the requirement text, semantic analysis using the BERT model, structured requirement model verification and ambiguity processing operations; when executing the data model adaptation step, the method specifically performs data model similarity calculation, association relationship analysis, processing logic generation and model optimization operations; when executing the code template selection step, the method specifically performs template classification retrieval, matching and update operations; when executing the code generation and optimization step, the method specifically performs code filling, verification, optimization and annotation generation and security check operations; when executing the interface testing step, the method specifically performs test case generation, test environment construction, test execution and result analysis operations.
Citation Information
Cited By
Automatic code generation system and method
CN121387267A
Automatic interface generation method and device, computer equipment and storage medium
CN121858087A
