Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
是阿延啊
gin-vue-admin
提交
a35e7563
G
gin-vue-admin
项目概览
是阿延啊
/
gin-vue-admin
与 Fork 源项目一致
Fork自
FLIPPED-AURORA / gin-vue-admin
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
a35e7563
编写于
3月 30, 2020
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
代码生成器最后一步(仅剩传给前端下载)
上级
6fbb6f23
变更
17
隐藏空白更改
内联
并排
Showing
17 changed file
with
234 addition
and
815 deletion
+234
-815
QMPlusServer/autoCode/fe/autocode/api/api.js
QMPlusServer/autoCode/fe/autocode/api/api.js
+0
-84
QMPlusServer/autoCode/te/autocode/api/api.go
QMPlusServer/autoCode/te/autocode/api/api.go
+0
-118
QMPlusServer/autoCode/te/autocode/model/model.go
QMPlusServer/autoCode/te/autocode/model/model.go
+0
-52
QMPlusServer/autoCode/te/autocode/router/router.go
QMPlusServer/autoCode/te/autocode/router/router.go
+0
-18
QMPlusServer/controller/api/sys_autoCode.go
QMPlusServer/controller/api/sys_autoCode.go
+33
-0
QMPlusServer/init/initRouter/init_router.go
QMPlusServer/init/initRouter/init_router.go
+2
-1
QMPlusServer/main.go
QMPlusServer/main.go
+2
-0
QMPlusServer/model/autoCodeModel/autoCode.go
QMPlusServer/model/autoCodeModel/autoCode.go
+114
-74
QMPlusServer/model/autoCodeModel/autoCode_test.go
QMPlusServer/model/autoCodeModel/autoCode_test.go
+0
-7
QMPlusServer/router/sys_autoCode.go
QMPlusServer/router/sys_autoCode.go
+14
-0
QMPlusServer/tools/zipfiles.go
QMPlusServer/tools/zipfiles.go
+57
-0
QMPlusServer/tpl/readme.txt.tpl
QMPlusServer/tpl/readme.txt.tpl
+9
-0
QMPlusServer/tpl/te/model.go.tpl
QMPlusServer/tpl/te/model.go.tpl
+2
-2
QMPlusVuePage/src/view/superAdmin/autoCode/component/componentDialog.vue
...rc/view/superAdmin/autoCode/component/componentDialog.vue
+0
-182
QMPlusVuePage/src/view/superAdmin/autoCode/index.vue
QMPlusVuePage/src/view/superAdmin/autoCode/index.vue
+0
-167
QMPlusVuePage/src/view/superAdmin/menu/menu.vue
QMPlusVuePage/src/view/superAdmin/menu/menu.vue
+1
-0
QMPlusVuePage/src/view/superAdmin/system/system.vue
QMPlusVuePage/src/view/superAdmin/system/system.vue
+0
-110
未找到文件。
QMPlusServer/autoCode/fe/autocode/api/api.js
已删除
100644 → 0
浏览文件 @
6fbb6f23
import
service
from
'
@/utils/request
'
// @Tags Test
// @Summary 创建Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "创建Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /t/createTest [post]
export
const
createTest
=
(
data
)
=>
{
return
service
({
url
:
"
/t/createTest
"
,
method
:
'
post
'
,
data
})
}
// @Tags Test
// @Summary 删除Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "删除Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /t/deleteTest [post]
export
const
deleteTest
=
(
data
)
=>
{
return
service
({
url
:
"
/t/deleteTest
"
,
method
:
'
post
'
,
data
})
}
// @Tags Test
// @Summary 更新Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "更新Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /t/updateTest [post]
export
const
updateTest
=
(
data
)
=>
{
return
service
({
url
:
"
/t/updateTest
"
,
method
:
'
post
'
,
data
})
}
// @Tags Test
// @Summary 用id查询Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "用id查询Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /t/findTest [post]
export
const
findTest
=
(
data
)
=>
{
return
service
({
url
:
"
/t/findTest
"
,
method
:
'
post
'
,
data
})
}
// @Tags Test
// @Summary 分页获取Test列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取Test列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /t/getTestList [post]
export
const
getTestList
=
(
data
)
=>
{
return
service
({
url
:
"
/t/getTestList
"
,
method
:
'
post
'
,
data
})
}
\ No newline at end of file
QMPlusServer/autoCode/te/autocode/api/api.go
已删除
100644 → 0
浏览文件 @
6fbb6f23
package
api
import
(
"fmt"
"gin-vue-admin/controller/servers"
"gin-vue-admin/model/modelInterface"
// 请自行引入model路径
"github.com/gin-gonic/gin"
)
// @Tags Test
// @Summary 创建Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "创建Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /t/createTest [post]
func
CreateTest
(
c
*
gin
.
Context
)
{
var
t
autocode
.
Test
_
=
c
.
ShouldBindJSON
(
&
t
)
err
:=
t
.
CreateTest
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"创建失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"创建成功"
,
gin
.
H
{})
}
}
// @Tags Test
// @Summary 删除Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "删除Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /t/deleteTest [post]
func
DeleteTest
(
c
*
gin
.
Context
)
{
var
t
autocode
.
Test
_
=
c
.
ShouldBindJSON
(
&
t
)
err
:=
t
.
DeleteTest
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"删除失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"创建成功"
,
gin
.
H
{})
}
}
// @Tags Test
// @Summary 更新Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "更新Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /t/updateTest [post]
func
UpdateTest
(
c
*
gin
.
Context
)
{
var
t
autocode
.
Test
_
=
c
.
ShouldBindJSON
(
&
t
)
err
,
ret
:=
t
.
UpdateTest
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"更新失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"更新成功"
,
gin
.
H
{
"ret"
:
ret
,
})
}
}
// @Tags Test
// @Summary 用id查询Test
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autocode.Test true "用id查询Test"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /t/findTest [post]
func
FindTest
(
c
*
gin
.
Context
)
{
var
t
autocode
.
Test
_
=
c
.
ShouldBindJSON
(
&
t
)
err
,
ret
:=
t
.
FindById
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"查询失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"查询成功"
,
gin
.
H
{
"ret"
:
ret
,
})
}
}
// @Tags Test
// @Summary 分页获取Test列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "分页获取Test列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /t/getTestList [post]
func
GetTestList
(
c
*
gin
.
Context
)
{
var
pageInfo
modelInterface
.
PageInfo
_
=
c
.
ShouldBindJSON
(
&
pageInfo
)
err
,
list
,
total
:=
new
(
autocode
.
Test
)
.
GetInfoList
(
pageInfo
)
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"获取数据失败,%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"获取数据成功"
,
gin
.
H
{
"autocodeList"
:
list
,
"total"
:
total
,
"page"
:
pageInfo
.
Page
,
"pageSize"
:
pageInfo
.
PageSize
,
})
}
}
\ No newline at end of file
QMPlusServer/autoCode/te/autocode/model/model.go
已删除
100644 → 0
浏览文件 @
6fbb6f23
// 自动生成模板Test
package
autocode
import
(
"gin-vue-admin/controller/servers"
"gin-vue-admin/init/qmsql"
"gin-vue-admin/model/modelInterface"
"github.com/jinzhu/gorm"
)
type
Test
struct
{
gorm
.
Model
TestComponent
string
`json:"testComponent"`
TestBigComponent
int
`json:"testBigComponent"`
}
// 创建Test
func
(
t
*
Test
)
CreateTest
()(
err
error
){
err
=
qmsql
.
DEFAULTDB
.
Create
(
t
)
.
Error
return
err
}
// 删除Test
func
(
t
*
Test
)
DeleteTest
()(
err
error
){
err
=
qmsql
.
DEFAULTDB
.
Delete
(
t
)
.
Error
return
err
}
// 更新Test
func
(
t
*
Test
)
UpdateTest
()(
err
error
,
ret
Test
){
err
=
qmsql
.
DEFAULTDB
.
Save
(
t
)
.
Error
return
err
,
*
t
}
// 根据ID查看单条Test
func
(
t
*
Test
)
FindById
()(
err
error
,
ret
Test
){
err
=
qmsql
.
DEFAULTDB
.
Where
(
"id = ?"
,
t
.
ID
)
.
First
(
&
ret
)
.
Error
return
err
,
ret
}
// 分页获取Test
func
(
t
*
Test
)
GetInfoList
(
info
modelInterface
.
PageInfo
)(
err
error
,
list
interface
{},
total
int
){
// 封装分页方法 调用即可 传入 当前的结构体和分页信息
err
,
db
,
total
:=
servers
.
PagingServer
(
t
,
info
)
if
err
!=
nil
{
return
}
else
{
var
reTestList
[]
Test
err
=
db
.
Find
(
&
reTestList
)
.
Error
return
err
,
reTestList
,
total
}
}
\ No newline at end of file
QMPlusServer/autoCode/te/autocode/router/router.go
已删除
100644 → 0
浏览文件 @
6fbb6f23
package
router
import
(
"gin-vue-admin/controller/api"
"gin-vue-admin/middleware"
"github.com/gin-gonic/gin"
)
func
InitTestRouter
(
Router
*
gin
.
RouterGroup
)
{
TestRouter
:=
Router
.
Group
(
"t"
)
.
Use
(
middleware
.
JWTAuth
())
.
Use
(
middleware
.
CasbinHandler
())
{
TestRouter
.
POST
(
"createTest"
,
api
.
CreateTest
)
// 新建Test
TestRouter
.
POST
(
"deleteTest"
,
api
.
DeleteTest
)
//删除Test
TestRouter
.
POST
(
"updateTest"
,
api
.
UpdateTest
)
//更新Test
TestRouter
.
POST
(
"findTest "
,
api
.
FindTest
)
// 根据ID获取Test
TestRouter
.
POST
(
"getTestList"
,
api
.
GetTestList
)
//获取Test列表
}
}
QMPlusServer/controller/api/sys_autoCode.go
0 → 100644
浏览文件 @
a35e7563
package
api
import
(
"fmt"
"gin-vue-admin/controller/servers"
"gin-vue-admin/model/autoCodeModel"
"github.com/gin-gonic/gin"
"os"
)
// @Tags SysApi
// @Summary 自动代码模板
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body autoCodeModel.AutoCodeStruct true "创建自动代码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /autoCode/createTemp [post]
func
CreateTemp
(
c
*
gin
.
Context
)
{
var
a
autoCodeModel
.
AutoCodeStruct
_
=
c
.
ShouldBindJSON
(
&
a
)
err
:=
a
.
CreateTemp
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"创建失败:%v"
,
err
),
gin
.
H
{})
os
.
Remove
(
"./ginvueadmin.zip"
)
}
else
{
c
.
Writer
.
Header
()
.
Add
(
"Content-Disposition"
,
fmt
.
Sprintf
(
"attachment; filename=%s"
,
"ginvueadmin.zip"
))
//fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
c
.
Writer
.
Header
()
.
Add
(
"Content-Type"
,
"application/json"
)
c
.
Writer
.
Header
()
.
Add
(
"success"
,
"true"
)
c
.
File
(
"./ginvueadmin.zip"
)
os
.
Remove
(
"./ginvueadmin.zip"
)
}
}
QMPlusServer/init/initRouter/init_router.go
浏览文件 @
a35e7563
...
@@ -35,7 +35,8 @@ func InitRouter() *gin.Engine {
...
@@ -35,7 +35,8 @@ func InitRouter() *gin.Engine {
router
.
InitCasbinRouter
(
ApiGroup
)
// 权限相关路由
router
.
InitCasbinRouter
(
ApiGroup
)
// 权限相关路由
router
.
InitJwtRouter
(
ApiGroup
)
// jwt相关路由
router
.
InitJwtRouter
(
ApiGroup
)
// jwt相关路由
router
.
InitSystemRouter
(
ApiGroup
)
// system相关路由
router
.
InitSystemRouter
(
ApiGroup
)
// system相关路由
router
.
InitCustomerRouter
(
ApiGroup
)
// 客户路由
router
.
InitCustomerRouter
(
ApiGroup
)
// 客户路由
router
.
InitAutoCodeRouter
(
ApiGroup
)
// 创建自动化代码
log
.
L
.
Info
(
"router register success"
)
log
.
L
.
Info
(
"router register success"
)
return
Router
return
Router
}
}
QMPlusServer/main.go
浏览文件 @
a35e7563
...
@@ -47,6 +47,8 @@ func main() {
...
@@ -47,6 +47,8 @@ func main() {
defer
qmsql
.
DEFAULTDB
.
Close
()
defer
qmsql
.
DEFAULTDB
.
Close
()
// 注册路由
// 注册路由
Router
:=
initRouter
.
InitRouter
()
Router
:=
initRouter
.
InitRouter
()
Router
.
Static
(
"/form-generator"
,
"./static/form-generator"
)
//Router.RunTLS(":443","ssl.pem", "ssl.key") // https支持 需要添加中间件
//Router.RunTLS(":443","ssl.pem", "ssl.key") // https支持 需要添加中间件
//sysType := runtime.GOOS
//sysType := runtime.GOOS
//
//
...
...
QMPlusServer/model/autoCodeModel/autoCode.go
浏览文件 @
a35e7563
package
autoCodeModel
package
autoCodeModel
import
(
import
(
"fmt"
"gin-vue-admin/tools"
"gin-vue-admin/tools"
"html/template"
"html/template"
"os"
"os"
...
@@ -9,21 +8,17 @@ import (
...
@@ -9,21 +8,17 @@ import (
//开发中功能,若您发现这块代码可以研究,可以无视
//开发中功能,若您发现这块代码可以研究,可以无视
type
AutoCodeStruct
struct
{
type
AutoCodeStruct
struct
{
StructName
string
`json:"structName"`
StructName
string
`json:"structName"`
PackageName
string
`json:"packageName"`
PackageName
string
`json:"packageName"`
Abbreviation
string
`json:"abbreviation"`
Abbreviation
string
`json:"abbreviation"`
Components
[]
Component
`json:"component
s"`
Fields
[]
Field
`json:"field
s"`
}
}
type
Component
struct
{
type
Field
struct
{
ComponentName
string
`json:"componentName"`
FieldName
string
`json:"fieldName"`
ComponentType
string
`json:"componentType"`
FieldType
string
`json:"fieldType"`
ComponentJson
string
`json:"componentJson"`
FieldJson
string
`json:"fieldJson"`
Ismultiple
bool
`json:"isMultiple"`
ColumnName
string
`json:"columnName"`
ComponentShowType
string
`json:"componentShowType"`
NideDictionary
bool
`json:"nideDictionary"`
DictionaryName
string
`json:"dictionaryName"`
ComponentDictionary
[]
Dictionary
`json:"dictionary"`
}
}
type
Dictionary
struct
{
type
Dictionary
struct
{
...
@@ -31,68 +26,113 @@ type Dictionary struct {
...
@@ -31,68 +26,113 @@ type Dictionary struct {
Value
string
`json:"value"`
Value
string
`json:"value"`
}
}
func
Temp
()
{
func
(
a
*
AutoCodeStruct
)
CreateTemp
()
(
err
error
)
{
modelTmpl
,
modelTplErr
:=
template
.
ParseFiles
(
"../../tpl/te/model.go.tpl"
)
basePath
:=
"./tpl"
apiTmpl
,
apiTplErr
:=
template
.
ParseFiles
(
"../../tpl/te/api.go.tpl"
)
modelTmpl
,
err
:=
template
.
ParseFiles
(
basePath
+
"/te/model.go.tpl"
)
routerTmpl
,
routerTplErr
:=
template
.
ParseFiles
(
"../../tpl/te/router.go.tpl"
)
if
err
!=
nil
{
feapiTmpl
,
feapiTplErr
:=
template
.
ParseFiles
(
"../../tpl/fe/api.js.tpl"
)
return
err
}
fmt
.
Println
(
modelTplErr
,
apiTplErr
,
routerTplErr
,
feapiTplErr
)
apiTmpl
,
err
:=
template
.
ParseFiles
(
basePath
+
"/te/api.go.tpl"
)
if
err
!=
nil
{
a1
:=
Component
{
return
err
ComponentName
:
"TestComponent"
,
}
ComponentType
:
"string"
,
routerTmpl
,
err
:=
template
.
ParseFiles
(
basePath
+
"/te/router.go.tpl"
)
ComponentJson
:
"testComponent"
,
if
err
!=
nil
{
Ismultiple
:
false
,
return
err
ComponentShowType
:
""
,
}
NideDictionary
:
false
,
feapiTmpl
,
err
:=
template
.
ParseFiles
(
basePath
+
"/fe/api.js.tpl"
)
DictionaryName
:
""
,
if
err
!=
nil
{
ComponentDictionary
:
nil
,
return
err
}
}
a2
:=
Component
{
readmeTmpl
,
err
:=
template
.
ParseFiles
(
basePath
+
"/readme.txt.tpl"
)
ComponentName
:
"TestBigComponent"
,
if
err
!=
nil
{
ComponentType
:
"int"
,
return
err
ComponentJson
:
"testBigComponent"
,
}
Ismultiple
:
false
,
//自动化总目录
ComponentShowType
:
""
,
_autoCode
:=
"./autoCode/"
NideDictionary
:
false
,
//自动化后台代码目录
DictionaryName
:
""
,
_te
:=
"./autoCode/te/"
ComponentDictionary
:
nil
,
_dir
:=
_te
+
a
.
PackageName
}
_modeldir
:=
_te
+
a
.
PackageName
+
"/model"
a
:=
AutoCodeStruct
{
_apidir
:=
_te
+
a
.
PackageName
+
"/api"
StructName
:
"Test"
,
_routerdir
:=
_te
+
a
.
PackageName
+
"/router"
PackageName
:
"autocode"
,
//自动化前台代码目录
Abbreviation
:
"t"
,
_fe
:=
"./autoCode/fe/"
Components
:
[]
Component
{
a1
,
a2
},
_fe_dir
:=
_fe
+
a
.
PackageName
}
_fe_apidir
:=
_fe
+
a
.
PackageName
+
"/api"
_autoCode
:=
"../../autoCode/"
err
=
createDir
(
_autoCode
,
_te
,
_dir
,
_modeldir
,
_apidir
,
_routerdir
,
_fe
,
_fe_dir
,
_fe_apidir
)
_te
:=
"../../autoCode/te/"
if
err
!=
nil
{
_dir
:=
"../../autoCode/te/"
+
a
.
PackageName
return
err
_modeldir
:=
"../../autoCode/te/"
+
a
.
PackageName
+
"/model"
}
_apidir
:=
"../../autoCode/te/"
+
a
.
PackageName
+
"/api"
model
,
err
:=
os
.
OpenFile
(
_te
+
a
.
PackageName
+
"/model/model.go"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
_routerdir
:=
"../../autoCode/te/"
+
a
.
PackageName
+
"/router"
if
err
!=
nil
{
_fe
:=
"../../autoCode/fe/"
return
err
_fe_dir
:=
"../../autoCode/fe/"
+
a
.
PackageName
}
_fe_apidir
:=
"../../autoCode/fe/"
+
a
.
PackageName
+
"/api"
api
,
err
:=
os
.
OpenFile
(
_te
+
a
.
PackageName
+
"/api/api.go"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
mkerr
:=
createDir
(
_autoCode
,
_te
,
_dir
,
_modeldir
,
_apidir
,
_routerdir
,
_fe
,
_fe_dir
,
_fe_apidir
)
if
err
!=
nil
{
fmt
.
Print
(
mkerr
)
return
err
model
,
_
:=
os
.
OpenFile
(
"../../autoCode/te/"
+
a
.
PackageName
+
"/model/model.go"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
}
api
,
_
:=
os
.
OpenFile
(
"../../autoCode/te/"
+
a
.
PackageName
+
"/api/api.go"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
router
,
err
:=
os
.
OpenFile
(
_te
+
a
.
PackageName
+
"/router/router.go"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
router
,
_
:=
os
.
OpenFile
(
"../../autoCode/te/"
+
a
.
PackageName
+
"/router/router.go"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
if
err
!=
nil
{
feapi
,
_
:=
os
.
OpenFile
(
"../../autoCode/fe/"
+
a
.
PackageName
+
"/api/api.js"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
return
err
modelErr
:=
modelTmpl
.
Execute
(
model
,
a
)
}
apiErr
:=
apiTmpl
.
Execute
(
api
,
a
)
feapi
,
err
:=
os
.
OpenFile
(
_fe
+
a
.
PackageName
+
"/api/api.js"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
routerErr
:=
routerTmpl
.
Execute
(
router
,
a
)
if
err
!=
nil
{
feapiErr
:=
feapiTmpl
.
Execute
(
feapi
,
a
)
return
err
}
fmt
.
Println
(
modelErr
,
apiErr
,
routerErr
,
feapiErr
)
readme
,
err
:=
os
.
OpenFile
(
_autoCode
+
"readme.txt"
,
os
.
O_CREATE
|
os
.
O_WRONLY
,
0755
)
if
err
!=
nil
{
return
err
}
// 生成代码
{
err
=
modelTmpl
.
Execute
(
model
,
a
)
if
err
!=
nil
{
return
err
}
err
=
apiTmpl
.
Execute
(
api
,
a
)
if
err
!=
nil
{
return
err
}
err
=
routerTmpl
.
Execute
(
router
,
a
)
if
err
!=
nil
{
return
err
}
err
=
feapiTmpl
.
Execute
(
feapi
,
a
)
if
err
!=
nil
{
return
err
}
err
=
readmeTmpl
.
Execute
(
readme
,
a
)
if
err
!=
nil
{
return
err
}
}
model
.
Close
()
api
.
Close
()
router
.
Close
()
feapi
.
Close
()
readme
.
Close
()
fileList
:=
[]
string
{
_te
+
a
.
PackageName
+
"/model/model.go"
,
_te
+
a
.
PackageName
+
"/api/api.go"
,
_te
+
a
.
PackageName
+
"/router/router.go"
,
_fe
+
a
.
PackageName
+
"/api/api.js"
,
_autoCode
+
"readme.txt"
,
}
err
=
tools
.
ZipFiles
(
"./ginvueadmin.zip"
,
fileList
,
"."
,
"."
)
if
err
!=
nil
{
return
err
}
err
=
os
.
RemoveAll
(
_autoCode
)
if
err
!=
nil
{
return
err
}
return
nil
}
}
//批量创建文件夹
//批量创建文件夹
func
createDir
(
dirs
...
string
)
(
err
error
)
{
func
createDir
(
dirs
...
string
)
(
err
error
)
{
for
_
,
v
:=
range
dirs
{
for
_
,
v
:=
range
dirs
{
exist
,
err
:=
tools
.
PathExists
(
v
)
exist
,
err
:=
tools
.
PathExists
(
v
)
if
err
!=
nil
{
if
err
!=
nil
{
//log.L.Info(fmt.Sprintf("get dir error![%v]\n", err))
//log.L.Info(fmt.Sprintf("get dir error![%v]\n", err))
...
@@ -112,4 +152,4 @@ func createDir(dirs ...string)(err error){
...
@@ -112,4 +152,4 @@ func createDir(dirs ...string)(err error){
}
}
}
}
return
err
return
err
}
}
\ No newline at end of file
QMPlusServer/model/autoCodeModel/autoCode_test.go
已删除
100644 → 0
浏览文件 @
6fbb6f23
package
autoCodeModel
import
"testing"
func
TestTemp
(
t
*
testing
.
T
)
{
Temp
()
}
QMPlusServer/router/sys_autoCode.go
0 → 100644
浏览文件 @
a35e7563
package
router
import
(
"gin-vue-admin/controller/api"
"gin-vue-admin/middleware"
"github.com/gin-gonic/gin"
)
func
InitAutoCodeRouter
(
Router
*
gin
.
RouterGroup
)
{
AutoCodeRouter
:=
Router
.
Group
(
"autoCode"
)
.
Use
(
middleware
.
JWTAuth
())
.
Use
(
middleware
.
CasbinHandler
())
{
AutoCodeRouter
.
POST
(
"createTemp"
,
api
.
CreateTemp
)
//创建自动化代码
}
}
QMPlusServer/tools/zipfiles.go
0 → 100644
浏览文件 @
a35e7563
package
tools
import
(
"archive/zip"
"io"
"os"
"strings"
)
func
ZipFiles
(
filename
string
,
files
[]
string
,
oldform
,
newform
string
)
error
{
newZipFile
,
err
:=
os
.
Create
(
filename
)
if
err
!=
nil
{
return
err
}
defer
newZipFile
.
Close
()
zipWriter
:=
zip
.
NewWriter
(
newZipFile
)
defer
zipWriter
.
Close
()
// 把files添加到zip中
for
_
,
file
:=
range
files
{
zipfile
,
err
:=
os
.
Open
(
file
)
if
err
!=
nil
{
return
err
}
defer
zipfile
.
Close
()
// 获取file的基础信息
info
,
err
:=
zipfile
.
Stat
()
if
err
!=
nil
{
return
err
}
header
,
err
:=
zip
.
FileInfoHeader
(
info
)
if
err
!=
nil
{
return
err
}
//使用上面的FileInforHeader() 就可以把文件保存的路径替换成我们自己想要的了,如下面
header
.
Name
=
strings
.
Replace
(
file
,
oldform
,
newform
,
-
1
)
// 优化压缩
// 更多参考see http://golang.org/pkg/archive/zip/#pkg-constants
header
.
Method
=
zip
.
Deflate
writer
,
err
:=
zipWriter
.
CreateHeader
(
header
)
if
err
!=
nil
{
return
err
}
if
_
,
err
=
io
.
Copy
(
writer
,
zipfile
);
err
!=
nil
{
return
err
}
}
return
nil
}
QMPlusServer/tpl/readme.txt.tpl
0 → 100644
浏览文件 @
a35e7563
代码解压后把fe的api文件内容粘贴进前端api文件夹下并修改为自己想要的名字即可
后端代码解压后同理,放到自己想要的 mvc对应路径 并且到 initRouter中注册自动生成的路由 到registTable中注册自动生成的model
项目github:"https://github.com/piexlmax/gin-vue-admin"
希望大家给个star多多鼓励
暂时不保存大家生成的结构体 只为方便一次性使用
\ No newline at end of file
QMPlusServer/tpl/te/model.go.tpl
浏览文件 @
a35e7563
...
@@ -9,8 +9,8 @@ import (
...
@@ -9,8 +9,8 @@ import (
)
)
type {{.StructName}} struct {
type {{.StructName}} struct {
gorm.Model {
{
range
.
Component
s
}
}
gorm.Model {
{
range
.
Field
s
}
}
{{.
ComponentName}} {{.ComponentType}} `json:"{{.ComponentJson}}"`
{{ end }}
{{.
FieldName}} {{.FieldType}} `json:"{{.FieldJson}}"{
{
if
.
ColumnName
}
} gorm:"column:{{.ColumnName}}"{
{
end
}
}`
{{ end }}
}
}
// 创建{{.StructName}}
// 创建{{.StructName}}
...
...
QMPlusVuePage/src/view/superAdmin/autoCode/component/componentDialog.vue
已删除
100644 → 0
浏览文件 @
6fbb6f23
<
template
>
<div>
<el-form
:model=
"dialogMiddle"
:inline=
"true"
>
<el-form-item
label=
"组件名称"
label-width=
"80"
:span=
"8"
>
<el-input
v-model=
"dialogMiddle.componentName"
autocomplete=
"off"
></el-input>
</el-form-item>
<el-form-item
label=
"组件JSON"
label-width=
"80"
:span=
"8"
>
<el-input
v-model=
"dialogMiddle.componentJson"
autocomplete=
"off"
></el-input>
</el-form-item>
<el-form-item
label=
"数据类型"
label-width=
"80"
:span=
"8"
>
<el-select
v-model=
"dialogMiddle.componentType"
placeholder=
"请选择活动区域"
>
<el-option
v-for=
"item in typeOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item
label=
"展示类型"
label-width=
"80"
:span=
"8"
>
<el-select
v-model=
"dialogMiddle.componentShowType"
placeholder=
"请选择活动区域"
>
<el-option
v-for=
"item in showTypeOptions"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item
label=
"字典Key"
label-width=
"80"
:span=
"8"
>
<el-input
v-model=
"dialogMiddle.dictionaryName"
autocomplete=
"off"
></el-input>
</el-form-item>
<div>
<el-form-item
label=
"是否多选"
label-width=
"80"
>
<el-switch
v-model=
"dialogMiddle.isMultiple"
active-text=
"多选"
inactive-text=
"单选"
>
</el-switch>
</el-form-item>
</div>
<div>
<el-form-item
label=
"是否使用字典"
label-width=
"80"
>
<el-switch
v-model=
"dialogMiddle.nideDictionary"
active-text=
"使用"
inactive-text=
"不使用"
>
</el-switch>
</el-form-item>
</div>
</el-form>
<div
class=
"button-box clearflex"
>
<el-button
@
click=
"addDictionary"
type=
"primary"
>
新增字典
</el-button>
</div>
<el-table
:data=
"dialogMiddle.componentDictionary"
stripe
style=
"width: 100%"
>
<el-table-column
label=
"展示值"
>
<template
slot-scope=
"scope"
>
<el-input
v-model=
"scope.row.label"
></el-input>
</
template
>
</el-table-column>
<el-table-column
label=
"交互值"
>
<
template
slot-scope=
"scope"
>
<el-input
v-model=
"scope.row.value"
></el-input>
</
template
>
</el-table-column>
<el-table-column
label=
"操作"
>
<
template
slot-scope=
"scope"
>
<el-popover
placement=
"top"
width=
"160"
v-model=
"scope.row.visible"
>
<p>
这是一段内容这是一段内容确定删除吗?
</p>
<div
style=
"text-align: right; margin: 0"
>
<el-button
size=
"mini"
type=
"text"
@
click=
"scope.row.visible = false"
>
取消
</el-button>
<el-button
type=
"primary"
size=
"mini"
@
click=
"deleteRow(scope)"
>
确定
</el-button>
</div>
<el-button
type=
"text"
slot=
"reference"
>
删除
</el-button>
</el-popover>
</
template
>
</el-table-column>
</el-table>
</div>
</template>
<
script
>
const
dictionaryTemplate
=
{
label
:
""
,
value
:
""
,
visible
:
false
}
export
default
{
name
:
"
ComponentDialog
"
,
props
:{
dialogMiddle
:{
type
:
Object
,
default
:
function
(){
return
{}
}
}
},
data
(){
return
{
visible
:
false
,
typeOptions
:[
{
label
:
"
字符串
"
,
value
:
"
string
"
},
{
label
:
"
整型
"
,
value
:
"
int
"
},
{
label
:
"
布尔值
"
,
value
:
"
bool
"
},
{
label
:
"
浮点型
"
,
value
:
"
float64
"
},
{
label
:
"
时间
"
,
value
:
"
time.Time
"
},
],
showTypeOptions
:[
{
label
:
"
单选框
"
,
value
:
"
radio
"
},
{
label
:
"
多选框
"
,
value
:
"
checkBox
"
},
{
label
:
"
输入框
"
,
value
:
"
input
"
},
{
label
:
"
计数器
"
,
value
:
"
inputNumber
"
},
{
label
:
"
选择器
"
,
value
:
"
select
"
},
{
label
:
"
级联选择器
"
,
value
:
"
cascader
"
},
{
label
:
"
开关
"
,
value
:
"
switch
"
},
{
label
:
"
时间日期选择器
"
,
value
:
"
datePicker
"
}
]
}
},
methods
:{
addDictionary
(){
this
.
dialogMiddle
.
componentDictionary
.
push
({...
dictionaryTemplate
})
},
deleteRow
(
row
){
this
.
dialogMiddle
.
componentDictionary
.
splice
(
row
.
$index
,
1
)
}
}
}
</
script
>
<
style
lang=
"scss"
>
</
style
>
\ No newline at end of file
QMPlusVuePage/src/view/superAdmin/autoCode/index.vue
已删除
100644 → 0
浏览文件 @
6fbb6f23
<
template
>
<div>
<!-- 开发中功能,若您发现这块代码可以研究,可以无视 -->
<!-- 此版本为简单版 -->
<!-- 结构体基础配置 -->
<!-- develop分支中开发此功能 -->
<el-form
ref=
"form"
:model=
"form"
label-width=
"100px"
:inline=
"true"
>
<el-form-item
label=
"Struct名称"
:span=
"8"
>
<el-input
v-model=
"form.structName"
></el-input>
</el-form-item>
<el-form-item
label=
"Struct简称"
:span=
"8"
>
<el-input
v-model=
"form.structName"
></el-input>
</el-form-item>
<el-form-item
label=
"Package名称"
:span=
"8"
>
<el-input
v-model=
"form.packageName"
></el-input>
</el-form-item>
<!--
<el-form-item
label=
"结构类型"
:span=
"8"
>
<el-select
v-model=
"form.structType"
multiple
placeholder=
"请选择结构类型(多选)"
>
<el-option
v-for=
"item in options"
:key=
"item.value"
:label=
"item.label"
:value=
"item.value"
>
</el-option>
</el-select>
</el-form-item>
-->
</el-form>
<!-- 组件列表 -->
<div
class=
"button-box clearflex"
>
<el-button
@
click=
"editAndAddComponent()"
type=
"primary"
>
新增Field
</el-button>
</div>
<el-table
:data=
"form.components"
border
stripe
>
<el-table-column
type=
"index"
label=
"序列"
width=
"180"
>
</el-table-column>
<el-table-column
prop=
"componentName"
label=
"Field名"
width=
"180"
>
</el-table-column>
<el-table-column
prop=
"componentType"
label=
"Field数据类型"
width=
"180"
>
</el-table-column>
<el-table-column
prop=
"componentShowType"
label=
"Field展示类型"
>
</el-table-column>
<el-table-column
prop=
"dictionaryName"
label=
"字典名称(选)"
>
</el-table-column>
<el-table-column
label=
"操作"
>
<template
slot-scope=
"scope"
>
<el-button
@
click=
"editAndAddComponent(scope.row)"
>
编辑
</el-button>
<el-popover
placement=
"top"
width=
"160"
v-model=
"scope.row.visible"
>
<p>
这是一段内容这是一段内容确定删除吗?
</p>
<div
style=
"text-align: right; margin: 0"
>
<el-button
size=
"mini"
type=
"text"
@
click=
"scope.row.visible = false"
>
取消
</el-button>
<el-button
type=
"primary"
size=
"mini"
@
click=
"deleteComponent(scope.$index)"
>
确定
</el-button>
</div>
<el-button
slot=
"reference"
>
删除
</el-button>
</el-popover>
</
template
>
</el-table-column>
</el-table>
<!-- 组件列表 -->
<div
class=
"button-box clearflex"
>
<el-button
@
click=
"enterForm"
type=
"primary"
>
提交
</el-button>
</div>
<!-- 组件弹窗 -->
<el-dialog
title=
"组件内容"
:visible.sync=
"dialogFlag"
>
<ComponentDialog
:dialogMiddle=
"dialogMiddle"
/>
<div
slot=
"footer"
class=
"dialog-footer"
>
<el-button
@
click=
"closeDialog"
>
取 消
</el-button>
<el-button
type=
"primary"
@
click=
"enterDialog"
>
确 定
</el-button>
</div>
</el-dialog>
</div>
</template>
<
script
>
const
componentTemplate
=
{
componentName
:
""
,
componentType
:
""
,
componentShowType
:
""
,
dictionaryName
:
""
,
isMultiple
:
false
,
nideDictionary
:
false
,
visible
:
false
,
componentDictionary
:[]
}
import
ComponentDialog
from
"
@/view/superAdmin/autoCode/component/componentDialog.vue
"
export
default
{
name
:
"
autoCode
"
,
data
(){
return
{
addFlag
:
""
,
form
:{
structName
:
""
,
packageName
:
""
,
components
:[]
},
options
:[
{
label
:
"
表格类型
"
,
value
:
"
grid
"
},
{
label
:
"
表单类型
"
,
value
:
"
form
"
}
],
dialogMiddle
:{},
bk
:{},
dialogFlag
:
false
}
},
components
:{
ComponentDialog
},
methods
:{
editAndAddComponent
(
item
){
this
.
dialogFlag
=
true
if
(
item
){
this
.
addFlag
=
"
edit
"
this
.
bk
=
JSON
.
parse
(
JSON
.
stringify
(
item
))
this
.
dialogMiddle
=
item
}
else
{
this
.
addFlag
=
"
add
"
this
.
dialogMiddle
=
JSON
.
parse
(
JSON
.
stringify
(
componentTemplate
))
}
},
enterDialog
(){
if
(
this
.
addFlag
==
"
add
"
){
this
.
form
.
components
.
push
(
this
.
dialogMiddle
)
}
this
.
dialogFlag
=
false
},
closeDialog
(){
if
(
this
.
addFlag
==
"
edit
"
){
this
.
dialogMiddle
=
this
.
bk
}
this
.
dialogFlag
=
false
},
deleteComponent
(
index
){
this
.
form
.
components
.
splice
(
index
,
1
)
},
enterForm
(){
console
.
log
(
this
.
form
)
}
}
}
</
script
>
<
style
scope
lang=
"scss"
>
.button-box
{
padding
:
10px
20px
;
.el-button
{
float
:
right
;
}
}
</
style
>
\ No newline at end of file
QMPlusVuePage/src/view/superAdmin/menu/menu.vue
浏览文件 @
a35e7563
...
@@ -201,6 +201,7 @@ export default {
...
@@ -201,6 +201,7 @@ export default {
message
:
'
添加失败!
'
message
:
'
添加失败!
'
})
})
}
}
this
.
initForm
()
this
.
dialogFormVisible
=
false
this
.
dialogFormVisible
=
false
}
}
})
})
...
...
QMPlusVuePage/src/view/superAdmin/system/system.vue
已删除
100644 → 0
浏览文件 @
6fbb6f23
<
template
>
<div>
<el-form
:model=
"config"
label-width=
"100px"
ref=
"form"
class=
"system"
>
<h2>
系统配置
</h2>
<el-form-item
label=
"多点登录拦截"
>
<el-checkbox
v-model=
"config.system.useMultipoint"
>
开启
</el-checkbox>
</el-form-item>
<el-form-item
label=
"环境值"
>
<el-input
v-model=
"config.system.env"
></el-input>
</el-form-item>
<el-form-item
label=
"端口值"
>
<el-input
v-model=
"config.system.addr"
></el-input>
</el-form-item>
<h2>
jwt签名
</h2>
<el-form-item
label=
"jwt签名"
>
<el-input
v-model=
"config.jwt.signingKey"
></el-input>
</el-form-item>
<h2>
casbin配置
</h2>
<el-form-item
label=
"模型地址"
>
<el-input
v-model=
"config.casbinConfig.modelPath"
></el-input>
</el-form-item>
<h2>
mysql admin数据库配置
</h2>
<el-form-item
label=
"username"
>
<el-input
v-model=
"config.mysqlAdmin.username"
></el-input>
</el-form-item>
<el-form-item
label=
"password"
>
<el-input
v-model=
"config.mysqlAdmin.password"
></el-input>
</el-form-item>
<el-form-item
label=
"path"
>
<el-input
v-model=
"config.mysqlAdmin.path"
></el-input>
</el-form-item>
<el-form-item
label=
"dbname"
>
<el-input
v-model=
"config.mysqlAdmin.dbname"
></el-input>
</el-form-item>
<el-form-item
label=
"config"
>
<el-input
v-model=
"config.mysqlAdmin.config"
></el-input>
</el-form-item>
<h2>
Redis admin数据库配置
</h2>
<el-form-item
label=
"addr"
>
<el-input
v-model=
"config.redisAdmin.addr"
></el-input>
</el-form-item>
<el-form-item
label=
"password"
>
<el-input
v-model=
"config.redisAdmin.password"
></el-input>
</el-form-item>
<el-form-item
label=
"db"
>
<el-input
v-model=
"config.redisAdmin.db"
></el-input>
</el-form-item>
<h2>
七牛密钥配置
</h2>
<el-form-item
label=
"accessKey"
>
<el-input
v-model=
"config.qiniu.accessKey"
></el-input>
</el-form-item>
<el-form-item
label=
"secretKey"
>
<el-input
v-model=
"config.qiniu.secretKey"
></el-input>
</el-form-item>
<el-form-item>
<el-button
@
click=
"update"
type=
"primary"
>
立即更新
</el-button>
<el-button
@
click=
"reload"
type=
"primary"
>
重启服务(开发中)
</el-button>
</el-form-item>
</el-form>
</div>
</
template
>
<
script
>
import
{
getSystemConfig
,
setSystemConfig
}
from
'
@/api/system
'
export
default
{
name
:
'
Config
'
,
data
()
{
return
{
config
:
{
system
:
{},
jwt
:
{},
casbinConfig
:
{},
mysqlAdmin
:
{},
redisAdmin
:
{},
qiniu
:
{}
}
}
},
async
created
()
{
await
this
.
initForm
()
},
methods
:
{
async
initForm
()
{
const
res
=
await
getSystemConfig
()
if
(
res
.
success
)
{
this
.
config
=
res
.
data
.
config
}
},
reload
()
{},
async
update
()
{
const
res
=
await
setSystemConfig
({
config
:
this
.
config
})
if
(
res
.
success
)
{
this
.
$message
({
type
:
'
success
'
,
message
:
'
配置文件设置成功
'
})
await
this
.
initForm
()
}
}
}
}
</
script
>
<
style
lang=
"scss"
>
h2
{
padding
:
10px
;
margin
:
10px
0
;
font-size
:
16px
;
box-shadow
:
-4px
1px
3px
0px
#e7e8e8
}
</
style
>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录