Browse Source

update

master
dengbiao 4 months ago
parent
commit
dde162209c
24 changed files with 328 additions and 77 deletions
  1. +23
    -0
      cmd_dao.bat
  2. +25
    -0
      cmd_db.bat
  3. +21
    -0
      cmd_db.sh
  4. +23
    -0
      cmd_implement.bat
  5. +9
    -0
      etc/ps/ConvertToUpperCase.ps1
  6. +14
    -0
      etc/template/template_implement.tpl
  7. +5
    -0
      etc/template/template_interface.tpl
  8. +5
    -0
      src/dao/db_mapping_agent_dao.go
  9. +1
    -1
      src/dao/db_mapping_dao.go
  10. +5
    -0
      src/dao/db_mapping_medium_dao.go
  11. +0
    -10
      src/dao/medium_domain_dao.go
  12. +0
    -14
      src/implement/agent_domain_implement.go
  13. +0
    -36
      src/implement/medium_domain_implement.go
  14. +0
    -8
      src/model/agent_domain.go
  15. +0
    -8
      src/model/medium_domain.go
  16. +9
    -0
      src/super/dao/agent_app_domain_dao.go
  17. +9
    -0
      src/super/dao/medium_app_domain_dao.go
  18. +9
    -0
      src/super/dao/user_app_domain_dao.go
  19. +48
    -0
      src/super/implement/agent_app_domain_implement.go
  20. +48
    -0
      src/super/implement/medium_app_domain_implement.go
  21. +48
    -0
      src/super/implement/user_app_domain_implement.go
  22. +9
    -0
      src/super/model/agent_app_domain.go
  23. +9
    -0
      src/super/model/medium_app_domain.go
  24. +8
    -0
      src/super/model/user_app_domain.go

+ 23
- 0
cmd_dao.bat View File

@@ -0,0 +1,23 @@
@echo off
setlocal

set "BasePath=./"

REM 假设已经提供了文件名作为参数
set "FileName=%~1"

REM 将参数设置最终文件名
set "FinalFile=%BasePath%src\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

+ 25
- 0
cmd_db.bat View File

@@ -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="fnuoos_test1"
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/models/ %TName%

echo end

+ 21
- 0
cmd_db.sh View File

@@ -0,0 +1,21 @@
#!/bin/bash

# 使用方法, 直接执行该脚本更新所有表, cmd_db.sh 表名, 如 ./cmd_db.sh tableName

Table=*
TName=""
if [ "$1" ] ;then
Table=$1
TName="^$1$"
fi

BasePath="./"
DBUSER="root"
DBPSW="Fnuo123com@"
DBNAME="super_advertisement"
DBHOST="119.23.182.117"
DBPORT="3306"

rm -rf $BasePath/app/db/model/$Table.go && \

xorm reverse mysql "$DBUSER:$DBPSW@tcp($DBHOST:$DBPORT)/$DBNAME?charset=utf8" $BasePath/etc/db_tpl $BasePath/src/models/ $TName

+ 23
- 0
cmd_implement.bat View File

@@ -0,0 +1,23 @@
@echo off
setlocal

set "BasePath=./"

REM 假设已经提供了文件名作为参数
set "FileName=%~1"

REM 将参数设置最终文件名
set "FinalFile=%BasePath%src\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

+ 9
- 0
etc/ps/ConvertToUpperCase.ps1 View File

@@ -0,0 +1,9 @@
param($inputString)
$words = $inputString.Split('_')
$outputString = ""
foreach ($word in $words) {
$outputString += $word.Substring(0,1).ToUpper() + $word.Substring(1).ToLower() + ""
}
$outputString = $outputString.TrimEnd()
$outputString -replace ' ', '' # 如果想要没有空格的字符串,取消注释这行代码
$outputString

+ 14
- 0
etc/template/template_implement.tpl View File

@@ -0,0 +1,14 @@
package implement

import (
"applet/app/db/dao"
"xorm.io/xorm"
)

func NewDemoImplementDb(engine *xorm.Engine) dao.DemoImplementDao {
return &DemoImplementDb{Db: engine}
}

type DemoImplementDb struct {
Db *xorm.Engine
}

+ 5
- 0
etc/template/template_interface.tpl View File

@@ -0,0 +1,5 @@
package dao

type DemoInterfaceDao interface {
//TODO:: You can add specific method definitions here
}

+ 5
- 0
src/dao/db_mapping_agent_dao.go View File

@@ -0,0 +1,5 @@
package dao

type DbMappingAgentDao interface {
//TODO:: You can add specific method definitions here
}

src/dao/agent_domain_dao.go → src/dao/db_mapping_dao.go View File

@@ -1,5 +1,5 @@
package dao

