Code generation method and device based on interface contract, equipment and storage medium

Through the code generation method based on interface contract, the problem of inefficient traditional manual code writing is solved, the automatic generation and unified specification of code are realized, and the development efficiency and code quality are improved.

CN119645409APending Publication Date: 2025-03-18PING AN BANK CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411555867.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

Traditional manual code writing is inefficient, resulting in extended development cycles, increased costs and code quality limited by the professional level of developers.

Method used

Using a code generation method based on interface contracts, low-code platform plug-ins are generated by configuring the interface contract management environment, code scaffolding projects are generated based on target ID, and target code is generated through low-code platform plug-ins and code scaffolding projects.

Benefits of technology

Ensure that the code follows unified specifications and standards, reduce code errors caused by differences in developer technical level and subjective factors, and improve the efficiency of writing code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645409A_ABST
    Figure CN119645409A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of research and development management, is applied to the field of financial science and technology businesses, and discloses a code generation method, device and equipment based on an interface contract and a storage medium. The code generation method based on the interface contract comprises the steps that in response to a plug-in starting instruction, a low-code platform plug-in is generated by configuring an interface contract management environment; determining a target ID based on the target plug-in starting instruction, and generating a code scaffold project based on the low-code platform plug-in and the target ID; and generating a target code through the low-code platform plug-in and the code scaffold project. Through the mode, the code is generated based on the predefined interface contract and the template, it is ensured that the code follows the unified specification and standard, code errors caused by technical level differences of developers and subjective factors are reduced through automatic code generation, and then the code writing efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of R&D management technology, and is applied to the field of financial technology business, and in particular to a code generation method, device, equipment and storage medium based on an interface contract. Background Art

[0002] In the field of software development, the traditional development process usually involves manual code writing, which has several shortcomings. Manual code writing is a time-consuming process, especially for complex large-scale projects, which requires a lot of time and human resources. Developers must write code line by line, which not only prolongs the development cycle, but also increases project costs. Since code writing depends on the personal skills and experience of developers, the quality of code is easily affected by subjective factors. Differences in coding styles and technical levels among different developers may lead to reduced consistency and maintainability of code. The quality of manually written code is often limited by the professional level of developers. If developers lack sufficient experience and skills, the written code may have defects and errors, which will increase the workload of later testing and maintenance, thereby affecting the progress and quality of the project. In summary, the problem of manually writing code is reflected in the extremely low efficiency of correctly writing code. Therefore, how to improve the efficiency of writing code has become a technical problem that needs to be solved urgently. Summary of the invention

[0003] The present application provides a code generation method, apparatus, device and storage medium based on an interface contract to improve the efficiency of writing code.

[0004] In a first aspect, the present application provides a code generation method based on an interface contract, the method comprising:

[0005] In response to the plug-in startup instruction, a low-code platform plug-in is generated by configuring the interface contract management environment;

[0006] Determine a target ID based on the target plug-in startup instruction, and generate a code scaffolding project based on the low-code platform plug-in and the target ID;

[0007] The target code is generated through the low-code platform plug-in and the code scaffolding project.

[0008] In a second aspect, the present application further provides a code generation device based on an interface contract, the device comprising:

[0009] A low-code platform plug-in generation module, used to generate a low-code platform plug-in in response to a plug-in startup instruction by configuring an interface contract management environment;

[0010] A code scaffolding project generation module, used to determine a target ID based on the target plug-in startup instruction, and generate a code scaffolding project based on the low-code platform plug-in and the target ID;

[0011] The target code generation module is used to generate the target code through the low-code platform plug-in and the code scaffolding project.

[0012] In a third aspect, the present application also provides a computer device, comprising a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program and implement the above-mentioned interface contract-based code generation method when executing the computer program.

[0013] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the above-mentioned code generation method based on the interface contract.

[0014] The present application discloses a code generation method, apparatus, device and storage medium based on an interface contract, wherein the code generation method based on an interface contract includes generating a low-code platform plug-in by configuring an interface contract management environment in response to a plug-in startup instruction; determining a target ID based on the target plug-in startup instruction, and generating a code scaffolding project based on the low-code platform plug-in and the target ID; and generating a target code through the low-code platform plug-in and the code scaffolding project. In the above manner, the present application ensures that the code follows unified specifications and standards by generating code based on predefined interface contracts and templates, and automated code generation reduces code errors caused by differences in developer technical levels and subjective factors, thereby improving the efficiency of writing code. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0016] Figure 1 is a schematic flow chart of a code generation method based on an interface contract provided in the first embodiment of the present application;

