Automatic script generation method and system based on Internet
By obtaining the database connection address, database name and project name entered by the user, determining the field information of the target database and model, selecting suitable Redis cache and message queue plug-ins, generating basic functional frameworks, and generating automated scripts based on user-configured parameter information, the problem of insufficient flexibility in complex business needs is solved, and more efficient development and better system maintainability and scalability are achieved.
Patent Information
- Application Number
- CN202510002321.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-05-02
AI Technical Summary
Existing low-code platforms are not flexible enough to match traditional programming when implementing complex business needs, and have limited scalability when adding new features or adjusting existing features.
By obtaining the database connection address, database name and project name entered by the user, determining the field information of the target database and model, selecting suitable Redis cache and message queue plug-ins, generating basic functional frameworks, and generating automated scripts based on user-configured parameter information, improving development efficiency and system maintainability and scalability.
It improves development efficiency, enhances the maintainability and scalability of the project, and can more flexibly meet complex business needs.
Smart Images

Figure CN119917574A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of program editing, and in particular to an Internet-based automatic script generation method and system. Background Art
[0002] Code is a source file written by programmers in a language supported by development tools. It is a set of clear rules that represent information in discrete form using characters, symbols or signal code elements. The display end page on the computer is generated by code; for example, the low-code platform can realize the page generation of the display end by dragging and dropping configuration.
[0003] Low-code platforms usually provide predefined templates and components. For some complex business needs, low-code platforms may not provide enough flexibility to implement all functions. Even if a certain degree of custom code is allowed, it is still not comparable to the flexibility of traditional programming. When it is necessary to add new functions or adjust existing functions, the limitations of low-code platforms will become apparent.
[0004] This shows that the automated script generation method in the related technology has the technical problem of limited scalability. Summary of the invention
[0005] The present invention provides an Internet-based automated script generation method and system, which are used to solve the defect of limited scalability of the automated script generation method in the prior art, can improve development efficiency, and enhance the maintainability and scalability of the project.
[0006] The present invention provides an Internet-based automatic script generation method, comprising the following steps.
[0007] Obtain the database connection address, database name and project name input by the user; determine the target database based on the database connection address and database name; define the project name in the target database and determine the field information of the target model, wherein the field information includes at least one of the following: field name, field type, whether it is indexed, field length and whether it is a foreign key associated with other models; determine the Redis cache and message queue plug-in corresponding to the target model based on the field information of the target model; determine the model configuration of the target model based on the target task selected by the user and the field information; generate a basic function framework based on the model configuration of the target model, the Redis cache and the message queue plug-in, wherein the basic function framework includes: database table structure, routing file, view file, serialization file and interface function of the target model; generate an automation script based on the basic function framework according to the parameter information configured by the user.
[0008] According to an Internet-based automation script generation method provided by the present invention, after generating the automation script based on the parameter information configured by the user and based on the basic functional framework, the method further includes: packaging the automation script to obtain a DockerFile file; sending the automation script to a remote code repository, and sending the DockerFile file to an image repository.
[0009] According to an Internet-based automated script generation method provided by the present invention, after sending the automated script to a remote code repository and sending the DockerFile file to an image repository, the method further includes: pulling the Docker image corresponding to the DockerFile file in the image repository through the HTTPS protocol; calling a deployment target server to create a container service based on the Docker image; and calling the deployment target server to start the container service to run the container service.
[0010] According to an Internet-based automated script generation method provided by the present invention, after sending the automated script to a remote code repository and sending the DockerFile file to an image repository, the method further includes: calling a deployment target server to pull the automated script from the remote code repository in command line mode via an SSH protocol.
[0011] According to an Internet-based automated script generation method provided by the present invention, after generating the automated script based on the basic functional framework according to the parameter information configured by the user, the method further includes: generating a yml configuration file based on the automated script, wherein the yml configuration file includes: database connection information, cache connection information, log information and message queue connection information.
[0012] According to an Internet-based automated script generation method provided by the present invention, after generating a basic functional framework based on the model configuration of the target model, the Redis cache and the message queue plug-in, the method further includes: generating a JWT permission verification code based on the login configuration input by the user, wherein the JWT permission verification code is used for user login verification.
[0013] The present invention also provides an Internet-based automatic script generation system, comprising the following modules: An acquisition module is used to acquire a database connection address, a database name and a project name input by a user; a determination module is used to determine a target database based on the database connection address and the database name; a definition module is used to define in the target database based on the project name, and determine the field information of the target model, wherein the field information includes at least one of the following: field name, field type, whether it is indexed, field length and whether it is a foreign key associated with other models; a field module is used to determine the Redis cache and message queue plug-in corresponding to the target model based on the field information of the target model; a configuration module is used to determine the model configuration of the target model based on the target task selected by the user and the field information; a framework module is used to generate a basic function framework based on the model configuration of the target model, the Redis cache and the message queue plug-in, wherein the basic function framework includes: a database table structure, a routing file, a view file, a serialization file and an interface function of the target model; a generation module is used to generate an automation script based on the basic function framework according to the parameter information configured by the user.
[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for generating an automatic script based on the Internet as described in any one of the above is implemented.
[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described Internet-based automated script generation methods.
[0016] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned Internet-based automatic script generation methods.
[0017] The Internet-based automated script generation method and system provided by the present invention obtain a database connection address, a database name, and a project name input by a user; search and determine the field information of a target model in a target database according to the project name; including field name, type, index, length, and foreign key association, etc., so as to facilitate the subsequent generation of a database table structure and an interface function; determine a suitable Redis cache strategy and a message queue plug-in according to the field information of the target model, so as to improve the performance and scalability of the system and improve the development efficiency; the user can select a target task according to actual needs, and generate a model configuration that meets the target task according to the target task selected by the user according to the actual needs in combination with the field information, so as to enhance the flexibility and customizability of the model configuration; automatically generate a basic functional framework including a database table structure, a routing file, a view file, a serialization file, and an interface function according to the model configuration of the target model, the configuration of the Redis cache and the message queue plug-in; and generate an automated script according to the parameter information configured by the user based on the actual needs and the basic functional framework, so as to further improve the development efficiency and the degree of customization. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced one by one below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0019] Figure 1 It is a flow chart of the Internet-based automatic script generation method provided by the present invention.
[0020] Figure 2 It is a module schematic diagram of the Internet-based automatic script generation method provided by the present invention.
[0021] Figure 3 It is a structural diagram of the code generation system and deployment service provided by the present invention.
[0022] Figure 4 It is a structural schematic diagram of the Internet-based automatic script generation system provided by the present invention.
[0023] Figure 5 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are 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 creative work are within the scope of protection of the present invention.
[0025] Code is a source file written by programmers in a language supported by development tools. It is a set of clear rules that represent information in discrete form by characters, symbols or signal code elements. The display page on the computer is generated by code. One is the low-code platform. It realizes the page generation of the display end by dragging and dropping configuration. The second is the automated release platform CI / CD (Continuous Integration and Continuous Delivery). It refers to continuous integration, release and deployment. It is a set of processes to realize the automation of software construction, testing and deployment. At present, the low-code platform is mainly for non-developers on the business side. CICD is mainly for operation and maintenance personnel to deploy projects. Low-code platforms and CICD can improve the efficiency of system development and deployment. Let people focus more on the business side. Save development and deployment time. Shorten the cycle of project launch. It also greatly saves the time and economic costs of enterprise digital transformation.
[0026] At present, the low-code platforms in related technologies are mainly aimed at simple business scenarios, such as HTML 5 display without business data interaction. Generate form pages mainly for the purpose of collecting data. This type of technical solution has the following main defects.
[0027] It mainly displays pages and collects form data, and cannot realize complex data interaction. It is mainly SAAS (Software-as-a-Service) type, and cannot realize private deployment, or the cost of private deployment is relatively high, and it is also difficult to modify the code later. The data of this type of product is retained on a third-party platform, and cannot be connected with other proprietary systems, and data cannot be deposited; the data also has security risks. CICD tools are more oriented to the testing and release links after the system development is completed, and lack support for the development link.
[0028] Optionally, the Internet-based automated script generation method of the embodiment of the present application may be executed by a server, or by a terminal device, or jointly by a server and a terminal device, taking the example of the Internet-based automated script generation method of the embodiment being executed by a server.
[0029] Figure 1is a flow chart of the Internet-based automatic script generation method provided by the present invention, such as Figure 1 As shown, the method includes the following steps.
[0030] Step 101, obtaining the database connection address, database name and project name input by the user.
[0031] In an embodiment of the present invention, a user inputs a database connection address, such as an IP address, a port number, a user name and a password, through a visual interface in a client of a code generation system; the database name is the name of the database that the user specifies to operate; the project name is used to indicate the name of the project input by the user, and this name will be used to search for related models in the database.
[0032] In some embodiments, the user selects a database connection address from predefined options in the code generation system (perhaps through a drop-down menu, text box input, or connection profile selection). The user also selects or enters the name of the target database.
[0033] The code generation system verifies whether the database connection address, database name, and project name entered by the user are valid. If the input is invalid (such as the connection address cannot be accessed, the database does not exist, the project name cannot be matched to a table, etc.), an error message is displayed to the user and the user is requested to re-enter.
[0034] Here, the code generation system is used to automatically generate the underlying code of the application using predefined templates, visual development interfaces, and configurations made by users through graphical interfaces. Code generation systems usually integrate drag-and-drop components, model-driven development, and automation tools, allowing users to focus on business logic and functional implementation without having to delve into code details.
[0035] In some embodiments, the code generation system includes: a visual development interface, pre-built components and modules, automated code generation, and model-driven development.
[0036] Visual development interface: Low-code platforms provide an intuitive visual interface where users can build applications by dragging components and configuring properties.
[0037] Pre-built components and modules: The platform has a large number of pre-built components and modules, such as forms, data tables, workflows, etc., which users can use directly to reduce development time.
[0038] Automatic code generation: Based on the user's configuration in the visual interface, the system automatically generates the corresponding code, including the front-end interface, back-end logic, and database interaction code.
[0039] Model-driven development: Users can develop applications by defining business logic and rules rather than text-based code, which reduces the need for specialized programming skills.
[0040] Step 102: Determine the target database based on the database connection address and the database name.
[0041] In an embodiment of the present invention, the database connection address generally includes the IP address or host name of the database, and a possible port number (such as the default port of MySQL is 3306, and the default port of PostgreSQL is 5432); the database name is the name of the specific database to be connected; other connection parameters include user name, password, connection timeout setting, SSL / TLS configuration, etc.
[0042] Load the corresponding database driver according to the database type you are using (such as MySQL, PostgreSQL, SQLite, Oracle, etc.); use the API provided by the database driver to establish a database connection based on the connection address, database name, and other necessary connection parameters (for example, user name and password) to determine the target database.
[0043] In some embodiments, a connection to the target database is established using the database connection address and database name provided by the user. If the connection is successful, the next step is continued; if the connection fails, an error message is displayed to the user, and an option to retry the connection may be provided.
[0044] Step 103, based on the definition of the project name in the target database, determine the field information of the target model, wherein the field information includes at least one of the following: field name, field type, whether indexed, field length, and whether foreign keys are associated with other models.
[0045] In an embodiment of the present invention, all data items that need to be stored are collected, and a descriptive field name is determined for each data item. For example, field type: select an appropriate data type for each field based on the nature of the data item (such as numbers, text, dates, etc.). Field length: For data types that need to limit the length (such as strings), determine the maximum length of each field. Index requirements: Analyze query performance requirements and determine which fields need to create indexes to optimize query speed. Foreign key associations: Determine which fields need to establish foreign key associations with other tables or models to implement data integrity constraints and associated queries.
[0046] Based on the collected field information, write a CREATE TABLE statement to define the database table structure. In the SQL statement, specify the name, type, length (if applicable), index, and foreign key association to other tables for each field. Based on the field information, define the model class in the ORM framework. In the model class, specify the corresponding attributes (such as field type, length, index, foreign key, etc.) for each field. Use the migration tool provided by the ORM framework to generate and execute the database migration script to create the corresponding table structure in the database.
[0047] In the embodiment of the present invention, after determining the target database according to the database connection address and the database name, the code generation system searches for the corresponding target model (or target table) in the database according to the project name and a preset mapping table.
[0048] For example, according to the project name, find the corresponding target table (or target model) in the database, use the database metadata query function (such as INFORMATION_SCHEMA in SQL), and extract the field information of the target table (target model). The field information includes: field name, field type (such as integer, string, date, etc.), whether it is indexed (primary key, unique index, ordinary index, etc.), field length (for string type, etc.), and whether the foreign key is associated with other models (determined by finding foreign key constraints).
[0049] If you want to associate other models, select the corresponding model and the associated fields. If it is an enumeration type, configure the enumeration dictionary. Configure whether the field can be searched. You can select some default scenarios to generate models according to the template. Including articles, Q&A, document downloads, live broadcasts, meetings, personal centers, and points malls.
[0050] Step 104: Determine the Redis cache and message queue plug-ins corresponding to the target model based on the field information of the target model.
[0051] Based on the field information, you can formulate a Redis cache strategy, for example, select frequently accessed or computationally expensive fields for caching. Select the appropriate Redis data structure according to the field type, such as string, list, set, hash, or sorted set. Set the expiration time of the cache to avoid data staleness. Consider how to maintain consistency between the database and the cache, such as using a write-after-update or write-before-update strategy.
[0052] Select the appropriate message queue plugin based on the field information and the requirements of the target task, for example, determine whether the message is synchronous or asynchronous and whether persistence is required. Select the appropriate message queue plugin based on the throughput requirements of the system. Consider the integration of the plugin with the target model, database, and other system components.
[0053] In the embodiment of the present invention, Redis provides a variety of data structures, such as strings, hashes, lists, sets, and ordered sets. According to the field information of the target model, determine the appropriate data structure for storage; for example, if the target model contains multiple fields and these fields need to be accessed frequently, you can use the hash data structure of Redis to store the fields as key-value pairs.
[0054] The code generation system analyzes how the target model uses message queues in the business, such as whether asynchronous processing is required, whether the order of messages needs to be guaranteed, whether persistence is required, etc.
[0055] Redis provides a variety of message queue modes, such as FIFO (first-in-first-out) queue and Pub / Sub (publish / subscribe) model.
[0056] Among them, the FIFO queue is suitable for scenarios that need to process messages in sequence; the Pub / Sub model is suitable for scenarios that require asynchronous notification and broadcast messages; use the list command to create a message queue, use the rpush or lpush command to add messages, and use the brpop or blpop command to retrieve messages.
[0057] Step 105: Determine the model configuration of the target model based on the target task and field information selected by the user.
[0058] In the embodiment of the present invention, the user selects a predefined task as a target task according to the visual interface of the client.
[0059] The field information of the target model includes: field name, field type, whether it is indexed, field length, and whether it is a foreign key associated with other models; The field name indicates the unique identifier of each field. Field types include integer, floating point, string, date, Boolean, etc. Whether to index is used to mark whether the field is indexed, which can speed up the query. Field length indicates that for string type fields, its maximum length is specified. Whether to foreign key other models is used to mark whether the field has foreign key associations with other models, which helps to understand the relationship between data.
[0060] Based on the target task (such as classification, regression, clustering, etc.) and field information selected by the user, the code generation system generates the model configuration of the target model.
[0061] Step 106, based on the model configuration of the target model, Redis cache and message queue plug-in, generate a basic function framework, wherein the basic function framework includes: database table structure, routing files, view files, serialization files and interface functions of the target model.
[0062] The code generation system allows users to select appropriate Redis cache strategies and data structures based on model field information and target tasks; users can configure Redis connection information, such as Redis server address, port, etc.
[0063] The code generation system allows users to select message queue plug-ins (such as Redis-based List, Pub / Sub, or other independent message queue systems such as RabbitMQ, Kafka, etc.) based on model field information and target tasks. Users can configure relevant parameters of the message queue, such as queue name, message format, etc.
[0064] In the embodiment of the present invention, the code generation system parses the model configuration of the target model to obtain the database table structure, routing information, view information, serialization information and interface functions.
[0065] The database table structure includes: field type, field length, whether to index, index type, and foreign key constraint relationship.
[0066] The routing information includes: the URL path of the API endpoint, the HTTP method (GET, POST, PUT, DELETE, etc.), and the controller method that handles the request.
[0067] View information includes: the path of the view template, the way to render data, etc.
[0068] Serialization information includes: how to convert model data into JSON or other formats, and how to handle validation and conversion of input data.
[0069] Interface functions include: methods in the controller that handle specific business logic, such as create, read, update, and delete (CRUD) operations.
[0070] In the embodiment of the present invention, the code generation system generates corresponding SQL scripts or calls ORM tools to create database table structures based on field information (such as field name, type, index, foreign key, etc.) in the model configuration. Execute SQL scripts or run ORM commands in the database to actually create these tables.
[0071] The code generation system generates routing files based on the configured API endpoint information. These files define the URL path, HTTP method, and corresponding controller method.
[0072] For web applications that need to render HTML pages, the code generation system generates view files based on template engines (such as EJS, Handlebars, etc.).
[0073] The serialization file defines how to convert model data into JSON or other formats, and how to handle validation and conversion of input data. The code generation system creates a serializer or similar class that has methods for converting model instances into JSON objects, as well as methods for validating and creating model instances from request data.
[0074] The code generation system generates controller files and defines CRUD (create, read, update, delete) operations for the model and field search functions. These operations will call the methods of the model layer to implement specific business logic.
[0075] Step 107, generating an automation script based on the basic functional framework according to the parameter information configured by the user.
[0076] Here, automation scripts usually refer to codes written in a computer programming language to automate a series of tasks or processes.
[0077] In an embodiment of the present invention, user information about target models, database connections, routing settings, etc. is collected through configuration files, command line parameters, or interactive interfaces. The collected user configurations are parsed and processed to ensure that they meet the expected format and range. According to the parsed user configurations, the code files of the above basic functional framework are automatically generated, for example, including database migration scripts, routing definitions, view functions, serializer classes, etc. The generated automation scripts are run to actually create database table structures, configure routing, define views and serializers, etc. The generated code is verified and tested to ensure that it meets business requirements and can run correctly.
[0078] Through the above steps of the embodiment of the present invention, by obtaining the database connection address, database name and project name input by the user; searching and determining the field information of the target model in the target database according to the project name; including field name, type, index, length and foreign key association, etc., so as to facilitate the subsequent generation of database table structure and interface function; according to the field information of the target model, determining the appropriate Redis cache strategy and message queue plug-in to improve the performance and scalability of the system and improve development efficiency; the user can select the target task according to actual needs, and generate a model configuration that meets the target task according to the target task selected by the user according to actual needs in combination with the configuration of the Redis cache and message queue plug-in to enhance the flexibility and customizability of the model configuration; according to the model configuration of the target model, automatically generate a basic functional framework including database table structure, routing files, view files, serialization files and interface functions; and generate an automated script based on the parameter information configured by the user based on actual needs and the basic functional framework, further improving development efficiency and customization.
[0079] According to an Internet-based automated script generation method provided by the present invention, after generating an automated script based on the parameter information configured by the user and based on the basic functional framework, the method further includes: Package the automation script to obtain the DockerFile file; Send the automation script to the remote code repository and send the DockerFile file to the image repository.
[0080] In an embodiment of the present invention, the code generation system automatically packages the generated code (i.e., the automation script), and the packaging will generate a DockerFile file, wherein the DockerFile file is mainly used to create the dependent environment in which the program runs; or, according to the user's choice, directly use the image in the image repository.
[0081] In an embodiment of the present invention, after packaging is completed, the code generation system submits the generated code to the remote code repository to complete the code creation process. After the code is created, the R&D personnel can submit the code to git, and subsequent developers can execute the gitpul1 command to pull the code from the git repository. After pulling the code, it is necessary to create a docker-compose.yml configuration file and configure the port number and host disk mapping. After completion, the user can start the service in the local environment, and if the code needs to be adjusted, submit it to the code repository after modification.
[0082] In an embodiment of the present invention, a Dockerfile is generated according to the dependencies and runtime requirements of the application of the automation script. The Dockerfile defines the base image, dependency installation steps, file copying, port exposure, and startup commands required to create a Docker image.
[0083] Use Docker CLI or other Docker build tools to build a Docker image based on the Dockerfile file. This image contains all the dependencies and runtime environment of the application. After packaging, the code generation system submits the generated code (including Dockerfile and possible automation scripts) to a remote code repository (such as GitHub, GitLab, etc.).
[0084] Pushing the image generated by Dockerfile to the image repository makes it easy to manage and distribute the image. Other systems or developers can easily pull these images and deploy them when needed.
[0085] Through the embodiments of the present invention, standardization, repeatability and environmental consistency of the construction process are achieved through automated scripts and Dockerfile. Version control, collaboration, image management and continuous integration / continuous deployment are achieved by storing resources in remote code repositories and image repositories.
[0086] According to an Internet-based automated script generation method provided by the present invention, after sending the automated script to a remote code repository and sending the DockerFile file to an image repository, the method further includes: Pull the Docker image corresponding to the DockerFile file in the image repository through the HTTPS protocol; Call the deployment target server and create a container service based on the Docker image; Call the deployment target server to start the container service to run the container service.
[0087] In the embodiment of the present invention, the deployment target server is used to represent the server or virtual machine that will run the container service. The HTTPS protocol represents a secure network communication protocol for transmitting encrypted data between the client and the server. The image repository represents a repository for storing Docker images, such as Docker Hub, AWS ECR, Google ContainerRegistry, etc.
[0088] In an embodiment of the present invention, the server establishes a secure connection with the image repository through the HTTPS protocol. The server sends a request to the image repository, specifying the name and tag of the image to be pulled. After the image repository verifies the request, it sends the image data to the server. The server receives and stores the image data.
[0089] The server calls the deployment target server and creates a container service based on the Docker image; creating a container service means using a Docker command (such as docker run) to start a new container instance based on the pulled image.
[0090] For example, the deployment target server uses the Docker daemon (dockerd) to execute the command to create a container. The Docker daemon finds the corresponding image based on the image name and tag provided. The Docker daemon creates and starts a new container instance based on the configuration and instructions in the image. After the container instance is started, it can run the specified service or application.
[0091] refer to Figure 2 , Figure 2 It is a module diagram of the Internet-based automatic script generation method provided by the present invention, which includes user operation (client) 01, code generation system (server) 02 and code file 03.
[0092] In the embodiment of the present invention, the server includes a code warehouse module and an image warehouse module. The code warehouse module is mainly used to store code files and record code versions. The image warehouse module is used to save image files and image versions. The server can pull image files from the image warehouse module to the server locally through the HTTPS protocol and store them in a joint file system.
[0093] The deployment target server includes an initialization module and a service container module. The initialization module is used to provide an interface for users to configure generation parameters and to provide an operation entry for code generation and service deployment; the service container module is used to create a container service by pulling the image file, and start and run the application service. The deployment target server can pull code files from the code repository in command line mode through the SSH protocol.
[0094] In the initialization module, after the user completes the configuration on the operation interface, the configuration parameters are transmitted to the server code generation system via the HTTPS protocol, and the parameters are saved in the database storage medium.
[0095] refer to Figure 3 , Figure 3It is a structural diagram of the code generation system and deployment service provided by the present invention, which includes a code generation system, Docker, Git and a deployment service; the code generation system includes a user operation segment, a code generation system, a configuration file, code, a code repository, an image repository and an initialization module; the deployment service includes: a database, a cache, an application server, a static file and a proxy service.
[0096] Through the embodiment of the present invention, the Docker image is pulled from the image repository through the HTTPS protocol, ensuring the security of the data transmission process; the Docker image contains the application and all its dependencies, ensuring the consistent behavior of the application deployed in different environments; the container service is lightweight, portable and easy to expand. Through the Docker container, the same application can be easily run on different platforms without worrying about environmental differences.
[0097] According to an Internet-based automated script generation method provided by the present invention, after sending the automated script to a remote code repository and sending the DockerFile file to an image repository, the method further includes: Call the deployment target server and pull the automation script from the remote code repository in command line mode through the SSH protocol.
[0098] In the embodiment of the present invention, the SSH (Secure Shell) protocol is an encrypted network protocol used to remotely log in and manage a server securely in an insecure network.
[0099] Use the SSH protocol to call the deployment target server and interact with it through the command line interface (CLI); the command line interface allows the execution of various commands, including pulling code from remote code repositories. Remote code repositories (such as GitHub, GitLab, etc.) pre-store source code and automation scripts; use the command line tools of the version control system (such as Git) to pull these scripts from the remote repository; this usually involves using commands such as git clone and git pull to download or update the code base.
[0100] Through the embodiments of the present invention, the automation script can be safely deployed from the remote code repository to the target server, so as to prepare for subsequent automation tasks or application deployment.
[0101] According to an Internet-based automated script generation method provided by the present invention, after generating an automated script based on the parameter information configured by the user and based on the basic functional framework, the method further includes: Generate a yml configuration file based on the automated script, where the yml configuration file includes: database connection information, cache connection information, log information, and message queue connection information.
[0102] In an embodiment of the present invention, after the automated script is generated, the code generation system will create a yml configuration file, wherein the yml configuration file includes creation of database connection information, cache connection information, log information, and message queue connection information.
[0103] In the embodiment of the present invention, during the execution of the automation script, connection information of the database, cache and message queue is collected or generated. This information comes from environment variables, command line parameters, external configuration files, database query results or any other reliable data source.
[0104] The script uses a template of a yml configuration file. This template defines the structure and format of the configuration information. For example, it may contain a database part for database connections, a cache part for cache connections, and a message_queue part for message queue connections.
[0105] The script will fill the collected configuration information into the corresponding position in the yml template. This includes the host name, port number, username, password and database name of the database, the host name, port number and password of the cache, and the host name, port number, username, password and virtual host (vhost) of the message queue.
[0106] After the configuration information is filled into the template, the script will generate the final yml configuration file. The generated yml configuration file can be used by applications or services to establish database connections, cache connections, and message queue connections. These connection information are usually read when the application starts and used to initialize the corresponding connection object.
[0107] Through the embodiment of the present invention, the generated yml configuration file follows a unified format and structure, ensuring the consistency and readability of the configuration information. The automated script can generate corresponding configuration files for different environments (such as development, testing, and production), thereby ensuring the consistency of configuration between different environments.
[0108] According to an Internet-based automated script generation method provided by the present invention, after generating a basic functional framework based on the model configuration of the target model, Redis cache and message queue plug-in, the method further includes: Based on the login configuration entered by the user, a JWT permission verification code is generated, where the JWT permission verification code is used to perform user login verification.
[0109] Here, JWT, full name JSON Web Token, is an open standard (RFC 7519) that defines a compact and self-contained way to securely transmit information between parties as a JSON object. This information is digitally signed so it can be verified and trusted.
[0110] In an embodiment of the present invention, generating a JWT (JSON Web Token) permission verification code based on a login configuration input by a user generally involves the following steps: Step 1: Collect login information input by the user, for example, the login information includes a user name and a password.
[0111] Step 2, authenticate the user, for example, by comparing the username and password entered by the user with information stored in a database or other authentication system.
[0112] Step 3: Generate a JWT. For example, if the user identity authentication is successful, a JWT is generated. The token contains the user's identity information (such as user ID, user name, etc.) and the token's expiration time and other information.
[0113] Step 4, return the JWT, for example, return the generated JWT to the client, usually through the Authorization field in the HTTP response header, in the format of Bearer <token>.
[0114] Step 5, JWT verification, for example, in subsequent requests, the client needs to include JWT in the request header. The server will verify the validity of the JWT (such as whether the signature is correct, whether it has expired, whether it has been revoked, etc.).
[0115] Step 6, permission control, for example, based on the user information contained in the JWT, the server can execute permission control logic to determine whether the user has the right to access specific resources or perform specific operations.
[0116] Through the embodiment of the present invention, JWT uses JSON format to encapsulate user information and verifies it through digital signatures, ensuring the integrity and security of information during transmission; traditional session management requires storing a large amount of session information on the server side, while JWT is stateless and the server does not need to store any session information. This greatly reduces the burden on the server.
[0117] The following describes an example of the Internet-based automatic script generation method provided by the present invention in a practical application scenario.
[0118] Step 1: The user accesses the code generation system interface, selects the database connection address, database name, and enters the project name.
[0119] Step 2: The code generation system automatically matches the model's field name, field type, whether it is indexed, field length, and whether it is a foreign key associated with other models.
[0120] Step 3: The code generation system will automatically select tools such as Redis cache and message queue plug-ins for the user.
[0121] Step 4: The code generation system will help users select scheduled tasks, configure the execution time of scheduled tasks, and other tasks.
[0122] Step 5. After completing the above operations, the code generation system will automatically select Save, and you can save the configuration to the database and continue editing the next time you visit.
[0123] Step 6: After saving the required parameters, the code generation system will automatically execute the release program and generate the database table structure according to the model configuration.
[0124] Step 7, generate routing files, view files and serialization files, and create interface functions for the model, including addition, deletion, modification, and field search.
[0125] Step 8: After completing the basic functional framework, the code generation system will create a JWT permission verification code based on the user configuration, that is, user login verification.
[0126] Step 9. After completing the above operations, you can generate the automation script code.
[0127] Step 10: After the automatic script is generated, the code generation system will create a yml configuration file including database connection information, cache connection information, and message queue connection information.
[0128] Step 11. After completing the above operations, the code generation system will automatically package the generated code. The packaging will generate a DockerFile file, which is mainly used to create the dependent environment for the program to run. You can also directly use the image in the image repository according to your personal choice.
[0129] Step 12: After packaging is completed, the code generation system will submit the generated code to the remote code repository to complete the code creation process.
[0130] The following is a description of the Internet-based automated script generation system provided by the present invention. The Internet-based automated script generation system described below and the Internet-based automated script generation method described above can refer to each other.
[0131] refer to Figure 4 , Figure 4 It is a structural schematic diagram of the Internet-based automatic script generation system provided by the present invention.
[0132] The acquisition module 401 is used to acquire the database connection address, database name and project name input by the user; A determination module 402 is used to determine a target database based on a database connection address and a database name; A definition module 403 is used to define in the target database based on the project name and determine the field information of the target model, wherein the field information includes at least one of the following: field name, field type, whether it is indexed, field length, and whether a foreign key is associated with other models; Field module 404, used to determine the Redis cache and message queue plug-ins corresponding to the target model based on the field information of the target model; Configuration module 405, used to determine the model configuration of the target model based on the target task and field information selected by the user; Framework module 406, used to generate a basic function framework based on the model configuration of the target model, Redis cache and message queue plug-in, wherein the basic function framework includes: database table structure, routing files, view files, serialization files and interface functions of the target model; The generation module 407 is used to generate an automation script based on the basic function framework according to the parameter information configured by the user.
[0133] Specifically, the above-mentioned Internet-based automated script generation system provided by the present invention can implement all the method steps implemented by the above-mentioned Internet-based automated script generation method embodiment, and can achieve the same technical effects. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.
[0134] Figure 5 is a schematic diagram of the physical structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor (processor) 510, a communication interface (Communications Interface) 520, a memory (memory) 530 and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call the logic instructions in the memory 530 to execute an Internet-based automated script generation method, which includes: obtaining a database connection address, a database name, and a project name input by a user; determining a target database based on the database connection address and the database name; defining the target model in the target database based on the project name, wherein the field information includes at least one of the following: field name, field type, whether it is indexed, field length, and whether it is a foreign key associated with other models; determining a Redis cache and message queue plug-in corresponding to the target model based on the field information of the target model; determining a model configuration of the target model based on the target task and field information selected by the user; generating a basic functional framework based on the model configuration of the target model, the Redis cache, and the message queue plug-in, wherein the basic functional framework includes: a database table structure, a routing file, a view file, a serialization file, and an interface function of the target model; generating an automated script based on the basic functional framework according to the parameter information configured by the user.
[0135] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0136] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the Internet-based automated script generation method provided by the above methods, the method including: obtaining a database connection address, a database name and a project name input by a user; determining a target database based on the database connection address and the database name; defining the target model in the target database based on the project name, and determining the field information of the target model, wherein the field information includes at least one of the following: field name, field type, whether it is indexed, field length and whether foreign keys are associated with other models; determining a Redis cache and message queue plug-in corresponding to the target model based on the field information of the target model; determining a model configuration of the target model based on the target task and field information selected by the user; generating a basic functional framework based on the model configuration of the target model, the Redis cache and the message queue plug-in, wherein the basic functional framework includes: a database table structure, a routing file, a view file, a serialization file and an interface function of the target model; generating an automated script based on the basic functional framework according to the parameter information configured by the user.
[0137] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the Internet-based automated script generation method provided by the above-mentioned methods, the method comprising: obtaining a database connection address, a database name and a project name input by a user; determining a target database based on the database connection address and the database name; defining the target model in the target database based on the project name, and determining the field information of the target model, wherein the field information includes at least one of the following: field name, field type, whether it is indexed, field length and whether foreign keys are associated with other models; determining a Redis cache and message queue plug-in corresponding to the target model based on the field information of the target model; determining a model configuration of the target model based on the target task and field information selected by the user; generating a basic functional framework based on the model configuration of the target model, the Redis cache and the message queue plug-in, wherein the basic functional framework includes: a database table structure, a routing file, a view file, a serialization file and an interface function of the target model; generating an automated script based on the basic functional framework according to the parameter information configured by the user.
[0138] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0139] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0140] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.< / token>
Claims
1. An Internet-based automated script generation method, characterized in that: include: Get the database connection address, database name and project name entered by the user; Determine the target database based on the database connection address and the database name; Determine the field information of the target model based on the definition of the project name in the target database, wherein the field information includes at least one of the following: field name, field type, whether it is indexed, field length, and whether it is a foreign key associated with other models; Based on the field information of the target model, determine the Redis cache and message queue plug-ins corresponding to the target model; Determining a model configuration of a target model based on the target task selected by the user and the field information; Based on the model configuration of the target model, the Redis cache and the message queue plug-in, a basic function framework is generated, wherein the basic function framework includes: a database table structure, a routing file, a view file, a serialization file and an interface function of the target model; According to the parameter information configured by the user, an automation script is generated based on the basic functional framework.
2. The method for generating an automated script based on the Internet according to claim 1, characterized in that: After generating the automation script according to the parameter information configured by the user and based on the basic functional framework, the method further includes: Packaging the automation script to obtain a DockerFile file; The automation script is sent to a remote code repository, and the DockerFile file is sent to an image repository.
3. The method for generating an automated script based on the Internet according to claim 2, characterized in that: After sending the automation script to the remote code repository and sending the DockerFile file to the image repository, the method further includes: Pull the Docker image corresponding to the DockerFile file in the image repository through the HTTPS protocol; Call the deployment target server and create a container service based on the Docker image; The deployment target server is called to start the container service to run the container service.
4. The method for generating an automated script based on the Internet according to claim 3, characterized in that: After sending the automation script to the remote code repository and sending the DockerFile file to the image repository, the method further includes: The deployment target server is called to pull the automation script from the remote code repository in command line mode through the SSH protocol.
5. The method for generating an automated script based on the Internet according to claim 1, characterized in that: After generating the automation script according to the parameter information configured by the user and based on the basic functional framework, the method further includes: Based on the automation script, a yml configuration file is generated, wherein the yml configuration file includes: database connection information, cache connection information, log information and message queue connection information.
6. The method for generating an automated script based on the Internet according to claim 1, characterized in that: After generating a basic functional framework based on the model configuration of the target model, the Redis cache, and the message queue plug-in, the method further includes: Based on the login configuration input by the user, a JWT permission verification code is generated, wherein the JWT permission verification code is used to perform user login verification.
7. An Internet-based automated script generation system, characterized in that: include: The acquisition module is used to obtain the database connection address, database name and project name input by the user; A determination module, used to determine a target database based on the database connection address and the database name; A definition module, configured to define the target model in the target database based on the project name, and determine the field information of the target model, wherein the field information includes at least one of the following: field name, field type, whether it is indexed, field length, and whether it is a foreign key associated with other models; A field module, used to determine a Redis cache and message queue plug-in corresponding to the target model based on the field information of the target model; A configuration module, used to determine a model configuration of a target model based on a target task selected by a user and the field information; A framework module, used to generate a basic function framework based on the model configuration of the target model, the Redis cache and the message queue plug-in, wherein the basic function framework includes: a database table structure, a routing file, a view file, a serialization file and an interface function of the target model; The generation module is used to generate an automation script based on the basic function framework according to the parameter information configured by the user.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the Internet-based automated script generation method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the Internet-based automated script generation method according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the Internet-based automated script generation method according to any one of claims 1 to 6 is implemented.
Citation Information
Cited By
Automatic generation method and device for database change script and medium
CN120596458A
Message forwarding method and device, telecontrol machine and readable storage medium
CN121396972A