64 lines
3.0 KiB
Go
64 lines
3.0 KiB
Go
package service
|
|
|
|
import (
|
|
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
|
|
"git.huangwc.com/pig/pig-farm-controller/internal/infra/repository"
|
|
)
|
|
|
|
// MonitorService 定义了监控相关的业务逻辑服务
|
|
type MonitorService struct {
|
|
sensorDataRepo repository.SensorDataRepository
|
|
deviceCommandLogRepo repository.DeviceCommandLogRepository
|
|
executionLogRepo repository.ExecutionLogRepository
|
|
pendingCollectionRepo repository.PendingCollectionRepository
|
|
userActionLogRepo repository.UserActionLogRepository
|
|
// 在这里可以添加其他超表模型的仓库依赖
|
|
}
|
|
|
|
// NewMonitorService 创建一个新的 MonitorService 实例
|
|
func NewMonitorService(
|
|
sensorDataRepo repository.SensorDataRepository,
|
|
deviceCommandLogRepo repository.DeviceCommandLogRepository,
|
|
executionLogRepo repository.ExecutionLogRepository,
|
|
pendingCollectionRepo repository.PendingCollectionRepository,
|
|
userActionLogRepo repository.UserActionLogRepository,
|
|
) *MonitorService {
|
|
return &MonitorService{
|
|
sensorDataRepo: sensorDataRepo,
|
|
deviceCommandLogRepo: deviceCommandLogRepo,
|
|
executionLogRepo: executionLogRepo,
|
|
pendingCollectionRepo: pendingCollectionRepo,
|
|
userActionLogRepo: userActionLogRepo,
|
|
}
|
|
}
|
|
|
|
// ListSensorData 负责处理查询传感器数据列表的业务逻辑
|
|
func (s *MonitorService) ListSensorData(opts repository.SensorDataListOptions, page, pageSize int) ([]models.SensorData, int64, error) {
|
|
return s.sensorDataRepo.List(opts, page, pageSize)
|
|
}
|
|
|
|
// ListDeviceCommandLogs 负责处理查询设备命令日志列表的业务逻辑
|
|
func (s *MonitorService) ListDeviceCommandLogs(opts repository.DeviceCommandLogListOptions, page, pageSize int) ([]models.DeviceCommandLog, int64, error) {
|
|
return s.deviceCommandLogRepo.List(opts, page, pageSize)
|
|
}
|
|
|
|
// ListPlanExecutionLogs 负责处理查询计划执行日志列表的业务逻辑
|
|
func (s *MonitorService) ListPlanExecutionLogs(opts repository.PlanExecutionLogListOptions, page, pageSize int) ([]models.PlanExecutionLog, int64, error) {
|
|
return s.executionLogRepo.ListPlanExecutionLogs(opts, page, pageSize)
|
|
}
|
|
|
|
// ListTaskExecutionLogs 负责处理查询任务执行日志列表的业务逻辑
|
|
func (s *MonitorService) ListTaskExecutionLogs(opts repository.TaskExecutionLogListOptions, page, pageSize int) ([]models.TaskExecutionLog, int64, error) {
|
|
return s.executionLogRepo.ListTaskExecutionLogs(opts, page, pageSize)
|
|
}
|
|
|
|
// ListPendingCollections 负责处理查询待采集请求列表的业务逻辑
|
|
func (s *MonitorService) ListPendingCollections(opts repository.PendingCollectionListOptions, page, pageSize int) ([]models.PendingCollection, int64, error) {
|
|
return s.pendingCollectionRepo.List(opts, page, pageSize)
|
|
}
|
|
|
|
// ListUserActionLogs 负责处理查询用户操作日志列表的业务逻辑
|
|
func (s *MonitorService) ListUserActionLogs(opts repository.UserActionLogListOptions, page, pageSize int) ([]models.UserActionLog, int64, error) {
|
|
return s.userActionLogRepo.List(opts, page, pageSize)
|
|
}
|