feat: 网元配置文件备份记录功能接口

This commit is contained in:
TsMask
2024-07-23 11:57:10 +08:00
parent fb4c6b483d
commit 0a3a835a85
6 changed files with 490 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
package service
import "be.ems/src/modules/network_element/model"
// INeConfigBackup 网元配置文件备份记录 服务层接口
type INeConfigBackup interface {
// SelectNeHostPage 分页查询列表数据
SelectPage(query map[string]any) map[string]any
// SelectList 根据实体查询
SelectList(item model.NeConfigBackup) []model.NeConfigBackup
// SelectByIds 通过ID查询
SelectById(id string) model.NeConfigBackup
// Insert 新增信息
Insert(item model.NeConfigBackup) string
// Update 修改信息
Update(item model.NeConfigBackup) int64
// DeleteByIds 批量删除信息
DeleteByIds(ids []string) (int64, error)
}

View File

@@ -0,0 +1,67 @@
package service
import (
"fmt"
"be.ems/src/modules/network_element/model"
"be.ems/src/modules/network_element/repository"
)
// NewNeConfigBackupImpl 网元配置文件备份记录 实例化服务层
var NewNeConfigBackupImpl = &NeConfigBackupImpl{
neConfigBackupRepository: repository.NewNeConfigBackupImpl,
}
// NeConfigBackupImpl 网元配置文件备份记录 服务层处理
type NeConfigBackupImpl struct {
// 网元配置文件备份记录
neConfigBackupRepository repository.INeConfigBackup
}
// SelectNeHostPage 分页查询列表数据
func (r *NeConfigBackupImpl) SelectPage(query map[string]any) map[string]any {
return r.neConfigBackupRepository.SelectPage(query)
}
// SelectConfigList 查询列表
func (r *NeConfigBackupImpl) SelectList(item model.NeConfigBackup) []model.NeConfigBackup {
return r.neConfigBackupRepository.SelectList(item)
}
// SelectByIds 通过ID查询
func (r *NeConfigBackupImpl) SelectById(id string) model.NeConfigBackup {
if id == "" {
return model.NeConfigBackup{}
}
arr := r.neConfigBackupRepository.SelectByIds([]string{id})
if len(arr) > 0 {
return arr[0]
}
return model.NeConfigBackup{}
}
// Insert 新增信息
func (r *NeConfigBackupImpl) Insert(item model.NeConfigBackup) string {
return r.neConfigBackupRepository.Insert(item)
}
// Update 修改信息
func (r *NeConfigBackupImpl) Update(item model.NeConfigBackup) int64 {
return r.neConfigBackupRepository.Update(item)
}
// DeleteByIds 批量删除信息
func (r *NeConfigBackupImpl) DeleteByIds(ids []string) (int64, error) {
// 检查是否存在
data := r.neConfigBackupRepository.SelectByIds(ids)
if len(data) <= 0 {
return 0, fmt.Errorf("neConfigBackup.noData")
}
if len(data) == len(ids) {
rows := r.neConfigBackupRepository.DeleteByIds(ids)
return rows, nil
}
// 删除信息失败!
return 0, fmt.Errorf("delete fail")
}