当前位置: 首页>>代码示例>>Java>>正文


Java CommentGenerator.addModelClassComment方法代码示例

本文整理汇总了Java中org.mybatis.generator.api.CommentGenerator.addModelClassComment方法的典型用法代码示例。如果您正苦于以下问题:Java CommentGenerator.addModelClassComment方法的具体用法?Java CommentGenerator.addModelClassComment怎么用?Java CommentGenerator.addModelClassComment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mybatis.generator.api.CommentGenerator的用法示例。


在下文中一共展示了CommentGenerator.addModelClassComment方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCompilationUnits

import org.mybatis.generator.api.CommentGenerator; //导入方法依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.7", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    TopLevelClass topLevelClass = new TopLevelClass(introspectedTable
            .getPrimaryKeyType());
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    String rootClass = getRootClass();
    if (rootClass != null) {
        topLevelClass.setSuperClass(new FullyQualifiedJavaType(rootClass));
        topLevelClass.addImportedType(topLevelClass.getSuperClass());
    }

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);
        
        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }

    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);

    for (IntrospectedColumn introspectedColumn : introspectedTable
            .getPrimaryKeyColumns()) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn, context, introspectedTable);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.PRIMARY_KEY)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.PRIMARY_KEY)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn, context, introspectedTable);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.PRIMARY_KEY)) {
                topLevelClass.addMethod(method);
            }
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelPrimaryKeyClassGenerated(
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:69,代码来源:PrimaryKeyGenerator.java

示例2: getCompilationUnits

import org.mybatis.generator.api.CommentGenerator; //导入方法依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getBaseRecordType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    FullyQualifiedJavaType superClass = getSuperClass();
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }
    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);

    List<IntrospectedColumn> introspectedColumns = getColumnsInThisClass();

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass, introspectedTable.getNonBLOBColumns());

        if(includeBLOBColumns()) {
            addParameterizedConstructor(topLevelClass, introspectedTable.getAllColumns());
        }

        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }
    
    String rootClass = getRootClass();
    for (IntrospectedColumn introspectedColumn : introspectedColumns) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn, context, introspectedTable);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn, context, introspectedTable);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.BASE_RECORD)) {
                topLevelClass.addMethod(method);
            }
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:75,代码来源:BaseRecordGenerator.java

示例3: getCompilationUnits

import org.mybatis.generator.api.CommentGenerator; //导入方法依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString(
            "Progress.9", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    TopLevelClass topLevelClass = new TopLevelClass(introspectedTable
            .getRecordWithBLOBsType());
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    String rootClass = getRootClass();
    if (introspectedTable.getRules().generateBaseRecordClass()) {
        topLevelClass.setSuperClass(introspectedTable.getBaseRecordType());
    } else {
        topLevelClass.setSuperClass(introspectedTable.getPrimaryKeyType());
    }
    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);
        
        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }
    
    for (IntrospectedColumn introspectedColumn : introspectedTable
            .getBLOBColumns()) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn, context, introspectedTable);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.RECORD_WITH_BLOBS)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.RECORD_WITH_BLOBS)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn, context, introspectedTable);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.RECORD_WITH_BLOBS)) {
                topLevelClass.addMethod(method);
            }
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelRecordWithBLOBsClassGenerated(
            topLevelClass, introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:69,代码来源:RecordWithBLOBsGenerator.java

示例4: getCompilationUnits

import org.mybatis.generator.api.CommentGenerator; //导入方法依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getBaseRecordType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    FullyQualifiedJavaType superClass = getSuperClass();
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }

    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);
    
    List<IntrospectedColumn> introspectedColumns = introspectedTable.getAllColumns();

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);

        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }

    String rootClass = getRootClass();
    for (IntrospectedColumn introspectedColumn : introspectedColumns) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn, context, introspectedTable);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn, context, introspectedTable);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.BASE_RECORD)) {
                topLevelClass.addMethod(method);
            }
        }
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass,
            introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
开发者ID:DomKing,项目名称:server-utility,代码行数:71,代码来源:SimpleModelGenerator.java

示例5: getCompilationUnits

import org.mybatis.generator.api.CommentGenerator; //导入方法依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getBaseRecordType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    FullyQualifiedJavaType superClass = getSuperClass();
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }


    // 注解
    topLevelClass.addAnnotation("@Data");

    // import
    topLevelClass.addImportedType("lombok.Data");

    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);
    
    List<IntrospectedColumn> introspectedColumns = introspectedTable.getAllColumns();

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);

        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }

    String rootClass = getRootClass();
    for (IntrospectedColumn introspectedColumn : introspectedColumns) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn, context, introspectedTable);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        // 去掉getter setter 方法,使用 lombok

       /* Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn, context, introspectedTable);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.BASE_RECORD)) {
                topLevelClass.addMethod(method);
            }
        }*/
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass,
            introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:80,代码来源:SimpleModelGenerator.java

