CN116954621A - Code generation method and code generation device - Google Patents

Code generation method and code generation device Download PDF

Info

Publication number
CN116954621A
CN116954621A CN202311080069.5A CN202311080069A CN116954621A CN 116954621 A CN116954621 A CN 116954621A CN 202311080069 A CN202311080069 A CN 202311080069A CN 116954621 A CN116954621 A CN 116954621A
Authority
CN
China
Prior art keywords
target
ejs
code
code generation
template
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
CN202311080069.5A
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.)
GRG Banking IT Co Ltd
Original Assignee
GRG Banking IT 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 GRG Banking IT Co Ltd filed Critical GRG Banking IT Co Ltd
Priority to CN202311080069.5A priority Critical patent/CN116954621A/en
Publication of CN116954621A publication Critical patent/CN116954621A/en
Pending legal-status Critical Current

Links

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/447Target code generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

The application discloses a code generation method and a code generation device, and belongs to the field of code generation. The code generation method comprises the following steps: acquiring a target table based on a target plug-in; receiving a first input of a target EJS template in at least one EJS template provided by a user on the target plugin; the target plugin is pre-generated; in response to the first input, a target code is generated based on the target plugin processing the target table and the target EJS template. According to the code generation method, complex metadata is not required to be defined in advance, only the target EJS template is required to be selected, plug-in units of front-end page codes can be easily generated without participation of a back-end developer, and the working efficiency of the front-end developer is improved.

Description

