lightConditionService.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package service
  2. import (
  3. "iot_manager_service/app/device/dao"
  4. "iot_manager_service/util"
  5. "time"
  6. )
  7. // 灯控策略服务
  8. var LightConditionService = new(lightConditionService)
  9. type lightConditionService struct{}
  10. func (s *lightConditionService) Get(id int) (*dao.LightCondition, *util.Errors) {
  11. // 创建查询实例
  12. condition := &dao.LightCondition{
  13. ID: id,
  14. }
  15. err := condition.Get()
  16. if err != nil {
  17. return nil, util.FailResponse(err.Error(), nil)
  18. }
  19. return condition, nil
  20. }
  21. func (s *lightConditionService) BatchGet(ids []int) []dao.LightCondition {
  22. // 创建查询实例
  23. condition := &dao.LightCondition{}
  24. conditions, err := condition.BatchGet(ids)
  25. if err != nil {
  26. return nil
  27. }
  28. return conditions
  29. }
  30. func (s *lightConditionService) CreateOrUpdate(req dao.LightCondition) *util.Errors {
  31. return nil
  32. }
  33. func (s *lightConditionService) Remove(id int) *util.Errors {
  34. // 创建查询实例
  35. device := &dao.Gateway{
  36. ID: id,
  37. IsDeleted: 1,
  38. UpdateUser: "TODO", // todo 使用登录态
  39. UpdateTime: time.Now(),
  40. }
  41. //todo
  42. // service.gatewayService.CountRelation()
  43. //todo operation record
  44. err := device.Delete()
  45. if err != nil {
  46. return util.FailResponse(err.Error(), nil)
  47. }
  48. return nil
  49. }
  50. func (s *lightConditionService) Save([]dao.LightCondition) error {
  51. return nil
  52. }