[0017] Figure 2 is a schematic flow chart of a code generation method based on an interface contract provided in the second embodiment of the present application;

[0018] Figure 3is a schematic flow chart of a code generation method based on an interface contract provided in the third embodiment of the present application;

[0019] Figure 4 A schematic block diagram of a code generation device based on an interface contract provided in an embodiment of the present application;

[0020] Figure 5 A schematic block diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0021] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0022] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.

[0023] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0024] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0025] The embodiments of the present application provide a method, device, equipment and storage medium for generating code based on an interface contract. The method for generating code based on an interface contract can be applied to a server. By generating code based on a predefined interface contract and a template, it is ensured that the code follows a unified specification and standard. Automatic code generation reduces code errors caused by differences in developer skills and subjective factors, thereby improving the efficiency of writing code. The server can be an independent server or a server cluster.

[0026] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.

[0027] See also Figure 1 , Figure 1 This is a schematic flow chart of a code generation method based on an interface contract provided by the first embodiment of the present application. The code generation method based on an interface contract can be applied to a server, and is used to generate codes based on predefined interface contracts and templates, thereby ensuring that the codes follow unified specifications and standards. Automated code generation reduces code errors caused by differences in developer technical levels and subjective factors, thereby improving the efficiency of writing code.

[0028] like Figure 1 As shown, the code generation method based on the interface contract specifically includes steps S10 to S30.

[0029] Step S10: In response to the plug-in startup instruction, generate a low-code platform plug-in by configuring the interface contract management environment;

[0030] Step S20: determining a target ID based on the target plug-in startup instruction, and generating a code scaffolding project based on the low-code platform plug-in and the target ID;

[0031] Specifically, after filling in the project information, such as App I d (application ID), clicking query will automatically display the Group Id (group ID) and Artifact I d (element ID).

[0032] Step S30: Generate target code through the low-code platform plug-in and the code scaffolding project.

[0033] In one embodiment, in a development environment, triggering the startup instruction of the low-code platform plug-in can be completed by clicking an interface button, executing a command line instruction, or through the plug-in management interface of the IDE. Set up an interface contract management environment in the low-code platform, including configuring the contract storage location, access rights, contract version control, etc. Generate or update the low-code platform plug-in according to the configured interface contract management environment to ensure that the plug-in can interact correctly with the interface contract management environment.

[0034] The target plugin launch command determines the specific target ID for which code needs to be generated. The target ID can be a project identifier, a module identifier, or an identifier for a specific function.

[0035] Use the low-code platform plug-in and the determined target ID to generate a code scaffolding project, including creating a project structure, initializing necessary files and directories, configuring project dependencies, etc. Use the code scaffolding project to automatically generate target code through the plug-in, involving steps such as parsing interface contracts, applying code generation rules, and filling in templates. Store the generated target code in the specified location of the local development environment.

[0036] This embodiment discloses a code generation method, apparatus, device and storage medium based on an interface contract, wherein the code generation method based on an interface contract includes generating a low-code platform plug-in by configuring an interface contract management environment in response to a plug-in startup instruction; determining a target ID based on the target plug-in startup instruction, and generating a code scaffolding project based on the low-code platform plug-in and the target ID; and generating a target code through the low-code platform plug-in and the code scaffolding project. In the above manner, the present application ensures that the code follows unified specifications and standards by generating code based on predefined interface contracts and templates, and automated code generation reduces code errors caused by differences in developer technical levels and subjective factors, thereby improving the efficiency of writing code.

[0037] See also Figure 2 , Figure 2 This is a schematic flow chart of a code generation method based on an interface contract provided in the second embodiment of the present application. The code generation method based on an interface contract can be applied to a server, and is used to generate code based on a predefined interface contract and template, thereby ensuring that the code follows a unified specification and standard. Automated code generation reduces code errors caused by differences in developer technical levels and subjective factors, thereby improving the efficiency of writing code.

[0038] based on Figure 1 The embodiment shown, this embodiment Figure 2 As shown, step S20 includes steps S201 to S203.

