Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
c91dcf24
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
345
Star
18155
Fork
5506
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
c91dcf24
编写于
3月 16, 2021
作者:
Mr.奇淼(
提交者:
GitHub
3月 16, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #397 from songzhibin97/gva_gormv2_dev
代码自动迁移动态适配
上级
b737b6c4
1cf61a65
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
18 deletion
+59
-18
server/config.yaml
server/config.yaml
+15
-0
server/config/auto_code.go
server/config/auto_code.go
+16
-0
server/config/config.go
server/config/config.go
+6
-4
server/core/viper.go
server/core/viper.go
+4
-2
server/service/sys_auto_code.go
server/service/sys_auto_code.go
+18
-12
未找到文件。
server/config.yaml
浏览文件 @
c91dcf24
...
...
@@ -64,6 +64,21 @@ mysql:
log-mode
:
false
log-zap
:
"
"
autoCode
:
root
:
'
'
server
:
'
/server'
server-api
:
'
/api/v1'
server-model
:
'
/model'
server-request
:
'
/model/request/'
server-router
:
'
/router'
server-service
:
'
/service'
web
:
'
/web/src'
web-api
:
'
/api'
web-form
:
'
/view'
web-table
:
'
/view'
web-flow
:
'
/view'
# local configuration
local
:
path
:
'
uploads/file'
...
...
server/config/auto_code.go
0 → 100644
浏览文件 @
c91dcf24
package
config
type
Autocode
struct
{
Root
string
`mapstructure:"root" json:"root" yaml:"root"`
Server
string
`mapstructure:"server" json:"server" yaml:"server"`
SApi
string
`mapstructure:"server-api" json:"serverApi" yaml:"server-api"`
SModel
string
`mapstructure:"server-model" json:"serverModel" yaml:"server-model"`
SRequest
string
`mapstructure:"server-request" json:"serverRequest" yaml:"server-request"`
SRouter
string
`mapstructure:"server-router" json:"serverRouter" yaml:"server-router"`
SService
string
`mapstructure:"server-service" json:"serverService" yaml:"server-service"`
Web
string
`mapstructure:"web" json:"web" yaml:"web"`
WApi
string
`mapstructure:"web-api" json:"webApi" yaml:"web-api"`
WForm
string
`mapstructure:"web-form" json:"webForm" yaml:"web-form"`
WTable
string
`mapstructure:"web-table" json:"webTable" yaml:"web-table"`
WFlow
string
`mapstructure:"web-flow" json:"webFlow" yaml:"web-flow"`
}
server/config/config.go
浏览文件 @
c91dcf24
...
...
@@ -8,12 +8,14 @@ type Server struct {
Casbin
Casbin
`mapstructure:"casbin" json:"casbin" yaml:"casbin"`
System
System
`mapstructure:"system" json:"system" yaml:"system"`
Captcha
Captcha
`mapstructure:"captcha" json:"captcha" yaml:"captcha"`
// aoto
AutoCode
Autocode
`mapstructure:"autoCode" json:"autoCode" yaml:"autoCode"`
// gorm
Mysql
Mysql
`mapstructure:"mysql" json:"mysql" yaml:"mysql"`
// oss
Local
Local
`mapstructure:"local" json:"local" yaml:"local"`
Qiniu
Qiniu
`mapstructure:"qiniu" json:"qiniu" yaml:"qiniu"`
AliyunOSS
AliyunOSS
`mapstructure:"aliyun-oss" json:"aliyunOSS" yaml:"aliyun-oss"`
Local
Local
`mapstructure:"local" json:"local" yaml:"local"`
Qiniu
Qiniu
`mapstructure:"qiniu" json:"qiniu" yaml:"qiniu"`
AliyunOSS
AliyunOSS
`mapstructure:"aliyun-oss" json:"aliyunOSS" yaml:"aliyun-oss"`
TencentCOS
TencentCOS
`mapstructure:"tencent-cos" json:"tencentCOS" yaml:"tencent-cos"`
Excel
Excel
`mapstructure:"excel" json:"excel" yaml:"excel"`
Excel
Excel
`mapstructure:"excel" json:"excel" yaml:"excel"`
}
server/core/viper.go
浏览文件 @
c91dcf24
...
...
@@ -6,9 +6,11 @@ import (
"gin-vue-admin/global"
_
"gin-vue-admin/packfile"
"gin-vue-admin/utils"
"os"
"path/filepath"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
"os"
)
func
Viper
(
path
...
string
)
*
viper
.
Viper
{
...
...
@@ -46,9 +48,9 @@ func Viper(path ...string) *viper.Viper {
fmt
.
Println
(
err
)
}
})
if
err
:=
v
.
Unmarshal
(
&
global
.
GVA_CONFIG
);
err
!=
nil
{
fmt
.
Println
(
err
)
}
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
_
=
filepath
.
Abs
(
".."
)
return
v
}
server/service/sys_auto_code.go
浏览文件 @
c91dcf24
...
...
@@ -2,7 +2,6 @@ package service
import
(
"errors"
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
...
...
@@ -132,7 +131,6 @@ func CreateTemp(autoCode model.AutoCodeStruct) (err error) {
}
for
_
,
value
:=
range
dataList
{
// 移动文件
if
err
:=
utils
.
FileMove
(
value
.
autoCodePath
,
value
.
autoMoveFilePath
);
err
!=
nil
{
fmt
.
Println
(
err
)
return
err
}
}
...
...
@@ -212,7 +210,6 @@ func GetColumn(tableName string, dbName string) (err error, Columns []request.Co
//@return: null
func
addAutoMoveFile
(
data
*
tplData
)
{
dir
:=
filepath
.
Base
(
filepath
.
Dir
(
data
.
autoCodePath
))
base
:=
filepath
.
Base
(
data
.
autoCodePath
)
fileSlice
:=
strings
.
Split
(
data
.
autoCodePath
,
string
(
os
.
PathSeparator
))
n
:=
len
(
fileSlice
)
...
...
@@ -221,25 +218,34 @@ func addAutoMoveFile(data *tplData) {
}
if
strings
.
Contains
(
fileSlice
[
1
],
"server"
)
{
if
strings
.
Contains
(
fileSlice
[
n
-
2
],
"router"
)
{
data
.
autoMoveFilePath
=
filepath
.
Join
(
dir
,
base
)
data
.
autoMoveFilePath
=
filepath
.
Join
(
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
global
.
GVA_CONFIG
.
AutoCode
.
Server
,
global
.
GVA_CONFIG
.
AutoCode
.
SRouter
,
base
)
}
else
if
strings
.
Contains
(
fileSlice
[
n
-
2
],
"api"
)
{
data
.
autoMoveFilePath
=
filepath
.
Join
(
dir
,
"v1"
,
base
)
data
.
autoMoveFilePath
=
filepath
.
Join
(
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
global
.
GVA_CONFIG
.
AutoCode
.
Server
,
global
.
GVA_CONFIG
.
AutoCode
.
SApi
,
base
)
}
else
if
strings
.
Contains
(
fileSlice
[
n
-
2
],
"service"
)
{
data
.
autoMoveFilePath
=
filepath
.
Join
(
dir
,
base
)
data
.
autoMoveFilePath
=
filepath
.
Join
(
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
global
.
GVA_CONFIG
.
AutoCode
.
Server
,
global
.
GVA_CONFIG
.
AutoCode
.
SService
,
base
)
}
else
if
strings
.
Contains
(
fileSlice
[
n
-
2
],
"model"
)
{
data
.
autoMoveFilePath
=
filepath
.
Join
(
dir
,
base
)
data
.
autoMoveFilePath
=
filepath
.
Join
(
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
global
.
GVA_CONFIG
.
AutoCode
.
Server
,
global
.
GVA_CONFIG
.
AutoCode
.
SModel
,
base
)
}
else
if
strings
.
Contains
(
fileSlice
[
n
-
2
],
"request"
)
{
data
.
autoMoveFilePath
=
filepath
.
Join
(
"model"
,
dir
,
base
)
data
.
autoMoveFilePath
=
filepath
.
Join
(
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
global
.
GVA_CONFIG
.
AutoCode
.
Server
,
global
.
GVA_CONFIG
.
AutoCode
.
SRequest
,
base
)
}
}
else
if
strings
.
Contains
(
fileSlice
[
1
],
"web"
)
{
if
strings
.
Contains
(
fileSlice
[
n
-
1
],
"js"
)
{
data
.
autoMoveFilePath
=
filepath
.
Join
(
"../"
,
"web"
,
"src"
,
dir
,
base
)
data
.
autoMoveFilePath
=
filepath
.
Join
(
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
global
.
GVA_CONFIG
.
AutoCode
.
Web
,
global
.
GVA_CONFIG
.
AutoCode
.
WApi
,
base
)
}
else
if
strings
.
Contains
(
fileSlice
[
n
-
2
],
"workflowForm"
)
{
data
.
autoMoveFilePath
=
filepath
.
Join
(
"../"
,
"web"
,
"src"
,
"view"
,
filepath
.
Base
(
filepath
.
Dir
(
filepath
.
Dir
(
data
.
autoCodePath
))),
strings
.
TrimSuffix
(
base
,
filepath
.
Ext
(
base
))
+
"WorkflowForm.vue"
)
data
.
autoMoveFilePath
=
filepath
.
Join
(
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
global
.
GVA_CONFIG
.
AutoCode
.
Web
,
global
.
GVA_CONFIG
.
AutoCode
.
WFlow
,
filepath
.
Base
(
filepath
.
Dir
(
filepath
.
Dir
(
data
.
autoCodePath
))),
strings
.
TrimSuffix
(
base
,
filepath
.
Ext
(
base
))
+
"WorkflowForm.vue"
)
}
else
if
strings
.
Contains
(
fileSlice
[
n
-
2
],
"form"
)
{
data
.
autoMoveFilePath
=
filepath
.
Join
(
"../"
,
"web"
,
"src"
,
"view"
,
filepath
.
Base
(
filepath
.
Dir
(
filepath
.
Dir
(
data
.
autoCodePath
))),
strings
.
TrimSuffix
(
base
,
filepath
.
Ext
(
base
))
+
"Form.vue"
)
data
.
autoMoveFilePath
=
filepath
.
Join
(
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
global
.
GVA_CONFIG
.
AutoCode
.
Web
,
global
.
GVA_CONFIG
.
AutoCode
.
WForm
,
filepath
.
Base
(
filepath
.
Dir
(
filepath
.
Dir
(
data
.
autoCodePath
))),
strings
.
TrimSuffix
(
base
,
filepath
.
Ext
(
base
))
+
"Form.vue"
)
}
else
if
strings
.
Contains
(
fileSlice
[
n
-
2
],
"table"
)
{
data
.
autoMoveFilePath
=
filepath
.
Join
(
"../"
,
"web"
,
"src"
,
"view"
,
filepath
.
Base
(
filepath
.
Dir
(
filepath
.
Dir
(
data
.
autoCodePath
))),
base
)
data
.
autoMoveFilePath
=
filepath
.
Join
(
global
.
GVA_CONFIG
.
AutoCode
.
Root
,
global
.
GVA_CONFIG
.
AutoCode
.
Web
,
global
.
GVA_CONFIG
.
AutoCode
.
WTable
,
filepath
.
Base
(
filepath
.
Dir
(
filepath
.
Dir
(
data
.
autoCodePath
))),
base
)
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录