From c37ec92bfc03b59942493af1891dd18e1ca3c0d5 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 31 Aug 2024 10:45:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd_master_db.bat | 25 +++++++++++++++++++++++++ cmd_super_db.bat | 2 +- src/model/agent.go | 6 +++--- src/model/medium.go | 6 +++--- 4 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 cmd_master_db.bat diff --git a/cmd_master_db.bat b/cmd_master_db.bat new file mode 100644 index 0000000..041af6d --- /dev/null +++ b/cmd_master_db.bat @@ -0,0 +1,25 @@ +@echo off + +set Table=* +set TName="" +set one=%1 + +if "%one%" NEQ "" ( + set Table=%one% + set TName="^%one%$" +) + +set BasePath="./" +set DBUSER="root" +set DBPSW="Fnuo123com@" +set DBNAME="advertisement" +set DBHOST="119.23.182.117" +set DBPORT="3306" + +del "src\model\%Table%.go" + +echo start reverse table %Table% + +xorm reverse mysql "%DBUSER%:%DBPSW%@tcp(%DBHOST%:%DBPORT%)/%DBNAME%?charset=utf8" %BasePath%/etc/db_tpl %BasePath%/src/model/ %TName% + +echo end \ No newline at end of file diff --git a/cmd_super_db.bat b/cmd_super_db.bat index 9b7480a..1ba399f 100644 --- a/cmd_super_db.bat +++ b/cmd_super_db.bat @@ -16,7 +16,7 @@ set DBNAME="super_advertisement" set DBHOST="119.23.182.117" set DBPORT="3306" -del "src\models\%Table%.go" +del "src\model\%Table%.go" echo start reverse table %Table% diff --git a/src/model/agent.go b/src/model/agent.go index 703db69..d883370 100644 --- a/src/model/agent.go +++ b/src/model/agent.go @@ -1,13 +1,13 @@ package model type Agent struct { - Id int `json:"id" xorm:"not null pk default 0 INT(11)"` + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` AgentId int `json:"agent_id" xorm:"not null default 0 comment('代理id') INT(11)"` Username string `json:"username" xorm:"not null default '' comment('用户名') VARCHAR(255)"` Password string `json:"password" xorm:"not null default '' comment('密码') VARCHAR(255)"` State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` IsSuperAdministrator int `json:"is_super_administrator" xorm:"not null default 0 comment('是否为超级管理员(0:否 1:是)') TINYINT(1)"` Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` - CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + CreateAt string `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` } diff --git a/src/model/medium.go b/src/model/medium.go index a728b69..d8248c1 100644 --- a/src/model/medium.go +++ b/src/model/medium.go @@ -1,13 +1,13 @@ package model type Medium struct { - Id int `json:"id" xorm:"not null pk default 0 INT(11)"` + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` MediumId int `json:"medium_id" xorm:"not null default 0 comment('媒体id') INT(11)"` Username string `json:"username" xorm:"not null default '' comment('用户名') VARCHAR(255)"` Password string `json:"password" xorm:"not null default '' comment('密码') VARCHAR(255)"` State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(1)"` IsSuperAdministrator int `json:"is_super_administrator" xorm:"not null default 0 comment('是否为超级管理员(0:否 1:是)') TINYINT(1)"` Memo string `json:"memo" xorm:"not null default '' comment('备注信息') VARCHAR(244)"` - CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + CreateAt string `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt string `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` }