[0039] Step S201: Based on the type of the target plug-in startup instruction, obtain a target contract corresponding to the interface contract management environment from the low-code plug-in platform;

[0040] Step S202: Obtain the ID of the target contract as the target ID;

[0041] Step S203: Based on the low-code platform plug-in and the target ID, configure local project information and generate the code scaffolding project.

[0042] In one embodiment, in a development environment, triggering the startup instruction of the low-code platform plug-in can be completed by clicking an interface button, executing a command line instruction, or through the plug-in management interface of the IDE, and determining its type according to the received startup instruction. According to the type of the startup instruction, the target contract corresponding to the interface contract management environment is retrieved from the low-code plug-in platform, including querying the contract database, accessing the contract warehouse, or calling the contract management API (Application Programming Interface).

[0043] Extract the unique identifier (ID) from the retrieved target contract and use it as the target ID for subsequent operations. Use the low-code platform plug-in and the obtained target ID to configure local project information, including:

[0044] Create a new local project directory structure.

[0045] Initialize the files and directories required for the project.

[0046] Configure project dependencies and build scripts.

[0047] Set project properties and environment variables.

[0048] Generate code scaffolding project:

[0049] Using the configured local project information, the steps to generate a code scaffolding project include:

[0050] Apply code generation templates and rules;

[0051] Fill in placeholders and variables in templates;

[0052] Generate the initial code and resource files required for the project;

[0053] Local storage code scaffolding project:

[0054] Store the generated code scaffolding project to the specified location of the local development environment.

[0055] The present embodiment discloses a code generation method, apparatus, device and storage medium based on an interface contract, wherein the code generation method based on an interface contract includes generating a low-code platform plug-in by configuring an interface contract management environment in response to a plug-in startup instruction; obtaining a target contract corresponding to the interface contract management environment from the low-code plug-in platform based on the type of the target plug-in startup instruction; obtaining the ID of the target contract as the target ID; configuring local project information based on the low-code platform plug-in and the target ID to generate the code scaffolding project; and generating the target code through the low-code platform plug-in and the code scaffolding project. In the above manner, the present application ensures that the code follows unified specifications and standards by generating code based on predefined interface contracts and templates, and the automated code generation reduces code errors caused by differences in developer technical levels and subjective factors, thereby improving the efficiency of writing code.

[0056] In a more preferred embodiment, step S203 includes:

[0057] Create a new initial project in the low-code platform plug-in and name the initial project with the target ID;

[0058] Obtaining preset project information corresponding to the target ID, and configuring the local project information according to the preset project information;

[0059] When the local project information is detected to be in a correct state, the code scaffolding project is generated.

[0060] In one embodiment, the low-code platform plug-in is started in an integrated development environment (IDE), the option to create a new project is selected, a target ID is entered or selected, and the ID is used as the name of the new project. According to the target ID, the corresponding preset project information is retrieved from the interface contract management environment of the low-code platform, including project structure, dependencies, configuration parameters, etc.

[0061] Use the obtained preset project information to configure the local project environment, including:

[0062] Set the basic properties of the project, such as Group Id, Artifact Id, version information, etc.

[0063] Configure the project's build script, such as pom.xml (for Maven projects), define the dependency libraries and plugins required by the project and set project-specific build and deployment parameters.

[0064] Verify the local project configuration:

[0065] Check the project configuration in the IDE to make sure all necessary files and directories have been created correctly. Run the build command to verify that the project is configured correctly.

[0066] After confirming that the local project information is correct, use the low-code platform plug-in to generate a code scaffolding project, and apply the code generation template to create the basic code structure of the project.

[0067] The present embodiment discloses a code generation method, apparatus, device and storage medium based on an interface contract, wherein the code generation method based on an interface contract includes generating a low-code platform plug-in in response to a plug-in startup instruction by configuring an interface contract management environment; obtaining a target contract corresponding to the interface contract management environment from the low-code plug-in platform based on the type of the target plug-in startup instruction; obtaining the ID of the target contract as the target ID; creating a new initial project in the low-code platform plug-in and naming the initial project with the target ID; obtaining the preset project information corresponding to the target ID, and configuring the local project information through the preset project information; generating the code scaffolding project when detecting that the local project information is in a correct state; and generating the target code through the low-code platform plug-in and the code scaffolding project. In the above manner, the present application ensures that the code follows unified specifications and standards by generating code based on predefined interface contracts and templates, and the automated code generation reduces code errors caused by differences in the technical level of developers and subjective factors, thereby improving the efficiency of writing code.

