The project is a common code generator for the Javaweb project, generates the corresponding Jsp,js,java file according to the database table and custom code template, generates the Javaweb Project development tool under the specified path;
Project Open Source Address: https://gitee.com/okrs.cn/CodeGenerator
Code generator:
The project is a code generator based on the Apache Velocity Java template engine
Base_build folder is the most original code
For the finishing version
Perform:
Com.mmk.BaseApplication.java or generate JAR package: Run Maven intall
Access path: http://localhost:10001/codeUI/index.html
Unavailable IP Access
The login interface was entered by the author
Template Load Address:
Resources/static/template.json
Add Template Address:
src/main/resources/
Com.mmk.code.common.PropertyNameTools.java the Entity field type corresponding to the database field type when the table is initially loaded
#foreach ($field in $fieldList)
#if ($!{ velocitycount}==$! {fieldlist.size ()}) When you loop to 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} entity Field name
${field.fieldup} entity Field name uppercase
${field.type} entity field type
$field. FindBy) Enable special methods FindBy
The corresponding field value settings above
\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} Uppercase Entity name
${model.modell} first Letter Lowercase entity name
${model.comment}
* @author ${model.author} ${date}
${model.tablename} database name
Form validation:
<input type= "text" Name= "${field.field}" placeholder= "Please enter ${field.comment}" autocomplete= "Off" data-rule= "${ field.comment};required; #if (${field.validate}) ${field.validate}; "data-msg=" does not conform to the rules #else "#end value=" ${${ Model.modell}.${field.field}} "/>
Generated:
<input type= "text" name= "type" placeholder= "Please enter a violation type, 0-general, 1-critical" autocomplete= "off" data-rule= "violation type, 0-general, 1-severe; Required;number; "data-msg=" does not conform to the rules "value=" ${cbviolatenotice.type} "/>
SQL stitching
#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 simulation file structure cannot be changed, and deleting the file will cause an error.
Attention:
1, generated code will be directly covered
2, MAVEN generated jar package will be garbled problem: Workaround: Command line execution Java-dfile.encoding=utf-8-jar Apa_build-1.0.0.jar
-------------------------------------------------------------------
1, generated code will be directly covered
2, must design the table when
Fields Fill in comments
Fill in the comments on the table
3, the database design must have: ID (self-increment), code (UUID, Identity), Create_time,create_code,update_code,update_time,del_flag (tombstone, 1)
-------------------------------------------------------------
Javaweb code generator, focusing on javaweb common purpose code generator