add: 新增告警数据信息接口
This commit is contained in:
12
src/modules/network_data/service/alarm.go
Normal file
12
src/modules/network_data/service/alarm.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package service
|
||||
|
||||
import "be.ems/src/modules/network_data/model"
|
||||
|
||||
// 告警 服务层接口
|
||||
type IAlarm interface {
|
||||
// SelectPage 根据条件分页查询
|
||||
SelectPage(querys model.AlarmQuery) map[string]any
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
DeleteByIds(ids []string) (int64, error)
|
||||
}
|
||||
40
src/modules/network_data/service/alarm.impl.go
Normal file
40
src/modules/network_data/service/alarm.impl.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"be.ems/src/modules/network_data/model"
|
||||
"be.ems/src/modules/network_data/repository"
|
||||
)
|
||||
|
||||
// 实例化数据层 AlarmImpl 结构体
|
||||
var NewAlarmImpl = &AlarmImpl{
|
||||
alarmRepository: repository.NewAlarmImpl,
|
||||
}
|
||||
|
||||
// AlarmImpl 告警 服务层处理
|
||||
type AlarmImpl struct {
|
||||
// 告警数据信息
|
||||
alarmRepository repository.IAlarm
|
||||
}
|
||||
|
||||
// SelectPage 根据条件分页查询
|
||||
func (r *AlarmImpl) SelectPage(querys model.AlarmQuery) map[string]any {
|
||||
return r.alarmRepository.SelectPage(querys)
|
||||
}
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
func (r *AlarmImpl) DeleteByIds(ids []string) (int64, error) {
|
||||
// 检查是否存在
|
||||
data := r.alarmRepository.SelectByIds(ids)
|
||||
if len(data) <= 0 {
|
||||
return 0, fmt.Errorf("no data")
|
||||
}
|
||||
|
||||
if len(data) == len(ids) {
|
||||
rows := r.alarmRepository.DeleteByIds(ids)
|
||||
return rows, nil
|
||||
}
|
||||
// 删除信息失败!
|
||||
return 0, fmt.Errorf("delete fail")
|
||||
}
|
||||
Reference in New Issue
Block a user