1. 程式人生 > 其它 >修改mybatis-generator-gui生成的程式碼

修改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 真的是一個很棒的命令