Object Code Generator method and device
Technical field
The present invention relates to Computer Applied Technology field, more particularly, to a kind of Object Code Generator method and device.
Background technology
During Project-developing, generally there is a configuration item of many repetitions, such as MyBatis, Spring,
The XML (Extensible markup Language extensible markup languages) of the technologies such as SpringMVC configuration file, typically
Way be manual newly-built configuration file, replicate the unified XSD of XML (XML Schemas Definition, XML structure definition)
Specification head defines, and then creates node configuration information according to standard criterion.
But mistake easily occurs in mode of manual new files in this, and different personnel have the coding of oneself
Style, the skimble-scamble problem of code specification is easily caused, takes a substantial amount of time follow-up debugging and running, also one
Determine to reduce the efficiency of exploitation in degree.
For above-mentioned due to code specification disunity, take a substantial amount of time debugging and running, and then reduce and open
The problem of efficiency of hair, effective solution is not yet proposed at present.
The content of the invention
In view of this, it is an object of the invention to provide a kind of Object Code Generator method and device, to alleviate above-mentioned open
Send out the technical problem that efficiency reduces.
In a first aspect, the embodiments of the invention provide a kind of Object Code Generator method, including:Receive the generation of user's input
Code generation instruction, generation configuration interface is instructed according to code building;Configuration information is filled in configuration interface, carries out configuration operation,
Wherein, configuration information includes:Author's title, working directory, project name and database address information;Built according to configuration information
Vertical operation interface, table information filling is carried out according to the template of operation interface;Wherein, table information includes:Table name, entity class name and road
Footpath information;Object code is generated according to table information.
With reference in a first aspect, the embodiments of the invention provide the possible embodiment of the first of first aspect, wherein, on
State and fill in configuration information in configuration interface, carrying out configuration operation includes:The configuration item shown according to configuration interface is filled in confidence
Breath;Database connecting test is carried out to configuration interface according to configuration information, when the success of configuration interface display data storehouse connecting test
Afterwards, configuration information is preserved.
With reference in a first aspect, the embodiments of the invention provide the possible embodiment of second of first aspect, wherein, on
State includes according to table information generation object code:Entity generation side of the selection corresponding to the entity class name included in table information
Method, object code is generated according to table information and entity generation method.
With reference in a first aspect, the embodiments of the invention provide the possible embodiment of the third of first aspect, wherein, on
State also includes according to table information generation object code:Code logic hierarchical information is selected, according to code logic hierarchical information and table
Information generates object code.
With reference to the first possible embodiment of first aspect, the embodiments of the invention provide the 4th of first aspect kind
Possible embodiment, wherein, the above method also includes:In configuration interface interpolation data storehouse information, wherein, database information bag
Include database user name information and database encrypted message;Whether validation database information is correct;If it is, according to configuration interface
Database connecting test is carried out with database information;If not, the prompt message of ejection database information mistake.
Second aspect, the embodiment of the present invention also provide a kind of Object Code Generator device, including:Configuration interface generates mould
Block, for receiving the code building instruction of user's input, generation configuration interface is instructed according to code building;Configuration information fills in mould
Block, for filling in configuration information in configuration interface, configuration operation is carried out, wherein, configuration information includes:Author's title, work mesh
Record, project name and database address information;Operation interface establishes module, for establishing operation interface according to configuration information,
Table information filling is carried out according to the template of operation interface;Wherein, table information includes:Table name, entity class name and routing information;Target
Code generation module, for generating object code according to table information.
With reference to second aspect, the embodiments of the invention provide the possible embodiment of the first of second aspect, wherein, on
State configuration information and fill in module and be used for:The configuration item shown according to configuration interface fills in configuration information;According to configuration information to
Put interface and carry out database connecting test, after the success of configuration interface display data storehouse connecting test, preserve configuration information.
With reference to second aspect, the embodiments of the invention provide the possible embodiment of second of second aspect, wherein, on
Object Code Generator module is stated to be used for:Entity generation method of the selection corresponding to the entity class name included in table information, according to
Table information and entity generation method generation object code.
With reference to second aspect, the embodiments of the invention provide the possible embodiment of the third of second aspect, wherein, on
Object Code Generator module is stated to be additionally operable to:Code logic hierarchical information is selected, is given birth to according to code logic hierarchical information and table information
Into object code.
With reference to the first possible embodiment of second aspect, the embodiments of the invention provide the 4th of second aspect kind
Possible embodiment, wherein, said apparatus also includes:Database information add module, in configuration interface interpolation data
Storehouse information, wherein, database information includes database user name information and database encrypted message;Database information verifies mould
Block, it is whether correct for validation database information;Database test module, for when the checking knot of database information authentication module
Fruit is when being, database connecting test is carried out according to configuration interface and database information;Nformation alert module, for working as database
When the result of information authentication module is no, the prompt message of database information mistake is ejected.
The embodiment of the present invention brings following beneficial effect:
Object Code Generator method and device provided in an embodiment of the present invention, refer in the code building for receiving user's input
When making, configuration interface can be generated, operating personnel is carried out configuration operation, operation interface is generated after the completion of configuration, make operation
Personnel carry out the filling of table information according to the template of operation interface, are effectively guaranteed the normalization and correctness of code, reduce
The time that follow-up debugging and running expend, improve the efficiency of exploitation.
Other features and advantages of the present invention will illustrate in the following description, also, partly become from specification
Obtain it is clear that or being understood by implementing the present invention.The purpose of the present invention and other advantages are in specification, claims
And specifically noted structure is realized and obtained in accompanying drawing.
To enable the above objects, features and advantages of the present invention to become apparent, preferred embodiment cited below particularly, and coordinate
Appended accompanying drawing, is described in detail below.
Brief description of the drawings
, below will be to specific in order to illustrate more clearly of the specific embodiment of the invention or technical scheme of the prior art
The required accompanying drawing used is briefly described in embodiment or description of the prior art, it should be apparent that, in describing below
Accompanying drawing is some embodiments of the present invention, for those skilled in the art, on the premise of not paying creative work,
Other accompanying drawings can also be obtained according to these accompanying drawings.
Fig. 1 is a kind of flow chart of Object Code Generator method provided in an embodiment of the present invention;
Fig. 2 is the flow chart of another Object Code Generator method provided in an embodiment of the present invention;
Fig. 3 is a kind of schematic diagram of configuration interface provided in an embodiment of the present invention;
Fig. 4 is a kind of schematic diagram of Object Code Generator operation interface provided in an embodiment of the present invention;
Fig. 5 is a kind of structural representation of Object Code Generator device provided in an embodiment of the present invention;
Fig. 6 is the structural representation of another Object Code Generator device provided in an embodiment of the present invention.
Embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with accompanying drawing to the present invention
Technical scheme be clearly and completely described, it is clear that described embodiment is part of the embodiment of the present invention, rather than
Whole embodiments.Based on the embodiment in the present invention, those skilled in the art institute under the premise of creative work is not made
The every other embodiment obtained, belongs to the scope of protection of the invention.
At present, a large amount of repeated encoding processes be present for database table to entity class object, data access, interface etc., it is right
The exploitation of each process is required for carrying out code check, unit testing, reduces development efficiency, simultaneously as lower bound time stamp,
The exhibition of not stopping paying out of IT technologies, existing code generating system can not meet business scenario complicated and changeable now, based on this,
A kind of Object Code Generator method and device provided in an embodiment of the present invention, to carry out unification to code specification, and then meet generation
Code generation business demand.
For ease of understanding the present embodiment, first to a kind of Object Code Generator side disclosed in the embodiment of the present invention
Method describes in detail.
Embodiment one:
The embodiments of the invention provide a kind of Object Code Generator method, this method can apply to code generating system
On server, a kind of flow chart of Object Code Generator method as shown in Figure 1, comprise the following steps:
Step S102, receives the code building instruction of user's input, and generation configuration interface is instructed according to code building;
Step S104, configuration information is filled in configuration interface, carry out configuration operation;
Wherein, above-mentioned configuration information includes:Author's title, working directory, project name and database address information;Behaviour
Making personnel can be operated on configuration interface, and configuration information is filled according to being actually needed, and effectively increase the flexible of code
Property and development efficiency.
Step S106, operation interface is established according to configuration information, table information filling is carried out according to the template of operation interface;
Wherein, above-mentioned table information includes:Table name, entity class name and routing information;
Step S108, object code is generated according to table information.
Object Code Generator method provided in an embodiment of the present invention, when receiving the code building instruction of user's input,
Configuration interface can be generated, operating personnel is carried out configuration operation, operation interface is generated after the completion of configuration, makes operating personnel's root
The filling of table information is carried out according to the template of operation interface, is effectively guaranteed the normalization and correctness of code, is reduced follow-up
Debugging and time for expending of running, improve the efficiency of exploitation.
Embodiment two:
For the ease of understanding Object Code Generator method provided in an embodiment of the present invention, in the base of above-described embodiment
On plinth, the embodiment of the present invention additionally provides another Object Code Generator method, and this method can apply to code generating system
Server on, the flow chart of another Object Code Generator method as shown in Figure 2, comprise the following steps:
Step S202, receives the code building instruction of user's input, and generation configuration interface is instructed according to code building;
Step S204, the configuration item shown according to configuration interface fill in configuration information;
Fig. 3 shows a kind of schematic diagram of configuration interface, and the configuration information for needing to fill on above-mentioned configuration interface includes:
Author's title, working directory, project name and database address information etc..Wherein, author's title represents the acquiescence of generation class
Author's title;Working directory represents generating item purpose root;Project name represents the project name of generation;Database address is believed
Breath is database URL, represents database connection source information.
Step S206, database connecting test is carried out to configuration interface according to configuration information, when configuration interface display data
After the connecting test success of storehouse, configuration information is preserved;
Specifically, the connecting test button shown in Fig. 3 can be clicked on after configuration information has been filled in, carries out database company
Test is connect, if after the success of database connecting test, is ejected " successful connection ", and preserve configuration information;If database connects
Test crash is connect, then ejects " connection failure ", operating personnel can modify, and then re-start database connecting test.
Further, it is contemplated that the security of code, when filling in configuration information, the above method also includes adding database
Close processing, specifically, comprise the following steps:(1) in configuration interface interpolation data storehouse information, wherein, database information includes number
According to storehouse username information and database encrypted message;Configuration interface as shown in Figure 3;Wherein, database user name information includes
The connection user name of database;Database password information includes:The connection password of database;(2) whether validation database information
Correctly;(3) if it is, carrying out database connecting test according to configuration interface and database information;(4) if not, ejection data
The prompt message of storehouse information errors.
Step S208, operation interface is established according to configuration information, table information filling is carried out according to the template of operation interface;
After data library test successful connection, then operation interface is established, above-mentioned table information includes:Table name, entity class name and
Routing information etc..In actual use, the template at aforesaid operations interface may be referred to Freemarker template files,
FreeMarker is a template engine:It is i.e. a kind of to export the logical of text based on template and the data to be changed, and for generating
With instrument, compared with the text that other makers use is as template, it possesses bigger autgmentability, and performance is more preferable.
Fig. 4 shows a kind of schematic diagram of Object Code Generator operation interface, including table name, entity class name and bag path (routing information)
Deng, wherein, table name represents some specific table name of database;Physical name represents the entity name of generation, in order to unified
Specification entity title is preferably table name+Entity;Wrap the path address of path (routing information) presentation-entity generation.User can be with
It is configured by the settings button at aforesaid operations interface, to meet code building demand.
Step S210, entity generation method of the selection corresponding to the entity class name included in table information;
Entity generation method is selected to be realized by the operation interface shown in Fig. 4 described in the embodiment of the present invention, specifically
Ground, the content for each square frame that can be illustrated below by choosing table information, realizes the selection of entity generation method, wherein, respectively
The implication of the content representation of individual square frame is as follows:
Increase:Newly-increased method after choosing in each layer generation of code generating system to entity;
Delete:Delet method after choosing in each layer generation of code generating system to entity;
Change:Amending method after choosing in each layer generation of code generating system to entity;
Entity is looked into:Querying method after choosing in each layer generation of code generating system to entity;
List is looked into:The method for obtaining list of entities in each layer generation of code generating system after choosing;
Paging is looked into:The method for obtaining entity paging list in each layer generation of code generating system after choosing;
Batch increases:In each layer generation of code generating system newly method is increased to the batch of entity after choosing;
Batch changes:Batch modification method after choosing in each layer generation of code generating system to entity;
Batch is deleted:Batch delet method after choosing in each layer generation of code generating system to entity.
Step S212, object code is generated according to table information and entity generation method.
Further, generating the process of object code also includes:Code logic hierarchical information is selected, generates corresponding logic
Layer, object code is generated according to code logic hierarchical information and table information.During specific implementation, the operation shown in Fig. 4 can be passed through
The selection of layering logic layers information is realized at interface, i.e., dao, service shown in Fig. 4,With controller square frames, respectively
The implication of the content representation of individual square frame is as follows:
dao:Dao layers are generated after choosing;
service:Service layers are generated after choosing;
facade:Facade layers are generated after choosing;
controller:Controller layers are generated after choosing.
Further, above-mentioned Object Code Generator operation interface also includes page generation option, and " page is chosen as shown in figure 4, working as
During the square frame in face ", the corresponding page can be generated.
Object Code Generator method provided in an embodiment of the present invention, when receiving the code building instruction of user's input,
Configuration interface can be generated, operating personnel is carried out configuration operation, operation interface is generated after the completion of configuration, makes operating personnel's root
The filling of table information is carried out according to the template of operation interface, is effectively guaranteed the normalization and correctness of code, is reduced follow-up
Debugging and time for expending of running, improve the efficiency of exploitation.
Embodiment three:
The embodiment of the present invention additionally provides a kind of Object Code Generator device on the basis of above-described embodiment, and the device can
To be arranged on the server of code generating system, a kind of structural representation of Object Code Generator device as shown in Figure 5 should
Device includes configuration interface generation module 101, configuration information fills in module 102, operation interface establishes module 103 and object code
Generation module 104, the function of modules are as follows:
Configuration interface generation module 101, for receiving the code building instruction of user's input, instructed and given birth to according to code building
Into configuration interface;
Configuration information fills in module 102, for filling in configuration information in configuration interface, carries out configuration operation, wherein, configuration
Information includes:Author's title, working directory, project name and database address information;
Operation interface establishes module 103, for establishing operation interface according to configuration information, enters according to the template of operation interface
Row table information is filled;Wherein, table information includes:Table name, entity class name and routing information;
Object Code Generator module 104, for generating object code according to table information.
Object Code Generator device provided in an embodiment of the present invention, when receiving the code building instruction of user's input,
Configuration interface can be generated, operating personnel is carried out configuration operation, operation interface is generated after the completion of configuration, makes operating personnel's root
The filling of table information is carried out according to the template of operation interface, is effectively guaranteed the normalization and correctness of code, is reduced follow-up
Debugging and time for expending of running, improve the efficiency of exploitation.
Further, above-mentioned configuration information is filled in module 102 and is used for:The configuration item shown according to configuration interface is filled in confidence
Breath;Database connecting test is carried out to configuration interface according to configuration information, when the success of configuration interface display data storehouse connecting test
Afterwards, configuration information is preserved.
Further, above-mentioned Object Code Generator module 104 is used for:Corresponding to the entity class name included in selection and table information
Entity generation method, object code is generated according to table information and entity generation method.
Further, above-mentioned Object Code Generator module 104 is additionally operable to:Code logic hierarchical information is selected, is patrolled according to code
Collect hierarchical information and table information generation object code.
Preferably, Fig. 6 shows the structural representation of another Object Code Generator device, except each knot shown in Fig. 5
Beyond structure, said apparatus also includes:
Database information add module 105, in configuration interface interpolation data storehouse information, wherein, database information bag
Include database user name information and database encrypted message;
Database information authentication module 106, it is whether correct for validation database information;
Database test module 107, for when database information authentication module 106 the result for be when, according to
Put interface and database information carries out database connecting test;
Nformation alert module 108, for when the result of database information authentication module 106 is no, ejecting data
The prompt message of storehouse information errors.
Object Code Generator device provided in an embodiment of the present invention, the Object Code Generator method provided with above-described embodiment
With identical technical characteristic, so can also solve identical technical problem, reach identical technique effect.
The computer program product for the Object Code Generator method and device that the embodiment of the present invention is provided, including store
The computer-readable recording medium of program code, the instruction that described program code includes can be used for performing in previous methods embodiment
Described method, specific implementation can be found in embodiment of the method, will not be repeated here.
It is apparent to those skilled in the art that for convenience and simplicity of description, the device of foregoing description
Specific work process, may be referred to the corresponding process in preceding method embodiment, will not be repeated here.
If the function is realized in the form of SFU software functional unit and is used as independent production marketing or in use, can be with
It is stored in a computer read/write memory medium.Based on such understanding, technical scheme is substantially in other words
The part to be contributed to prior art or the part of the technical scheme can be embodied in the form of software product, the meter
Calculation machine software product is stored in a storage medium, including some instructions are causing a computer equipment (can be
People's computer, server, or network equipment etc.) perform all or part of step of each embodiment methods described of the present invention.
And foregoing storage medium includes:USB flash disk, mobile hard disk, read-only storage (ROM, Read-Only Memory), arbitrary access are deposited
Reservoir (RAM, Random Access Memory), magnetic disc or CD etc. are various can be with the medium of store program codes.
Finally it should be noted that:Above example, it is only the embodiment of the present invention, to illustrate the skill of the present invention
Art scheme, rather than its limitations, protection scope of the present invention is not limited thereto, although entering with reference to the foregoing embodiments to the present invention
Go detailed description, it should be understood by those skilled in the art that:Any one skilled in the art takes off in the present invention
In the technical scope of dew, it can still modify to the technical scheme described in previous embodiment or can readily occur in change
Change, or equivalent substitution is carried out to which part technical characteristic;And these modifications, change or replacement, do not make relevant art
Scheme essence depart from technical scheme of the embodiment of the present invention spirit and scope, should all cover protection scope of the present invention it
It is interior.Therefore, protection scope of the present invention should be defined by scope of the claims.