[0068] In a more preferred embodiment, obtaining preset project information corresponding to the target ID, and configuring the local project information by using the preset project information includes:

[0069] Retrieving the preset project information through the target ID;

[0070] Calling the group ID, element ID and version information of the preset project information;

[0071] The group ID, the element ID and the version information are encapsulated and configured as the local project information.

[0072] Specifically, start the low-code platform plug-in in the integrated development environment (IDE), which is completed through the IDE's plug-in manager or through specific command line instructions. Use the target ID as a query parameter, call the backend service or database through the low-code platform plug-in, and retrieve the preset project information associated with the target ID. Extract key information from the retrieved preset project information, including group ID, element ID, and version information. This information usually exists in the form of fields or attributes in the data structure of the preset project information. Encapsulate the extracted group ID, element ID, and version information into a data structure, such as an object, dictionary, or key-value pair. The purpose of this step is to organize this information together for subsequent configuration and use.

[0073] Use the key information of the package to configure the local engineering environment, including the following steps:

[0074] Set the group ID of the project;

[0075] Set the element ID of the item;

[0076] Set the project version information, corresponding to the current version number of the project.

[0077] See also Figure 3 , Figure 3 This is a schematic flow chart of a code generation method based on an interface contract provided in the third embodiment of the present application. The code generation method based on an interface contract can be applied to a server, and is used to generate code based on a predefined interface contract and template, thereby ensuring that the code follows a unified specification and standard. Automated code generation reduces code errors caused by differences in developer technical levels and subjective factors, thereby improving the efficiency of writing code.

[0078] based on Figure 1 The embodiment shown, this embodiment Figure 3 As shown, step S30 includes steps S301 to S303.

[0079] Step S301: Access the code scaffolding project through the low-code platform plug-in;

[0080] Step S302: Based on the target ID, identify the target code and detect the integrity of the target code;

[0081] Step S303: When the integrity of the target code is lower than a preset threshold, the target code is adjusted through the low-code platform plug-in.

[0082] In one embodiment, the low-code platform plugin is launched in an integrated development environment, either through the IDE's plugin manager or through specific command line instructions.

[0083] Through the low-code platform plug-in, access the code scaffolding project that has been generated or is being generated, and provide or enter the target ID, which is the key identifier for identifying the target code. Use the target ID to identify specific target code in the code scaffolding project, including searching for specific files, classes, functions, or modules. Perform integrity checks on the identified target code, including:

[0084] Check the code for missing functions or modules;

[0085] Verify that the code complies with the predetermined architecture and design patterns;

[0086] Run static code analysis tools to detect potential code defects or errors.

[0087] The steps to assess completeness include:

[0088] Based on the results of the integrity test, the integrity of the target code is evaluated. A preset threshold is set to determine whether the code meets the acceptable integrity standard;

[0089] If the completeness of the target code is below the preset threshold, adjustments are made through the low-code platform plug-in. The adjustment methods include automatically generating missing code parts, providing code repair suggestions, and allowing developers to apply these repairs manually or automatically, regenerating or synchronizing the code to ensure that all required parts are included.

[0090] The present embodiment discloses a code generation method, apparatus, device and storage medium based on an interface contract, wherein the code generation method based on an interface contract includes generating a low-code platform plug-in by configuring an interface contract management environment in response to a plug-in startup instruction; determining a target ID based on the target plug-in startup instruction, and generating a code scaffolding project based on the low-code platform plug-in and the target ID; accessing the code scaffolding project through the low-code platform plug-in; identifying the target code based on the target ID, and detecting the integrity of the target code; and adjusting the target code through the low-code platform plug-in when the integrity of the target code is lower than a preset threshold. In the above manner, the present application ensures that the code follows unified specifications and standards by generating code based on predefined interface contracts and templates, and the automated code generation reduces code errors caused by differences in the technical level of developers and subjective factors, thereby improving the efficiency of writing code.

