cn.schoolwow.quickdao.module.operation.flow.generateEntity.single.GenerateClassTableFlow Maven / Gradle / Ivy
package cn.schoolwow.quickdao.module.operation.flow.generateEntity.single;
import cn.schoolwow.quickdao.domain.entity.Entity;
import cn.schoolwow.quickdao.domain.operation.GenerateJavaSourceFileRequest;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
public class GenerateClassTableFlow implements BusinessFlow {
@Override
public void executeBusinessFlow(FlowContext flowContext) throws Exception {
GenerateJavaSourceFileRequest generateJavaSourceFileRequest = (GenerateJavaSourceFileRequest) flowContext.checkData("generateJavaSourceFileRequest");
Entity databaseEntity = (Entity) flowContext.checkData("databaseEntity");
String entityClassName = (String) flowContext.checkData("entityClassName");
StringBuilder builder = (StringBuilder) flowContext.checkData("builder");
builder.append("package " +generateJavaSourceFileRequest.packageName + (entityClassName.contains(".")?"."+entityClassName.substring(0,entityClassName.lastIndexOf(".")):"") +";\n");
builder.append("import cn.schoolwow.quickdao.annotation.*;\n\n");
if(null!=databaseEntity.comment){
builder.append("@Comment(\""+databaseEntity.comment+"\")\n");
}
if(null!=databaseEntity.tableName){
builder.append("@TableName(\""+databaseEntity.tableName+"\")\n");
}
builder.append("public class "+(entityClassName.contains(".")?entityClassName.substring(entityClassName.lastIndexOf(".")+1):entityClassName)+"{\n");
}
@Override
public String name() {
return "生成实体类的类名部分";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy