src/main/java/com/itfsw/mybatis/generator/plugins/IncrementsPlugin.java
private void generatedWithSelective(XmlElement element, IntrospectedTable introspectedTable, boolean hasPrefix) {
        if (this.support()) {
            // 查找 set->if->text
            List<XmlElement> sets = XmlElementTools.findXmlElements(element, "set");
            if (sets.size() > 0) {
                List<XmlElement> ifs = XmlElementTools.findXmlElements(sets.get(0), "if");
                if (ifs.size() > 0) {
                    for (XmlElement xmlElement : ifs) {
                        // 下面为if的text节点
                        List<Element> textEles = xmlElement.getElements();
                        TextElement textEle = (TextElement) textEles.get(0);
                        String[] strs = textEle.getContent().split("=");
                        String columnName = strs[0].trim();
                        IntrospectedColumn introspectedColumn = IntrospectedTableTools.safeGetColumn(introspectedTable, columnName);
                        // 查找是否需要进行增量操作
                        List<Element> incrementEles = PluginTools.getHook(IIncrementsPluginHook.class).incrementSetElementGenerated(introspectedColumn, hasPrefix ? "record." : null, true);
                        if (!incrementEles.isEmpty()) {
                            xmlElement.getElements().clear();
                            xmlElement.getElements().addAll(incrementEles);
                        }
                    }
                }
            }
        }
    }
private void generatedWithSelective(XmlElement element, IntrospectedTable introspectedTable, boolean hasPrefix) {
        if (this.support()) {
            // 查找 set->if->text
            List<XmlElement> sets = XmlElementTools.findXmlElements(element, "set");
            if (sets.size() > 0) {
                List<XmlElement> ifs = XmlElementTools.findXmlElements(sets.get(0), "if");
                if (ifs.size() > 0) {
                    for (XmlElement xmlElement : ifs) {
                        // 下面为if的text节点
                        List<Element> textEles = xmlElement.getElements();
                        TextElement textEle = (TextElement) textEles.get(0);
                        String[] strs = textEle.getContent().split("=");
                        String columnName = strs[0].trim();
                        IntrospectedColumn introspectedColumn = IntrospectedTableTools.safeGetColumn(introspectedTable, columnName);
                        // 查找是否需要进行增量操作
                        List<Element> incrementEles = PluginTools.getHook(IIncrementsPluginHook.class).incrementSetElementGenerated(introspectedColumn, hasPrefix ? "record." : null, true);
                        if (!incrementEles.isEmpty()) {
                            xmlElement.getElements().clear();
                            xmlElement.getElements().addAll(incrementEles);
                        }
                    }
                }
            }
        }
    }
private void generatedWithSelective ( XmlElement element , IntrospectedTable introspectedTable , boolean hasPrefix ) { if ( this . support ( ) ) { // 查找 set->if->text List < XmlElement > sets = XmlElementTools . findXmlElements ( element , "set" ) ; if ( sets . size ( ) > 0 ) { List < XmlElement > ifs = XmlElementTools . findXmlElements ( sets . get ( 0 ) , "if" ) ; if ( ifs . size ( ) > 0 ) { for ( XmlElement xmlElement : ifs ) { // 下面为if的text节点 List < Element > textEles = xmlElement . getElements ( ) ; TextElement textEle = ( TextElement ) textEles . get ( 0 ) ; String [ ] strs = textEle . getContent ( ) . split ( "=" ) ; String columnName = strs [ 0 ] . trim ( ) ; IntrospectedColumn introspectedColumn = IntrospectedTableTools . safeGetColumn ( introspectedTable , columnName ) ; // 查找是否需要进行增量操作 List < Element > incrementEles = PluginTools . getHook ( IIncrementsPluginHook . class ) . incrementSetElementGenerated ( introspectedColumn , hasPrefix ? "record." : null , true ) ; if ( ! incrementEles . isEmpty ( ) ) { xmlElement . getElements ( ) . clear ( ) ; xmlElement . getElements ( ) . addAll ( incrementEles ) ; } } } } } }
有Selective代码生成
@param element
有Selective代码生成