Code generation method and code generation device
Technical Field
The present application is in the field of code generation, and more particularly, to a code generation method and a code generation apparatus.
Background
Currently, code generators on the market are mostly realized based on rear-end languages such as JAVA and C, and in the use process of front-end personnel, the front-end personnel need to input time to learn the rear-end language and communicate with the rear-end developer, so that development cost is increased; in the front-end and back-end joint debugging process, the front end can carry out interface joint debugging only after the back end defines the structure and the field of the request and the return data, so that the workload is increased; some existing code generators need to define complex metadata in advance, so that development efficiency is reduced, and codes generated by the code generators are long and difficult to understand and read, so that later maintenance and expansion are not facilitated.
Disclosure of Invention
The present application aims to solve at least one of the technical problems existing in the prior art. Therefore, the application provides a code generation method and a code generation device, which solve the problems that front-end personnel are required to input time to learn a back-end language and are required to participate in the development process in the current code generation method, so that the working efficiency of the front-end developer is improved, and the development cost is reduced.
In a first aspect, the present application provides a code generation method, including:
acquiring a target table based on a target plug-in;
receiving a first input of a target EJS template in at least one EJS template provided by a user on the target plugin; the target plugin is pre-generated;
in response to the first input, object code is generated based on the object plug-in processing the object table and the object EJS template.
According to the code generation method, the target table is acquired based on the target plug-in, so that a front-end personnel does not need to consider how to connect the database, and the working efficiency is improved; the method has the advantages that the required EJS templates are selected from the commonly used EJS templates provided by the target plug-in based on the first input of the user, and the target codes can be generated by combining the target table, so that front-end developers do not need to write the EJS templates by themselves, the work of the front-end developers is simplified, the participation of the rear-end developers is not needed, the operation is simple and convenient, the use threshold is reduced, the user can customize the EJS templates under the condition that the default EJS templates do not meet the user requirement, the development efficiency of the front-end developers is improved, and the development cost is reduced.
According to the code generation method of the present application, the target table and the target EJS template are processed based on the target plug-in, and target code is generated, including:
based on the fact that the target plug-in is connected to a target database corresponding to the target table, target metadata in the target table are read, and target format data are generated;
and rendering html elements based on the target EJS template and the target format data, storing the html elements in a target file, and generating the target code.
According to the code generation method of the present application, the obtaining the target table based on the target plug-in includes:
receiving a second input from the user to the at least one candidate list;
in response to the second input, the at least one candidate table is determined to be the target table.
According to the code generation method of the present application, before the target table is acquired based on the target plug-in, the method further includes:
initializing a target item;
integrating target database dependence under the target item, and establishing a connection relation with the target database;
encapsulating a target nodejs module based on the connection relation;
and packaging the target item and generating the target plug-in.
According to the code generation method of the present application, the encapsulating target nodes module based on the connection relation includes:
using nodejs to connect the target database based on the connection relation, and reading at least part of the table in the target database;
reading the structural information of the at least partial table;
reading the at least one EJS template, and performing template rendering by adopting the EJS template based on the structural information to generate a front-end page code;
and writing the front-end page code into a text file, and packaging the target nodejs module.
According to the code generation method of the present application, after the initializing the target null item, the method further includes:
EJS dependencies are integrated.
In a second aspect, the present application provides a code generating apparatus comprising:
the first processing module is used for acquiring a target table based on the target plug-in;
the second processing module is used for receiving a first input of a target EJS template in at least one EJS template provided by a user on the target plugin; the target plugin is pre-generated;
and a third processing module, configured to, in response to the first input, process the target table and the target EJS template based on the target plug-in, and generate target code.
According to the code generating device, the target table is acquired based on the target plug-in, so that a front-end personnel does not need to consider how to connect the database, and the working efficiency is improved; the method has the advantages that the required EJS templates are selected from the commonly used EJS templates provided by the target plug-in based on the first input of the user, and the target codes can be generated by combining the target table, so that front-end developers do not need to write the EJS templates by themselves, the work of the front-end developers is simplified, the participation of the rear-end developers is not needed, the operation is simple and convenient, the use threshold is reduced, the user can customize the EJS templates under the condition that the default EJS templates do not meet the user requirement, the development efficiency of the front-end developers is improved, and the development cost is reduced.
In a third aspect, the present application provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the method of generating code as described in the first aspect when executing the computer program.
In a fourth aspect, the present application provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method of generating code as described in the first aspect above.
In a fifth aspect, the present application provides a computer program product comprising a computer program which, when executed by a processor, implements a code generation method as described in the first aspect above.
The above technical solutions in the embodiments of the present application have at least one of the following technical effects:
the target table is acquired based on the target plug-in, so that a front-end personnel does not need to consider how to connect the database, and the working efficiency is improved; the method has the advantages that the required EJS templates are selected from the commonly used EJS templates provided by the target plug-in based on the first input of the user, and the target codes can be generated by combining the target table, so that front-end developers do not need to write the EJS templates by themselves, the work of the front-end developers is simplified, the participation of the rear-end developers is not needed, the operation is simple and convenient, the use threshold is reduced, the user can customize the EJS templates under the condition that the default EJS templates do not meet the user requirement, the development efficiency of the front-end developers is improved, and the development cost is reduced.
Furthermore, by creating an initial empty project and integrating necessary database dependence and encapsulating a nodejs module, a code generation plug-in which can be easily developed only by the front end can be realized, and the front end personnel do not need to pay attention to the operation of the database and page rendering by using a target plug-in, so that the participation of the back end developer is not needed, and the development work of the front end developer on the front end page is simplified.
Furthermore, on the basis of integrating the necessary database dependency, the database is connected by using the nodejs, so that the table structure can be directly read, complex metadata is not required to be predefined, complex database connection and data reading are not required to be considered, a front-end page code is generated through the EJS template, and the operations are packaged into the nodejs module, so that later calling can be facilitated.
Still further, by reading the target metadata in the target table, the problem of predefining complex metadata is avoided, so that the interface field in the front-end generated code is the field which is finally transferred, the structure and the field of the back-end definition request and the return data required by the joint debugging are avoided, the additional workload that the front end can only perform the interface joint debugging is avoided, the time spent by the joint debugging is saved, and the workload is reduced.
Additional aspects and advantages of the application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application.
Drawings
The foregoing and/or additional aspects and advantages of the application will become apparent and may be better understood from the following description of embodiments taken in conjunction with the accompanying drawings in which:
FIG. 1 is a schematic flow chart of a code generation method according to an embodiment of the present application;
FIG. 2 is a second flowchart of a code generation method according to an embodiment of the present application;
FIG. 3 is a third schematic diagram of a code generating device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions of the embodiments of the present application will be clearly described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which are obtained by a person skilled in the art based on the embodiments of the present application, fall within the scope of protection of the present application.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, as appropriate, such that embodiments of the present application may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of a type, and are not limited to the number of objects, such as the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
In the related art, code generators are divided into two main types:
firstly, based on the rear-end languages such as JAVA and C, the front-end personnel need to input a certain time to learn the rear-end language, and the participation of the rear-end personnel is also needed in the use process, so that the development period and the cost are increased.
Secondly, the existing code generator needs to define complex metadata in advance, which is not beneficial to quick development, and in addition, in order to consider multiple aspects, the generated code of the code generator is long and difficult to read and understand, and is not beneficial to subsequent maintenance and expansion.
The two types of code generators have higher development cost.
The code generation method, the code generation device, the electronic device and the readable storage medium provided by the embodiment of the application are described in detail below through specific embodiments and application scenes thereof with reference to the accompanying drawings.
Wherein the code generation method is applicable to a terminal, in particular by hardware or software in the terminal.
The terminal comprises portable communication equipment such as a mobile phone or a tablet computer. It should also be appreciated that in some embodiments, the terminal may not be a portable communication device, but rather a desktop computer.
In the following various embodiments, a terminal including a display and a touch sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, mouse, and joystick.
The execution subject of the code generation method provided by the embodiment of the application may be an electronic device or a functional module or a functional entity in the electronic device capable of implementing the code generation method, and the electronic device in the embodiment of the application includes, but is not limited to, a mobile phone, a tablet computer, a camera, a wearable device, and the like.
As shown in fig. 1, the code generation method includes: step 110, step 120 and step 130.
Step 110, acquiring a target table based on a target plug-in;
in this step, the target plugin generates plugins for the front end page code of the present application.
The target plugin is pre-generated.
In the actual application process, a developer can issue a target plug-in to the official network application market for a user to download and acquire; alternatively, the user may send the file in which the target plug-in is located to the user, which is not limited by the present application.
The target table is a table associated with the generated code.
The target table is a table related to generating a front-end page code in a database connected with the target plug-in.
In actual execution, the target table may be one or more tables associated with the generated code.
For example, in the development process of the relevant front-end page of a college, the relevant tables may be a student table storing student information, a teacher table storing teacher information, a logistical table storing logistical personnel information, and the like, which are relevant to the development of the front-end page.
The target table may be selected by the user himself or may be default to the system.
In some embodiments, step 110 comprises, comprising:
receiving a second input from the user to the at least one candidate list;
in response to the second input, at least one candidate table is determined as the target table.
In this embodiment, the candidate table is at least a portion of a table in the database including the target table.
The second input is used to select a desired target table from the candidate tables.
The second input may be any of the following:
the first and second inputs may be touch operations including, but not limited to, click operations, slide operations, press operations, and the like.
In this embodiment, the receiving of the second input by the user may be receiving a touch operation by the user in the display area of the terminal display screen.
In order to reduce the user's rate of misoperation, the active area of the second input may be defined within a specific area, such as the upper middle area of the code generation interface; or displaying a target control on the current interface in the state of displaying the code generation interface, and touching the target control to realize the second input; or the second input is set as a continuous multi-tap operation of the display area within the target time interval.
Second, the second input may be a physical key input.
In this embodiment, the body of the terminal is provided with an entity key corresponding to code generation, and the second input of the user is received, which may be that the operation of pressing the corresponding entity key by the user is received; the second input may also be a combined operation of simultaneously pressing multiple physical keys.
Third, the second input may be a voice input.
In this embodiment, the terminal may trigger speech recognition upon receiving speech, such as "select target table", to select at least one target table.
Of course, in other embodiments, the second input may also be in other forms, including but not limited to character input, etc., which may be specifically determined according to actual needs, which is not limited in the embodiments of the present application.
In the actual execution process, the user can input the account number and the password of the database where the target table is located, connect the database by using nodejs, read at least part of the tables in the database, and select the target table to generate the code through the second input.
It can be understood that after the user selects the target table, before the next operation, the reminder box is popped up to check the correctness of the selected target table again.
According to the code generation method, the target table is read through the nodejs connection database, so that a front-end personnel does not need to consider how to connect the database, complex metadata does not need to be predefined, and the required code can be generated according to the development requirement of the front-end page only according to the table structure in the generated database.
Step 120, receiving a first input of a target EJS template in at least one EJS template provided by a user to a target plug-in; the target plugins are pre-generated;
in this step, the target plugin provides a plurality of EJS templates in common use, namely a default EJS template.
The first input is for selecting a desired EJS template from a plurality of EJS templates provided by the target plug-in.
The first input may be the same touch input, physical key input, voice input, character belonging to any other input that can be realized as the second input, which is not described herein.
In this step, the target EJS template is the EJS template required in the front-end page development process.
In the actual execution process, after the user enters the corresponding interface of the database, a selection frame can be displayed on the EJS template selection interface, wherein the selection frame comprises a plurality of selection controls corresponding to the EJS templates, and the target EJS template is selected by clicking the corresponding selection controls.
In some embodiments, after obtaining the target table, the method may further comprise:
receiving a third input of a user under the condition that at least one EJS template provided by the target plugin does not meet the user demand, wherein the third input is used for customizing the EJS template;
in response to the third input, the target code is generated based on the target plugin processing the target table and the custom EJS template.
Under the condition that the default EJS template does not meet the requirement of a user, the user can customize the EJS template, so that the flexibility and the application range of code generation are improved.
In this embodiment, the third input is used to write an EJS template.
The third input may be the same touch input, physical key input, voice input, character belonging to any other input that can be implemented as the second input, which is not described herein.
In the actual execution process, under the condition that the default EJS template does not meet the front-end business requirement, the default EJS template can be replaced by the custom EJS template according to the front-end page development requirement.
In the application, under the condition that the default EJS template does not meet the requirement of a user, the user can customize the EJS template through the third input, so that the flexibility and the application range of code generation are improved.
Step 130, in response to the first input, generating object code based on the object plugin processing the object table and the object EJS template.
In this step, based on the obtained target table and target EJS template, HTML elements are rendered by the EJS template engine and summarized as one file.
It will be appreciated that the aggregated files may be html, vue and js formatted files, and the application is not limited.
In the actual execution process, the summarized files are returned to the user and saved locally for development of the front-end page.
As shown in fig. 2, in some embodiments, step 130 may include:
based on the connection of the target plug-in to the target database corresponding to the target table, reading target metadata in the target table and generating target format data;
based on the target EJS template and the target format data, rendering html elements and storing the html elements in a target file to generate a target code.
In this embodiment, the target database is a database corresponding to the storage target table, for example, may be an SQL database.
The target metadata is a field name of the target table, that is, a variable name.
For example, the metadata of the book table may be information such as book name, number, author information, and location.
The target format data is a data format in which front-end and back-end data interactions can be performed.
In the actual execution process, the target data format may be JSON format data.
The target file is a file storing html elements, and in the implementation process, the target file can be files in the formats of html, vue, js. and the like.
In the step, a target database is connected, metadata in the target database is read, target format data is generated, complex metadata is not required to be defined in advance, html elements are rendered through a template engine based on the target format data and a target EJS template, the rendered html is summarized, a target code is generated, and a required code is provided for front-end development.
According to the code generation method, the problem of predefining complex metadata is avoided by reading the target metadata in the target table, so that the interface field in the front-end generated code is the field finally transferred, the structure and the field of the back-end definition request and the back-end definition data are avoided, the additional workload that the front end can perform interface joint debugging is avoided, the time spent by joint debugging is saved, and the workload is reduced.
The inventor finds that in the research and development process, in the related technology, a mode of generating the front-end page code by combining the methods of node. Js and EJS also exists, but the method needs front-end developers to write the EJS template by themselves, so that the development process is complicated and difficult.
In the application, a plurality of EJS templates are provided by the target plug-in, and a front-end developer only needs to select a required template from the plurality of EJS templates in the use process, so that the EJS templates do not need to be written by himself, the development process is obviously simplified, and the front-end use difficulty is reduced.
According to the code generation method, the target table is acquired based on the target plug-in, so that a front-end personnel does not need to consider how to connect the database, and the working efficiency is improved; the method has the advantages that the required EJS templates are selected from the commonly used EJS templates provided by the target plug-in based on the first input of the user, and the target codes can be generated by combining the target table, so that front-end developers do not need to write the EJS templates by themselves, the work of the front-end developers is simplified, the participation of the rear-end developers is not needed, the operation is simple and convenient, the use threshold is reduced, the user can customize the EJS templates under the condition that the default EJS templates do not meet the user requirement, the development efficiency of the front-end developers is improved, and the development cost is reduced.
In some embodiments, before step 110 includes, the method may further include:
initializing a target item;
integrating the dependence of the target database under the target item, and establishing a connection relation with the target database;
encapsulating the target nodejs module based on the connection relation;
and packing the target item and generating a target plug-in.
In this embodiment, the target item is an item created for the plug-in.
Target database dependencies are database-related dependencies.
In the actual implementation process, the integration target database depends on metadata such as the read table structure of the database and DDL.
The target nodejs module is an externally exposed nodejs module, i.e., a block of code written in the method.
The target plug-in is a plug-in for generating the front-end page code, which is proposed by the application.
In the actual execution process, initializing a target item, integrating target database dependencies, packaging a nodejs module in the target item based on the integrated dependencies, and packaging the initialized target item into a plug-in.
The plug-in can be released to the official network application market for downloading by a user.
In some embodiments, where the plug-in functionality is updated, the version number update plug-in may be modified.
According to the code generation method, the code generation plug-in which can be easily developed only by the front end can be realized by creating the initial empty project, integrating the necessary database dependence and packaging the nodejs module, and the front end personnel do not need to pay attention to the operation of the database and the page rendering by using the target plug-in, so that the participation of the back end developer is not needed, and the development work of the front end developer on the front end page is simplified.
In some embodiments, encapsulating the target nodejs module based on connection relationships may further include:
connecting the target database based on the connection relation by using nodejs, and reading at least part of the table in the target database;
reading structural information of at least part of the table;
reading at least one EJS template, and performing template rendering by adopting the EJS template based on the structural information to generate a front-end page code;
and writing the front-end page code into the text file, and packaging the target nodejs module.
In this embodiment, the structure information of the table is a file name defining the table, which fields the table contains, the field name, the field type, and the width of each field are determined, and these data are input into the computer.
In actual execution, the structural information of the table may be read using a structured query language.
For example, DESCRIBE statements may be used to read table structure information in the MySQL database.
The EJS template is the default EJS template provided by the target plug-in.
In actual execution, prior to generating the target plugin, multiple commonly used EJS templates may also be created as default EJS templates for use in generating the plugin.
The text file is a new empty file created by the user.
In the actual execution process, using nodejs to connect with a target database, reading a table related to the generated code in the database, and reading a table structure; reading an EJS template based on structural information of a table, performing template rendering by using a template engine, writing a front-end page code generated by rendering into a text file, and packaging the partial code block, namely a nodejs module after the steps are completed.
According to the code generation method, on the basis of integrating the necessary database dependence, the nodejs connection database is used, the table structure can be directly read, complex metadata is not required to be defined in advance, complex database connection and data reading are not required to be considered, the front-end page code is generated through the EJS template, and the operations are packaged into the nodejs module, so that later calling can be facilitated.
In some embodiments, prior to step 110, the method may further comprise:
EJS dependencies are integrated.
Wherein the EJS dependency is a dependency related to the EJS template.
In the actual execution process, the integration of the EJS dependency is to perform formatting parsing on the default EJS template file provided by the target plugin.
In other embodiments, prior to step 110, the method may further comprise: the default EJS template is parsed by writing regular expressions, using a template parser, and the like.
According to the code generation method, the EJS template can be effectively formatted and analyzed by integrating the EJS dependencies.
According to the code generation method provided by the embodiment of the application, the execution main body can be a code generation device. In the embodiment of the present application, a method for executing a code by a code generating device is taken as an example, and the code generating device provided in the embodiment of the present application is described.
The embodiment of the application also provides a code generation device.
As shown in fig. 3, the code generating apparatus includes: a first processing module 310, a second processing module 320, and a third processing module 330.
A first processing module 310, configured to obtain a target table based on a target plugin;
a second processing module 320, configured to receive a first input of a target EJS template from at least one EJS template provided by a user to a target plugin; the target plugins are pre-generated;
the third processing module 330 is configured to process the target table and the target EJS template based on the target plug-in and generate target code in response to the first input.
According to the code generating device, the target table is acquired based on the target plug-in, so that a front-end personnel does not need to consider how to connect the database, and the working efficiency is improved; the method has the advantages that the required EJS templates are selected from the commonly used EJS templates provided by the target plug-in based on the first input of the user, and the target codes can be generated by combining the target table, so that front-end developers do not need to write the EJS templates by themselves, the work of the front-end developers is simplified, the participation of the rear-end developers is not needed, the operation is simple and convenient, the use threshold is reduced, the user can customize the EJS templates under the condition that the default EJS templates do not meet the user requirement, the development efficiency of the front-end developers is improved, and the development cost is reduced.
In some embodiments, the third processing module 330 may also be configured to:
based on the connection of the target plug-in to the target database corresponding to the target table, reading target metadata in the target table and generating target format data;
based on the target EJS template and the target format data, rendering html elements and storing the html elements in a target file to generate a target code.
In some embodiments, the first processing module 310 may also be configured to:
receiving a second input from the user to the at least one candidate list;
in response to the second input, at least one candidate table is determined as the target table.
In some embodiments, the apparatus may further comprise: a fourth processing module for:
initializing a target item before acquiring a target table based on a target plug-in;
integrating the dependence of the target database under the target item, and establishing a connection relation with the target database;
encapsulating the target nodejs module based on the connection relation;
and packing the target item and generating a target plug-in.
In some embodiments, the fourth processing module may be further configured to:
connecting the target database based on the connection relation by using nodejs, and reading at least part of the table in the target database;
reading structural information of at least part of the table;
reading at least one EJS template, and performing template rendering by adopting the EJS template based on the structural information to generate a front-end page code;
and writing the front-end page code into the text file, and packaging the target nodejs module.
In some embodiments, the fourth processing module may be further configured to:
EJS dependencies are integrated.
The code generating device in the embodiment of the application can be an electronic device or a component in the electronic device, such as an integrated circuit or a chip. The electronic device may be a terminal, or may be other devices than a terminal. By way of example, the electronic device may be a mobile phone, tablet computer, notebook computer, palm computer, vehicle-mounted electronic device, mobile internet appliance (Mobile Internet Device, MID), augmented reality (augmented reality, AR)/Virtual Reality (VR) device, robot, wearable device, ultra-mobile personal computer, UMPC, netbook or personal digital assistant (personal digital assistant, PDA), etc., but may also be a server, network attached storage (Network Attached Storage, NAS), personal computer (personal computer, PC), television (TV), teller machine or self-service machine, etc., and the embodiments of the present application are not limited in particular.
The code generating device in the embodiment of the application can be a device with an operating system. The operating system may be an Android operating system, an IOS operating system, or other possible operating systems, and the embodiment of the present application is not limited specifically.
The code generating device provided by the embodiment of the present application can implement each process implemented by the method embodiments of fig. 1 to 2, and in order to avoid repetition, a description is omitted here.
In some embodiments, as shown in fig. 4, an electronic device 400 is further provided in the embodiments of the present application, which includes a processor 401, a memory 402, and a computer program stored in the memory 402 and capable of running on the processor 401, where the program, when executed by the processor 401, implements the respective processes of the foregoing code generation method embodiments, and the same technical effects can be achieved, so that repetition is avoided, and no further description is given here.
The electronic device in the embodiment of the application includes the mobile electronic device and the non-mobile electronic device.
The embodiment of the application also provides a non-transitory computer readable storage medium, on which a computer program is stored, which when executed by a processor, implements the processes of the code generation method embodiment, and can achieve the same technical effects, and in order to avoid repetition, the description is omitted here.
Wherein the processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes computer readable storage medium such as computer readable memory ROM, random access memory RAM, magnetic or optical disk, etc.
The embodiment of the application also provides a computer program product, which comprises a computer program, and the computer program realizes the code generation method when being executed by a processor.
Wherein the processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes computer readable storage medium such as computer readable memory ROM, random access memory RAM, magnetic or optical disk, etc.
The embodiment of the application further provides a chip, which comprises a processor and a communication interface, wherein the communication interface is coupled with the processor, and the processor is used for running programs or instructions to realize the processes of the code generation method embodiment, and the same technical effects can be achieved, so that repetition is avoided, and the description is omitted here.
It should be understood that the chips referred to in the embodiments of the present application may also be referred to as system-on-chip chips, chip systems, or system-on-chip chips, etc.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Furthermore, it should be noted that the scope of the methods and apparatus in the embodiments of the present application is not limited to performing the functions in the order shown or discussed, but may also include performing the functions in a substantially simultaneous manner or in an opposite order depending on the functions involved, e.g., the described methods may be performed in an order different from that described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art in the form of a computer software product stored in a storage medium (e.g. ROM/RAM, magnetic disk, optical disk) comprising instructions for causing a terminal (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present application.
The embodiments of the present application have been described above with reference to the accompanying drawings, but the present application is not limited to the above-described embodiments, which are merely illustrative and not restrictive, and many forms may be made by those having ordinary skill in the art without departing from the spirit of the present application and the scope of the claims, which are to be protected by the present application.
In the description of the present specification, reference to the terms "one embodiment," "some embodiments," "illustrative embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
While embodiments of the present application have been shown and described, it will be understood by those of ordinary skill in the art that: many changes, modifications, substitutions and variations may be made to the embodiments without departing from the spirit and principles of the application, the scope of which is defined by the claims and their equivalents.

Claims (10)

1. A code generation method, comprising:
acquiring a target table based on a target plug-in;
receiving a first input of a target EJS template in at least one EJS template provided by a user on the target plugin; the target plugin is pre-generated;
in response to the first input, object code is generated based on the object plug-in processing the object table and the object EJS template.
2. The code generation method of claim 1, wherein the processing the target table and the target EJS template based on the target plug-in to generate target code includes:
based on the fact that the target plug-in is connected to a target database corresponding to the target table, target metadata in the target table are read, and target format data are generated;
and rendering html elements based on the target EJS template and the target format data, storing the html elements in a target file, and generating the target code.
3. The code generation method according to claim 1, wherein the obtaining the target table based on the target plug-in includes:
receiving a second input from the user to the at least one candidate list;
in response to the second input, the at least one candidate table is determined to be the target table.
4. A code generation method according to any of claims 1-3, wherein prior to the obtaining of the target table based on the target plugin, the method further comprises:
initializing a target item;
integrating target database dependence under the target item, and establishing a connection relation with the target database;
encapsulating a target nodejs module based on the connection relation;
and packaging the target item and generating the target plug-in.
5. The code generation method according to claim 4, wherein the encapsulating the target nodejs module based on the connection relation includes:
using nodejs to connect the target database based on the connection relation, and reading at least part of the table in the target database;
reading the structural information of the at least partial table;
reading the at least one EJS template, and performing template rendering by adopting the EJS template based on the structural information to generate a front-end page code;
and writing the front-end page code into a text file, and packaging the target nodejs module.
6. The code generation method of claim 4, wherein after the initializing the target null item, the method further comprises:
EJS dependencies are integrated.
7. A code generating apparatus, comprising:
the first processing module is used for acquiring a target table based on the target plug-in;
the second processing module is used for receiving a first input of a target EJS template in at least one EJS template provided by a user on the target plugin; the target plugin is pre-generated;
and a third processing module, configured to, in response to the first input, process the target table and the target EJS template based on the target plug-in, and generate target code.
8. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the code generation method of any of claims 1-6 when the program is executed by the processor.
9. A non-transitory computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when executed by a processor, implements the code generation method according to any of claims 1-6.
10. A computer program product comprising a computer program which, when executed by a processor, implements the code generation method of any of claims 1-6.
CN202311080069.5A 2023-08-24 2023-08-24 Code generation method and code generation device Pending CN116954621A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311080069.5A CN116954621A (en) 2023-08-24 2023-08-24 Code generation method and code generation device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311080069.5A CN116954621A (en) 2023-08-24 2023-08-24 Code generation method and code generation device

Publications (1)

Publication Number Publication Date
CN116954621A true CN116954621A (en) 2023-10-27

Family

ID=88451342

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311080069.5A Pending CN116954621A (en) 2023-08-24 2023-08-24 Code generation method and code generation device

Country Status (1)

Country Link
CN (1) CN116954621A (en)

Similar Documents

Publication Publication Date Title
CN111026470B (en) System and method for verification and conversion of input data
CN105354013A (en) Application interface rendering method and apparatus
US8209598B1 (en) Exporting electronic documents from rich internet applications
CN105354014A (en) Application interface rendering display method and apparatus
KR102133906B1 (en) Data analysis and processing methods, devices, computer devices and storage media
CN113535164A (en) Front-end interface generation method and device, electronic equipment and storage medium
Fischer et al. DIY assistant: a multi-modal end-user programmable virtual assistant
CN111414350A (en) Service generation method and device
Yeh et al. Iterative design and evaluation of an event architecture for pen-and-paper interfaces
CN114020194A (en) Display data modification method and device, computer equipment and medium
US20220284371A1 (en) Method, device and medium for a business function page
CN116257232A (en) Table generation method, device, equipment and storage medium based on table component
Kapoor et al. Mathaino: simultaneous legacy interface migration to multiple platforms
CN116954621A (en) Code generation method and code generation device
Fischer et al. Multi-modal end-user programming of web-based virtual assistant skills
CN111126012B (en) Custom generation expression method and device
CN114579461A (en) Browser compatibility detection method and related equipment
Watson Portable GUI development with C++
Escott et al. Design patterns for angular hotdraw
Chan Unix system programming using C++
CN109561146A (en) Document down loading method, device, terminal device
CN114185618B (en) Service tool configuration method, device, computer equipment and storage medium
CN115826961B (en) Design method and device for data analysis system for separated reuse of designer and engine
CN113822033B (en) Report generation method, device, equipment and storage medium
Gärtner et al. NLATool: An Application for Enhanced Deep Text Understanding

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