diff --git a/README.md b/README.md index 7a4895f..191f875 100644 --- a/README.md +++ b/README.md @@ -40,5 +40,5 @@ 确保安装了所需的依赖,然后运行以下命令: ```bash -pip install -r requirements.txt -python main.py \ No newline at end of file +.\cmd_db.bat HelloWorld +.\cmd_dao.bat HelloWorld \ No newline at end of file diff --git a/cmd_dao.bat b/cmd_dao.bat new file mode 100644 index 0000000..b1d17a8 --- /dev/null +++ b/cmd_dao.bat @@ -0,0 +1,20 @@ +@echo off +setlocal + +set "BasePath=./" + +REM 假设已经提供了接口名作为参数 +set "InterfaceName=%~1" + +REM 将接口名转换为小写并设置最终文件名 +for /f "delims=" %%i in ('powershell -Command "('%InterfaceName%').ToLower()"') do set "LowerInterfaceName=%%i" +set "FinalFile=%BasePath%src\dao\%LowerInterfaceName%_dao.go" + +REM 使用 PowerShell 替换接口名称,并指定 UTF-8 编码 +powershell -Command "(Get-Content '%BasePath%etc\template\template_interface.tpl') -replace 'DemoInterface', '%InterfaceName%' | Out-File -FilePath '%BasePath%temp_interface.go' -Encoding UTF8" + +REM 如果需要,将临时文件重命名为最终文件(取决于move Y?N) +move /Y "%BasePath%temp_interface.go" "%FinalFile%" + +endlocal +echo Interface file %LowerInterfaceName%_dao.go generated successfully. \ No newline at end of file diff --git a/cmd_db.bat b/cmd_db.bat index bb9d486..f17da43 100644 --- a/cmd_db.bat +++ b/cmd_db.bat @@ -16,7 +16,7 @@ set DBNAME="fnuoos_test1" set DBHOST="119.23.182.117" set DBPORT="3306" -del "app\db\model\%Table%.go" +del "src\models\%Table%.go" echo start reverse table %Table% diff --git a/etc/template/template_interface.tpl b/etc/template/template_interface.tpl new file mode 100644 index 0000000..2a05d90 --- /dev/null +++ b/etc/template/template_interface.tpl @@ -0,0 +1,5 @@ +package dao + +type DemoInterfaceDao interface { + //TODO:: You can add specific method definitions here +} diff --git a/src/implement/happy_orchard_reward_exchange_records_db.go b/src/implement/happy_orchard_reward_exchange_records_db.go index 9d2c307..96f3236 100644 --- a/src/implement/happy_orchard_reward_exchange_records_db.go +++ b/src/implement/happy_orchard_reward_exchange_records_db.go @@ -11,7 +11,7 @@ type happyOrchardRewardExchangeRecordsDb struct { Db *xorm.Engine } -func NewHappyOrchardRewardExchangeRecordsDb(engine *xorm.Engine) dao.HappyOrchardRewardExchangeRecordsDao { +func NewHappyOrchardRewardExchangeRecordsDb123456(engine *xorm.Engine) dao.HappyOrchardRewardExchangeRecordsDao { return &happyOrchardRewardExchangeRecordsDb{Db: engine} }