Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Elij4h
gin-vue-admin
提交
b7c816b9
G
gin-vue-admin
项目概览
Elij4h
/
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,发现更多精彩内容 >>
提交
b7c816b9
编写于
5月 03, 2020
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加是否自动创建api入库的开关 可自动产生api入库
上级
9d97f128
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
4 deletion
+49
-4
server/api/v1/sys_auto_code.go
server/api/v1/sys_auto_code.go
+44
-0
server/model/sys_auto_code.go
server/model/sys_auto_code.go
+5
-4
未找到文件。
server/api/v1/sys_auto_code.go
浏览文件 @
b7c816b9
...
...
@@ -6,6 +6,7 @@ import (
"gin-vue-admin/model"
"gin-vue-admin/service"
"github.com/gin-gonic/gin"
"net/url"
"os"
)
...
...
@@ -21,6 +22,49 @@ func CreateTemp(c *gin.Context) {
var
a
model
.
AutoCodeStruct
_
=
c
.
ShouldBindJSON
(
&
a
)
err
:=
service
.
CreateTemp
(
a
)
if
a
.
AutoCreateApiToSql
{
apiList
:=
[
5
]
model
.
SysApi
{
{
Path
:
"/"
+
a
.
Abbreviation
+
"/"
+
"create"
+
a
.
StructName
,
Description
:
"新增"
+
a
.
StructName
,
ApiGroup
:
a
.
Abbreviation
,
Method
:
"POST"
,
},
{
Path
:
"/"
+
a
.
Abbreviation
+
"/"
+
"delete"
+
a
.
StructName
,
Description
:
"删除"
+
a
.
StructName
,
ApiGroup
:
a
.
Abbreviation
,
Method
:
"DELETE"
,
},
{
Path
:
"/"
+
a
.
Abbreviation
+
"/"
+
"update"
+
a
.
StructName
,
Description
:
"更新"
+
a
.
StructName
,
ApiGroup
:
a
.
Abbreviation
,
Method
:
"POST"
,
},
{
Path
:
"/"
+
a
.
Abbreviation
+
"/"
+
"find"
+
a
.
StructName
,
Description
:
"根据ID获取"
+
a
.
StructName
,
ApiGroup
:
a
.
Abbreviation
,
Method
:
"GET"
,
},
{
Path
:
"/"
+
a
.
Abbreviation
+
"/"
+
"get"
+
a
.
StructName
+
"List"
,
Description
:
"获取"
+
a
.
StructName
+
"列表"
,
ApiGroup
:
a
.
StructName
,
Method
:
"GET"
,
},
}
for
_
,
v
:=
range
apiList
{
errC
:=
service
.
CreateApi
(
v
)
if
errC
!=
nil
{
c
.
Writer
.
Header
()
.
Add
(
"success"
,
"false"
)
c
.
Writer
.
Header
()
.
Add
(
"msg"
,
url
.
QueryEscape
(
fmt
.
Sprintf
(
"自动化创建失败,%v,请自行清空垃圾数据"
,
errC
)))
return
}
}
}
if
err
!=
nil
{
response
.
FailWithMessage
(
fmt
.
Sprintf
(
"创建失败,%v"
,
err
),
c
)
os
.
Remove
(
"./ginvueadmin.zip"
)
...
...
server/model/sys_auto_code.go
浏览文件 @
b7c816b9
...
...
@@ -2,10 +2,11 @@ package model
// 初始版本自动化代码工具
type
AutoCodeStruct
struct
{
StructName
string
`json:"structName"`
PackageName
string
`json:"packageName"`
Abbreviation
string
`json:"abbreviation"`
Fields
[]
Field
`json:"fields"`
StructName
string
`json:"structName"`
PackageName
string
`json:"packageName"`
Abbreviation
string
`json:"abbreviation"`
AutoCreateApiToSql
bool
`json:"autoCreateApiToSql"`
Fields
[]
Field
`json:"fields"`
}
type
Field
struct
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录