From a6a05bde8f6713076969d386036a8a0170a34991 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 20 Aug 2024 17:55:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E8=B4=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd_db.bat | 4 +- cmd_super_dao.bat | 23 ++++++++++ cmd_super_db.bat | 25 +++++++++++ cmd_super_implement.bat | 23 ++++++++++ src/super/dao/agent_bank_info_dao.go | 16 +++++++ src/super/dao/agent_contact_info_dao.go | 16 +++++++ src/super/dao/medium_bank_info_dao.go | 16 +++++++ src/super/dao/medium_contact_info_dao.go | 16 +++++++ src/super/implement/agent_bank_info_db.go | 43 +++++++++++++++++++ src/super/implement/agent_contact_info_db.go | 43 +++++++++++++++++++ src/super/implement/medium_bank_info_db.go | 43 +++++++++++++++++++ src/super/implement/medium_contact_info_db.go | 43 +++++++++++++++++++ src/super/model/agent_bank_info.go | 20 +++++++++ src/super/model/agent_contact_info.go | 19 ++++++++ src/super/model/medium_bank_info.go | 20 +++++++++ src/super/model/medium_contact_info.go | 19 ++++++++ 16 files changed, 387 insertions(+), 2 deletions(-) create mode 100644 cmd_super_dao.bat create mode 100644 cmd_super_db.bat create mode 100644 cmd_super_implement.bat create mode 100644 src/super/dao/agent_bank_info_dao.go create mode 100644 src/super/dao/agent_contact_info_dao.go create mode 100644 src/super/dao/medium_bank_info_dao.go create mode 100644 src/super/dao/medium_contact_info_dao.go create mode 100644 src/super/implement/agent_bank_info_db.go create mode 100644 src/super/implement/agent_contact_info_db.go create mode 100644 src/super/implement/medium_bank_info_db.go create mode 100644 src/super/implement/medium_contact_info_db.go create mode 100644 src/super/model/agent_bank_info.go create mode 100644 src/super/model/agent_contact_info.go create mode 100644 src/super/model/medium_bank_info.go create mode 100644 src/super/model/medium_contact_info.go diff --git a/cmd_db.bat b/cmd_db.bat index f17da43..455dd9f 100644 --- a/cmd_db.bat +++ b/cmd_db.bat @@ -12,7 +12,7 @@ if "%one%" NEQ "" ( set BasePath="./" set DBUSER="root" set DBPSW="Fnuo123com@" -set DBNAME="fnuoos_test1" +set DBNAME="advertisement" set DBHOST="119.23.182.117" set DBPORT="3306" @@ -20,6 +20,6 @@ del "src\models\%Table%.go" echo start reverse table %Table% -xorm reverse mysql "%DBUSER%:%DBPSW%@tcp(%DBHOST%:%DBPORT%)/%DBNAME%?charset=utf8" %BasePath%/etc/db_tpl %BasePath%/src/models/ %TName% +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_dao.bat b/cmd_super_dao.bat new file mode 100644 index 0000000..a86892b --- /dev/null +++ b/cmd_super_dao.bat @@ -0,0 +1,23 @@ +@echo off +setlocal + +set "BasePath=./" + +REM 假设已经提供了文件名作为参数 +set "FileName=%~1" + +REM 将参数设置最终文件名 +set "FinalFile=%BasePath%src\super\dao\%FileName%_dao.go" + +REM 将文件名转换成大驼峰格式并设置成最终接口名 +for /f "delims=" %%i in ('powershell -File "%BasePath%etc\ps\ConvertToUpperCase.ps1" -inputString "%FileName%"') do set "InterfaceName=%%i" + +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%" + +echo Interface file %FileName%_dao.go generated successfully. + +endlocal diff --git a/cmd_super_db.bat b/cmd_super_db.bat new file mode 100644 index 0000000..9b7480a --- /dev/null +++ b/cmd_super_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="super_advertisement" +set DBHOST="119.23.182.117" +set DBPORT="3306" + +del "src\models\%Table%.go" + +echo start reverse table %Table% + +xorm reverse mysql "%DBUSER%:%DBPSW%@tcp(%DBHOST%:%DBPORT%)/%DBNAME%?charset=utf8" %BasePath%/etc/db_tpl %BasePath%/src/super/model/ %TName% + +echo end \ No newline at end of file diff --git a/cmd_super_implement.bat b/cmd_super_implement.bat new file mode 100644 index 0000000..83457cf --- /dev/null +++ b/cmd_super_implement.bat @@ -0,0 +1,23 @@ +@echo off +setlocal + +set "BasePath=./" + +REM 假设已经提供了文件名作为参数 +set "FileName=%~1" + +REM 将参数设置最终文件名 +set "FinalFile=%BasePath%src\super\implement\%FileName%_db.go" + +REM 将文件名转换成大驼峰格式并设置成最终实现类名 +for /f "delims=" %%i in ('powershell -File "%BasePath%etc\ps\ConvertToUpperCase.ps1" -inputString "%FileName%"') do set "ImplementName=%%i" + +REM 使用 PowerShell 替换接口名称,并指定 UTF-8 编码 +powershell -Command "(Get-Content '%BasePath%etc\template\template_implement.tpl') -replace 'DemoImplement', '%ImplementName%' | Out-File -FilePath '%BasePath%temp_implement.go' -Encoding UTF8" + +REM 如果需要,将临时文件重命名为最终文件(取决于move Y?N) +move /Y "%BasePath%temp_implement.go" "%FinalFile%" + +echo Implement file %FileName%_dao.go generated successfully. + +endlocal diff --git a/src/super/dao/agent_bank_info_dao.go b/src/super/dao/agent_bank_info_dao.go new file mode 100644 index 0000000..fe01d16 --- /dev/null +++ b/src/super/dao/agent_bank_info_dao.go @@ -0,0 +1,16 @@ +package dao + +import "code.fnuoos.com/zhimeng/model.git/src/super/model" + +type AgentBankInfoDao interface { + GetAgentBankInfoList(agentId int) (medium *model.AgentBankInfo, err error) + FindAgentBankInfoList(name, state string, page, limit int) (list []AgentBankInfoGroup, total int64, err error) +} +type AgentBankInfoGroup struct { + model.AgentList `xorm:"extends"` + model.AgentBankInfo `xorm:"extends"` +} + +func (AgentBankInfoGroup) TableName() string { + return "agent_bank_info" +} diff --git a/src/super/dao/agent_contact_info_dao.go b/src/super/dao/agent_contact_info_dao.go new file mode 100644 index 0000000..171a380 --- /dev/null +++ b/src/super/dao/agent_contact_info_dao.go @@ -0,0 +1,16 @@ +package dao + +import "code.fnuoos.com/zhimeng/model.git/src/super/model" + +type AgentContactInfoDao interface { + GetAgentContactInfoList(agentId int) (medium *model.AgentContactInfo, err error) + FindAgentContactInfoList(name, state string, page, limit int) (list []AgentContactInfoGroup, total int64, err error) +} +type AgentContactInfoGroup struct { + model.AgentList `xorm:"extends"` + model.AgentContactInfo `xorm:"extends"` +} + +func (AgentContactInfoGroup) TableName() string { + return "agent_contact_info" +} diff --git a/src/super/dao/medium_bank_info_dao.go b/src/super/dao/medium_bank_info_dao.go new file mode 100644 index 0000000..15a8da9 --- /dev/null +++ b/src/super/dao/medium_bank_info_dao.go @@ -0,0 +1,16 @@ +package dao + +import "code.fnuoos.com/zhimeng/model.git/src/super/model" + +type MediumBankInfoDao interface { + GetMediumBankInfoList(MediumId int) (medium *model.MediumBankInfo, err error) + FindMediumBankInfoList(name, state string, page, limit int) (list []MediumBankInfoGroup, total int64, err error) +} +type MediumBankInfoGroup struct { + model.MediumList `xorm:"extends"` + model.MediumBankInfo `xorm:"extends"` +} + +func (MediumBankInfoGroup) TableName() string { + return "medium_bank_info" +} diff --git a/src/super/dao/medium_contact_info_dao.go b/src/super/dao/medium_contact_info_dao.go new file mode 100644 index 0000000..de27098 --- /dev/null +++ b/src/super/dao/medium_contact_info_dao.go @@ -0,0 +1,16 @@ +package dao + +import "code.fnuoos.com/zhimeng/model.git/src/super/model" + +type MediumContactInfoDao interface { + GetMediumContactInfoList(MediumId int) (medium *model.MediumContactInfo, err error) + FindMediumContactInfoList(name, state string, page, limit int) (list []MediumContactInfoGroup, total int64, err error) +} +type MediumContactInfoGroup struct { + model.MediumList `xorm:"extends"` + model.MediumContactInfo `xorm:"extends"` +} + +func (MediumContactInfoGroup) TableName() string { + return "medium_contact_info" +} diff --git a/src/super/implement/agent_bank_info_db.go b/src/super/implement/agent_bank_info_db.go new file mode 100644 index 0000000..3b49a94 --- /dev/null +++ b/src/super/implement/agent_bank_info_db.go @@ -0,0 +1,43 @@ +package implement + +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/dao" + "code.fnuoos.com/zhimeng/model.git/src/super/model" + zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" + "xorm.io/xorm" +) + +func NewAgentBankInfoDb(engine *xorm.Engine) dao.AgentBankInfoDao { + return &AgentBankInfoDb{Db: engine} +} + +type AgentBankInfoDb struct { + Db *xorm.Engine +} + +func (a AgentBankInfoDb) GetAgentBankInfoList(agentId int) (medium *model.AgentBankInfo, err error) { + medium = new(model.AgentBankInfo) + has, err := a.Db.Where("agent_id =?", agentId).Get(medium) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return medium, nil +} +func (a AgentBankInfoDb) FindAgentBankInfoList(name, state string, page, limit int) (list []dao.AgentBankInfoGroup, total int64, err error) { + sess := a.Db.Where("agent_bank_info.state>0").Desc("agent_bank_info.id").Limit(limit, (page-1)*limit) + if name != "" { + sess.And("agent_list.company_name like ?", "%"+name+"%") + } + if state != "" { + sess.And("agent_bank_info.state = ?", state) + } + sess.Join("LEFT", "agent_list", "agent_list.agent_id = agent_bank_info.agent_id") + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/agent_contact_info_db.go b/src/super/implement/agent_contact_info_db.go new file mode 100644 index 0000000..0ec85b5 --- /dev/null +++ b/src/super/implement/agent_contact_info_db.go @@ -0,0 +1,43 @@ +package implement + +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/dao" + "code.fnuoos.com/zhimeng/model.git/src/super/model" + zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" + "xorm.io/xorm" +) + +func NewAgentContactInfoDb(engine *xorm.Engine) dao.AgentContactInfoDao { + return &AgentContactInfoDb{Db: engine} +} + +type AgentContactInfoDb struct { + Db *xorm.Engine +} + +func (a AgentContactInfoDb) GetAgentContactInfoList(agentId int) (medium *model.AgentContactInfo, err error) { + medium = new(model.AgentContactInfo) + has, err := a.Db.Where("agent_id =?", agentId).Get(medium) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return medium, nil +} +func (a AgentContactInfoDb) FindAgentContactInfoList(name, state string, page, limit int) (list []dao.AgentContactInfoGroup, total int64, err error) { + sess := a.Db.Where("agent_contact_info.state>0").Desc("agent_contact_info.id").Limit(limit, (page-1)*limit) + if name != "" { + sess.And("agent_list.company_name like ?", "%"+name+"%") + } + if state != "" { + sess.And("agent_contact_info.state = ?", state) + } + sess.Join("LEFT", "agent_list", "agent_list.agent_id = agent_contact_info.agent_id") + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/medium_bank_info_db.go b/src/super/implement/medium_bank_info_db.go new file mode 100644 index 0000000..8856b14 --- /dev/null +++ b/src/super/implement/medium_bank_info_db.go @@ -0,0 +1,43 @@ +package implement + +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/dao" + "code.fnuoos.com/zhimeng/model.git/src/super/model" + zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" + "xorm.io/xorm" +) + +func NewMediumBankInfoDb(engine *xorm.Engine) dao.MediumBankInfoDao { + return &MediumBankInfoDb{Db: engine} +} + +type MediumBankInfoDb struct { + Db *xorm.Engine +} + +func (a MediumBankInfoDb) GetMediumBankInfoList(MediumId int) (medium *model.MediumBankInfo, err error) { + medium = new(model.MediumBankInfo) + has, err := a.Db.Where("medium_id =?", MediumId).Get(medium) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return medium, nil +} +func (a MediumBankInfoDb) FindMediumBankInfoList(name, state string, page, limit int) (list []dao.MediumBankInfoGroup, total int64, err error) { + sess := a.Db.Where("medium_bank_info.state>0").Desc("medium_bank_info.id").Limit(limit, (page-1)*limit) + if name != "" { + sess.And("medium_list.company_name like ?", "%"+name+"%") + } + if state != "" { + sess.And("medium_bank_info.state = ?", state) + } + sess.Join("LEFT", "medium_list", "medium_list.medium_id = medium_bank_info.medium_id") + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/implement/medium_contact_info_db.go b/src/super/implement/medium_contact_info_db.go new file mode 100644 index 0000000..d8e0bfb --- /dev/null +++ b/src/super/implement/medium_contact_info_db.go @@ -0,0 +1,43 @@ +package implement + +import ( + "code.fnuoos.com/zhimeng/model.git/src/super/dao" + "code.fnuoos.com/zhimeng/model.git/src/super/model" + zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx" + "xorm.io/xorm" +) + +func NewMediumContactInfoDb(engine *xorm.Engine) dao.MediumContactInfoDao { + return &MediumContactInfoDb{Db: engine} +} + +type MediumContactInfoDb struct { + Db *xorm.Engine +} + +func (a MediumContactInfoDb) GetMediumContactInfoList(MediumId int) (medium *model.MediumContactInfo, err error) { + medium = new(model.MediumContactInfo) + has, err := a.Db.Where("medium_id =?", MediumId).Get(medium) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + if has == false { + return nil, nil + } + return medium, nil +} +func (a MediumContactInfoDb) FindMediumContactInfoList(name, state string, page, limit int) (list []dao.MediumContactInfoGroup, total int64, err error) { + sess := a.Db.Where("medium_contact_info.state>0").Desc("medium_contact_info.id").Limit(limit, (page-1)*limit) + if name != "" { + sess.And("medium_list.company_name like ?", "%"+name+"%") + } + if state != "" { + sess.And("medium_contact_info.state = ?", state) + } + sess.Join("LEFT", "medium_list", "medium_list.medium_id = medium_contact_info.medium_id") + total, err = sess.FindAndCount(&list) + if err != nil { + return nil, 0, err + } + return +} diff --git a/src/super/model/agent_bank_info.go b/src/super/model/agent_bank_info.go new file mode 100644 index 0000000..486fd15 --- /dev/null +++ b/src/super/model/agent_bank_info.go @@ -0,0 +1,20 @@ +package model + +import ( + "time" +) + +type AgentBankInfo struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Uuid int `json:"uuid" xorm:"not null comment('站长id') index unique(IDX_UUID_TYPE) INT(11)"` + AgentId int `json:"agent_id" xorm:"not null comment('代理id') unique(IDX_UUID_TYPE) INT(11)"` + State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝)') TINYINT(1)"` + CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + Memo string `json:"memo" xorm:"comment('备注 审核时填写的') VARCHAR(255)"` + CurrencyConf int `json:"currency_conf" xorm:"default 0 comment('结算币种 1人民币') TINYINT(1)"` + Bank string `json:"bank" xorm:"comment('开户银行') VARCHAR(255)"` + BankBranch string `json:"bank_branch" xorm:"comment('开户银行分行') VARCHAR(255)"` + BankNo string `json:"bank_no" xorm:"comment('银行卡号') VARCHAR(255)"` + Licence string `json:"licence" xorm:"comment('开户许可证') VARCHAR(255)"` +} diff --git a/src/super/model/agent_contact_info.go b/src/super/model/agent_contact_info.go new file mode 100644 index 0000000..bed6b35 --- /dev/null +++ b/src/super/model/agent_contact_info.go @@ -0,0 +1,19 @@ +package model + +import ( + "time" +) + +type AgentContactInfo struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Uuid int `json:"uuid" xorm:"not null comment('站长id') index unique(IDX_UUID_TYPE) INT(11)"` + AgentId int `json:"agent_id" xorm:"not null comment('代理id') unique(IDX_UUID_TYPE) INT(11)"` + State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝)') TINYINT(1)"` + CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + Memo string `json:"memo" xorm:"comment('备注 审核时填写的') VARCHAR(255)"` + Name string `json:"name" xorm:"comment('联系人') VARCHAR(255)"` + Email string `json:"email" xorm:"comment('邮箱地址') VARCHAR(255)"` + Phone string `json:"phone" xorm:"comment('联系电话') VARCHAR(255)"` + Address string `json:"address" xorm:"comment('联系地址') VARCHAR(255)"` +} diff --git a/src/super/model/medium_bank_info.go b/src/super/model/medium_bank_info.go new file mode 100644 index 0000000..b1da7df --- /dev/null +++ b/src/super/model/medium_bank_info.go @@ -0,0 +1,20 @@ +package model + +import ( + "time" +) + +type MediumBankInfo struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Uuid int `json:"uuid" xorm:"not null comment('站长id') index unique(IDX_UUID_TYPE) INT(11)"` + MediumId int `json:"medium_id" xorm:"not null comment('代理id') unique(IDX_UUID_TYPE) INT(11)"` + State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝)') TINYINT(1)"` + CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + Memo string `json:"memo" xorm:"comment('备注 审核时填写的') VARCHAR(255)"` + CurrencyConf int `json:"currency_conf" xorm:"default 0 comment('结算币种 1人民币') TINYINT(1)"` + Bank string `json:"bank" xorm:"comment('开户银行') VARCHAR(255)"` + BankBranch string `json:"bank_branch" xorm:"comment('开户银行分行') VARCHAR(255)"` + BankNo string `json:"bank_no" xorm:"comment('银行卡号') VARCHAR(255)"` + Licence string `json:"licence" xorm:"comment('开户许可证') VARCHAR(255)"` +} diff --git a/src/super/model/medium_contact_info.go b/src/super/model/medium_contact_info.go new file mode 100644 index 0000000..c9dddb5 --- /dev/null +++ b/src/super/model/medium_contact_info.go @@ -0,0 +1,19 @@ +package model + +import ( + "time" +) + +type MediumContactInfo struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Uuid int `json:"uuid" xorm:"not null comment('站长id') index unique(IDX_UUID_TYPE) INT(11)"` + MediumId int `json:"medium_id" xorm:"not null comment('代理id') unique(IDX_UUID_TYPE) INT(11)"` + State int `json:"state" xorm:"not null default 0 comment('状态(0:待审核 1:审核通过 2:审核拒绝)') TINYINT(1)"` + CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"not null default CURRENT_TIMESTAMP DATETIME"` + Memo string `json:"memo" xorm:"comment('备注 审核时填写的') VARCHAR(255)"` + Name string `json:"name" xorm:"comment('联系人') VARCHAR(255)"` + Email string `json:"email" xorm:"comment('邮箱地址') VARCHAR(255)"` + Phone string `json:"phone" xorm:"comment('联系电话') VARCHAR(255)"` + Address string `json:"address" xorm:"comment('联系地址') VARCHAR(255)"` +}