[0091] based on Figure 1 In the embodiment shown, in this embodiment, step S10 includes:

[0092] In case of receiving the plug-in startup instruction, determining the interface contract management environment according to the type of the plug-in startup instruction;

[0093] Based on the interface contract management environment, determine the environment configuration directory, plug-in name and plug-in version;

[0094] Call the preset plug-in library, and determine the low-code platform plug-in from the preset plug-in library based on the environment configuration directory, the plug-in name and the plug-in version.

[0095] Specifically, in the development environment, a plug-in startup instruction is received through user interaction, automated scripts, or the plug-in manager of the IDE, and the received plug-in startup instruction is analyzed to determine its type. According to the type of the plug-in startup instruction, the corresponding interface contract management environment is determined. The directory for storing the interface contract management environment configuration is determined. According to the configuration of the interface contract management environment, the name and version of the plug-in to be used are determined, and the preset plug-in library is called or accessed. Based on the determined environment configuration directory, plug-in name, and plug-in version, the corresponding low-code platform plug-in is retrieved from the preset plug-in library.

[0096] Based on any of the above embodiments, in this embodiment, after step S30, the following steps are further included:

[0097] Verifying user identity information in the low-code platform plug-in;

[0098] When the user identity information passes the verification, the state of the target code is changed to a download-allowed state.

[0099] Specifically, select a corresponding operation in the plug-in, such as "Login", "Authentication" or "User Information", to trigger the user identity verification process, prompting the user to enter identity information, including user name, password, access token or other authentication credentials.

[0100] The plugin sends the identity information entered by the user to the backend service or authentication server for verification, including checking whether the credentials match the stored user information, verifying the user's access rights and roles, and confirming whether the user is activated or restricted.

[0101] Receive the verification result returned by the backend service. If the verification succeeds, the plugin will receive a success response; if it fails, it will receive an error or rejection response.

[0102] If the user identity information passes the verification:

[0103] Update the user interface to show that the user is logged in or authenticated, and grant the user the appropriate access rights and capabilities.

[0104] If the user identity information fails to pass the verification:

[0105] Prompt the user if verification fails, provide the option to re-enter or reset credentials, and log events of identity verification failure for security auditing and monitoring.

[0106] See also Figure 4 , Figure 4The embodiment of the present application provides a schematic block diagram of a code generation device based on an interface contract, and the code generation device based on an interface contract is used to execute the aforementioned code generation method based on an interface contract. The code generation device based on an interface contract can be configured on a server.

[0107] like Figure 4 As shown, the code generation device 400 based on the interface contract includes:

[0108] A low-code platform plug-in generation module 410 is used to generate a low-code platform plug-in by configuring an interface contract management environment in response to a plug-in startup instruction;

[0109] A code scaffolding project generation module 420, for determining a target ID based on the target plug-in startup instruction, and generating a code scaffolding project based on the low-code platform plug-in and the target ID;

[0110] The target code generation module 430 is used to generate the target code through the low-code platform plug-in and the code scaffolding project.

[0111] Furthermore, the code scaffolding project generation module 420 includes:

[0112] A target contract acquisition submodule, used to acquire a target contract corresponding to the interface contract management environment from the low-code plug-in platform based on the type of the target plug-in startup instruction;

[0113] A target ID determination submodule, used to obtain the ID of the target contract as the target ID;

[0114] The code scaffolding project generation submodule is used to configure local project information based on the low-code platform plug-in and the target ID to generate the code scaffolding project.

[0115] Furthermore, the code scaffolding project generates a submodule, including:

[0116] An initial project creation unit, used to create a new initial project in the low-code platform plug-in and name the initial project with the target ID;

[0117] A local engineering information configuration unit, used to obtain preset engineering information corresponding to the target ID, and configure the local engineering information according to the preset engineering information;

[0118] The code scaffolding project generating unit is used to generate the code scaffolding project when detecting that the local project information is in a correct state.

[0119] Furthermore, the local engineering information configuration unit includes:

[0120] A preset project information retrieval subunit, used to retrieve the preset project information through the target ID;

[0121] An information calling subunit, used to call the group ID, element ID and version information of the preset project information;

[0122] The local project information configuration subunit is used to encapsulate the group ID, the element ID and the version information to configure them as the local project information.

[0123] Furthermore, the target code generation module 430 includes:

