src/main/java/com/itfsw/mybatis/generator/plugins/ExampleEnhancedPlugin.java
@Deprecated
    private void addAndIfMethodToCriteria(TopLevelClass topLevelClass, InnerClass innerClass, IntrospectedTable introspectedTable) {
        // 添加接口CriteriaAdd
        InnerInterface criteriaAddInterface = new InnerInterface("ICriteriaAdd");
        criteriaAddInterface.setVisibility(JavaVisibility.PUBLIC);
        criteriaAddInterface.addAnnotation("@Deprecated");
        logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "增加接口ICriteriaAdd");

        // ICriteriaAdd增加接口add
        Method addMethod = JavaElementGeneratorTools.generateMethod(
                "add",
                JavaVisibility.DEFAULT,
                innerClass.getType(),
                new Parameter(innerClass.getType(), "add")
        );
        commentGenerator.addGeneralMethodComment(addMethod, introspectedTable);
        FormatTools.addMethodWithBestPosition(criteriaAddInterface, addMethod);
        logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "." + criteriaAddInterface.getType().getShortName() + "增加方法add");

        InnerClass innerClassWrapper = new InnerInterfaceWrapperToInnerClass(criteriaAddInterface);
        // 添加注释
        commentGenerator.addClassComment(innerClassWrapper, introspectedTable);
        innerClass.addInnerClass(innerClassWrapper);

        // 添加andIf方法
        Method andIfMethod = JavaElementGeneratorTools.generateMethod(
                "andIf",
                JavaVisibility.PUBLIC,
                innerClass.getType(),
                new Parameter(FullyQualifiedJavaType.getBooleanPrimitiveInstance(), "ifAdd"),
                new Parameter(criteriaAddInterface.getType(), "add")
        );
        andIfMethod.addAnnotation("@Deprecated");
        commentGenerator.addGeneralMethodComment(andIfMethod, introspectedTable);
        andIfMethod = JavaElementGeneratorTools.generateMethodBody(
                andIfMethod,
                "if (ifAdd) {",
                "add.add(this);",
                "}",
                "return this;"
        );
        FormatTools.addMethodWithBestPosition(innerClass, andIfMethod);
        logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "增加方法andIf");
    }
@Deprecated
    private void addAndIfMethodToCriteria(TopLevelClass topLevelClass, InnerClass innerClass, IntrospectedTable introspectedTable) {
        // 添加接口CriteriaAdd
        InnerInterface criteriaAddInterface = new InnerInterface("ICriteriaAdd");
        criteriaAddInterface.setVisibility(JavaVisibility.PUBLIC);
        criteriaAddInterface.addAnnotation("@Deprecated");
        logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "增加接口ICriteriaAdd");

        // ICriteriaAdd增加接口add
        Method addMethod = JavaElementGeneratorTools.generateMethod(
                "add",
                JavaVisibility.DEFAULT,
                innerClass.getType(),
                new Parameter(innerClass.getType(), "add")
        );
        commentGenerator.addGeneralMethodComment(addMethod, introspectedTable);
        FormatTools.addMethodWithBestPosition(criteriaAddInterface, addMethod);
        logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "." + criteriaAddInterface.getType().getShortName() + "增加方法add");

        InnerClass innerClassWrapper = new InnerInterfaceWrapperToInnerClass(criteriaAddInterface);
        // 添加注释
        commentGenerator.addClassComment(innerClassWrapper, introspectedTable);
        innerClass.addInnerClass(innerClassWrapper);

        // 添加andIf方法
        Method andIfMethod = JavaElementGeneratorTools.generateMethod(
                "andIf",
                JavaVisibility.PUBLIC,
                innerClass.getType(),
                new Parameter(FullyQualifiedJavaType.getBooleanPrimitiveInstance(), "ifAdd"),
                new Parameter(criteriaAddInterface.getType(), "add")
        );
        andIfMethod.addAnnotation("@Deprecated");
        commentGenerator.addGeneralMethodComment(andIfMethod, introspectedTable);
        andIfMethod = JavaElementGeneratorTools.generateMethodBody(
                andIfMethod,
                "if (ifAdd) {",
                "add.add(this);",
                "}",
                "return this;"
        );
        FormatTools.addMethodWithBestPosition(innerClass, andIfMethod);
        logger.debug("itfsw(Example增强插件):" + topLevelClass.getType().getShortName() + "." + innerClass.getType().getShortName() + "增加方法andIf");
    }
@ Deprecated private void addAndIfMethodToCriteria ( TopLevelClass topLevelClass , InnerClass innerClass , IntrospectedTable introspectedTable ) { // 添加接口CriteriaAdd InnerInterface criteriaAddInterface = new InnerInterface ( "ICriteriaAdd" ) ; criteriaAddInterface . setVisibility ( JavaVisibility . PUBLIC ) ; criteriaAddInterface . addAnnotation ( "@Deprecated" ) ; logger . debug ( "itfsw(Example增强插件):" + topLe e Class.getType ( ).getSh o r t Name() + "." + i ner l ss.getType ( ).getSh o r t Name() + "增加 接 口 C iteriaAdd"); // ICriteriaAdd增加接口add Method addMethod = JavaElementGeneratorTools . generateMethod ( "add" , JavaVisibility . DEFAULT , innerClass . getType ( ) , new Parameter ( innerClass . getType ( ) , "add" ) ) ; commentGenerator . addGeneralMethodComment ( addMethod , introspectedTable ) ; FormatTools . addMethodWithBestPosition ( criteriaAddInterface , addMethod ) ; logger . debug ( "itfsw(Example增强插件):" + topLe e Class.getType ( ).getSh o r t Name() + "." + i ner l ss.getType ( ).getSh o r t Name() + "." + c ite i AddInterface.getType ( ).getSh o r t Name() + "增加 方 法 d "); InnerClass innerClassWrapper = new InnerInterfaceWrapperToInnerClass ( criteriaAddInterface ) ; // 添加注释 commentGenerator . addClassComment ( innerClassWrapper , introspectedTable ) ; innerClass . addInnerClass ( innerClassWrapper ) ; // 添加andIf方法 Method andIfMethod = JavaElementGeneratorTools . generateMethod ( "andIf" , JavaVisibility . PUBLIC , innerClass . getType ( ) , new Parameter ( FullyQualifiedJavaType . getBooleanPrimitiveInstance ( ) , "ifAdd" ) , new Parameter ( criteriaAddInterface . getType ( ) , "add" ) ) ; andIfMethod . addAnnotation ( "@Deprecated" ) ; commentGenerator . addGeneralMethodComment ( andIfMethod , introspectedTable ) ; andIfMethod = JavaElementGeneratorTools . generateMethodBody ( andIfMethod , "if (ifAdd) {" , "add.add(this);" , "}" , "return this;" ) ; FormatTools . addMethodWithBestPosition ( innerClass , andIfMethod ) ; logger . debug ( "itfsw(Example增强插件):" + topLe e Class.getType ( ).getSh o r t Name() + "." + i ner l ss.getType ( ).getSh o r t Name() + "增加 方 法 n If"); }
增强Criteria的链式调用，添加andIf(boolean addIf, CriteriaAdd add)方法，实现链式调用中按条件增加查询语句
@param topLevelClass
@param innerClass
@param introspectedTable
增强Criteria的链式调用，添加andIf ( boolean addIf CriteriaAdd add ) 方法，实现链式调用中按条件增加查询语句