feat: 更新多个模块以支持新的数据结构和日志格式
This commit is contained in:
59
src/modules/network_data/service/alarm.go
Normal file
59
src/modules/network_data/service/alarm.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"be.ems/src/modules/network_data/model"
|
||||
"be.ems/src/modules/network_data/repository"
|
||||
)
|
||||
|
||||
// 实例化数据层 Alarm 结构体
|
||||
var NewAlarm = &Alarm{
|
||||
alarmRepository: repository.NewAlarm,
|
||||
}
|
||||
|
||||
// Alarm 告警 服务层处理
|
||||
type Alarm struct {
|
||||
alarmRepository *repository.Alarm // 告警数据信息
|
||||
}
|
||||
|
||||
// FindByPage 根据条件分页查询
|
||||
func (r Alarm) FindByPage(query model.AlarmQuery) ([]model.Alarm, int64) {
|
||||
return r.alarmRepository.SelectByPage(query)
|
||||
}
|
||||
|
||||
// Find 查询
|
||||
func (r Alarm) Find(param model.Alarm) []model.Alarm {
|
||||
return r.alarmRepository.Select(param)
|
||||
}
|
||||
|
||||
// Insert 新增信息
|
||||
func (s Alarm) Insert(param model.Alarm) int64 {
|
||||
return s.alarmRepository.Insert(param)
|
||||
}
|
||||
|
||||
// Update 修改信息
|
||||
func (s Alarm) Update(param model.Alarm) int64 {
|
||||
return s.alarmRepository.Update(param)
|
||||
}
|
||||
|
||||
// DeleteByIds 批量删除信息
|
||||
func (r Alarm) DeleteByIds(ids []int64) (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")
|
||||
}
|
||||
|
||||
// FindAlarmSeqLast 查询网元告警最后一条序号
|
||||
func (s Alarm) FindAlarmSeqLast(neType, neId string) int64 {
|
||||
return s.alarmRepository.SelectAlarmSeqLast(neType, neId)
|
||||
}
|
||||
Reference in New Issue
Block a user