fix: 统一备份接口和前端组件封装
This commit is contained in:
@@ -210,90 +210,6 @@ func (b *BaseApi) ListDBName(c *gin.Context) {
|
||||
helper.SuccessWithData(c, list)
|
||||
}
|
||||
|
||||
// @Tags Database Mysql
|
||||
// @Summary Backup mysql database
|
||||
// @Description 备份 mysql 数据库
|
||||
// @Accept json
|
||||
// @Param request body dto.BackupDB true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /databases/backup [post]
|
||||
// @x-panel-log {"bodyKeys":["mysqlName","dbName"],"paramKeys":[],"BeforeFuntions":[],"formatZH":"备份 mysql 数据库 [mysqlName][dbName]","formatEN":"backup mysql database [mysqlName][dbName]"}
|
||||
func (b *BaseApi) BackupMysql(c *gin.Context) {
|
||||
var req dto.BackupDB
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
if err := global.VALID.Struct(req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := mysqlService.Backup(req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags Database Mysql
|
||||
// @Summary Recover mysql database by upload file
|
||||
// @Description Mysql 数据库从上传文件恢复
|
||||
// @Accept json
|
||||
// @Param request body dto.UploadRecover true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /databases/recover/byupload [post]
|
||||
// @x-panel-log {"bodyKeys":["fileDir","fileName","mysqlName","dbName"],"paramKeys":[],"BeforeFuntions":[],"formatZH":"mysql 数据库从 [fileDir]/[fileName] 恢复 [mysqlName][dbName]","formatEN":"mysql database recover [fileDir]/[fileName] from [mysqlName][dbName]"}
|
||||
func (b *BaseApi) RecoverMysqlByUpload(c *gin.Context) {
|
||||
var req dto.UploadRecover
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
if err := global.VALID.Struct(req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := mysqlService.RecoverByUpload(req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags Database Mysql
|
||||
// @Summary Recover mysql database
|
||||
// @Description Mysql 数据库恢复
|
||||
// @Accept json
|
||||
// @Param request body dto.RecoverDB true "request"
|
||||
// @Success 200
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /databases/recover [post]
|
||||
// @x-panel-log {"bodyKeys":["mysqlName","dbName","backupName"],"paramKeys":[],"BeforeFuntions":[],"formatZH":"恢复 mysql 数据库 [mysqlName][dbName] [backupName]","formatEN":"恢复 mysql 数据库 [mysqlName][dbName] [backupName]"}
|
||||
func (b *BaseApi) RecoverMysql(c *gin.Context) {
|
||||
var req dto.RecoverDB
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
if err := global.VALID.Struct(req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := mysqlService.Recover(req); err != nil {
|
||||
helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err)
|
||||
return
|
||||
}
|
||||
|
||||
helper.SuccessWithData(c, nil)
|
||||
}
|
||||
|
||||
// @Tags Database Mysql
|
||||
// @Summary Check before delete mysql database
|
||||
// @Description Mysql 数据库删除前检查
|
||||
|
Reference in New Issue
Block a user