feat: 内转请求的网元参数配置接口

This commit is contained in:
TsMask
2024-06-25 17:03:56 +08:00
parent d92ca5f2e4
commit c816b64b31
9 changed files with 610 additions and 2 deletions

View File

@@ -0,0 +1,24 @@
package service
import "be.ems/src/modules/network_element/model"
// INeConfig 网元参数配置可用属性值 服务层接口
type INeConfig interface {
// SelectPage 根据条件分页查询字典类型
SelectPage(query map[string]any) map[string]any
// SelectList 根据实体查询
SelectList(param model.NeConfig) []model.NeConfig
// SelectByIds 通过ID查询
SelectById(id string) model.NeConfig
// Insert 新增信息
Insert(param model.NeConfig) string
// Update 修改信息
Update(param model.NeConfig) 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"
)
// NewNeConfigImpl 网元参数配置可用属性值 实例化服务层
var NewNeConfigImpl = &NeConfigImpl{
neConfigRepository: repository.NewNeConfigImpl,
}
// NeConfigImpl 网元参数配置可用属性值 服务层处理
type NeConfigImpl struct {
// 网元参数配置可用属性值表
neConfigRepository repository.INeConfig
}
// SelectNeHostPage 分页查询列表数据
func (r *NeConfigImpl) SelectPage(query map[string]any) map[string]any {
return r.neConfigRepository.SelectPage(query)
}
// SelectConfigList 查询列表
func (r *NeConfigImpl) SelectList(param model.NeConfig) []model.NeConfig {
return r.neConfigRepository.SelectList(param)
}
// SelectByIds 通过ID查询
func (r *NeConfigImpl) SelectById(id string) model.NeConfig {
if id == "" {
return model.NeConfig{}
}
neHosts := r.neConfigRepository.SelectByIds([]string{id})
if len(neHosts) > 0 {
return neHosts[0]
}
return model.NeConfig{}
}
// Insert 新增信息
func (r *NeConfigImpl) Insert(param model.NeConfig) string {
return r.neConfigRepository.Insert(param)
}
// Update 修改信息
func (r *NeConfigImpl) Update(param model.NeConfig) int64 {
return r.neConfigRepository.Update(param)
}
// DeleteByIds 批量删除信息
func (r *NeConfigImpl) DeleteByIds(ids []string) (int64, error) {
// 检查是否存在
data := r.neConfigRepository.SelectByIds(ids)
if len(data) <= 0 {
return 0, fmt.Errorf("param.noData")
}
if len(data) == len(ids) {
rows := r.neConfigRepository.DeleteByIds(ids)
return rows, nil
}
// 删除信息失败!
return 0, fmt.Errorf("delete fail")
}