[0124] A code scaffolding project access submodule, used to access the code scaffolding project through the low-code platform plug-in;

[0125] A code integrity detection submodule, used to identify the target code based on the target ID and detect the integrity of the target code;

[0126] The target code adjustment submodule is used to adjust the target code through the low-code platform plug-in when the integrity of the target code is lower than a preset threshold.

[0127] Furthermore, the low-code platform plug-in generation module 410 includes:

[0128] An interface contract management environment determination submodule, configured to determine the interface contract management environment according to the type of the plug-in startup instruction when the plug-in startup instruction is received;

[0129] The interface contract management environment parsing submodule is used to determine the environment configuration directory, plug-in name and plug-in version based on the interface contract management environment;

[0130] The low-code platform plug-in determination submodule is used to call a preset plug-in library and determine the low-code platform plug-in from the preset plug-in library based on the environment configuration directory, the plug-in name and the plug-in version.

[0131] Furthermore, the interface contract-based code generation device 400 includes:

[0132] A user identity information verification module, used to verify user identity information in the low-code platform plug-in;

[0133] The state changing module is used to change the state of the target code to a download-allowed state when the user identity information passes the verification.

[0134] It should be noted that those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described device and each module can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0135] The above-mentioned device can be implemented in the form of a computer program. Figure 5 Runs on the computer device shown.

[0136] See also Figure 5 , Figure 5 1 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device may be a server.

[0137] See also Figure 5 The computer device includes a processor, a memory and a network interface connected through a system bus, wherein the memory may include a non-volatile storage medium and an internal memory.

[0138] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any code generation method based on the interface contract.

[0139] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.

[0140] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any code generation method based on the interface contract.

[0141] The network interface is used for network communication, such as sending assigned tasks, etc. Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0142] It should be understood that the processor may be a central processing unit (CPU), and the processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0143] In one embodiment, the processor is used to run a computer program stored in the memory to implement the following steps:

[0144] In response to the plug-in startup instruction, a low-code platform plug-in is generated by configuring the interface contract management environment;

[0145] Determine a target ID based on the target plug-in startup instruction, and generate a code scaffolding project based on the low-code platform plug-in and the target ID;

[0146] The target code is generated through the low-code platform plug-in and the code scaffolding project.

[0147] In one embodiment, a target ID is determined based on the target plug-in startup instruction, and a code scaffolding project is generated based on the low-code platform plug-in and the target ID to achieve:

[0148] Based on the type of the target plug-in startup instruction, obtaining a target contract corresponding to the interface contract management environment from the low-code plug-in platform;

[0149] Obtaining the ID of the target contract as the target ID;

[0150] Based on the low-code platform plug-in and the target ID, local project information is configured to generate the code scaffolding project.

[0151] In one embodiment, based on the low-code platform plug-in and the target ID, local project information is configured to generate the code scaffolding project for implementing:

[0152] Create a new initial project in the low-code platform plug-in and name the initial project with the target ID;

[0153] Obtaining preset project information corresponding to the target ID, and configuring the local project information according to the preset project information;

[0154] When the local project information is detected to be in a correct state, the code scaffolding project is generated.

[0155] In one embodiment, the preset project information corresponding to the target ID is obtained, and the local project information is configured by the preset project information to achieve:

[0156] Retrieving the preset project information through the target ID;

[0157] Calling the group ID, element ID and version information of the preset project information;

[0158] The group ID, the element ID and the version information are encapsulated and configured as the local project information.

[0159] In one embodiment, the low-code platform plug-in and the code scaffolding project are used to generate target code for implementing:

[0160] Access the code scaffolding project through the low-code platform plug-in;

[0161] Based on the target ID, identifying the target code and detecting the integrity of the target code;

[0162] When the integrity of the target code is lower than a preset threshold, the target code is adjusted through the low-code platform plug-in.

[0163] In one embodiment, in response to a plug-in startup instruction, a low-code platform plug-in is generated by configuring an interface contract management environment to implement:

[0164] In case of receiving the plug-in startup instruction, determining the interface contract management environment according to the type of the plug-in startup instruction;

[0165] Based on the interface contract management environment, determine the environment configuration directory, plug-in name and plug-in version;

