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 // 在这里可以添加其他超表模型的仓库依赖 } // NewMonitorService 创建一个新的 MonitorService 实例 func NewMonitorService( sensorDataRepo repository.SensorDataRepository, deviceCommandLogRepo repository.DeviceCommandLogRepository, executionLogRepo repository.ExecutionLogRepository, ) *MonitorService { return &MonitorService{ sensorDataRepo: sensorDataRepo, deviceCommandLogRepo: deviceCommandLogRepo, executionLogRepo: executionLogRepo, } } // 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) }