Browse Source
Merge pull request #584 from songzhibin97/gva_gormv2_dev
feat:增加删除历史记录api
main
奇淼(piexlmax
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
35 additions and
8 deletions
-
server/api/v1/sys_auto_code.go
-
server/router/sys_auto_code.go
-
server/service/sys_autocode_history.go
|
|
@ -16,6 +16,26 @@ import ( |
|
|
|
"go.uber.org/zap" |
|
|
|
) |
|
|
|
|
|
|
|
// @Tags AutoCode
|
|
|
|
// @Summary 删除回滚记录
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
// @accept application/json
|
|
|
|
// @Produce application/json
|
|
|
|
// @Param data body request.AutoHistoryByID true "删除回滚记录"
|
|
|
|
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
|
|
|
// @Router /autoCode/delSysHistory [post]
|
|
|
|
func DelSysHistory(c *gin.Context) { |
|
|
|
var id request.AutoHistoryByID |
|
|
|
_ = c.ShouldBindJSON(&id) |
|
|
|
err := service.DeletePage(id.ID) |
|
|
|
if err != nil { |
|
|
|
global.GVA_LOG.Error("获取失败!", zap.Any("err", err)) |
|
|
|
response.FailWithMessage("获取失败", c) |
|
|
|
} |
|
|
|
response.OkWithMessage("删除成功", c) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// @Tags AutoCode
|
|
|
|
// @Summary 查询回滚记录
|
|
|
|
// @Security ApiKeyAuth
|
|
|
|
|
|
@ -8,6 +8,7 @@ import ( |
|
|
|
func InitAutoCodeRouter(Router *gin.RouterGroup) { |
|
|
|
AutoCodeRouter := Router.Group("autoCode") |
|
|
|
{ |
|
|
|
AutoCodeRouter.POST("delSysHistory", v1.DelSysHistory) // 删除回滚记录
|
|
|
|
AutoCodeRouter.POST("getMeta", v1.GetMeta) // 根据id获取meta信息
|
|
|
|
AutoCodeRouter.POST("getSysHistory", v1.GetSysHistory) // 获取回滚记录分页
|
|
|
|
AutoCodeRouter.POST("rollback", v1.RollBack) // 回滚
|
|
|
|
|
|
@ -70,6 +70,7 @@ func GetMeta(id uint) (string, error) { |
|
|
|
return meta, global.GVA_DB.Model(model.SysAutoCodeHistory{}).Select("request_meta").First(&meta, id).Error |
|
|
|
} |
|
|
|
|
|
|
|
// GetSysHistoryPage 获取系统历史数据
|
|
|
|
func GetSysHistoryPage(info request.PageInfo) (err error, list interface{}, total int64) { |
|
|
|
limit := info.PageSize |
|
|
|
offset := info.PageSize * (info.Page - 1) |
|
|
@ -79,3 +80,8 @@ func GetSysHistoryPage(info request.PageInfo) (err error, list interface{}, tota |
|
|
|
err = db.Limit(limit).Offset(offset).Order("updated_at desc").Select("id,created_at,updated_at,struct_name,struct_cn_name,flag,table_name").Find(&fileLists).Error |
|
|
|
return err, fileLists, total |
|
|
|
} |
|
|
|
|
|
|
|
// DeletePage 删除历史数据
|
|
|
|
func DeletePage(id uint) error { |
|
|
|
return global.GVA_DB.Delete(model.SysAutoCodeHistory{}, id).Error |
|
|
|
} |