zoukankan      html  css  js  c++  java
  • 修改mybatis-generator-gui生成的代码

    本想改 mybatis-generator-gui Java代码,但是看到要修改的部分是在一个jar包中

     改jar包的话得找到源码,修改后重新打包,觉得好麻烦

    就选择了使用bat二次操作

    @echo off
    
    :: 插入andOther
    for /r %%i in (*Example.java) do (
    call %~dp0JavaOther.bat %%~fi
    )
    
    :: 插入inset
    for /r %%i in (*.xml) do (
    call %~dp0XmlInsert.bat %%~fi
    )
    
    :: 复制xml
    for /r %%i in (*.xml) do (
    copy "%%~fi" %%~niExtend.xml
    )
    @echo off
    
    setlocal enabledelayedexpansion
    
    :: 等号两边不能有空格
    :: 变量是变量得用惊叹号
    :: /a用于变量数字计算
    
    set "Str01=        public Criteria andOther(String condition, Object value) {"
    set "Str02=            addCriterion(condition, value, condition);"
    set "Str03=            return (Criteria) this;"
    set "Str04=        }"
    
    set XmlFile="%1"
    
    echo %XmlFile%
    
    for /f "tokens=1* delims=:" %%i in ('findstr /i /n /c:"class Criteria" %XmlFile%') do (
    echo %%i
    set /a HangHao=%%i+3
    echo !HangHao!
    )
    
    (for /f "tokens=1* delims=:" %%i in ('findstr /n . %XmlFile%') do (
    echo %%j
    if %%i equ !HangHao! echo !Str01! & echo !Str02! & echo !Str03! & echo !Str04!
    )) > lcx.txt
    
    move lcx.txt %XmlFile%
    
    pause
    @echo off
    
    setlocal enabledelayedexpansion
    
    :: 等号两边不能有空格
    :: 变量是变量得用惊叹号
    
    set "Str01=    <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">"
    set "Str02=      SELECT LAST_INSERT_ID()"
    set "Str03=    </selectKey>"
    
    set XmlFile="%1"
    
    echo %XmlFile%
    
    for /f "tokens=1* delims=:" %%i in ('findstr /i /n "id="insert"" %XmlFile%') do (
    echo %%i
    set HangHao=%%i
    echo !HangHao!
    )
    
    (for /f "tokens=1* delims=:" %%i in ('findstr /n . %XmlFile%') do (
    echo %%j
    if %%i equ !HangHao! echo !Str01! & echo !Str02! & echo !Str03!
    )) > lcx.txt
    
    move lcx.txt %XmlFile%
    
    pause

     不得不说 findstr 真的是一个很棒的命令

  • 相关阅读:
    HDU 3033 I love sneakers!
    HDU 1712 ACboy needs your help
    FZU 1608 Huge Mission
    HDU 3394 Railway
    【MySQL】20个经典面试题,全部答对月薪10k+
    mysql故障解决笔记
    mysql 索引类型
    linux禁用锁定和解除解锁用户账号的方法
    Linux服务器制定mysql数据库备份的计划任务
    网站服务器安全防范小知识
  • 原文地址:https://www.cnblogs.com/LcxSummer/p/15481549.html
Copyright © 2011-2022 走看看