feat: 新增网元软件包信息/网元版本信息接口
This commit is contained in:
27
src/modules/network_element/service/ne_software.go
Normal file
27
src/modules/network_element/service/ne_software.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import "be.ems/src/modules/network_element/model"
|
||||
|
||||
// INeSoftware 网元软件包信息 服务层接口
|
||||
type INeSoftware interface {
|
||||
// SelectPage 根据条件分页查询字典类型
|
||||
SelectPage(query map[string]any) map[string]any
|
||||
|
||||
// SelectList 根据实体查询
|
||||
SelectList(neSoftware model.NeSoftware) []model.NeSoftware
|
||||
|
||||
// SelectById 通过ID查询
|
||||
SelectById(id string) model.NeSoftware
|
||||
|
||||
// Insert 新增信息
|
||||
Insert(neSoftware model.NeSoftware) string
|
||||
|
||||
// Update 修改信息
|
||||
Update(neSoftware model.NeSoftware) int64
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
DeleteByIds(ids []string) (int64, error)
|
||||
|
||||
// CheckUniqueTypeAndFileNameAndVersion 校验网元类型和文件名版本是否唯一
|
||||
CheckUniqueTypeAndFileNameAndVersion(neType, fileName, version, id string) bool
|
||||
}
|
||||
80
src/modules/network_element/service/ne_software.impl.go
Normal file
80
src/modules/network_element/service/ne_software.impl.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"be.ems/src/modules/network_element/model"
|
||||
"be.ems/src/modules/network_element/repository"
|
||||
)
|
||||
|
||||
// 实例化服务层 NeSoftwareImpl 结构体
|
||||
var NewNeSoftwareImpl = &NeSoftwareImpl{
|
||||
neSoftwareRepository: repository.NewNeSoftwareImpl,
|
||||
}
|
||||
|
||||
// NeSoftwareImpl 网元软件包信息 服务层处理
|
||||
type NeSoftwareImpl struct {
|
||||
// 网元软件包信息
|
||||
neSoftwareRepository repository.INeSoftware
|
||||
}
|
||||
|
||||
// SelectNeHostPage 分页查询列表数据
|
||||
func (r *NeSoftwareImpl) SelectPage(query map[string]any) map[string]any {
|
||||
return r.neSoftwareRepository.SelectPage(query)
|
||||
}
|
||||
|
||||
// SelectConfigList 查询列表
|
||||
func (r *NeSoftwareImpl) SelectList(neSoftware model.NeSoftware) []model.NeSoftware {
|
||||
return r.neSoftwareRepository.SelectList(neSoftware)
|
||||
}
|
||||
|
||||
// SelectByIds 通过ID查询
|
||||
func (r *NeSoftwareImpl) SelectById(id string) model.NeSoftware {
|
||||
if id == "" {
|
||||
return model.NeSoftware{}
|
||||
}
|
||||
neHosts := r.neSoftwareRepository.SelectByIds([]string{id})
|
||||
if len(neHosts) > 0 {
|
||||
return neHosts[0]
|
||||
}
|
||||
return model.NeSoftware{}
|
||||
}
|
||||
|
||||
// Insert 新增信息
|
||||
func (r *NeSoftwareImpl) Insert(neSoftware model.NeSoftware) string {
|
||||
return r.neSoftwareRepository.Insert(neSoftware)
|
||||
}
|
||||
|
||||
// Update 修改信息
|
||||
func (r *NeSoftwareImpl) Update(neSoftware model.NeSoftware) int64 {
|
||||
return r.neSoftwareRepository.Update(neSoftware)
|
||||
}
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
func (r *NeSoftwareImpl) DeleteByIds(ids []string) (int64, error) {
|
||||
// 检查是否存在
|
||||
rowIds := r.neSoftwareRepository.SelectByIds(ids)
|
||||
if len(rowIds) <= 0 {
|
||||
return 0, fmt.Errorf("neSoftware.noData")
|
||||
}
|
||||
|
||||
if len(rowIds) == len(ids) {
|
||||
rows := r.neSoftwareRepository.DeleteByIds(ids)
|
||||
return rows, nil
|
||||
}
|
||||
// 删除信息失败!
|
||||
return 0, fmt.Errorf("delete fail")
|
||||
}
|
||||
|
||||
// CheckUniqueTypeAndFileNameAndVersion 校验网元类型和文件名版本是否唯一
|
||||
func (r *NeSoftwareImpl) CheckUniqueTypeAndFileNameAndVersion(neType, fileName, version, id string) bool {
|
||||
uniqueId := r.neSoftwareRepository.CheckUniqueTypeAndFileNameAndVersion(model.NeSoftware{
|
||||
NeType: neType,
|
||||
FileName: fileName,
|
||||
Version: version,
|
||||
})
|
||||
if uniqueId == id {
|
||||
return true
|
||||
}
|
||||
return uniqueId == ""
|
||||
}
|
||||
27
src/modules/network_element/service/ne_version.go
Normal file
27
src/modules/network_element/service/ne_version.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import "be.ems/src/modules/network_element/model"
|
||||
|
||||
// INeVersion 网元版本信息 服务层接口
|
||||
type INeVersion interface {
|
||||
// SelectPage 根据条件分页查询字典类型
|
||||
SelectPage(query map[string]any) map[string]any
|
||||
|
||||
// SelectList 根据实体查询
|
||||
SelectList(neVersion model.NeVersion) []model.NeVersion
|
||||
|
||||
// SelectById 通过ID查询
|
||||
SelectById(id string) model.NeVersion
|
||||
|
||||
// Insert 新增信息
|
||||
Insert(neVersion model.NeVersion) string
|
||||
|
||||
// Update 修改信息
|
||||
Update(neVersion model.NeVersion) int64
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
DeleteByIds(ids []string) (int64, error)
|
||||
|
||||
// CheckUniqueTypeAndID 校验网元类型和网元ID是否唯一
|
||||
CheckUniqueTypeAndID(neType, neId, id string) bool
|
||||
}
|
||||
79
src/modules/network_element/service/ne_version.impl.go
Normal file
79
src/modules/network_element/service/ne_version.impl.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"be.ems/src/modules/network_element/model"
|
||||
"be.ems/src/modules/network_element/repository"
|
||||
)
|
||||
|
||||
// 实例化服务层 NeVersionImpl 结构体
|
||||
var NewNeVersionImpl = &NeVersionImpl{
|
||||
neVersionRepository: repository.NewNeVersionImpl,
|
||||
}
|
||||
|
||||
// NeVersionImpl 网元版本信息 服务层处理
|
||||
type NeVersionImpl struct {
|
||||
// 网元版本信息表
|
||||
neVersionRepository repository.INeVersion
|
||||
}
|
||||
|
||||
// SelectNeHostPage 分页查询列表数据
|
||||
func (r *NeVersionImpl) SelectPage(query map[string]any) map[string]any {
|
||||
return r.neVersionRepository.SelectPage(query)
|
||||
}
|
||||
|
||||
// SelectConfigList 查询列表
|
||||
func (r *NeVersionImpl) SelectList(neVersion model.NeVersion) []model.NeVersion {
|
||||
return r.neVersionRepository.SelectList(neVersion)
|
||||
}
|
||||
|
||||
// SelectByIds 通过ID查询
|
||||
func (r *NeVersionImpl) SelectById(id string) model.NeVersion {
|
||||
if id == "" {
|
||||
return model.NeVersion{}
|
||||
}
|
||||
neHosts := r.neVersionRepository.SelectByIds([]string{id})
|
||||
if len(neHosts) > 0 {
|
||||
return neHosts[0]
|
||||
}
|
||||
return model.NeVersion{}
|
||||
}
|
||||
|
||||
// Insert 新增信息
|
||||
func (r *NeVersionImpl) Insert(neVersion model.NeVersion) string {
|
||||
return r.neVersionRepository.Insert(neVersion)
|
||||
}
|
||||
|
||||
// Update 修改信息
|
||||
func (r *NeVersionImpl) Update(neVersion model.NeVersion) int64 {
|
||||
return r.neVersionRepository.Update(neVersion)
|
||||
}
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
func (r *NeVersionImpl) DeleteByIds(ids []string) (int64, error) {
|
||||
// 检查是否存在
|
||||
rowIds := r.neVersionRepository.SelectByIds(ids)
|
||||
if len(rowIds) <= 0 {
|
||||
return 0, fmt.Errorf("neVersion.noData")
|
||||
}
|
||||
|
||||
if len(rowIds) == len(ids) {
|
||||
rows := r.neVersionRepository.DeleteByIds(ids)
|
||||
return rows, nil
|
||||
}
|
||||
// 删除信息失败!
|
||||
return 0, fmt.Errorf("delete fail")
|
||||
}
|
||||
|
||||
// CheckUniqueTypeAndID 校验网元类型和网元ID是否唯一
|
||||
func (r *NeVersionImpl) CheckUniqueTypeAndID(neType, neId, id string) bool {
|
||||
uniqueId := r.neVersionRepository.CheckUniqueTypeAndID(model.NeVersion{
|
||||
NeType: neType,
|
||||
NeId: neId,
|
||||
})
|
||||
if uniqueId == id {
|
||||
return true
|
||||
}
|
||||
return uniqueId == ""
|
||||
}
|
||||
Reference in New Issue
Block a user