Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
飞一样的人
gin-vue-admin
提交
946b51c9
G
gin-vue-admin
项目概览
飞一样的人
/
gin-vue-admin
与 Fork 源项目一致
Fork自
FLIPPED-AURORA / gin-vue-admin
通知
1
Star
1
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,发现更多精彩内容 >>
提交
946b51c9
编写于
7月 10, 2021
作者:
S
songzhibin97
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat:增加查询api
上级
e1e3a31e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
49 addition
and
6 deletion
+49
-6
server/api/v1/sys_auto_code.go
server/api/v1/sys_auto_code.go
+28
-2
server/model/request/sys_autocode.go
server/model/request/sys_autocode.go
+8
-0
server/model/sys_auto_code.go
server/model/sys_auto_code.go
+0
-4
server/router/sys_auto_code.go
server/router/sys_auto_code.go
+1
-0
server/service/sys_autocode_history.go
server/service/sys_autocode_history.go
+12
-0
未找到文件。
server/api/v1/sys_auto_code.go
浏览文件 @
946b51c9
...
...
@@ -5,6 +5,7 @@ import (
"fmt"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
"gin-vue-admin/model/response"
"gin-vue-admin/service"
"gin-vue-admin/utils"
...
...
@@ -15,16 +16,41 @@ import (
"go.uber.org/zap"
)
// @Tags AutoCode
// @Summary 查询回滚记录
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.SysAutoHistory true "查询回滚记录"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"回滚成功"}"
// @Router /autoCode/preview [post]
func
GetSysHistory
(
c
*
gin
.
Context
)
{
var
search
request
.
SysAutoHistory
_
=
c
.
ShouldBindJSON
(
&
search
)
err
,
list
,
total
:=
service
.
GetSysHistoryPage
(
search
.
PageInfo
)
if
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"获取失败!"
,
zap
.
Any
(
"err"
,
err
))
response
.
FailWithMessage
(
"获取失败"
,
c
)
}
else
{
response
.
OkWithDetailed
(
response
.
PageResult
{
List
:
list
,
Total
:
total
,
Page
:
search
.
Page
,
PageSize
:
search
.
PageSize
,
},
"获取成功"
,
c
)
}
}
// @Tags AutoCode
// @Summary 回滚
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body
uint
true "回滚自动生成代码"
// @Param data body
request.AutoHistoryByID
true "回滚自动生成代码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"回滚成功"}"
// @Router /autoCode/preview [post]
func
RollBack
(
c
*
gin
.
Context
)
{
var
id
model
.
AutoHistoryByID
var
id
request
.
AutoHistoryByID
_
=
c
.
ShouldBindJSON
(
&
id
)
if
err
:=
service
.
RollBack
(
id
.
ID
);
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
...
...
server/model/request/sys_autocode.go
浏览文件 @
946b51c9
package
request
type
SysAutoHistory
struct
{
PageInfo
}
type
AutoHistoryByID
struct
{
ID
uint
`json:"id"`
}
type
DBReq
struct
{
Database
string
`json:"database" gorm:"column:database"`
}
...
...
server/model/sys_auto_code.go
浏览文件 @
946b51c9
...
...
@@ -2,10 +2,6 @@ package model
import
"errors"
type
AutoHistoryByID
struct
{
ID
uint
`json:"id"`
}
// 初始版本自动化代码工具
type
AutoCodeStruct
struct
{
StructName
string
`json:"structName"`
// Struct名称
...
...
server/router/sys_auto_code.go
浏览文件 @
946b51c9
...
...
@@ -8,6 +8,7 @@ import (
func
InitAutoCodeRouter
(
Router
*
gin
.
RouterGroup
)
{
AutoCodeRouter
:=
Router
.
Group
(
"autoCode"
)
{
AutoCodeRouter
.
POST
(
"getSysHistory"
,
v1
.
GetSysHistory
)
// 获取回滚记录分页
AutoCodeRouter
.
POST
(
"rollback"
,
v1
.
RollBack
)
// 回滚
AutoCodeRouter
.
POST
(
"preview"
,
v1
.
PreviewTemp
)
// 获取自动创建代码预览
AutoCodeRouter
.
POST
(
"createTemp"
,
v1
.
CreateTemp
)
// 创建自动化代码
...
...
server/service/sys_autocode_history.go
浏览文件 @
946b51c9
...
...
@@ -4,6 +4,7 @@ import (
"errors"
"gin-vue-admin/global"
"gin-vue-admin/model"
"gin-vue-admin/model/request"
"gin-vue-admin/utils"
"strings"
...
...
@@ -20,6 +21,7 @@ func CreateAutoCodeHistory(autoCodeMeta string, injectionMeta string, tableName
})
.
Error
}
// RollBack 回滚
func
RollBack
(
id
uint
)
error
{
md
:=
model
.
SysAutoCodeHistory
{}
if
err
:=
global
.
GVA_DB
.
First
(
&
md
,
id
)
.
Error
;
err
!=
nil
{
...
...
@@ -61,3 +63,13 @@ func RollBack(id uint) error {
md
.
Flag
=
1
return
global
.
GVA_DB
.
Save
(
&
md
)
.
Error
}
func
GetSysHistoryPage
(
info
request
.
PageInfo
)
(
err
error
,
list
interface
{},
total
int64
)
{
limit
:=
info
.
PageSize
offset
:=
info
.
PageSize
*
(
info
.
Page
-
1
)
db
:=
global
.
GVA_DB
var
fileLists
[]
model
.
SysAutoCodeHistory
err
=
db
.
Find
(
&
fileLists
)
.
Count
(
&
total
)
.
Error
err
=
db
.
Limit
(
limit
)
.
Offset
(
offset
)
.
Order
(
"updated_at desc"
)
.
Find
(
&
fileLists
)
.
Error
return
err
,
fileLists
,
total
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录