type AgentDomainDao interface {
type DbMappingDao interface {
//TODO:: You can add specific method definitions here
}

+ 5
- 0
src/dao/db_mapping_medium_dao.go View File

@@ -0,0 +1,5 @@
package dao

type DbMappingMediumDao interface {
//TODO:: You can add specific method definitions here
}

+ 0
- 10
src/dao/medium_domain_dao.go View File

@@ -1,10 +0,0 @@
package dao

import (
"code.fnuoos.com/zhimeng/model.git/src/model"
)

type MediumDomainDao interface {
GetMediumDomain(mediumId int) (medium *model.MediumDomain, err error)
MediumDomainInsert(m *model.MediumDomain) (int64, error)
}

+ 0
- 14
src/implement/agent_domain_implement.go View File

@@ -1,14 +0,0 @@
package implement

import (
"code.fnuoos.com/zhimeng/model.git/src/dao"
"xorm.io/xorm"
)

func NewAgentDomainDb(engine *xorm.Engine) dao.AgentDomainDao {
return &AgentDomainDb{Db: engine}
}

type AgentDomainDb struct {
Db *xorm.Engine
}

+ 0
- 36
src/implement/medium_domain_implement.go View File

@@ -1,36 +0,0 @@
package implement

import (
"code.fnuoos.com/zhimeng/model.git/src/dao"
"code.fnuoos.com/zhimeng/model.git/src/model"
zhios_order_relate_logx "code.fnuoos.com/zhimeng/model.git/utils/logx"
"xorm.io/xorm"
)

func NewMediumDomainDb(engine *xorm.Engine) dao.MediumDomainDao {
return &MediumDomainDb{Db: engine}
}

type MediumDomainDb struct {
Db *xorm.Engine
}

func (m MediumDomainDb) GetMediumDomain(mediumId int) (medium *model.MediumDomain, err error) {
medium = new(model.MediumDomain)
has, err := m.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 (m MediumDomainDb) MediumDomainInsert(medium *model.MediumDomain) (int64, error) {
insertAffected, err := m.Db.InsertOne(medium)
if err != nil {
return 0, err
}
return insertAffected, nil
}

+ 0
- 8
src/model/agent_domain.go View File

@@ -1,8 +0,0 @@
package model

type AgentDomain struct {
Domain string `json:"domain" xorm:"not null pk comment('绑定域名') VARCHAR(100)"`
MediumId int `json:"medium_id" xorm:"not null comment('媒体id') index unique INT(11)"`
IsOfficial int `json:"is_official" xorm:"not null default 1 comment('是否官方指定域名(1:是 2:否)') TINYINT(1)"`
IsSsl int `json:"is_ssl" xorm:"not null default 0 comment('是否开启ssl:0否;1是') TINYINT(255)"`
}

+ 0
- 8
src/model/medium_domain.go View File

@@ -1,8 +0,0 @@
package model

type MediumDomain struct {
Domain string `json:"domain" xorm:"not null pk comment('绑定域名') VARCHAR(100)"`
MediumId int `json:"medium_id" xorm:"not null comment('媒体id') index unique INT(11)"`
IsOfficial int `json:"is_official" xorm:"not null default 1 comment('是否官方指定域名(1:是 2:否)') TINYINT(1)"`
IsSsl int `json:"is_ssl" xorm:"not null default 0 comment('是否开启ssl:0否;1是') TINYINT(255)"`
}

+ 9
- 0
src/super/dao/agent_app_domain_dao.go View File

@@ -0,0 +1,9 @@
package dao

import "code.fnuoos.com/zhimeng/model.git/src/super/model"

type AgentAppDomainDao interface {
GetAgentAppDomain(agentId int) (m *model.AgentAppDomain, err error)
GetAgentAppDomainByHost(host string) (m *model.AgentAppDomain, err error)
AgentAppDomainInsert(m *model.AgentAppDomain) (int64, error)
}

+ 9
- 0
src/super/dao/medium_app_domain_dao.go View File

@@ -0,0 +1,9 @@
package dao

import "code.fnuoos.com/zhimeng/model.git/src/super/model"

type MediumAppDomainDao interface {
GetMediumAppDomain(mediumId int) (m *model.MediumAppDomain, err error)
GetMediumAppDomainByHost(host string) (m *model.MediumAppDomain, err error)
MediumAppDomainInsert(m *model.MediumAppDomain) (int64, error)
}

+ 9
- 0
src/super/dao/user_app_domain_dao.go View File

@@ -0,0 +1,9 @@
package dao

import "code.fnuoos.com/zhimeng/model.git/src/super/model"

type UserAppDomainDao interface {
GetUserAppDomain(masterId int) (m *model.UserAppDomain, err error)
GetMediumAppDomainByHost(host string) (m *model.UserAppDomain, err error)
UserAppDomainInsert(m *model.UserAppDomain) (int64, error)
}

+ 48
- 0
src/super/implement/agent_app_domain_implement.go View File

@@ -0,0 +1,48 @@
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 NewAgentAppDomainDb(engine *xorm.Engine) dao.AgentAppDomainDao {
return &AgentAppDomainDb{Db: engine}
}

type AgentAppDomainDb struct {
Db *xorm.Engine
}

func (a AgentAppDomainDb) GetAgentAppDomainByHost(host string) (m *model.AgentAppDomain, err error) {
m = new(model.AgentAppDomain)
has, err := a.Db.Where("domain =?", host).Get(m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (a AgentAppDomainDb) GetAgentAppDomain(agent int) (m *model.AgentAppDomain, err error) {
m = new(model.AgentAppDomain)
has, err := a.Db.Where("agent_id =?", agent).Get(m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (a AgentAppDomainDb) AgentAppDomainInsert(m *model.AgentAppDomain) (int64, error) {
insertAffected, err := a.Db.InsertOne(m)
if err != nil {
return 0, err
}
return insertAffected, nil
}

+ 48
- 0
src/super/implement/medium_app_domain_implement.go View File

@@ -0,0 +1,48 @@
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 NewMediumAppDomainDb(engine *xorm.Engine) dao.MediumAppDomainDao {
return &MediumAppDomainDb{Db: engine}
}

type MediumAppDomainDb struct {
Db *xorm.Engine
}

func (m2 MediumAppDomainDb) GetMediumAppDomainByHost(host string) (m *model.MediumAppDomain, err error) {
m = new(model.MediumAppDomain)
has, err := m2.Db.Where("domain =?", host).Get(m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (m2 MediumAppDomainDb) GetMediumAppDomain(mediumId int) (m *model.MediumAppDomain, err error) {
m = new(model.MediumAppDomain)
has, err := m2.Db.Where("medium_id =?", mediumId).Get(m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (m2 MediumAppDomainDb) MediumAppDomainInsert(m *model.MediumAppDomain) (int64, error) {
insertAffected, err := m2.Db.InsertOne(m)
if err != nil {
return 0, err
}
return insertAffected, nil
}

+ 48
- 0
src/super/implement/user_app_domain_implement.go View File

@@ -0,0 +1,48 @@
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 NewUserAppDomainDb(engine *xorm.Engine) dao.UserAppDomainDao {
return &UserAppDomainDb{Db: engine}
}

type UserAppDomainDb struct {
Db *xorm.Engine
}

func (u UserAppDomainDb) GetMediumAppDomainByHost(host string) (m *model.UserAppDomain, err error) {
m = new(model.UserAppDomain)
has, err := u.Db.Where("domain =?", host).Get(m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (u UserAppDomainDb) GetUserAppDomain(masterId int) (m *model.UserAppDomain, err error) {
m = new(model.UserAppDomain)
has, err := u.Db.Where("uuid =?", masterId).Get(m)
if err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (u UserAppDomainDb) UserAppDomainInsert(m *model.UserAppDomain) (int64, error) {
insertAffected, err := u.Db.InsertOne(m)
if err != nil {
return 0, err
}
return insertAffected, nil
}

+ 9
- 0
src/super/model/agent_app_domain.go View File

@@ -0,0 +1,9 @@
package model

type AgentAppDomain struct {
Domain string `json:"domain" xorm:"not null pk comment('绑定域名') VARCHAR(100)"`
AgentId int `json:"agent_id" xorm:"not null comment('代理id') index unique(IDX_UUID_TYPE) INT(10)"`
Uuid int `json:"uuid" xorm:"not null comment('对应APP ID编号') index unique(IDX_UUID_TYPE) INT(10)"`
Type string `json:"type" xorm:"not null comment('api接口域名,wap.h5域名,admin管理后台') unique(IDX_UUID_TYPE) ENUM('admin','api','wap')"`
IsSsl int `json:"is_ssl" xorm:"not null default 0 comment('是否开启ssl:0否;1是') TINYINT(255)"`
}

+ 9
- 0
src/super/model/medium_app_domain.go View File

@@ -0,0 +1,9 @@
package model

type MediumAppDomain struct {
Domain string `json:"domain" xorm:"not null pk comment('绑定域名') VARCHAR(100)"`
MediumId int `json:"medium_id" xorm:"not null comment('媒体id') index unique(IDX_UUID_TYPE) INT(10)"`
Uuid int `json:"uuid" xorm:"not null comment('对应APP ID编号') index unique(IDX_UUID_TYPE) INT(10)"`
Type string `json:"type" xorm:"not null comment('api接口域名,wap.h5域名,admin管理后台') unique(IDX_UUID_TYPE) ENUM('admin','api','wap')"`
IsSsl int `json:"is_ssl" xorm:"not null default 0 comment('是否开启ssl:0否;1是') TINYINT(255)"`
}

+ 8
- 0
src/super/model/user_app_domain.go View File

@@ -0,0 +1,8 @@
package model

type UserAppDomain struct {
Domain string `json:"domain" xorm:"not null pk comment('绑定域名') VARCHAR(100)"`
Uuid int `json:"uuid" xorm:"not null comment('对应APP ID编号') index unique(IDX_UUID_TYPE) INT(10)"`
Type string `json:"type" xorm:"not null comment('api接口域名,wap.h5域名,admin管理后台') unique(IDX_UUID_TYPE) ENUM('admin','api','wap')"`
IsSsl int `json:"is_ssl" xorm:"not null default 0 comment('是否开启ssl:0否;1是') TINYINT(255)"`
}

Loading…
Cancel
Save