CN115291886A - Code lightweight generation tool, code generation method and storage medium - Google Patents

Code lightweight generation tool, code generation method and storage medium Download PDF

Info

Publication number
CN115291886A
CN115291886A CN202210933256.2A CN202210933256A CN115291886A CN 115291886 A CN115291886 A CN 115291886A CN 202210933256 A CN202210933256 A CN 202210933256A CN 115291886 A CN115291886 A CN 115291886A
Authority
CN
China
Prior art keywords
code
data
mode
interface
module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210933256.2A
Other languages
Chinese (zh)
Inventor
林超群
李仁杰
吴俊�
张翔
王彪
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Lop Xiamen System Integration Co ltd
Ropt Shanghai Technology Co ltd
Ropt Technology Group Co ltd
Original Assignee
Lop Xiamen System Integration Co ltd
Ropt Shanghai Technology Co ltd
Ropt Technology Group Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Lop Xiamen System Integration Co ltd, Ropt Shanghai Technology Co ltd, Ropt Technology Group Co ltd filed Critical Lop Xiamen System Integration Co ltd
Priority to CN202210933256.2A priority Critical patent/CN115291886A/en
Publication of CN115291886A publication Critical patent/CN115291886A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/44Encoding
    • G06F8/443Optimisation

Abstract

The application relates to a code lightweight generation tool, which comprises a client, a server and an interface carrier, wherein the language used by the client is HTML, the language used by the server is node.js, and the interface carrier is a browser; the client comprises a mode management module, a code template editor, a data configurator and a code generator; the server side comprises a management mode module, a user management module, a sharing module and a data analysis module. The code lightweight generation tool provided by the application uses a simple code template grammar, the difference between a code template and a target code is small, and the code lightweight generation tool is easy to write; the readability of the code mode is improved by a storage framework with the code template, the data source configuration file and the data source separated; the B/S architecture is adopted, so that the application supports offline or online deployment; supporting multiple code languages; sharing of code generation mode is supported; and the file storage is adopted, and a database is not required to be installed.

Description