示例6: getCompilationUnits

import org.mybatis.generator.api.CommentGenerator; //导入方法依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getServiceImplType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    // 实现的接口
    FullyQualifiedJavaType superInterface = new FullyQualifiedJavaType(introspectedTable.getServiceInterfaceType());
    if (superInterface != null) {
        topLevelClass.addSuperInterface(superInterface);
        topLevelClass.addImportedType(superInterface);
    }

    // #### 需要导入的包
    topLevelClass.addImportedType(introspectedTable.getBaseRecordType());
    topLevelClass.addImportedType(FullyQualifiedJavaType.getNewListInstance());
    topLevelClass.addImportedType(new FullyQualifiedJavaType("com.github.pagehelper.PageInfo"));
    topLevelClass.addImportedType("org.springframework.beans.BeanUtils");
    topLevelClass.addImportedType("com.github.pagehelper.PageHelper");


    // 注解

    topLevelClass.addAnnotation("@Service");
    topLevelClass.addImportedType("org.springframework.stereotype.Service");

    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);

    // 方法
    addSaveMethod(topLevelClass);
    addUpdateMethod(topLevelClass);
    addGetByIdMethod(topLevelClass);
    addListPageMethod(topLevelClass);
    addListAllMethod(topLevelClass);
    addGetPageInfoMethod(topLevelClass);

    // 字段
    Field mapper = new Field(introspectedTable.getFullyQualifiedTable().getRequestMappingObjectName() + "Mapper", new FullyQualifiedJavaType(
            introspectedTable.getMyBatis3JavaMapperType()));
    mapper.addAnnotation("@Autowired");
    mapper.setVisibility(JavaVisibility.PRIVATE);
    topLevelClass.addField(mapper);

    topLevelClass.addImportedType(introspectedTable.getMyBatis3JavaMapperType());
    topLevelClass.addImportedType("org.springframework.beans.factory.annotation.Autowired");

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass,
            introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:61,代码来源:ServiceImplGenerator.java

示例7: getCompilationUnits

import org.mybatis.generator.api.CommentGenerator; //导入方法依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getBaseVOType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);

    FullyQualifiedJavaType superClass = getSuperClass();
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }

    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);
    
    List<IntrospectedColumn> introspectedColumns = introspectedTable.getAllColumns();

    if (introspectedTable.isConstructorBased()) {
        addParameterizedConstructor(topLevelClass);

        if (!introspectedTable.isImmutable()) {
            addDefaultConstructor(topLevelClass);
        }
    }

    // 注解
    topLevelClass.addAnnotation("@Data");

    // import
    topLevelClass.addImportedType("lombok.Data");

    String rootClass = getRootClass();
    for (IntrospectedColumn introspectedColumn : introspectedColumns) {
        if (RootClassInfo.getInstance(rootClass, warnings)
                .containsProperty(introspectedColumn)) {
            continue;
        }

        Field field = getJavaBeansField(introspectedColumn, context, introspectedTable);
        if (plugins.modelFieldGenerated(field, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addField(field);
            topLevelClass.addImportedType(field.getType());
        }

        // 去掉getter setter 方法,使用 lombok

       /* Method method = getJavaBeansGetter(introspectedColumn, context, introspectedTable);
        if (plugins.modelGetterMethodGenerated(method, topLevelClass,
                introspectedColumn, introspectedTable,
                Plugin.ModelClassType.BASE_RECORD)) {
            topLevelClass.addMethod(method);
        }

        if (!introspectedTable.isImmutable()) {
            method = getJavaBeansSetter(introspectedColumn, context, introspectedTable);
            if (plugins.modelSetterMethodGenerated(method, topLevelClass,
                    introspectedColumn, introspectedTable,
                    Plugin.ModelClassType.BASE_RECORD)) {
                topLevelClass.addMethod(method);
            }
        }*/
    }

    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass,
            introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:79,代码来源:VOGenerator.java

示例8: getCompilationUnits

import org.mybatis.generator.api.CommentGenerator; //导入方法依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getControllerType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);


    // 字段
    Field serviceMapper = new Field(introspectedTable.getFullyQualifiedTable().getRequestMappingObjectName() + "Service", new FullyQualifiedJavaType(
            introspectedTable.getServiceInterfaceType()));
    serviceMapper.addAnnotation("@Autowired");
    serviceMapper.setVisibility(JavaVisibility.PRIVATE);
    topLevelClass.addField(serviceMapper);

    topLevelClass.addImportedType(introspectedTable.getServiceInterfaceType());
    topLevelClass.addImportedType("org.springframework.beans.factory.annotation.Autowired");


    // 父类
    /*FullyQualifiedJavaType superClass = new FullyQualifiedJavaType(Constants.baseControllerFullName);
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }*/


    // 注解
    topLevelClass.addAnnotation("@Controller");
    topLevelClass.addAnnotation("@RequestMapping(\"/" + introspectedTable.getFullyQualifiedTable().getRequestMappingObjectName() + "\")");

    topLevelClass.addImportedType(new FullyQualifiedJavaType("org.springframework.stereotype.Controller"));
    topLevelClass.addImportedType("org.springframework.web.bind.annotation.RequestMapping");
    topLevelClass.addImportedType("org.springframework.web.bind.annotation.RequestMethod");
    topLevelClass.addImportedType("org.springframework.web.bind.annotation.PathVariable");

    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);

    // 方法
    addSaveMethod(topLevelClass);
    addUpdateMethod(topLevelClass);
    addGetByIdMethod(topLevelClass);
    addListPageMethod(topLevelClass);
    addListAllMethod(topLevelClass);

    // #### 需要导入的包
    topLevelClass.addImportedType(FullyQualifiedJavaType.getNewListInstance());


    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass,
            introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:63,代码来源:ControllerGenerator.java

