javaweb code generator, focusing on general purpose code generators for javaweb projects

This project is a general code generator for javaWEB projects. It generates corresponding jsp, js, and java files according to database tables and custom code templates, and generates them to the specified path. It is a tool for javaweb project development;

Project open source address: https://gitee.com/okrs.cn/CodeGenerator

Code generator:
This project is a code generator based on Apache Velocity's Java template engine
. The base_build folder is the most original code
for the compiled version
execution:
com. mmk.BaseApplication.java or generate a jar package: run Maven intall


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


unavailable ip access

The login interface input is the author 




 

Template load address:

resources/static/template.json


Add template address:
src/main/resources/


 


com.mmk.code.common.PropertyNameTools.java Set 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 looping 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 method findBy


to set the corresponding field value 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} initial 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="Not Compliant" #else " #end value="${$ {model.modelL}.${field.field}}"/>

generates:
 <input type="text"  name="type" placeholder="请输入违规类型,0-一般,1-严重" autocomplete="off"  data-rule="违规类型,0-一般,1-严重;required;number;" data-msg="不符合规则"  value="${cbViolateNotice.type}"/>
                       
   


sql拼接
#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}())){













        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, and an error will be reported if the file is deleted.




Note:
1. When generating the code, it will be directly overwritten.
2. The jar package generated by maven will have garbled characters: Solution: execute java -Dfile.encoding= on the command line utf-8 -jar APA_BUILD-1.0.0.jar


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


1. When generating the code, it will be directly covered.
2. When the table must be designed, fill in the
fields and fill in the comments
on the comment form.
3. The design in the database must have: id( Auto increment), code (uuid, identity), create_time, create_code, update_code, update_time, del_flag (logical deletion, 1)




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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326087892&siteId=291194637