Package org.mybatis.generator.api.dom.java

Examples of org.mybatis.generator.api.dom.java.Method.addParameter()


    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("findByCriteria");
    FullyQualifiedJavaType pType = new FullyQualifiedJavaType(
        introspectedTable.getExampleType());
    importedTypes.add(pType);
    method.addParameter(new Parameter(pType, "criteria"));
    method
        .addBodyLine("return " + mapperObjName + ".selectByCriteria(criteria);");
    method.addAnnotation("@Override");
    topLevelClass.addImportedTypes(importedTypes);
    topLevelClass.addMethod(method);
View Full Code Here


    importedTypes.add(returnType);
    Method method = new Method();
    method.setReturnType(returnType);
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("findById");
    method.addParameter(new Parameter(
        new FullyQualifiedJavaType("long"), "id"))
    // return userMapper.selectByPrimaryKey(id);
    method
        .addBodyLine("return " + mapperObjName + ".selectByPrimaryKey(id);");
    method.addAnnotation("@Override");
View Full Code Here

    importedTypes.add(returnType);
    Method method = new Method();
    method.setReturnType(returnType);
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("findPagination");
    method.addParameter(new Parameter(type, "queryMap"))
    method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "currentPage"));// int currentPage
    method.addParameter(new Parameter(FullyQualifiedJavaType .getIntInstance(), "pageSize"));// int pageSize
    method.addBodyLine("" + recordFullType + "Criteria " + recordLowCaseFullType + "Criteria = new " + recordFullType + "Criteria();");
    method.addBodyLine("//Criteria criteria = " + recordLowCaseFullType + "Criteria.createCriteria();");
    method.addBodyLine("// 设置搜索条件参数");
View Full Code Here

    Method method = new Method();
    method.setReturnType(returnType);
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("findPagination");
    method.addParameter(new Parameter(type, "queryMap"))
    method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "currentPage"));// int currentPage
    method.addParameter(new Parameter(FullyQualifiedJavaType .getIntInstance(), "pageSize"));// int pageSize
    method.addBodyLine("" + recordFullType + "Criteria " + recordLowCaseFullType + "Criteria = new " + recordFullType + "Criteria();");
    method.addBodyLine("//Criteria criteria = " + recordLowCaseFullType + "Criteria.createCriteria();");
    method.addBodyLine("// 设置搜索条件参数");
    method.addBodyLine("//if(queryMap != null){");
View Full Code Here

    method.setReturnType(returnType);
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("findPagination");
    method.addParameter(new Parameter(type, "queryMap"))
    method.addParameter(new Parameter(FullyQualifiedJavaType.getIntInstance(), "currentPage"));// int currentPage
    method.addParameter(new Parameter(FullyQualifiedJavaType .getIntInstance(), "pageSize"));// int pageSize
    method.addBodyLine("" + recordFullType + "Criteria " + recordLowCaseFullType + "Criteria = new " + recordFullType + "Criteria();");
    method.addBodyLine("//Criteria criteria = " + recordLowCaseFullType + "Criteria.createCriteria();");
    method.addBodyLine("// 设置搜索条件参数");
    method.addBodyLine("//if(queryMap != null){");
    method.addBodyLine("//if(queryMap.containsKey(\"username\")) {");
View Full Code Here

    method.setReturnType(returnType);

    method.setName("selectCount"
        + introspectedTable.getSelectByExampleStatementId()
            .substring(6));
    method.addParameter(new Parameter(type, "example")); //$NON-NLS-1$ 
    method.addJavaDocLine("/**");
    method.addJavaDocLine(" * @Description : 根据查询条件获取总的记录数量");
    method.addJavaDocLine(" */");

    interfaze.addImportedTypes(importedTypes);
 
View Full Code Here

    importedTypes.add(listType);
    returnType.addTypeArgument(listType);
    method.setReturnType(returnType);

    method.setName("selectByMap");
    method.addParameter(new Parameter(type, "paramMap")); //$NON-NLS-1$ 
    method.addSuppressTypeWarningsAnnotation();
    method.addJavaDocLine("/**");
    method.addJavaDocLine(" * @Description : 通过map参数进行查询");
    method.addJavaDocLine(" */");

 
View Full Code Here

    Method setMethod = new Method();
    setMethod.setName("set" + fieldName.toUpperCase().substring(0, 1)
        + fieldName.substring(1));
    Parameter param = new Parameter(fieldType, fieldName);
    setMethod.addParameter(param);
    setMethod.setVisibility(JavaVisibility.PUBLIC);
    setMethod.addBodyLine("this." + fieldName + "=" + fieldName + ";");

    topLevelClass.addMethod(setMethod);
View Full Code Here

    addField("startIndex", intType, topLevelClass, "// 开始索引号");
    addField("pageSize", intType, topLevelClass, "// 每页大小");

    Method newConstructorMethod = new Method();
    newConstructorMethod.setConstructor(true);
    newConstructorMethod.addParameter(new Parameter(intType, "pageSize"));
    newConstructorMethod.addParameter(new Parameter(intType, "startIndex"));
    newConstructorMethod.addBodyLine("this();");
    newConstructorMethod.addBodyLine("this.pageSize=pageSize;");
    newConstructorMethod.addBodyLine("this.startIndex=startIndex;");
    newConstructorMethod.setVisibility(JavaVisibility.PUBLIC);
View Full Code Here

    addField("pageSize", intType, topLevelClass, "// 每页大小");

    Method newConstructorMethod = new Method();
    newConstructorMethod.setConstructor(true);
    newConstructorMethod.addParameter(new Parameter(intType, "pageSize"));
    newConstructorMethod.addParameter(new Parameter(intType, "startIndex"));
    newConstructorMethod.addBodyLine("this();");
    newConstructorMethod.addBodyLine("this.pageSize=pageSize;");
    newConstructorMethod.addBodyLine("this.startIndex=startIndex;");
    newConstructorMethod.setVisibility(JavaVisibility.PUBLIC);
    newConstructorMethod.setName(topLevelClass.getType().getShortName());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.