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

Examples of org.mybatis.generator.api.dom.java.Method


   */
  private void addSetBaseRecordMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable, String recordFullType,
      String recordLowerFullType)
  {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("set" + recordFullType); //$NON-NLS-1$
    method.addParameter(new Parameter(new FullyQualifiedJavaType(
        recordFullType), recordLowerFullType));
    method
        .addBodyLine("this." + recordLowerFullType + " = " + recordLowerFullType + ";"); //$NON-NLS-1$
    topLevelClass.addMethod(method);
  }
View Full Code Here


   * @param introspectedTable
   */
  private void addGetPageMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setReturnType(new FullyQualifiedJavaType(
        "com.eatle.utils.Pagination"));
    method.setName("getPage"); //$NON-NLS-1$
    method.addBodyLine("return this.page;"); //$NON-NLS-1$
    topLevelClass.addMethod(method);
  }
View Full Code Here

   * @param introspectedTable
   */
  private void addSetPageMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("setPage"); //$NON-NLS-1$
    method.addParameter(new Parameter(new FullyQualifiedJavaType(
        "com.eatle.utils.Pagination"), "page"));
    method.addBodyLine("this.page = page;"); //$NON-NLS-1$
    topLevelClass.addMethod(method);
  }
View Full Code Here

  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType type = FullyQualifiedJavaType
        .getStringInstance();
    importedTypes.add(type);
    Method method = new Method();
    method.setReturnType(type);
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("showIndex");

    method
        .addBodyLine("Map<String,Object> params = super.getRequestParameters(request);");
    method.addBodyLine("int pageNum = Pagination.CURRENTPAGE;");
    method.addBodyLine("int pageSize = Pagination.PAGESIZE;");
    method.addBodyLine("if(params.containsKey(\"pageNum\")){");
    method
        .addBodyLine("pageNum = Integer.parseInt((String)params.get(\"pageNum\"));");
    method.addBodyLine("}");
    method.addBodyLine("if(params.containsKey(\"numPerPage\")){");
    method
        .addBodyLine("pageSize = Integer.parseInt((String)params.get(\"numPerPage\"));");
    method.addBodyLine("}");
    method.addBodyLine("page = " + serviceObjName
        + ".findPagination(params, pageNum, pageSize);");
    method.addBodyLine("return \"showIndex\";");
    topLevelClass.addImportedTypes(importedTypes);
    topLevelClass.addMethod(method);
  }
View Full Code Here

   */
  private void addDeleteMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("delete");
    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
        "java.io.IOException");
    importedTypes.add(type);
    method.addException(type);

    method
        .addBodyLine("Map<String, Object> json = DwzAjaxJsonUtil.getDefaultAjaxJson();");
    method.addBodyLine("json.put(DwzAjaxJsonUtil.KEY_NAVTABID, navTabId);");
    method.addBodyLine("json.put(DwzAjaxJsonUtil.KEY_CALLBACKTYPE, \"\");");
    method.addBodyLine("if(" + recordLowerFullType + " == null){");
    method.addBodyLine("json.put(DwzAjaxJsonUtil.KEY_STATUSCODE, 300);");
    method.addBodyLine("json.put(DwzAjaxJsonUtil.KEY_MESSAGE, \"操作失败!\");");
    method.addBodyLine("}else{");
    method.addBodyLine(serviceObjName + ".delete(" + recordLowerFullType
        + ");");
    method.addBodyLine("}");
    method.addBodyLine("super.writeMap(json);");
    topLevelClass.addImportedTypes(importedTypes);
    topLevelClass.addMethod(method);
  }
View Full Code Here

  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType type = FullyQualifiedJavaType
        .getStringInstance();
    importedTypes.add(type);
    Method method = new Method();
    method.setReturnType(type);
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("showUpdate");

    method.addBodyLine(recordLowerFullType + " = " + serviceObjName
        + ".findById(" + recordLowerFullType + ".getId());");
    method.addBodyLine("return \"showUpdate\";");
    topLevelClass.addImportedTypes(importedTypes);
    topLevelClass.addMethod(method);
  }
View Full Code Here

   */
  private void addUpdateMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("update");

    method
        .addBodyLine("Map<String,Object> json = DwzAjaxJsonUtil.getDefaultAjaxJson();");
    method.addBodyLine("json.put(DwzAjaxJsonUtil.KEY_NAVTABID, navTabId);");
    method.addBodyLine("if(" + recordLowerFullType + " == null){");
    method.addBodyLine("json.put(DwzAjaxJsonUtil.KEY_STATUSCODE, 300);");
    method.addBodyLine("json.put(DwzAjaxJsonUtil.KEY_MESSAGE, \"操作失败!\");");
    method.addBodyLine("}else{");
    method.addBodyLine(serviceObjName + ".update(" + recordLowerFullType
        + ");");
    method.addBodyLine("}");
    method.addBodyLine("super.writeMap(json);");
    method.addException(new FullyQualifiedJavaType("java.io.IOException"));
    topLevelClass.addImportedTypes(importedTypes);
    topLevelClass.addMethod(method);
  }
View Full Code Here

  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType type = FullyQualifiedJavaType
        .getStringInstance();
    importedTypes.add(type);
    Method method = new Method();
    method.setReturnType(type);
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("showAdd");
    method.addBodyLine("return \"showAdd\";");
    topLevelClass.addImportedTypes(importedTypes);
    topLevelClass.addMethod(method);
  }
View Full Code Here

   */
  private void addAddMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    Method method = new Method();
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("add");
    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
        "java.io.IOException");
    importedTypes.add(type);
    method.addException(type);

    method
        .addBodyLine("Map<String,Object> json = DwzAjaxJsonUtil.getDefaultAjaxJson();");
    method.addBodyLine("json.put(DwzAjaxJsonUtil.KEY_NAVTABID, navTabId);");
    method.addBodyLine("if(" + recordLowerFullType + " == null){");
    method.addBodyLine("json.put(DwzAjaxJsonUtil.KEY_STATUSCODE, 300);");
    method.addBodyLine("json.put(DwzAjaxJsonUtil.KEY_MESSAGE, \"操作失败!\");");
    method.addBodyLine("}else{");
    method.addBodyLine(serviceObjName + ".add(" + recordLowerFullType
        + ");");
    method.addBodyLine("}");
    method.addBodyLine("super.writeMap(json);");
    topLevelClass.addImportedTypes(importedTypes);
    topLevelClass.addMethod(method);
  }
View Full Code Here

    Field tmpField = new Field(fieldName, fieldType);
    tmpField.setVisibility(JavaVisibility.PRIVATE);
    tmpField.addJavaDocLine(javaDocLine);
    topLevelClass.addField(tmpField);

    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);

    Method getMethod = new Method();
    getMethod.setName("get" + fieldName.toUpperCase().substring(0, 1)
        + fieldName.substring(1));

    getMethod.setReturnType(fieldType);
    getMethod.setVisibility(JavaVisibility.PUBLIC);
    getMethod.addBodyLine("return this." + fieldName + ";");

    topLevelClass.addMethod(getMethod);

  }
View Full Code Here

TOP

Related Classes of org.mybatis.generator.api.dom.java.Method

Copyright © 2018 www.massapicom. 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.