intelligentbuildingcontrol.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package service
  2. import (
  3. "city_chips/internal/model"
  4. "city_chips/internal/repository"
  5. "context"
  6. )
  7. type IntelligentBuildingControlService interface {
  8. GetIntelligentBuildingControl(ctx context.Context, id int64) (*model.IntelligentBuildingControl, error)
  9. GetPoint(conds map[string]any) (*[]model.Point, error)
  10. GetPointType() ([]string, error)
  11. DeviceType() ([]string, error)
  12. DeviceCount() (int64, error)
  13. }
  14. func NewIntelligentBuildingControlService(
  15. service *Service,
  16. intelligentBuildingControlRepository repository.IntelligentBuildingControlRepository,
  17. ) IntelligentBuildingControlService {
  18. return &intelligentBuildingControlService{
  19. Service: service,
  20. intelligentBuildingControlRepository: intelligentBuildingControlRepository,
  21. }
  22. }
  23. type intelligentBuildingControlService struct {
  24. *Service
  25. intelligentBuildingControlRepository repository.IntelligentBuildingControlRepository
  26. }
  27. // DeviceCount 获取设备总数
  28. func (s *intelligentBuildingControlService) DeviceCount() (int64, error) {
  29. //TODO implement me
  30. count, err := s.intelligentBuildingControlRepository.DeviceCount()
  31. if err != nil {
  32. return 0, err
  33. }
  34. return count, nil
  35. }
  36. // DeviceType 获取设备类型
  37. func (s *intelligentBuildingControlService) DeviceType() ([]string, error) {
  38. //TODO implement me
  39. poions, err := s.intelligentBuildingControlRepository.DeviceType()
  40. if err != nil {
  41. return nil, err
  42. }
  43. return poions, nil
  44. }
  45. // GetPointType 获取点位类型
  46. func (s *intelligentBuildingControlService) GetPointType() ([]string, error) {
  47. poions, err := s.intelligentBuildingControlRepository.GetPointType()
  48. if err != nil {
  49. return nil, err
  50. }
  51. return poions, nil
  52. }
  53. // GetPoint 获取点位列表
  54. func (s *intelligentBuildingControlService) GetPoint(conds map[string]any) (*[]model.Point, error) {
  55. points, err := s.intelligentBuildingControlRepository.GetPoint(conds)
  56. if err != nil {
  57. return &[]model.Point{}, err
  58. }
  59. return points, err
  60. }
  61. func (s *intelligentBuildingControlService) GetIntelligentBuildingControl(ctx context.Context, id int64) (*model.IntelligentBuildingControl, error) {
  62. return s.intelligentBuildingControlRepository.GetIntelligentBuildingControl(ctx, id)
  63. }