Examples of FullyQualifiedJavaType


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

    String serviceInterfaceFullName = serveicePackge + ".I"
        + recordFullType + "Service";
    recordLowCaseFullType = recordFullType.substring(0, 1).toLowerCase()
        + recordFullType.substring(1);
    mapperObjName = recordLowCaseFullType + "Mapper";
    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
        serviceInterfaceFullName);
    Interface interfaze = new Interface(type);
    interfaze.setVisibility(JavaVisibility.PUBLIC);
    addAddMethod(interfaze, introspectedTable);
    addDeleteMethod(interfaze, introspectedTable);
    addUpdateMethod(interfaze, introspectedTable);
    addFindPaginationMethod(interfaze, introspectedTable);
    addFindByIdMethod(interfaze, introspectedTable);
    addFindAllMethod(interfaze, introspectedTable);
    addFindByCriteriaMethod(interfaze, introspectedTable);
    addGetExportDataMethod(interfaze, introspectedTable);

    // 生成Service实现类
    String serviceImplFullName = serveiceImplPackge + "." + recordFullType + "ServiceImpl";
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    importedTypes.add(type)// 导入接口
    type = new FullyQualifiedJavaType(serviceImplFullName);
    TopLevelClass topLevelClass = new TopLevelClass(type);
    topLevelClass.setVisibility(JavaVisibility.PUBLIC);
    type = new FullyQualifiedJavaType(serviceInterfaceFullName);
    topLevelClass.addSuperInterface(type);
    topLevelClass.addAnnotation("@Service(\"" + recordLowCaseFullType + "Service\")");
    type = new FullyQualifiedJavaType("org.springframework.stereotype.Service");
    importedTypes.add(type);

    // add field, getter, setter for orderby clause
    // @Resource private UserMapper userMapper;
    type = new FullyQualifiedJavaType("javax.annotation.Resource");
    importedTypes.add(type);

    Field field = new Field();
    field.setVisibility(JavaVisibility.PRIVATE);
    String mapper = introspectedTable.getMyBatis3JavaMapperType();
    type = new FullyQualifiedJavaType(mapper);
    field.setType(type);
    idx = mapper.lastIndexOf(".");
    if (idx != -1)
    {
      mapper = mapper.substring(idx + 1);
View Full Code Here

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

  private void addGetExportDataMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType returnType = new FullyQualifiedJavaType("java.util.LinkedHashMap");
    returnType.addTypeArgument(new FullyQualifiedJavaType("java.lang.String"));
    returnType.addTypeArgument(new FullyQualifiedJavaType("java.util.List"));
    importedTypes.add(returnType);
    Method method = new Method();
    method.addAnnotation("@Override");
    method.addSuppressTypeWarningsAnnotation();
    method.setReturnType(returnType);
View Full Code Here

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

   */
  private void addFindByCriteriaMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType returnType = FullyQualifiedJavaType.getNewListInstance();
    returnType.addTypeArgument(new FullyQualifiedJavaType(introspectedTable.getBaseRecordType()));
    importedTypes.add(returnType);
    Method method = new Method();
    method.setReturnType(returnType);
    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);");
View Full Code Here

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

   */
  private void addFindAllMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType returnType = FullyQualifiedJavaType
        .getNewListInstance();
    returnType.addTypeArgument(new FullyQualifiedJavaType(introspectedTable
        .getBaseRecordType()));
    importedTypes.add(returnType);
    Method method = new Method();
    method.setReturnType(returnType);
    method.setVisibility(JavaVisibility.PUBLIC);
View Full Code Here

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

   */
  private void addFindByIdMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType returnType = new FullyQualifiedJavaType(
        introspectedTable.getBaseRecordType());
    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");
    topLevelClass.addImportedTypes(importedTypes);
