feat: 网元配置文件备份记录文件下载/记录更新功能接口
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package controller
|
package controller
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -43,8 +44,8 @@ func (s *NeConfigBackupController) List(c *gin.Context) {
|
|||||||
|
|
||||||
// 网元配置文件备份记录信息
|
// 网元配置文件备份记录信息
|
||||||
//
|
//
|
||||||
// GET /?id=xx
|
// GET /download?id=xx
|
||||||
func (s *NeConfigBackupController) Info(c *gin.Context) {
|
func (s *NeConfigBackupController) Download(c *gin.Context) {
|
||||||
language := ctx.AcceptLanguage(c)
|
language := ctx.AcceptLanguage(c)
|
||||||
id, ok := c.GetQuery("id")
|
id, ok := c.GetQuery("id")
|
||||||
if !ok || id == "" {
|
if !ok || id == "" {
|
||||||
@@ -59,7 +60,46 @@ func (s *NeConfigBackupController) Info(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(200, result.OkData(item))
|
if _, err := os.Stat(item.Path); err != nil {
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "neConfigBackup.notFoundFile")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.FileAttachment(item.Path, item.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 网元配置文件备份记录修改
|
||||||
|
//
|
||||||
|
// PUT /
|
||||||
|
func (s *NeConfigBackupController) Edit(c *gin.Context) {
|
||||||
|
language := ctx.AcceptLanguage(c)
|
||||||
|
var body struct {
|
||||||
|
ID string `json:"id" binding:"required"` // 记录ID
|
||||||
|
Name string `json:"name" binding:"required"` // 名称
|
||||||
|
Remark string `json:"remark" binding:"required"` // 备注
|
||||||
|
}
|
||||||
|
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||||
|
if err != nil || body.ID == "" {
|
||||||
|
c.JSON(400, result.CodeMsg(400, i18n.TKey(language, "app.common.err400")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否存在
|
||||||
|
data := s.neConfigBackupService.SelectById(body.ID)
|
||||||
|
if data.ID != body.ID {
|
||||||
|
// 没有可访问主机命令数据!
|
||||||
|
c.JSON(200, result.ErrMsg(i18n.TKey(language, "neConfig.noData")))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data.Name = body.Name
|
||||||
|
data.Remark = body.Remark
|
||||||
|
data.UpdateBy = ctx.LoginUserToUserName(c)
|
||||||
|
rows := s.neConfigBackupService.Update(data)
|
||||||
|
if rows > 0 {
|
||||||
|
c.JSON(200, result.Ok(nil))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(200, result.Err(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// 网元配置文件备份记录删除
|
// 网元配置文件备份记录删除
|
||||||
|
|||||||
@@ -317,12 +317,18 @@ func Setup(router *gin.Engine) {
|
|||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
controller.NewNeConfigBackup.List,
|
controller.NewNeConfigBackup.List,
|
||||||
)
|
)
|
||||||
neConfigBackupGroup.GET("",
|
neConfigBackupGroup.GET("/download",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
controller.NewNeConfigBackup.Info,
|
controller.NewNeConfigBackup.Download,
|
||||||
|
)
|
||||||
|
neConfigBackupGroup.PUT("",
|
||||||
|
middleware.PreAuthorize(nil),
|
||||||
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neConfigBackup", collectlogs.BUSINESS_TYPE_UPDATE)),
|
||||||
|
controller.NewNeConfigBackup.Edit,
|
||||||
)
|
)
|
||||||
neConfigBackupGroup.DELETE("",
|
neConfigBackupGroup.DELETE("",
|
||||||
middleware.PreAuthorize(nil),
|
middleware.PreAuthorize(nil),
|
||||||
|
collectlogs.OperateLog(collectlogs.OptionNew("log.operate.title.neConfigBackup", collectlogs.BUSINESS_TYPE_DELETE)),
|
||||||
controller.NewNeConfigBackup.Remove,
|
controller.NewNeConfigBackup.Remove,
|
||||||
)
|
)
|
||||||
neConfigBackupGroup.POST("/import",
|
neConfigBackupGroup.POST("/import",
|
||||||
|
|||||||
Reference in New Issue
Block a user