Java Web code generator, which focuses on Java Web project general purpose code generator and Java Web Code Generator

Source: Internet
Author: User

Java Web code generator, which focuses on Java Web project general purpose code generator and Java Web Code Generator

This project is a general code generator for the javaWEB project. jsp, js, And java files are generated based on database tables and custom code templates. It is a powerful tool for developing javaweb projects;

Open Source Address: https://gitee.com/okrs.cn/CodeGenerator

Code Generator:
This project is a Java template engine based on Apache Velocity.
Base_build folder is the original code
For the sorted version
Run:
Com. mmk. BaseApplication. java or generate the jar package: run Maven intall


Access path: http: // localhost: 10001/codeUI/index.html


Unavailable ip Address Access

On the logon page, enter the author.

 

Template loading address:

Resources/static/template. json


Add template address:
Src/main/resources/


 


Com. mmk. code. common. propertynamerels. java sets the object field type corresponding to the database field type during initial table loading.








# Foreach ($ field in $ fieldList)
# If ($! {VelocityCount }=$! {FieldList. size ()}) // when the loop reaches the last one
"S. $ {field. columnName}" +
# Else
"S. $ {field. columnName}," +
# End
# End;

$ FieldList Field List
$ {Field. comment} field description
$ {Field. columnName} database field name
$ {Field. inputType} Database Type
$ {Field. validate}
$ {Field. field} object field name
$ {Field. fieldUp} entity field name in uppercase
$ {Field. type} object field type

$ Field. findBy) Enable the special method findBy


Set the corresponding Field Values
\ Resources \ static \ codeUI \ app \ store
$ {Field. inputType} = "input"
# If ($ field. validate = "mobile") lay-verify = "phone" # elseif (! $ Field. nullable) lay-verify = "required" # end
# If ($ field. type = "Date ")



$ {Model. packageName}. $ {model. modulePackage}
$ {Model. model} capital entity name
Lower-case entity name at the first letter of $ {model. modelL}
$ {Model. comment}


* @ Author $ {model. author }$ {date}


$ {Model. tableName} Database Name


Form Verification:
<Input type = "text" name = "$ {field. field} "placeholder =" Enter $ {field. comment} "autocomplete =" off "data-rule =" $ {field. comment}; required; # if ($ {field. validate}) $ {field. validate}; "data-msg =" non-compliant rules "# else" # end value = "$ {$ {model. modelL }. $ {field. field} "/>

Generation:
<Input type = "text" name = "type" placeholder = "Enter the violation type, 0-normal, 1-severe "autocomplete =" off "data-rule =" violation type, 0-average, 1-severe; required; number; "data-msg =" non-compliant rules "value =" $ {cbViolateNotice. type} "/>




SQL concatenation
# If ($ field. type = "String ")
# If ($ field. matchType = 'any ')
SQL. append ("and s. name like '%"). append (search_name). append ("% '");
# Elseif ($ field. matchType = 'eq ')
If (StringUtils. isNotBlank (condition. get $ {field. fieldUp }())){
Sb. append ("and $ {field. columnName} =? $! {VelocityCount }");
Params. put ($! {VelocityCount}, condition. get $ {field. fieldUp }());
}
# Elseif ($ field. matchType = 'left ')
If (StringUtils. isNotBlank (condition. get $ {field. fieldUp }())){
Sb. append ("and $ {field. columnName} like? $! {VelocityCount }");
Params. put ($! {VelocityCount}, condition. get $ {field. fieldUp} () + "% ");
}
# Elseif ($ field. matchType = 'right ')
If (StringUtils. isNotBlank (condition. get $ {field. fieldUp }())){
Sb. append ("and $ {field. columnName} like? $! {VelocityCount }");
Params. put ($! {VelocityCount}, "%" + condition. get $ {field. fieldUp }());
}
# Elseif ($ field. matchType = 'daterange ')
If (condition. get $ {field. fieldUp} Begin ()! = Null ){
Sb. append ("and $ {field. columnName} >=? $! {VelocityCount }");
Params. put ($! {VelocityCount}, condition. get $ {field. fieldUp} Begin ());
}
If (condition. get $ {field. fieldUp} End ()! = Null ){
Sb. append ("and $ {field. columnName} >=? $! {VelocityCount }");
Params. put ($! {VelocityCount}, condition. get $ {field. fieldUp} End ());
}
# End
# Else
# If ($ field. matchType! = 'None ')
If (condition. get $ {field. fieldUp }()! = Null ){
Sb. append ("and $ {field. columnName} =? $! {VelocityCount }");
Params. put ($! {VelocityCount}, condition. get $ {field. fieldUp }());
}
# End
# End


The structure of the simulated file cannot be changed. An error is returned when you delete the file.




Note:
1. When the code is generated, it will be overwritten directly.
2. The jar package generated by maven will have garbled problem: solution: execute java-Dfile. encoding = UTF-8-jar APA_BUILD-1.0.0.jar in the command line


-------------------------------------------------------------------
 


1. When the code is generated, it will be overwritten directly.
2. When tables must be designed
Enter comments for fields
Enter comments in the table
3. database design must include: id (auto-increment), code (uuid, id), create_time, create_code, update_code, update_time, del_flag (logical deletion, 1)




-------------------------------------------------------------

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.