Code lightweight generation tool, code generation method and storage medium
Technical Field
The present application relates to the field of code generation tools, and in particular, to a code lightweight generation tool, a code generation method, and a storage medium.
Background
At present, codeSmith and the like and various development language special code generators are mainstream of general code generation tools.
The codeSmith adopts xml to write the code template grammar, and the following problems exist:
1. the grammar is complex, the difference between a code template and a target code is large, and the compiling difficulty is large;
2. the code template is not separated from the data source, so that reading is difficult;
3. the c/s architecture is adopted, so that the applications cannot be networked and deployed on line, and the code templates cannot be shared on line;
4. code templates cannot be mutually referenced;
5. data sources of the api type cannot be used.
And other various special code generators have the following problems:
1. no other language code can be generated;
2. the network cannot be connected;
3. some online code generators do not support multiple types of data sources, such as databases, remote interfaces, etc.
Disclosure of Invention
In view of the above technical problems, the present application provides a code lightweight generation tool, a code generation method, and a storage medium.
In a first aspect, the present application provides a code lightweight generation tool, which includes a client, a server, and an interface carrier, where a language used by the client is HTML, a language used by the server is node.js, and the interface carrier is a browser;
the client comprises a mode management module, a code template editor, a data configurator and a code generator, wherein the mode management module is used for creating, deleting, modifying or sharing code generation modes and displaying a list of all code generation modes, the code template editor is used for compiling codes, the data configurator is used for editing data source configuration files matched with the code templates, and the code generator is used for generating target codes;
the server side comprises a management mode module, a user management module, a sharing module and a data analysis module, wherein the management mode module is used for providing a relevant interface of mode management for the client side and storing code generation modes stored by all users, the data analysis module is used for converting data source configuration files into complete data, the user management module is used for adding, deleting, modifying or searching users of the system, and the sharing module is used for sharing the code generation modes among the users.
By adopting the technical scheme, the code lightweight generation tool provided by the application uses a simple code template grammar, has a small difference between a code template and a target code, and is easy to write; the code lightweight generation tool adopts a storage framework with a code template, a data source configuration file and a data source separated, so that the readability of a code mode is improved; the code lightweight generation tool adopts a B/S architecture, so that the application supports offline or online deployment; the code lightweight generation tool supports multiple code languages; the code lightweight generation tool supports sharing of code generation patterns; the code lightweight generation tool adopts file storage and does not need to install a database.
Preferably, the code template editor is used for writing codes of EJS language.
Preferably, the code generation mode is composed of a code template for providing a format of the code and a data source configuration file for providing variable data required in the code template.
Preferably, the data source configuration file is a file in a JSON file format.
Preferably, the data source configuration file stores a plurality of types of data sources, and the plurality of types of data sources comprise a relational database, a remote interface and directly represented data in the data source configuration file.
Preferably, the related interface includes: the interface of the new code generation mode, the interface of the saved code template, the interface of the saved data source configuration file, the interface of the deleted code generation mode and the interface of the list of all the code generation modes.
Preferably, the code lightweight generation tool reads the data source configuration file through traversal, and acquires data of each node through concurrent connection of the multiple types of data sources to integrally generate complete data, and compiles a code template into target code by using the complete data.
Preferably, the reading, by the code lightweight generation tool, the data source configuration file by traversing specifically includes:
traversing and reading the relational database: the method comprises the steps of connecting a database by utilizing a mysql tool library and connection information according to DBary, executing sql statements by utilizing DBary. Sql parameters to query data, and processing the queried data by lodash.get;
traversing the reading remote interface: and acquiring data by utilizing an http library axios and according to an apiArg request path, a request type, a request parameter and a request remote interface, and processing the acquired data by lodash.
In a second aspect, the present application further provides a code generation method, including the following steps:
s1: manufacturing a code lightweight generation tool;
the code lightweight generation tool comprises a client, a server and an interface carrier, wherein the language used by the client is HTML, the language used by the server is node.js, and the interface carrier is a browser;
the client comprises a mode management module, a code template editor, a data configurator and a code generator, wherein the mode management module is used for creating, deleting, modifying or sharing a code generation mode and displaying a list of all code generation modes, the code template editor is used for writing codes, the data configurator is used for editing data source configuration files matched with the code template, and the code generator is used for generating target codes;
the server comprises a management mode module, a user management module, a sharing module and a data analysis module, wherein the management mode module is used for providing a relevant interface of mode management for the client and storing code generation modes stored by each user, the data analysis module is used for converting a data source configuration file into complete data, the user management module is used for adding, deleting, modifying or searching users of the system, and the sharing module is used for sharing the code generation modes among the users;
s2: starting a server of the code lightweight generation tool;
s3: inputting a client website operated by the server, opening the client and logging in;
s4: acquiring a list of all code generation modes;
s5: generating a code using the code generation patterns in the list.
In a third aspect, the present application also proposes a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method according to the second aspect.
In summary, the present application at least includes the following beneficial technical effects:
1. the method has the advantages that the method is simple in code template grammar, small in difference between a code template and a target code and easy to write;
2. the readability of the code mode is improved by a storage framework with the code template, the data source configuration file and the data source separated;
3. the B/S architecture is adopted, so that the application supports offline or online deployment;
4. the data source is configured by adopting a data source configuration file, and supports various types of data sources, such as directly expressed data in a database, a remote interface and the data source configuration file;
5. supporting multiple code languages;
6. sharing of code generation patterns is supported;
7. the file storage is adopted, and a database does not need to be installed;
8. and E, taking EJS as code template grammar. The readability, expandability and simplicity of EJS grammar are inherited, and a plurality of code languages are supported;
9. the code is automatically compiled and generated based on the code generation mode, so that the workload is saved, and the development efficiency is improved.
Drawings
The accompanying drawings are included to provide a further understanding of the embodiments and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments and together with the description serve to explain the principles of the application. Other embodiments and many of the intended advantages of embodiments will be readily appreciated as they become better understood by reference to the following detailed description. The elements of the drawings are not necessarily to scale relative to each other. Like reference numerals designate corresponding similar parts.
FIG. 1 is a system configuration diagram of a code lightweight generation tool in one embodiment of the present application.
FIG. 2 is a flow chart of a method of code generation as disclosed in the present application.
FIG. 3 is a schematic diagram of one particular embodiment of a code generation method that may be applied to the present application.
FIG. 4 is a schematic block diagram of a computer system suitable for use to implement the electronic device of the embodiments of the subject application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 shows a system configuration diagram of a code lightweight generation tool according to the present application, and referring to fig. 1, the code lightweight generation tool includes a client, a server, and an interface carrier. The language used by the client is HTML, the language used by the server is node.
The client comprises a mode management module, a code template editor, a data configurator and a code generator.
The pattern management module is used for creating, deleting, modifying or sharing the code generation patterns, and is also used for displaying a list of all the code generation patterns,
in a particular embodiment, the pattern management module presents a list of all code generation patterns (M) created by currently logged-in users. At the module, operations of creating, deleting, modifying, generating object code and sharing the code generation mode (M) can be carried out.
At the module, a code generation mode (M) can be selected, performing the following operations:
1) Clicking a sharing button, inputting a shared user ID, calling a sharing interface of a server side, and realizing code generation mode (M) sharing.
2) And clicking a delete button, and calling a server-side delete interface to realize deletion operation.
3) Clicking a new button, and jumping to a new page composed of a code template editor and a data configurator for new addition.
4) And clicking an editing button, and jumping to an editing page consisting of a code template editor and a data configurator for editing.
5) Clicking a button for generating a target code, and jumping to a code generation page formed by a code generator to generate the code.
The code template editor is used to write code. Specifically, the code template editor is used for writing codes of the EJS language and is realized by adopting a codeiriror code editor.
The data configurator is used for editing a data source configuration file (SC) matched with the code template (T). And displaying the JSON structure of the data source configuration file (SC) through a tree control of the ElementUI. And realizing the display, editing, deletion and addition of data source configuration file (SC) nodes in the tree control.
The code generator is used for generating object codes. Specifically, the code generator is used for compiling and generating object code according to the code template (T) and the complete data (D).
Selecting a code generation mode (M), analyzing a data source configuration file (SC) of the code generation mode (M) through a data analysis module of a server side to obtain final complete data (D), and returning the final complete data (D) to the client side. If any error occurs in the process of analyzing the data source configuration file (SC) and acquiring the complete data (D), the error information is transmitted back to the client.
The error information includes, but is not limited to: data source configuration file (SC) format errors, request data source (S) errors, and the like.
Finally, the code template (T) and the complete data (D) of the code generation mode (M) are compiled through a render method of EJS.
The server side comprises a management mode module, a user management module, a sharing module and a data analysis module.
The management mode module is used for providing a mode management related interface for the client and storing code generation modes stored by each user. Specifically, the module provides a mode management related interface for the client, and stores code generation modes (M) stored by each user. The stack storing the code generation pattern (M) is an array, denoted (MList), and the data structure is as follows:
let MList=[M];
the data structure of M is as follows:
Figure BDA0003782350080000081
this module contains the model owner table (ModelOwnerTable). For storing the mapping between the schema and the owner. The data structure of the table is as follows:
Figure BDA0003782350080000082
in a specific embodiment, the correlation interface includes: an interface for creating a code generation pattern, an interface for saving a code template, an interface for saving a data source configuration file, an interface for deleting a code generation pattern, and an interface for searching a list of all code generation patterns
1) Interface for new code generation mode (M)
And newly establishing a code generation mode (M), and setting the name as the name of the code generation mode (M) transferred by the client calling the interface. A unique character string is generated by the UUID as the id of the code generation mode (M).
Newly creating a code template (T) file with [ id ] ejs as name, and storing the path to TPath
And a data source configuration file (SC) file named by [ id ] json is newly created, and the path is stored into the SCPath.
A mapping record is inserted into the ModelOwnerTable table.
Returning id to client
2) Interface for saving code templates (T)
The interface stores the code template (T) uploaded by the client into a file pointed by TPath of the code generation mode (M) through fs.
3) Interface for saving data source configuration files (SCs)
The interface stores a data source configuration file (SC) uploaded by a client into a file pointed by the SCPath of the code generation mode (M) through fs.
4) Interface for deleting code generation mode (M)
And deleting the item of the id in the MList according to the id provided by the client.
5) Interface for querying a schema list
And inquiring the current user Id, all ModelOwnerTable records and inquiring the MList according to the mode Id association. And finally, obtaining a mode list of the current user and returning the mode list to the client.
The data analysis module is used for converting the data source configuration file into complete data. In a specific embodiment, the data parsing module includes a data parsing interface, and the interface searches id uploaded by the client for a code generation mode (M) item of the id in MList. And reading a data source configuration file (SC) file of the SCPath of the code generation mode (M) item. According to the analysis mode, the data is requested, and the complete data (D) is generated by analysis and returned to the client.
The user management module is used for adding, deleting, modifying or searching the users of the system. Specifically, the user management module is responsible for performing conventional operations such as adding, deleting, modifying, checking and the like on the users of the system. There is a unique user ID in the user table for use in the shared module.
The sharing module is used for sharing the code generation mode among the users. Specifically, the module includes a mode sharing table (ModelSharedTable). The method is used for storing the mapping relation between the mode and the sharee. The data structure of the table is as follows:
Figure BDA0003782350080000101
the sharing module comprises the following interfaces:
1) Mode sharing interface
The interface receives two parameters: shared user ID, shared mode ID. Stored in Modlsharedtable.
2) Shared mode list query interface
And querying the current user Id, all ModelSharedTable records, and correlating and querying the MList according to the mode Id. And finally, obtaining a mode list of the current user and returning the mode list to the client.
In a particular embodiment, the system employs a B/S architecture. The user can use the system only by a browser, and code generation mode sharing among users is realized. Js is used as a server side (server side) language, HTML is used as a client side language, and a browser is used as an interface carrier. Data among users can be shared through the server. The system may also be user-initiated locally for use as an offline stand-alone application.
In a particular embodiment, the code generation mode (M) is composed of a code template (T) for providing the format of the code and a data source profile (SC) for providing the variable data required in the code template (T).
In a specific embodiment, the code template (T) in the present application takes the EJS file with suffix EJS. Naming rules: [ code template name ]. Ejs. EJS is a js-based code template language, and has the advantages of concise grammar and maximally maintained code structure.
In a specific embodiment, the data source configuration file (SC) is a JSON file format file. JSON is used as a data source configuration file, compared with XML, the JSON has the advantages of being small in code amount, clear in structure, easy to write and the like. Json is a postfix JSON file. Naming rules: code template name json.
The data structure of the data source configuration file (SC) is:
Figure BDA0003782350080000111
Figure BDA0003782350080000121
in a particular embodiment, the data source profile stores multiple types of data sources (S) including a relational database, a remote interface, and directly represented data in the data source profile.
1) Relational database
The corresponding data structure in the data source profile (SC) is DBArg. The data structure is as follows:
Figure BDA0003782350080000122
Figure BDA0003782350080000131
2) Remote interface
The corresponding data structure in the data source configuration file (SC) is apiArg. The data structure is as follows:
Figure BDA0003782350080000132
3) Directly represented data in a data source configuration file
The corresponding data structure in the data source profile (SC) is value. The data structure is as follows:
value null,// data node
In a relational database and a remote interface, a valuePath represents a value taking path of corresponding data. The representation form is:
valuePath:'firstKey.secondKey...lastKey'
after data (marked as data) is acquired from a data source, acquiring a required value (marked as value) from a value taking path by a get method of lodash, wherein the method comprises the following steps of: let value = lodash.get (data, valuePath).
In a specific embodiment, the code lightweight generation tool reads a data source configuration file (SC) through traversal, acquires data of each node by connecting a plurality of types of data sources (S) in parallel, generates complete data (D) in an integrated mode, and compiles a code template (T) into target code by using the complete data (D).
In a specific embodiment, the code lightweight generation tool reads the data source configuration file through traversal, and according to different sourcetypes, respectively performs the following processing:
1) Relational database
And connecting the database through a tool library of node.js databases such as mysql and the like according to the connection information of the DBary, executing sql statements through DBary.sql parameters, and inquiring data. Get processing is performed on the data through lodash, and final data is obtained.
2) Remote interface
And requesting a remote interface through an http library such as axios according to the apiArg request path, the request type and the request parameter to obtain data. Get processing is performed on the data through lodash, and final data is obtained.
3) Directly represented data in a data source profile
The data is used directly without processing. The data is used directly without processing.
In a specific embodiment, the data structure of the generated complete data is as follows:
Figure BDA0003782350080000141
wherein the variable name is a key value of a node in a data source configuration file (SC). Wherein the data values are the respective types of data acquired.
Reading the data source configuration file (SC) and generating the core code of the complete data (D) as follows:
Figure BDA0003782350080000151
Figure BDA0003782350080000161
in a specific embodiment, the code lightweight generation tool compiles the code template (T) into the object code through the complete data (D) specifically: compiled into object code by ejs' render method, such as: render (T, D).
This application uses node.js as the backend language for explanation, but is not limited to node.js.
In summary, the code lightweight generation tool disclosed in the present application has the following features:
1. the method has the advantages that the code template grammar is simple, the difference between the code template and the target code is small, and the compiling is simple;
2. the readability of the code mode is improved by a storage framework with the code template, the data source configuration file and the data source separated;
3. the B/S architecture is adopted, so that the application supports offline or online deployment;
4. the data source is configured by adopting a data source configuration file, and supports various types of data sources, such as directly expressed data in a database, a remote interface and the data source configuration file;
5. supporting multiple code languages;
6. sharing of code generation patterns is supported;
7. the file storage is adopted, and a database does not need to be installed;
8. pass EJS as code template grammar. The readability, the expandability and the simplicity of the EJS grammar are inherited, and a plurality of code languages are supported.
9. The codes are automatically compiled and generated based on the code generation mode, so that the workload is saved, and the development efficiency is improved.
Fig. 2 shows a flowchart of a code generation method of the present application, and fig. 3 shows a schematic diagram of a specific embodiment of a code generation method that can be applied to the present application, and with reference to fig. 2 and fig. 3, the method includes the following specific steps:
s1: manufacturing a code lightweight generation tool;
in a specific embodiment, the code lightweight generation tool comprises a client, a server and an interface carrier, wherein the language used by the client is HTML, the language used by the server is node.js, and the interface carrier is a browser;
the client comprises a mode management module, a code template editor, a data configurator and a code generator, wherein the mode management module is used for creating, deleting, modifying or sharing a code generation mode and displaying a list of all code generation modes;
the server comprises a management mode module, a user management module, a sharing module and a data analysis module, wherein the management mode module is used for providing a relevant interface of mode management for the client and storing code generation modes stored by each user;
it will be appreciated that the code lightweight generation tool may also include other portions of the above aspect disclosures.
S2: starting a server of the code lightweight generation tool;
s3: inputting a client website operated by a server, opening the client and logging in;
s4: acquiring a list of all code generation modes;
in a specific embodiment, the list of all code generation patterns includes a created pattern list, a shared pattern list, and the like.
S5: the code is generated using the code generation patterns in the list.
In a specific embodiment, before generating the code, operations such as deleting, sharing, modifying a code template, modifying a data configuration file, generating the code, and the like may be performed in the list.
Referring now to FIG. 4, shown is a block diagram of a computer system 500 suitable for use in implementing an electronic device of an embodiment of the present application. The electronic device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the use range of the embodiment of the present application.
As shown in fig. 4, the computer system 500 includes a Central Processing Unit (CPU) 501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Liquid Crystal Display (LCD) and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the method of the present application when executed by the Central Processing Unit (CPU) 501.
As another aspect, the present application also provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or may be separate and not incorporated into the electronic device. The computer readable storage medium carries one or more programs which, when executed by the electronic device, cause the electronic device to perform the method shown in fig. 1.
It should be noted that the computer readable storage medium described herein can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable storage medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable storage medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
While the present invention has been described with reference to the preferred embodiments, it will be understood by those skilled in the art that various changes and modifications may be made without departing from the spirit and scope of the invention as defined by the appended claims. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
In the description of the present application, it is to be understood that the terms "upper", "lower", "inner", "outer", and the like, indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, are only for convenience in describing the present application and simplifying the description, and do not indicate or imply that the referred devices or elements must have a specific orientation, be constructed in a specific orientation, and be operated, and thus, should not be construed as limiting the present application. The word 'comprising' does not exclude the presence of elements or steps not listed in a claim. The word 'a' or 'an' preceding an element does not exclude the presence of a plurality of such elements. The mere fact that certain measures are recited in mutually different dependent claims does not indicate that a combination of these measures cannot be used to advantage. Any reference signs in the claims shall not be construed as limiting the scope.

