ref: v3变更,,表结构变更coreId/neId
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"be.ems/src/framework/reqctx"
|
||||
"be.ems/src/framework/resp"
|
||||
"be.ems/src/framework/utils/file"
|
||||
"be.ems/src/framework/utils/parse"
|
||||
"be.ems/src/modules/ne/model"
|
||||
neService "be.ems/src/modules/ne/service"
|
||||
|
||||
@@ -35,11 +36,6 @@ type NeConfigBackupController struct {
|
||||
// GET /list
|
||||
func (s NeConfigBackupController) List(c *gin.Context) {
|
||||
query := reqctx.QueryMap(c)
|
||||
coreUid, coreUidOk := query["coreUid"]
|
||||
if !coreUidOk || coreUid == "" {
|
||||
c.JSON(422, resp.CodeMsg(resp.CODE_PARAM_CHEACK, "bind err: coreUid is empty"))
|
||||
return
|
||||
}
|
||||
rows, total := s.neConfigBackupService.FindByPage(query)
|
||||
c.JSON(200, resp.OkData(map[string]any{"rows": rows, "total": total}))
|
||||
}
|
||||
@@ -50,9 +46,7 @@ func (s NeConfigBackupController) List(c *gin.Context) {
|
||||
func (s NeConfigBackupController) Download(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
ID int64 `form:"id" binding:"required"` // 记录ID
|
||||
ID int64 `form:"id" binding:"required"` // 记录ID
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -62,9 +56,7 @@ func (s NeConfigBackupController) Download(c *gin.Context) {
|
||||
|
||||
// 检查是否存在
|
||||
rows := s.neConfigBackupService.Find(model.NeConfigBackup{
|
||||
CoreUID: query.CoreUID,
|
||||
NeUID: query.NeUID,
|
||||
ID: query.ID,
|
||||
ID: query.ID,
|
||||
})
|
||||
if len(rows) <= 0 {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "neConfigBackup.noData")))
|
||||
@@ -85,11 +77,9 @@ func (s NeConfigBackupController) Download(c *gin.Context) {
|
||||
func (s NeConfigBackupController) Edit(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
CoreUID string `json:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" binding:"required"` // 网元唯一标识
|
||||
ID int64 `json:"id" binding:"required"` // 记录ID
|
||||
Name string `json:"name" binding:"required"` // 名称
|
||||
Remark string `json:"remark" binding:"required"` // 备注
|
||||
ID int64 `json:"id" binding:"required"` // 记录ID
|
||||
Name string `json:"name" binding:"required"` // 名称
|
||||
Remark string `json:"remark" binding:"required"` // 备注
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -99,9 +89,7 @@ func (s NeConfigBackupController) Edit(c *gin.Context) {
|
||||
|
||||
// 检查是否存在
|
||||
rows := s.neConfigBackupService.Find(model.NeConfigBackup{
|
||||
CoreUID: body.CoreUID,
|
||||
NeUID: body.NeUID,
|
||||
ID: body.ID,
|
||||
ID: body.ID,
|
||||
})
|
||||
if len(rows) <= 0 {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "neConfigBackup.noData")))
|
||||
@@ -125,9 +113,7 @@ func (s NeConfigBackupController) Edit(c *gin.Context) {
|
||||
func (s NeConfigBackupController) Remove(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var query struct {
|
||||
CoreUID string `form:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `form:"neUid" binding:"required"` // 网元唯一标识
|
||||
ID int64 `form:"id" binding:"required"` // 记录ID
|
||||
ID string `form:"id" binding:"required"` // 记录ID 批量多个逗号分隔
|
||||
}
|
||||
if err := c.ShouldBindQuery(&query); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -135,7 +121,15 @@ func (s NeConfigBackupController) Remove(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
rows, err := s.neConfigBackupService.DeleteByIds(query.ID, query.CoreUID, query.NeUID)
|
||||
// 处理字符转id数组后去重
|
||||
uniqueIDs := parse.RemoveDuplicatesToArray(query.ID, ",")
|
||||
// 转换成int64数组类型
|
||||
ids := make([]int64, 0)
|
||||
for _, v := range uniqueIDs {
|
||||
ids = append(ids, parse.Number(v))
|
||||
}
|
||||
|
||||
rows, err := s.neConfigBackupService.DeleteByIds(ids)
|
||||
if err != nil {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, err.Error())))
|
||||
return
|
||||
@@ -150,10 +144,9 @@ func (s NeConfigBackupController) Remove(c *gin.Context) {
|
||||
func (s NeConfigBackupController) Import(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
CoreUID string `json:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" binding:"required"` // 网元唯一标识
|
||||
Type string `json:"type" binding:"required,oneof=backup upload"` // 导入类型 backup upload
|
||||
Path string `json:"path" binding:"required"` // 备份文件zip文件路径
|
||||
NeUID string `json:"neUid" binding:"required"` // 网元唯一标识
|
||||
Type string `json:"type" binding:"required,oneof=backup upload"` // 导入类型 backup upload
|
||||
Path string `json:"path" binding:"required"` // 备份文件zip文件路径
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -166,8 +159,8 @@ func (s NeConfigBackupController) Import(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 查网元
|
||||
neInfo := s.neInfoService.FindByCoreUidAndNeUid(body.CoreUID, body.NeUID)
|
||||
if neInfo.CoreUID != body.CoreUID || neInfo.NeUID != body.NeUID {
|
||||
neInfo := s.neInfoService.FindByNeUid(body.NeUID)
|
||||
if neInfo.ID == 0 || neInfo.NeUid != body.NeUID {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
@@ -189,8 +182,7 @@ func (s NeConfigBackupController) Import(c *gin.Context) {
|
||||
func (s NeConfigBackupController) Export(c *gin.Context) {
|
||||
language := reqctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
CoreUID string `json:"coreUid" binding:"required"` // 核心网唯一标识
|
||||
NeUID string `json:"neUid" binding:"required"` // 网元唯一标识
|
||||
NeUID string `json:"neUid" binding:"required"` // 网元唯一标识
|
||||
}
|
||||
if err := c.ShouldBindBodyWithJSON(&body); err != nil {
|
||||
errMsgs := fmt.Sprintf("bind err: %s", resp.FormatBindError(err))
|
||||
@@ -198,8 +190,8 @@ func (s NeConfigBackupController) Export(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
// 查网元
|
||||
neInfo := s.neInfoService.FindByCoreUidAndNeUid(body.CoreUID, body.NeUID)
|
||||
if neInfo.CoreUID != body.CoreUID || neInfo.NeUID != body.NeUID {
|
||||
neInfo := s.neInfoService.FindByNeUid(body.NeUID)
|
||||
if neInfo.ID == 0 || neInfo.NeUid != body.NeUID {
|
||||
c.JSON(200, resp.ErrMsg(i18n.TKey(language, "app.common.noNEInfo")))
|
||||
return
|
||||
}
|
||||
@@ -211,9 +203,7 @@ func (s NeConfigBackupController) Export(c *gin.Context) {
|
||||
}
|
||||
// 新增备份记录
|
||||
item := model.NeConfigBackup{
|
||||
CoreUID: neInfo.CoreUID,
|
||||
NeUID: neInfo.NeUID,
|
||||
NeType: neInfo.NeType,
|
||||
NeID: neInfo.ID,
|
||||
Name: filepath.Base(zipFilePath),
|
||||
Path: zipFilePath,
|
||||
CreateBy: reqctx.LoginUserToUserName(c),
|
||||
|
||||
Reference in New Issue
Block a user