feat: 新增网元主机命令接口
This commit is contained in:
27
src/modules/network_element/service/ne_host_cmd.go
Normal file
27
src/modules/network_element/service/ne_host_cmd.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package service
|
||||
|
||||
import "ems.agt/src/modules/network_element/model"
|
||||
|
||||
// INeHostCmd 网元主机命令 服务层接口
|
||||
type INeHostCmd interface {
|
||||
// SelectPage 根据条件分页查询字典类型
|
||||
SelectPage(query map[string]any) map[string]any
|
||||
|
||||
// SelectList 根据实体查询
|
||||
SelectList(neHostCmd model.NeHostCmd) []model.NeHostCmd
|
||||
|
||||
// SelectByIds 通过ID查询
|
||||
SelectById(cmdId string) model.NeHostCmd
|
||||
|
||||
// Insert 新增信息
|
||||
Insert(neHostCmd model.NeHostCmd) string
|
||||
|
||||
// Update 修改信息
|
||||
Update(neHostCmd model.NeHostCmd) int64
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
DeleteByIds(cmdIds []string) (int64, error)
|
||||
|
||||
// CheckUniqueGroupTitle 校验同类型组内是否唯一
|
||||
CheckUniqueGroupTitle(groupId, title, cmdType, cmdId string) bool
|
||||
}
|
||||
80
src/modules/network_element/service/ne_host_cmd.impl.go
Normal file
80
src/modules/network_element/service/ne_host_cmd.impl.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"ems.agt/src/modules/network_element/model"
|
||||
"ems.agt/src/modules/network_element/repository"
|
||||
)
|
||||
|
||||
// 实例化服务层 NeHostCmdImpl 结构体
|
||||
var NewNeHostCmdImpl = &NeHostCmdImpl{
|
||||
neHostCmdRepository: repository.NewNeHostCmdImpl,
|
||||
}
|
||||
|
||||
// NeHostCmdImpl 网元主机命令 服务层处理
|
||||
type NeHostCmdImpl struct {
|
||||
// 网元主机命令表
|
||||
neHostCmdRepository repository.INeHostCmd
|
||||
}
|
||||
|
||||
// SelectNeHostPage 分页查询列表数据
|
||||
func (r *NeHostCmdImpl) SelectPage(query map[string]any) map[string]any {
|
||||
return r.neHostCmdRepository.SelectPage(query)
|
||||
}
|
||||
|
||||
// SelectConfigList 查询列表
|
||||
func (r *NeHostCmdImpl) SelectList(neHostCmd model.NeHostCmd) []model.NeHostCmd {
|
||||
return r.neHostCmdRepository.SelectList(neHostCmd)
|
||||
}
|
||||
|
||||
// SelectByIds 通过ID查询
|
||||
func (r *NeHostCmdImpl) SelectById(cmdId string) model.NeHostCmd {
|
||||
if cmdId == "" {
|
||||
return model.NeHostCmd{}
|
||||
}
|
||||
neHosts := r.neHostCmdRepository.SelectByIds([]string{cmdId})
|
||||
if len(neHosts) > 0 {
|
||||
return neHosts[0]
|
||||
}
|
||||
return model.NeHostCmd{}
|
||||
}
|
||||
|
||||
// Insert 新增信息
|
||||
func (r *NeHostCmdImpl) Insert(neHostCmd model.NeHostCmd) string {
|
||||
return r.neHostCmdRepository.Insert(neHostCmd)
|
||||
}
|
||||
|
||||
// Update 修改信息
|
||||
func (r *NeHostCmdImpl) Update(neHostCmd model.NeHostCmd) int64 {
|
||||
return r.neHostCmdRepository.Update(neHostCmd)
|
||||
}
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
func (r *NeHostCmdImpl) DeleteByIds(cmdIds []string) (int64, error) {
|
||||
// 检查是否存在
|
||||
ids := r.neHostCmdRepository.SelectByIds(cmdIds)
|
||||
if len(ids) <= 0 {
|
||||
return 0, fmt.Errorf("neHostCmd.noData")
|
||||
}
|
||||
|
||||
if len(ids) == len(cmdIds) {
|
||||
rows := r.neHostCmdRepository.DeleteByIds(cmdIds)
|
||||
return rows, nil
|
||||
}
|
||||
// 删除信息失败!
|
||||
return 0, fmt.Errorf("delete fail")
|
||||
}
|
||||
|
||||
// CheckUniqueGroupTitle 校验同类型组内是否唯一
|
||||
func (r *NeHostCmdImpl) CheckUniqueGroupTitle(groupId, title, cmdType, cmdId string) bool {
|
||||
uniqueId := r.neHostCmdRepository.CheckUniqueGroupTitle(model.NeHostCmd{
|
||||
CmdType: cmdType,
|
||||
GroupID: groupId,
|
||||
Title: title,
|
||||
})
|
||||
if uniqueId == cmdId {
|
||||
return true
|
||||
}
|
||||
return uniqueId == ""
|
||||
}
|
||||
Reference in New Issue
Block a user