Claims (10)

1. A code lightweight generation tool, characterized by: the code lightweight generation tool comprises a client, a server and an interface carrier, wherein the language used by the client is HTML, the language used by the server is node.js, and the interface carrier is a browser;
the client comprises a mode management module, a code template editor, a data configurator and a code generator, wherein the mode management module is used for creating, deleting, modifying or sharing a code generation mode and displaying a list of all code generation modes, the code template editor is used for writing codes, the data configurator is used for editing data source configuration files matched with the code template, and the code generator is used for generating target codes;
the server side comprises a management mode module, a user management module, a sharing module and a data analysis module, wherein the management mode module is used for providing relevant interfaces of mode management for the client side and storing code generation modes stored by all users, the data analysis module is used for converting data source configuration files into complete data, the user management module is used for adding, deleting, modifying or searching users of the system, and the sharing module is used for sharing the code generation modes among the users.
2. A code lightweight generation tool as claimed in claim 1, wherein: the code template editor is used for writing codes of EJS language.
3. A code lightweight generation tool as claimed in claim 2, wherein: the code generation mode is composed of a code template and a data source configuration file, wherein the code template is used for providing the format of the code, and the data source configuration file is used for providing variable data required in the code template.
4. A code lightweight generation tool according to claim 3, wherein: the data source configuration file is a JSON file format file.
5. A code weight generation tool as recited in claim 4, wherein: the data source profile stores multiple types of data sources including a relational database, a remote interface, and directly represented data in the data source profile.
6. A code lightweight generation tool as claimed in claim 1, wherein: the correlation interface includes: the interface comprises an interface for creating a code generation mode, an interface for saving a code template, an interface for saving a data source configuration file, an interface for deleting the code generation mode and an interface for inquiring a list of all the code generation modes.
7. A code lightweight generation tool as claimed in claim 5, wherein: the code lightweight generation tool reads the data source configuration file in a traversing mode, acquires data of each node by connecting the data sources of the multiple types in a concurrent mode, integrates and generates complete data, and compiles a code template into a target code by utilizing the complete data.
8. A code weight generation tool as recited in claim 7, wherein: the step of reading the data source configuration file through traversal by the code lightweight generation tool specifically includes:
traversing and reading the relational database: the method comprises the steps of connecting a database by utilizing a mysql tool library and connection information according to DBary, executing sql statements by utilizing DBary. Sql parameters to query data, and processing the queried data by lodash.get;
traversing the reading remote interface: and acquiring data by utilizing an http library axios and according to an apiArg request path, a request type, a request parameter and a request remote interface, and processing the acquired data by lodash.
9. A code generation method characterized by: the method comprises the following steps:
s1: manufacturing a code lightweight generation tool;
the code lightweight generation tool comprises a client, a server and an interface carrier, wherein the language used by the client is HTML, the language used by the server is node.js, and the interface carrier is a browser;
the client comprises a mode management module, a code template editor, a data configurator and a code generator, wherein the mode management module is used for creating, deleting, modifying or sharing code generation modes and displaying a list of all code generation modes, the code template editor is used for compiling codes, the data configurator is used for editing data source configuration files matched with the code templates, and the code generator is used for generating target codes;
the server comprises a management mode module, a user management module, a sharing module and a data analysis module, wherein the management mode module is used for providing a relevant interface of mode management for the client and storing code generation modes stored by each user, the data analysis module is used for converting a data source configuration file into complete data, the user management module is used for adding, deleting, modifying or searching users of the system, and the sharing module is used for sharing the code generation modes among the users;
s2: starting a server of the code lightweight generation tool;
s3: inputting a client website operated by the server, opening the client and logging in;
s4: acquiring a list of all code generation modes;
s5: generating a code using the code generation patterns in the list.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method as claimed in claim 9.
CN202210933256.2A 2022-08-04 2022-08-04 Code lightweight generation tool, code generation method and storage medium Pending CN115291886A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210933256.2A CN115291886A (en) 2022-08-04 2022-08-04 Code lightweight generation tool, code generation method and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210933256.2A CN115291886A (en) 2022-08-04 2022-08-04 Code lightweight generation tool, code generation method and storage medium