[0166] Call the preset plug-in library, and determine the low-code platform plug-in from the preset plug-in library based on the environment configuration directory, the plug-in name and the plug-in version.

[0167] In one embodiment, after the target code is generated by the low-code platform plug-in and the code scaffolding project, it is used to implement:

[0168] Verifying user identity information in the low-code platform plug-in;

[0169] When the user identity information passes the verification, the state of the target code is changed to a download-allowed state.

[0170] A computer-readable storage medium is also provided in an embodiment of the present application, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and the processor executes the program instructions to implement any one of the interface contract-based code generation methods provided in the embodiments of the present application.

[0171] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Medi a Card, SMC), a secure digital (Secure Digital, SD) card, a flash memory card (Flash Card), etc., equipped on the computer device.

[0172] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A code generation method based on interface contract, characterized in that: include: In response to the plug-in startup instruction, a low-code platform plug-in is generated by configuring the interface contract management environment; Determine a target ID based on the target plug-in startup instruction, and generate a code scaffolding project based on the low-code platform plug-in and the target ID; The target code is generated through the low-code platform plug-in and the code scaffolding project.

2. The code generation method based on interface contract according to claim 1, characterized in that: The determining the target ID based on the target plug-in startup instruction, and generating a code scaffolding project based on the low-code platform plug-in and the target ID, includes: Based on the type of the target plug-in startup instruction, obtaining a target contract corresponding to the interface contract management environment from the low-code plug-in platform; Obtaining the ID of the target contract as the target ID; Based on the low-code platform plug-in and the target ID, local project information is configured to generate the code scaffolding project.

3. The code generation method based on interface contract according to claim 2 is characterized in that: The configuring local project information based on the low-code platform plug-in and the target ID and generating the code scaffolding project includes: Create a new initial project in the low-code platform plug-in and name the initial project with the target ID; Obtaining preset project information corresponding to the target ID, and configuring the local project information according to the preset project information; When the local project information is detected to be in a correct state, the code scaffolding project is generated.

4. The method for generating code based on interface contract according to claim 3, characterized in that: The obtaining the preset project information corresponding to the target ID and configuring the local project information by using the preset project information includes: Retrieving the preset project information through the target ID; Calling the group ID, element ID and version information of the preset project information; The group ID, the element ID and the version information are encapsulated and configured as the local project information.

5. The code generation method based on interface contract according to claim 1, characterized in that: The generating target code through the low-code platform plug-in and the code scaffolding project includes: Access the code scaffolding project through the low-code platform plug-in; Based on the target ID, identifying the target code and detecting the integrity of the target code; When the integrity of the target code is lower than a preset threshold, the target code is adjusted through the low-code platform plug-in.

6. The method for generating code based on interface contract according to claim 1, characterized in that: In response to the plug-in startup instruction, generating a low-code platform plug-in by configuring the interface contract management environment includes: In case of receiving the plug-in startup instruction, determining the interface contract management environment according to the type of the plug-in startup instruction; Based on the interface contract management environment, determine the environment configuration directory, plug-in name and plug-in version; Call the preset plug-in library, and determine the low-code platform plug-in from the preset plug-in library based on the environment configuration directory, the plug-in name and the plug-in version.

7. The method for generating code based on an interface contract according to any one of claims 1 to 6, characterized in that: After the target code is generated through the low-code platform plug-in and the code scaffolding project, it includes: Verifying user identity information in the low-code platform plug-in; When the user identity information passes the verification, the state of the target code is changed to a download-allowed state.

8. A code generation device based on an interface contract, characterized in that: include: A low-code platform plug-in generation module, used to generate a low-code platform plug-in in response to a plug-in startup instruction by configuring an interface contract management environment; A code scaffolding project generation module, used to determine a target ID based on the target plug-in startup instruction, and generate a code scaffolding project based on the low-code platform plug-in and the target ID; The target code generation module is used to generate the target code through the low-code platform plug-in and the code scaffolding project.

9. A computer device, characterized in that: The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is used to execute the computer program and implement the interface contract-based code generation method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, enables the processor to implement the code generation method based on an interface contract according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Project construction method and device, medium and electronic equipment

    CN114237582A

  • Service management method and device, computer equipment and storage medium

    CN116521251A

  • Cross-platform plug-in development methods, apparatuses, and electronic devices

    US20240296047A1