View Full Code Here

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

   */
  private void addFindPaginationMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType type = FullyQualifiedJavaType
        .getNewMapInstance();
    type.addTypeArgument(FullyQualifiedJavaType.getStringInstance());
    type.addTypeArgument(FullyQualifiedJavaType.getObjectInstance());
    importedTypes.add(type);

    FullyQualifiedJavaType returnType = new FullyQualifiedJavaType(
        "com.eatle.utils.Pagination");
    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("// 设置搜索条件参数");
    method.addBodyLine("//if(queryMap != null){");
    method.addBodyLine("//if(queryMap.containsKey(\"username\")) {");
    method.addBodyLine("//criteria.andUserNameLike(\"%\"+(String)queryMap.get(\"username\")+\"%\");");
    method.addBodyLine("//}");
    method.addBodyLine("//if(queryMap.containsKey(\"email\")){");
    method.addBodyLine("//criteria.andEmailLike((String)queryMap.get(\"email\"));");
    method.addBodyLine("//}");
    method.addBodyLine("//}");
    method.addBodyLine("// 设置分页参数");
    method.addBodyLine(recordLowCaseFullType + "Criteria.setPageSize(pageSize);");
    method.addBodyLine(recordLowCaseFullType + "Criteria.setStartIndex((currentPage-1)*pageSize);");
    method.addBodyLine("List<" + recordFullType + "> items = " + mapperObjName + ".selectByCriteria(" + recordLowCaseFullType + "Criteria);");
    method.addBodyLine("int totalCount = (int)" + mapperObjName + ".selectCountByCriteria(" + recordLowCaseFullType + "Criteria);");
    method.addBodyLine("return new Pagination(pageSize, currentPage, totalCount, items);");
    method.addAnnotation("@Override");

    // import com.eatle.persistent.pojo.admin.ObjectCriteria.Criteria;
    FullyQualifiedJavaType pType = new FullyQualifiedJavaType(
        introspectedTable.getExampleType() + ".Criteria");
    importedTypes.add(pType);

    topLevelClass.addImportedTypes(importedTypes);
    topLevelClass.addMethod(method);
View Full Code Here

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

   */
  private void addUpdateMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
        introspectedTable.getBaseRecordType());
    importedTypes.add(type);

    Method method = new Method();
    method.setReturnType(new FullyQualifiedJavaType("int"));
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("update");
    method.addParameter(new Parameter(type, "entity"));
    method.addBodyLine("return " + mapperObjName + ".updateByPrimaryKeySelective(entity);");
    method.addAnnotation("@Override");
View Full Code Here

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

   */
  private void addDeleteMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
        introspectedTable.getBaseRecordType());
    importedTypes.add(type);

    Method method = new Method();
    method.setReturnType(new FullyQualifiedJavaType("int"));
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("delete");
    method.addParameter(new Parameter(type, "entity"));
    method.addBodyLine("return " + mapperObjName + ".deleteByPrimaryKey(entity.getId());");
    method.addAnnotation("@Override");
View Full Code Here

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

   */
  private void addAddMethod(TopLevelClass topLevelClass,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
        introspectedTable.getBaseRecordType());
    importedTypes.add(type);

    Method method = new Method();
    method.setReturnType(new FullyQualifiedJavaType("int"));
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("add");
    method.addParameter(new Parameter(type, "entity"));
    method.addBodyLine("return " + mapperObjName + ".insert(entity);");
    method.addAnnotation("@Override");
View Full Code Here

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

  protected void addAddMethod(Interface interfaze,
      IntrospectedTable introspectedTable)
  {
    Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
    FullyQualifiedJavaType type = new FullyQualifiedJavaType(
        introspectedTable.getBaseRecordType());
    importedTypes.add(type);
    Method method = new Method();
    method.setReturnType(new FullyQualifiedJavaType("int"));
    method.setVisibility(JavaVisibility.PUBLIC);
    method.setName("add");
    method.addParameter(new Parameter(type, "entity"))
    method.addJavaDocLine("/**\n" + "* @Description:\n" + "* @param entity\n" + "*/");
    interfaze.addImportedTypes(importedTypes);
 
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.