src/main/java/com/itfsw/mybatis/generator/plugins/utils/FormatTools.java
public static void addMethodWithBestPosition(Interface interfacz, Method method) {
        // import
        Set<FullyQualifiedJavaType> importTypes = new TreeSet<>();
        // 返回
        if (method.getReturnType() != null) {
            importTypes.add(method.getReturnType());
            importTypes.addAll(method.getReturnType().getTypeArguments());
        }
        // 参数 比较特殊的是ModelColumn生成的Column
        for (Parameter parameter : method.getParameters()) {
            boolean flag = true;
            for (String annotation : parameter.getAnnotations()) {
                if (annotation.startsWith("@Param")) {
                    importTypes.add(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Param"));

                    if (annotation.matches(".*selective.*") && parameter.getType().getShortName().equals(ModelColumnPlugin.ENUM_NAME)) {
                        flag = false;
                    }
                }
            }
            if (flag) {
                importTypes.add(parameter.getType());
                importTypes.addAll(parameter.getType().getTypeArguments());
            }
        }
        interfacz.addImportedTypes(importTypes);
        addMethodWithBestPosition(method, interfacz.getMethods());
    }
public static void addMethodWithBestPosition(Interface interfacz, Method method) {
        // import
        Set<FullyQualifiedJavaType> importTypes = new TreeSet<>();
        // 返回
        if (method.getReturnType() != null) {
            importTypes.add(method.getReturnType());
            importTypes.addAll(method.getReturnType().getTypeArguments());
        }
        // 参数 比较特殊的是ModelColumn生成的Column
        for (Parameter parameter : method.getParameters()) {
            boolean flag = true;
            for (String annotation : parameter.getAnnotations()) {
                if (annotation.startsWith("@Param")) {
                    importTypes.add(new FullyQualifiedJavaType("org.apache.ibatis.annotations.Param"));

                    if (annotation.matches(".*selective.*") && parameter.getType().getShortName().equals(ModelColumnPlugin.ENUM_NAME)) {
                        flag = false;
                    }
                }
            }
            if (flag) {
                importTypes.add(parameter.getType());
                importTypes.addAll(parameter.getType().getTypeArguments());
            }
        }
        interfacz.addImportedTypes(importTypes);
        addMethodWithBestPosition(method, interfacz.getMethods());
    }
在最佳位置添加方法
@param interfacz
@param method