garden.go 720 B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2021 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. package common
  4. import (
  5. "context"
  6. "property-task/pb"
  7. pb_v1 "property-task/pb/v1"
  8. "time"
  9. )
  10. const TaskKey = "property_bill_task"
  11. // 获取小区列表
  12. var ids []*pb_v1.GardenIdInfo
  13. var timestamp int64
  14. func GetGardenList() []*pb_v1.GardenIdInfo {
  15. now := time.Now()
  16. nowDay := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
  17. if len(ids) > 0 && nowDay.Unix() == timestamp {
  18. return ids
  19. }
  20. reply, err := pb.System.GardenIds(context.Background(), &pb_v1.GardenIdsRequest{})
  21. if err != nil {
  22. return nil
  23. }
  24. ids = reply.GardenIds
  25. timestamp = nowDay.Unix()
  26. return reply.GardenIds
  27. }