CN109725893A - Code generating method, unit and computer readable storage medium - Google Patents

Code generating method, unit and computer readable storage medium Download PDF

Info

Publication number
CN109725893A
CN109725893A CN201810474661.6A CN201810474661A CN109725893A CN 109725893 A CN109725893 A CN 109725893A CN 201810474661 A CN201810474661 A CN 201810474661A CN 109725893 A CN109725893 A CN 109725893A
Authority
CN
China
Prior art keywords
database
keyword
code
data
attribute
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
CN201810474661.6A
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.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management 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 Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN201810474661.6A priority Critical patent/CN109725893A/en
Publication of CN109725893A publication Critical patent/CN109725893A/en
Pending legal-status Critical Current

Links

Abstract

The invention discloses a kind of code generating method, the code generating method is the following steps are included: obtain the configuration information of database, and be connected to the database according to the configuration information;Obtain the keyword of tables of data and corresponding key attribute in the database;According to the keyword and the key attribute, default template is filled;According to the filled default template generation bottom code file.The invention also discloses a kind of code generating device, device and computer readable storage mediums.Technical solution of the present invention helps to improve code development efficiency.

Description

Code generating method, unit and computer readable storage medium
Technical field
The present invention relates to field of computer technology more particularly to a kind of code generating method, unit and computer can Read storage medium.
Background technique
Currently, generally use JPA (Java Persistence Application Programming Interface, Java, persistent layer application programming interface) tool or MyBatis (Persistence Layer Framework based on Java) tool realize program with Connection between database, to realize the operation to database.In order to simplify the process that developer writes code, make to develop The function itself that personnel realize needed for capable of concentrating on as far as possible, can write bottom code file in advance, logical to include Bottom code, standard syntax etc..However, JPA tool has no corresponding bottom code file at present, and MyBatis tool Although there is bottom code file, must be based on certain frame, cannot it is customized specification and layering etc., scalability and flexibly Property is poor.But the considerations of for safety and practicability etc., developer generally requires customized specification or layering etc., existing Some JPA tools or MyBatis tool cannot support above-mentioned customized specification or layering, cause in the process of development, to lack Available bottom code file, needs developer to write whole codes manually, causes development efficiency lower.
Above content is only used to facilitate the understanding of the technical scheme, and is not represented and is recognized that above content is existing skill Art.
Summary of the invention
The main purpose of the present invention is to provide a kind of code generating methods, it is intended to solve above-mentioned needs and write whole manually The technical issues of code, improves development efficiency.
To achieve the above object, the present invention provides a kind of code generating method, comprising the following steps:
The configuration information for obtaining database, is connected to the database according to the configuration information;
Obtain the keyword of tables of data and corresponding key attribute in the database;
According to the keyword and the key attribute, default template is filled;
According to the filled default template generation bottom code file.
Preferably, after according to the filled default template generation bottom code file the step of, the code Generation method is further comprising the steps of:
Obtain function code;
The function code is filled into the bottom code file, to generate final code file.
Preferably, the configuration information includes username and password;
The configuration information of database is obtained, and the step of being connected to the database according to the configuration information includes:
Obtain the username and password of the database;
According to the user name and the password, the database is connected;
When connecting the failed database, the first standby signal is generated, and add up the connection number of continuously coupled failure;
According to first standby signal, the username and password of the database is reacquired;
The step of returning according to the user name and the password, connecting the database, until connecting the database Success or the connection number are greater than or equal to preset times;
When connecting the failed database, and when the connection number is greater than or equal to preset times, generates second and prompt Signal.
Preferably, the key attribute includes the data type of the keyword, the data length of the keyword, institute State whether keyword is whether major key, the keyword are at least one of unique.
Preferably, in obtaining the database keyword of tables of data and the step of corresponding key attribute after, The code generating method is further comprising the steps of:
Obtain the corresponding table data attribute of the keyword;
Compare the table data attribute and the key attribute;
When the table data attribute and the key attribute are not inconsistent, the table number is modified according to the key attribute According to, and/or generate third standby signal.
Preferably, according to the keyword and the key attribute, filling the step of presetting template includes:
Obtain the data attribute in default template;
Compare the data attribute and the key attribute;
When the data attribute is consistent with the key attribute, the keyword is filled to the default template In, until traversing all data attributes in the default template.
Preferably, include: according to the step of filled default template generation bottom code file
Obtain the directory information of the filled default template;
According to the directory information, corresponding layer is searched in the database;
In the presence of the layer, the bottom code file is stored into corresponding layer;
In the absence of the layer, according to the new build-up layers of the directory information, the bottom code file is stored to newly-built Layer in.
The present invention also proposes that a kind of code generating device, the code generating device include: memory, processor and storage On the memory and the computer program that can run on the processor, the computer program are held by the processor When row realize code generating method the step of, the code generating method the following steps are included: obtain database configuration information, The database is connected to according to the configuration information;Obtain the keyword of tables of data and corresponding keyword in the database Attribute;According to the keyword and the key attribute, default template is filled;According to the filled default template generation Bottom code file.
Present invention further propose that a kind of code generating unit, the code generating unit include database connection module, Keyword obtains module, template filling module and code file generation module, wherein database connection module is to obtain data The configuration information in library, and the database is connected to according to the configuration information;Keyword obtains module to obtain the number Keyword and corresponding key attribute according to tables of data in library;Template fills module to according to the keyword and the pass Key word attribute fills default template;Code file generation module is to according to the filled default template generation bottom generation Code file.
The present invention also proposes a kind of computer readable storage medium, is stored with code on the computer readable storage medium The step of generating program, code generating method is realized when the code generator is executed by processor, the code building side Method the following steps are included: obtain database configuration information, the database is connected to according to the configuration information;Described in acquisition The keyword of tables of data and corresponding key attribute in database;According to the keyword and the key attribute, filling Default template;According to the filled default template generation bottom code file.
In the technical solution of the present invention, code generating method the following steps are included: obtain database configuration information, according to Configuration information is connected to database;Obtain the keyword of tables of data and corresponding key attribute in database;According to keyword And key attribute, fill default template;According to filled default template generation bottom code file.Connected according to configuration information After being connected to database, according to default template, with the keyword of tables of data in the database got and corresponding key attribute Match, and filled keyword into default template automatically according to matching result, and according to filled default template generation Bottom code file.The process of above-mentioned generation bottom code file is not special for the specification of default template and layering etc. to be wanted It asks, default template can be write as based on primary Java, map (Object Relational independent of any ORM Mapping, Object Relation Mapping) frame, support the multitype databases such as Oracle, mySQL, Postgre, can based on JPA or The multiple types of tools such as MyBatis are realized, to improve the scalability and flexibility of bottom code, realize customized specification or Layering, solves developer and needs the technical issues of writing whole codes manually, improve the efficiency of exploitation.
Detailed description of the invention
Fig. 1 is the flow diagram of code generating method first embodiment of the present invention;
Fig. 2 is the flow diagram of code generating method second embodiment of the present invention;
Fig. 3 is the refinement flow diagram of step S100 in code generating method 3rd embodiment of the present invention;
Fig. 4 is the flow diagram of code generating method fourth embodiment of the present invention;
Fig. 5 is the refinement flow diagram of step S300 in the 5th embodiment of code generating method of the present invention;
Fig. 6 is the refinement flow diagram of step S400 in code generating method sixth embodiment of the present invention;
Fig. 7 is the code generating device structural schematic diagram for the hardware running environment that the embodiment of the present invention is related to.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
The primary solutions of the embodiment of the present invention are: according to the keyword and key attribute of tables of data in database, Default template is filled, to generate bottom code file.
Due to generalling use the connection between JPA tool or MyBatis tool realization program and database in the prior art, Scalability and flexibility are poor, in the case where needing customized specification or layering etc., lack available bottom code file, Developer must write whole codes manually, cause development efficiency lower.
The present invention provides a solution, and according to the keyword and key attribute of tables of data in database, filling is pre- If template is to generate bottom code file, so that the generation for supporting the bottom code file of customized specification or layering is realized, Improve development efficiency.
In the first embodiment of the present invention, as shown in Figure 1, code generating method the following steps are included:
Step S100, the configuration information of database is obtained, and database is connected to according to configuration information;
The configuration information of database includes user name, password etc., only in the correct situation of the configuration information of database, It can be connected to database, to ensure the information security of database.It, can phase in reading database after being connected to database Information is closed, to continue follow-up process.
Step S200, the keyword of tables of data and corresponding key attribute in database are obtained;
Database is the warehouse for coming tissue, storage and management data according to data structure.Tables of data is the important of database Component part, tables of data are made of table name, keyword and table data, wherein and table name can be used to find corresponding tables of data, Table data are corresponding with keyword, and table data are the particular content of keyword, correspondingly, table data should comply with keyword category Property.Tables of data in database is when constructing database with regard to already existing, is matched when existing with the keyword of tables of data Data parameters when, operation to table data in database can be executed according to corresponding code, that is, realize and database Connection.
Step S300, according to keyword and key attribute, default template is filled;
In default template, only exists and the relevant bottom code such as standardize and be layered, solve rule and grammer etc. Typical problem.For example, default template can be the template according to designs such as the existing project structure of enterprise, specification, layerings.? It does not include the specific required data parameter handled and specific function logic etc. in default template.And generate bottom code The purpose of file is the data parameter handled needed for filling in default template, to realize the connection with database, consequently facilitating Database is operated.Data parameter is closed in conjunction in the attribute and database for presetting the data parameter that itself is reserved in template What key word and corresponding key attribute obtained.In a specific example, by the attribute for matching data parameter in default template And key attribute, the keyword to match is filled into default template, hereinafter also will be apparent from.Specifically show another In example, qualified keyword can also be filled into default template according to the attribute of data parameter in default template in batches. Default template includes data template and operation data library template etc., after the filling for completing a default template, can directly into The filling of the next default template of row.
Step S400, according to filled default template generation bottom code file.
According to filled default template, bottom code file is generated, to include general bottom code, standard syntax Deng.During generating bottom code file, need to obtain the information such as the target position of bottom code file, so as to subsequent It calls.This mode for automatically generating bottom code file can be realized by scaffold tool, be programmed by scaffold tool It is a kind of method of metaprogramming, for constructing the application based on database, without developer manually according to data in database The information matches keyword and key attribute of table, are filled default template, to greatly reduce the weight of developer Multiple workload, improves development efficiency.
In the present embodiment, code generating method is the following steps are included: obtain the configuration information of database, according to confidence Breath is connected to database;Obtain the keyword of tables of data and corresponding key attribute in database;According to keyword and key Word attribute fills default template;According to filled default template generation bottom code file.Number is connected to according to configuration information Behind library, according to default template, match with the keyword of tables of data in the database got and corresponding key attribute, And keyword is filled automatically into default template according to matching result, and according to filled default template generation bottom code File.The process of above-mentioned generation bottom code file presets the not special requirements such as the specification of default template and layering Template can be write as based on primary Java, and independent of any ORM mapping, (Object Relational Mapping, object are closed System's mapping) frame, support the multitype databases such as Oracle, mySQL, Postgre, it can be based on a variety of works such as JPA or MyBatis Tool is realized, to improve the scalability and flexibility of bottom code, realizes customized specification or layering, solves exploitation Personnel need the technical issues of writing whole codes manually, improve the efficiency of exploitation.
In the various embodiments of the invention, key attribute include the data type of keyword, keyword data length, Whether keyword is whether major key, keyword are at least one of unique.Wherein, the data type of keyword is corresponding with keyword Table data executable operation it is related, data type includes numeric type, specifically include integer, long, single-precision floating point type, Double-precision floating point type, currency etc.;Byte type;Text-type etc..The data length of keyword defines the corresponding table number of keyword According to the size of shared maximum space, so as to the memory space of reasonable distribution database.Major key is in tables of data to unique terrestrial reference Know a certain item record, there are some rules for major key itself, such as major key cannot include null value etc., and table data corresponding with major key are also Need to meet the distinctive attribute of major key.The value of the value of unique key can be to uniquely identify the note of a certain item in tables of data Record.
Based on above-mentioned first embodiment, in the second embodiment of the present invention, as shown in Fig. 2, after step S400, generation Code generating method is further comprising the steps of:
Step S500, function code is obtained;
Step S600, filling function code is into bottom code file, to generate final code file.
Include in bottom code file and standardizes and be layered etc. involved by relevant bottom code and the bottom code file And to database in keyword.However, when realizing a certain specific function, it is also necessary to table data corresponding to keyword Specific logic calculation and analysis etc. are carried out, specific logic calculation and analysis etc. are present in function code.According to required reality Existing concrete function obtains function code, and function code is filled into bottom code file, to generate final code text Part.When needing to be implemented above-mentioned concrete function, by the final code file of automatic running to realize.Due in bottom code file The keyword for having set specification and being layered in relevant bottom code and required database, therefore, exploit person Member is when writing code for a certain concrete function, it is only necessary to the care function code directly related with concrete function itself, and nothing It need to be concerned about other public and bottom content, to simplify the written in code of developer, be conducive to improve development efficiency.
Based on the various embodiments described above, in the third embodiment of the present invention, configuration information includes username and password;Such as figure Shown in 3, step S100 includes:
Step S110, the username and password of database is obtained;
Step S120, according to username and password, database is connected;
Step S130, when connecting failed database, the first standby signal is generated, and add up the connection of continuously coupled failure Number;
Step S140, according to the first standby signal, the username and password of database is reacquired;
Return step S120, until connection data Kucheng function, or connection number are greater than or equal to preset times;
Step S150, when connecting failed database, and connecting number more than or equal to preset times, the second prompt is generated Signal.
In the present embodiment, when First Contact Connections failed database, by generating the first standby signal, with prompt system Or related personnel.It was waited in view of the username and password of acquired database may be wrong, or in data input, transmission Mistake has occurred in journey, leads to First Contact Connections failed database.In order to improve joint efficiency, according to the first standby signal, weight The new username and password for obtaining database reconnects database to correct mistake that may be present.Simultaneously, it is contemplated that if There are the malicious attacks such as virus, may bring security risk to database, add up to the connection number of continuously coupled failure, When continuous preset times are all connected with unsuccessfully, suspension continues to connect database, and generates the second standby signal, to related personnel It is handled, to ensure database security.
Based on the various embodiments described above, in the fourth embodiment of the present invention, as shown in figure 4, after step S200, code Generation method is further comprising the steps of:
Step S710, the corresponding table data attribute of keyword is obtained;
Step S720, deck watch's data attribute and key attribute;
Step S730, when table data attribute and key attribute are not inconsistent, according to key attribute modification table data, and/ Or generate third standby signal.
In the present embodiment, step S710 is to having no determining ordinal relation between step S730 and step S300.It is logical Often, obtain database in tables of data keyword and key attribute after, i.e., the table data in tables of data are checked, To determine that the corresponding key attribute of table data attribute is consistent, avoid subsequent in the specific logic calculation of execution and analysis When, since, there is mistake in the problem of table data attribute.It specifically includes for example, examining the data type of lookup data, data length etc. Whether key attribute is met.When table data attribute and key attribute are not inconsistent, table data are carried out according to key attribute Modification, so that table data meet key attribute.At the same time it can also generate third standby signal, to prompt related personnel's data There is modification in library.Certainly, if being difficult to directly modify to table data according to key attribute, can also be directly generated Three standby signals, to be handled to related personnel.
Based on the various embodiments described above, in the fifth embodiment of the present invention, as shown in figure 5, step S300 includes:
Step S310, the data attribute in default template is obtained;
Step S320, comparison data attribute and key attribute;
Step S330, when data attribute is consistent with key attribute, keyword is filled into default template, until time Go through all data attributes in default template.
During filling default template, according to the data attribute reserved in default template, filtered out from tables of data The keyword that key attribute matches.Specifically, can pass according to each data attribute in default template, with acquisition Key word attribute matches one by one, when being matched to key attribute, corresponding keyword is filled into default template, according still further to upper The lower data attribute of step process is stated, until traversing data attribute all in default template, filters out the default template pair All keywords answered.
Based on the various embodiments described above, in the sixth embodiment of the present invention, as shown in fig. 6, step S400 includes:
Step S410, the directory information of filled default template is obtained;
Step S420, according to directory information, corresponding layer is searched in the database;
Step S431, in the presence of layer, bottom code file is stored into corresponding layer;
Step S432, in the absence of layer, according to the new build-up layers of directory information, bottom code file is stored to newly-built layer In.
For the ease of calling bottom code file, by obtaining the directory information of filled default template, according to catalogue Information is stored in corresponding position according to filled default template bottom code file generated.In general, directory information refers to The position of layer in the database will be stored to bottom code file.For example, database may include operation data layer, behaviour Make operation layer, front end output layer, front end input layer, control layer etc., according to directory information, bottom code file is stored in correspondence Layer on, to call.The storage location of bottom code file is related to the function that it will be realized, by by correlation function Bottom code file is stored in the same layer of database, is conducive to optimize database structure, is more clear database clear. Therefore, in storing process, it may be necessary to create corresponding layer.According to directory information, if correspondence can be found in the database Layer, then direct storage bottom code file, otherwise, after new build-up layers again storage bottom code file into corresponding layer, from And keep database structure more reasonable.
As shown in fig. 7, the code generating device structure that Fig. 7 is the hardware running environment that the embodiment of the present invention is related to is shown It is intended to.
Code generating device of the embodiment of the present invention can be server, PC, be also possible to smart phone, tablet computer, just Take the packaged type terminal device having a display function such as computer.
As shown in fig. 7, the code generating device may include: processor 1001, such as CPU, network interface 1004, user Interface 1003, memory 1005, communication bus 1002.Wherein, communication bus 1002 is for realizing the connection between these components Communication.User interface 1003 may include display screen (Display), input unit such as keyboard (Keyboard), optional user Interface 1003 can also include standard wireline interface and wireless interface.Network interface 1004 optionally may include having for standard Line interface, wireless interface (such as WI-FI interface).Memory 1005 can be high speed RAM memory, be also possible to stable storage Device (non-volatile memory), such as magnetic disk storage.Memory 1005 optionally can also be independently of aforementioned processing The storage device of device 1001.
Optionally, code generating device can also include camera, RF (Radio Frequency, radio frequency) circuit, sensing Device, voicefrequency circuit, WiFi module etc..Wherein, sensor such as optical sensor, motion sensor and other sensors.Tool Body, optical sensor may include ambient light sensor and proximity sensor, wherein ambient light sensor can be according to ambient light Light and shade adjusts the brightness of display screen, and proximity sensor can close display screen and/or back when mobile terminal is moved in one's ear Light.As a kind of motion sensor, gravity accelerometer can detect (generally three axis) acceleration in all directions Size can detect that size and the direction of gravity when static, can be used to identify the application of mobile terminal posture, (for example horizontal/vertical screen is cut Change, dependent game, magnetometer pose calibrating), Vibration identification correlation function (such as pedometer, tap) etc.;Certainly, mobile terminal It can also configure the other sensors such as gyroscope, barometer, hygrometer, thermometer, infrared sensor, details are not described herein.
It will be understood by those skilled in the art that the restriction of terminal structure shown in Fig. 6 not structure paired terminal, can wrap It includes than illustrating more or fewer components, perhaps combines certain components or different component layouts.
As shown in fig. 7, as may include that operating system, network are logical in a kind of memory 1005 of computer storage medium Believe module, Subscriber Interface Module SIM and code generator.
In code generating device shown in Fig. 7, network interface 1004 is mainly used for connecting background server, takes with backstage Business device carries out data communication;User interface 1003 is mainly used for connecting client (user terminal), carries out data communication with client; And processor 1001 can be used for calling the code generator stored in memory 1005, and execute following operation:
The configuration information for obtaining database, is connected to database according to configuration information;
Obtain the keyword of tables of data and corresponding key attribute in database;
According to keyword and key attribute, default template is filled;
According to filled default template generation bottom code file.
Further, processor 1001 can call the code generator stored in memory 1005, according to filling After the operation of default template generation bottom code file afterwards, following operation is also executed:
Obtain function code;
Function code is filled into bottom code file, to generate final code file.
Further, processor 1001 can call the code generator stored in memory 1005, configuration information packet Include username and password;
The configuration information of database is obtained, and includes: according to the operation that configuration information is connected to database
Obtain the username and password of database;
According to username and password, database is connected;
When connecting failed database, the first standby signal is generated, and add up the connection number of continuously coupled failure;
According to the first standby signal, the username and password of database is reacquired;
The step of returning according to username and password, connecting database, until connection data Kucheng function, or connection number are big In or equal to preset times;
When connecting failed database, and connecting number more than or equal to preset times, the second standby signal is generated.
Further, processor 1001 can call the code generator stored in memory 1005, key attribute The data length of data type, keyword including keyword, keyword whether be during whether major key, keyword unique at least It is a kind of.
Further, processor 1001 can call the code generator stored in memory 1005, obtain data In library after the operation of the keyword of tables of data and corresponding key attribute, following operation is also executed:
Obtain the corresponding table data attribute of keyword;
Deck watch's data attribute and key attribute;
When table data attribute and key attribute are not inconsistent, table data are modified according to key attribute, and/or generate third Standby signal.
Further, processor 1001 can call the code generator stored in memory 1005, according to keyword And key attribute, the operation for filling default template include:
Obtain the data attribute in default template;
Comparison data attribute and key attribute;
When data attribute is consistent with key attribute, keyword is filled into default template, until traversing default mould All data attributes in plate.
Further, processor 1001 can call the code generator stored in memory 1005, after filling The operation of default template generation bottom code file include:
Obtain the directory information of filled default template;
According to directory information, corresponding layer is searched in the database;
In the presence of layer, bottom code file is stored into corresponding layer;
In the absence of layer, according to the new build-up layers of directory information, bottom code file is stored into newly-built layer.
The embodiment of the present invention also proposes that a kind of code generating unit, code generating unit include:
Database connection module is connected to database to obtain the configuration information of database, and according to configuration information;
Keyword obtains module, to obtain the keyword of tables of data and corresponding key attribute in database;
Template fills module, to fill default template according to keyword and key attribute;
Code file generation module, to according to filled default template generation bottom code file.
Further, code generating unit further include:
Function code obtains module, to obtain function code;
Final code generation module, to fill function code into bottom code file, to generate final code file.
Further, configuration information includes username and password;
Database connection module includes:
Configuration information acquiring unit, to obtain the username and password of database;
Connection unit, to connect database according to username and password;
First prompt generation unit, to generate the first standby signal when connecting failed database;Also to when connection Failed database, and connect number be greater than or equal to preset times when, generate the second standby signal;
Number accumulated unit, to add up the connection number of continuously coupled failure when connecting failed database.
Further, key attribute include the data type of keyword, the data length of keyword, keyword whether be Whether major key, keyword are at least one of unique.
Further, code generating unit further include:
Table data attribute obtains module, to obtain the corresponding table data attribute of keyword;
First comparison module, to deck watch's data attribute and key attribute;
Modified module, to modify table data according to key attribute when table data attribute and key attribute are not inconsistent; And/or the second prompt generation unit, to generate third standby signal when table data attribute and key attribute are not inconsistent.
Further, template filling generation module includes:
Data attribute acquiring unit, to obtain the data attribute in default template;
Second comparing unit, to comparison data attribute and key attribute;
Fills unit, keyword to be filled into default template, directly when data attribute is consistent with key attribute To all data attributes traversed in default template.
Further, code file generation module includes:
Directory information acquiring unit, to obtain the directory information of filled default template;
Layer searching unit, to search corresponding layer in the database according to directory information;
Storage unit, in the presence of layer, bottom code file to be stored into corresponding layer;
The newly-built unit of layer, in the absence of working as layer, according to the new build-up layers of directory information;
Storage unit is also storing bottom code file into newly-built layer.
In addition, the embodiment of the present invention also proposes a kind of computer readable storage medium, deposited on computer readable storage medium Code generator is contained, following operation is realized when code generator is executed by processor:
The configuration information for obtaining database, is connected to database according to configuration information;
Obtain the keyword of tables of data and corresponding key attribute in database;
According to keyword and key attribute, default template is filled;
According to filled default template generation bottom code file.
Further, when code generator is executed by processor, according to filled default template generation bottom generation After the operation of code file, following operation is also executed:
Obtain function code;
Function code is filled into bottom code file, to generate final code file.
Further, configuration information includes username and password;
The configuration information of database is obtained, and includes: according to the operation that configuration information is connected to database
Obtain the username and password of database;
According to username and password, database is connected;
When connecting failed database, the first standby signal is generated, and add up the connection number of continuously coupled failure;
According to the first standby signal, the username and password of database is reacquired;
The step of returning according to username and password, connecting database, until connection data Kucheng function, or connection number are big In or equal to preset times;
When connecting failed database, and connecting number more than or equal to preset times, the second standby signal is generated.
Further, key attribute include the data type of keyword, the data length of keyword, keyword whether be Whether major key, keyword are at least one of unique.
Further, when code generator is executed by processor, the keyword of tables of data and right in obtaining database After the operation for the key attribute answered, following operation is also executed:
Obtain the corresponding table data attribute of keyword;
Deck watch's data attribute and key attribute;
When table data attribute and key attribute are not inconsistent, table data are modified according to key attribute, and/or generate third Standby signal.
Further, according to keyword and key attribute, the operation for filling default template includes:
Obtain the data attribute in default template;
Comparison data attribute and key attribute;
When data attribute is consistent with key attribute, keyword is filled into default template, until traversing default mould All data attributes in plate.
Further, when code generator is executed by processor, according to filled default template generation bottom code The operation of file includes:
Obtain the directory information of filled default template;
According to directory information, corresponding layer is searched in the database;
In the presence of layer, bottom code file is stored into corresponding layer;
In the absence of layer, according to the new build-up layers of directory information, bottom code file is stored into newly-built layer.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or the system that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or system institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, method of element, article or system.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in one as described above In storage medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that terminal device (it can be mobile phone, Computer, server, air conditioner or network equipment etc.) execute method described in each embodiment of the present invention.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair Equivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skills Art field, is included within the scope of the present invention.

Claims (10)

1. a kind of code generating method, which is characterized in that the code generating method the following steps are included:
The configuration information for obtaining database, is connected to the database according to the configuration information;
Obtain the keyword of tables of data and corresponding key attribute in the database;
According to the keyword and the key attribute, default template is filled;
According to the filled default template generation bottom code file.
2. code generating method as described in claim 1, which is characterized in that according to the filled default template generation After the step of bottom code file, the code generating method is further comprising the steps of:
Obtain function code;
The function code is filled into the bottom code file, to generate final code file.
3. code generating method as described in claim 1, which is characterized in that the configuration information includes username and password;
The configuration information for obtaining database, and the step of being connected to the database according to the configuration information includes:
Obtain the username and password of the database;
According to the user name and the password, the database is connected;
When connecting the failed database, the first standby signal is generated, and add up the connection number of continuously coupled failure;
According to first standby signal, the username and password of the database is reacquired;
The step of returning according to the user name and the password, connecting the database, until the database success is connected, Or the connection number is greater than or equal to preset times;
When connecting the failed database, and when the connection number is greater than or equal to preset times, the second standby signal of generation.
4. code generating method as described in claim 1, which is characterized in that the key attribute includes the keyword Data type, the data length of the keyword, the keyword whether be during whether major key, the keyword unique at least It is a kind of.
5. code generating method as described in claim 1, which is characterized in that the key of tables of data in obtaining the database After the step of word and corresponding key attribute, the code generating method is further comprising the steps of:
Obtain the corresponding table data attribute of the keyword;
Compare the table data attribute and the key attribute;
When the table data attribute and the key attribute are not inconsistent, the table data are modified according to the key attribute, And/or generate third standby signal.
6. code generating method as described in claim 1, which is characterized in that according to the keyword and the keyword category Property, filling the step of presetting template includes:
Obtain the data attribute in default template;
Compare the data attribute and the key attribute;
When the data attribute is consistent with the key attribute, the keyword is filled into the default template, directly To all data attributes traversed in the default template.
7. code generating method as described in claim 1, which is characterized in that according to the filled default template generation bottom The step of layer identification code file includes:
Obtain the directory information of the filled default template;
According to the directory information, corresponding layer is searched in the database;
In the presence of the layer, the bottom code file is stored into corresponding layer;
In the absence of the layer, according to the new build-up layers of the directory information, the bottom code file is stored to newly-built layer In.
8. a kind of code generating device, which is characterized in that the code generating device includes: memory, processor and is stored in On the memory and the computer program that can run on the processor, the computer program are executed by the processor The step of code generating method of the Shi Shixian as described in any one of claims 1 to 7.
9. a kind of code generating unit, which is characterized in that the code generating unit includes:
Database connection module is connected to the data to obtain the configuration information of database, and according to the configuration information Library;
Keyword obtains module, to obtain the keyword of tables of data and corresponding key attribute in the database;
Template fills module, to fill default template according to the keyword and the key attribute;
Code file generation module, to according to the filled default template generation bottom code file.
10. a kind of computer readable storage medium, which is characterized in that it is raw to be stored with code on the computer readable storage medium The code building as described in any one of claims 1 to 7 is realized at program, when the code generator is executed by processor The step of method.
CN201810474661.6A 2018-05-17 2018-05-17 Code generating method, unit and computer readable storage medium Pending CN109725893A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810474661.6A CN109725893A (en) 2018-05-17 2018-05-17 Code generating method, unit and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810474661.6A CN109725893A (en) 2018-05-17 2018-05-17 Code generating method, unit and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN109725893A true CN109725893A (en) 2019-05-07

Family

ID=66293869

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810474661.6A Pending CN109725893A (en) 2018-05-17 2018-05-17 Code generating method, unit and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN109725893A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110096274A (en) * 2019-05-13 2019-08-06 电子科技大学 The generation code reuse matching management method of distributed memory columnar database
CN110489106A (en) * 2019-07-22 2019-11-22 北京字节跳动网络技术有限公司 A kind of generation method, device, medium and the electronic equipment of project initial code
CN110837363A (en) * 2019-11-05 2020-02-25 北京锐安科技有限公司 Code file generation method, device, equipment and medium
CN110851128A (en) * 2019-11-04 2020-02-28 紫光云技术有限公司 Application code generation method of basic function
CN111198680A (en) * 2019-12-20 2020-05-26 江苏原力动画制作股份有限公司 File generation system and method based on Arnold renderer
CN111427567A (en) * 2020-03-20 2020-07-17 杭州涂鸦信息技术有限公司 Intelligent product rapid generation method, system and equipment thereof
CN113535141A (en) * 2020-04-16 2021-10-22 浙江大搜车软件技术有限公司 Database operation code generation method and device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101819530A (en) * 2010-04-30 2010-09-01 山东中创软件工程股份有限公司 Program object generation method and device and computer
CN103412749A (en) * 2013-07-29 2013-11-27 福建联迪商用设备有限公司 Relational database based code generation method and code generator
CN104598233A (en) * 2015-01-12 2015-05-06 北京中交兴路车联网科技有限公司 Code generation method
US20160041815A1 (en) * 2014-08-11 2016-02-11 Chirag P. Bhagat Computer Source Code Generator for Building Software Applications
CN105677323A (en) * 2015-12-31 2016-06-15 合肥大多数信息科技有限公司 Method for automatically generating database operation layer codes
CN105677324A (en) * 2015-12-31 2016-06-15 合肥大多数信息科技有限公司 Method for automatically generating entity type codes
CN106469064A (en) * 2016-09-04 2017-03-01 深圳市云智易联科技有限公司 Code generating method and code generating unit

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101819530A (en) * 2010-04-30 2010-09-01 山东中创软件工程股份有限公司 Program object generation method and device and computer
CN103412749A (en) * 2013-07-29 2013-11-27 福建联迪商用设备有限公司 Relational database based code generation method and code generator
US20160041815A1 (en) * 2014-08-11 2016-02-11 Chirag P. Bhagat Computer Source Code Generator for Building Software Applications
CN104598233A (en) * 2015-01-12 2015-05-06 北京中交兴路车联网科技有限公司 Code generation method
CN105677323A (en) * 2015-12-31 2016-06-15 合肥大多数信息科技有限公司 Method for automatically generating database operation layer codes
CN105677324A (en) * 2015-12-31 2016-06-15 合肥大多数信息科技有限公司 Method for automatically generating entity type codes
CN106469064A (en) * 2016-09-04 2017-03-01 深圳市云智易联科技有限公司 Code generating method and code generating unit

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
冉春娟;黄华;: "基于关系数据模型代码生成器的设计与实现", 湖北大学学报(自然科学版), no. 02 *
周刚;: "J2EE轻量级框架代码生成工具的设计与实现", 广州广播电视大学学报, no. 06 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110096274A (en) * 2019-05-13 2019-08-06 电子科技大学 The generation code reuse matching management method of distributed memory columnar database
CN110489106A (en) * 2019-07-22 2019-11-22 北京字节跳动网络技术有限公司 A kind of generation method, device, medium and the electronic equipment of project initial code
CN110851128A (en) * 2019-11-04 2020-02-28 紫光云技术有限公司 Application code generation method of basic function
CN110837363A (en) * 2019-11-05 2020-02-25 北京锐安科技有限公司 Code file generation method, device, equipment and medium
CN111198680A (en) * 2019-12-20 2020-05-26 江苏原力动画制作股份有限公司 File generation system and method based on Arnold renderer
CN111198680B (en) * 2019-12-20 2020-12-11 江苏原力数字科技股份有限公司 File generation system and method based on Arnold renderer
CN111427567A (en) * 2020-03-20 2020-07-17 杭州涂鸦信息技术有限公司 Intelligent product rapid generation method, system and equipment thereof
CN111427567B (en) * 2020-03-20 2023-08-18 杭州涂鸦信息技术有限公司 Intelligent product rapid generation method, system and equipment thereof
CN113535141A (en) * 2020-04-16 2021-10-22 浙江大搜车软件技术有限公司 Database operation code generation method and device

Similar Documents

Publication Publication Date Title
CN109725893A (en) Code generating method, unit and computer readable storage medium
US20190034482A1 (en) Metadata-based general request translator for distributed computer systems
CN109325053A (en) Data processing method, device and the computer readable storage medium of reporting system
KR20160079408A (en) Method for processing a query, electronic apparatus and server
US10475146B2 (en) Device for controlling multiple areas of display independently and method thereof
CN103517229B (en) User information acquiring method, device, mobile terminal and server
CN111125269B (en) Data management method, blood relationship display method and related device
CN111353235B (en) Component port modeling method based on model drive and terminal
US11966384B2 (en) Generating external identifiers for data entities using a data catalog system
CN109643843A (en) Electronic equipment and its gripping recognition methods
CN114244595B (en) Authority information acquisition method and device, computer equipment and storage medium
CN111897525A (en) Big data processing method and system
CN113742366A (en) Data processing method and device, computer equipment and storage medium
CN111966491A (en) Method for counting occupied memory and terminal equipment
KR102471739B1 (en) Apparatus and method for managing of history information in a electronic device
KR20160026328A (en) Method for selecting area on web page and electronic device thereof
US20210209296A1 (en) Automatic propagation of column values from a source application to multiple destination applications
KR20170050170A (en) Method and apparauts for supplying contact information
CN108604362B (en) Electronic device and method for controlling display, and server and method for the same
US11687568B2 (en) Data catalog system for generating synthetic datasets
CN111522798B (en) Data synchronization method, device, equipment and readable storage medium
CN112988913B (en) Data processing method and related device
CN114996369A (en) Method and device for constructing data warehouse index library
CN113138763A (en) Page construction method, device, equipment and computer readable storage medium
CN114385723A (en) Data reading method and device, electronic equipment and storage medium

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