示例9: getCompilationUnits

import org.mybatis.generator.api.CommentGenerator; //导入方法依赖的package包/类
@Override
public List<CompilationUnit> getCompilationUnits() {
    FullyQualifiedTable table = introspectedTable.getFullyQualifiedTable();
    progressCallback.startTask(getString("Progress.8", table.toString())); //$NON-NLS-1$
    Plugin plugins = context.getPlugins();
    CommentGenerator commentGenerator = context.getCommentGenerator();

    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
            introspectedTable.getControllerType());
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    commentGenerator.addJavaFileComment(topLevelClass);


    // 字段
    Field serviceMapper = new Field(introspectedTable.getFullyQualifiedTable().getRequestMappingObjectName() + "Service", new FullyQualifiedJavaType(
            introspectedTable.getServiceInterfaceType()));
    serviceMapper.addAnnotation("@Autowired");
    serviceMapper.setVisibility(JavaVisibility.PRIVATE);
    topLevelClass.addField(serviceMapper);

    topLevelClass.addImportedType(introspectedTable.getServiceInterfaceType());
    topLevelClass.addImportedType("org.springframework.beans.factory.annotation.Autowired");


    // 父类
    /*FullyQualifiedJavaType superClass = new FullyQualifiedJavaType(Constants.baseControllerFullName);
    if (superClass != null) {
        topLevelClass.setSuperClass(superClass);
        topLevelClass.addImportedType(superClass);
    }*/



    // 注解
    topLevelClass.addAnnotation("@RestController");
    topLevelClass.addAnnotation("@RequestMapping(\"/"+introspectedTable.getFullyQualifiedTable().getRequestMappingObjectName()+"\")");

    topLevelClass.addImportedType(new FullyQualifiedJavaType("org.springframework.web.bind.annotation.RestController"));
    topLevelClass.addImportedType("org.springframework.web.bind.annotation.RequestMapping");
    topLevelClass.addImportedType("org.springframework.web.bind.annotation.RequestMethod");
    topLevelClass.addImportedType("org.springframework.web.bind.annotation.PathVariable");

    commentGenerator.addModelClassComment(topLevelClass, introspectedTable);

    // 方法
    addSaveMethod(topLevelClass);
    addUpdateMethod(topLevelClass);
    addGetByIdMethod(topLevelClass);
    addListPageMethod(topLevelClass);
    addListAllMethod(topLevelClass);

    // #### 需要导入的包
    topLevelClass.addImportedType(FullyQualifiedJavaType.getNewListInstance());


    List<CompilationUnit> answer = new ArrayList<CompilationUnit>();
    if (context.getPlugins().modelBaseRecordClassGenerated(topLevelClass,
            introspectedTable)) {
        answer.add(topLevelClass);
    }
    return answer;
}
 
开发者ID:nextyu,项目名称:summer-mybatis-generator,代码行数:64,代码来源:RestControllerGenerator.java


注:本文中的org.mybatis.generator.api.CommentGenerator.addModelClassComment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。