Publications (1)

Publication Number Publication Date
CN115291886A true CN115291886A (en) 2022-11-04

Family

ID=83825293

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210933256.2A Pending CN115291886A (en) 2022-08-04 2022-08-04 Code lightweight generation tool, code generation method and storage medium

Country Status (1)

Country Link
CN (1) CN115291886A (en)

Similar Documents

Publication Publication Date Title
US10318628B2 (en) System and method for creation of templates
JP4264118B2 (en) How to configure information from different sources on the network
US8375351B2 (en) Extensible rapid application development for disparate data sources
KR101122841B1 (en) System and method for schemaless data mapping with nested tables
Frischmuth et al. Ontowiki–an authoring, publication and visualization interface for the data web
US8433687B1 (en) Off-line indexing for client-based software development tools
US20020169789A1 (en) System and method for accessing, organizing, and presenting data
US9390127B2 (en) RDF graphs made of RDF query language queries
WO2004086222A2 (en) Development of software systems
US20040205615A1 (en) Enhanced mechanism for automatically generating a transformation document
EP3553670A1 (en) Querying a data source on a network
CA2329559A1 (en) Method and apparatus for generating serialization code for representing a model in different type systems
US10289620B1 (en) Reporting and data governance management
CN115774730A (en) Staged query compilation with common data structures
CN111125064A (en) Method and device for generating database mode definition statement
Valentine et al. EarthCube Data Discovery Studio: A gateway into geoscience data discovery and exploration with Jupyter notebooks
Angele et al. Graphsparql: A graphql interface for linked data
US10318524B2 (en) Reporting and data governance management
CN115291886A (en) Code lightweight generation tool, code generation method and storage medium
US20030037031A1 (en) Mechanism for automatically generating a transformation document
US20210124799A1 (en) Generation and application of object notation deltas
Fakhre Alam et al. A comparative study of RDF and topic maps development tools and APIs
Büch Publishing Linked Data-different approaches and tools
Geißner Modeling institutional research data repositories using the DCAT3 Data Catalog Vocabulary
Cen et al. Block affordances for graphql in mit app inventor

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination