client_query_response.go 829 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package client
  2. import (
  3. "git.sxidc.com/service-supports/dps-sdk/pb/v1/response"
  4. "time"
  5. )
  6. type EventInfo struct {
  7. Key string
  8. Version string
  9. Operation string
  10. Value string
  11. CreatorID string
  12. CreateTime time.Time
  13. }
  14. func FormEventInfo(info *response.EventInfo) *EventInfo {
  15. if info == nil {
  16. return &EventInfo{}
  17. }
  18. return &EventInfo{
  19. Key: info.Key,
  20. Version: info.Version,
  21. Operation: info.Operation,
  22. Value: info.Value,
  23. CreatorID: info.CreatorID,
  24. CreateTime: time.UnixMicro(info.CreateTimeUnix).Local(),
  25. }
  26. }
  27. func FormEventInfoBatch(infos []*response.EventInfo) []EventInfo {
  28. retInfos := make([]EventInfo, 0)
  29. if infos == nil || len(infos) == 0 {
  30. return retInfos
  31. }
  32. for _, info := range infos {
  33. retInfos = append(retInfos, *FormEventInfo(info))
  34. }
  35. return retInfos
  36. }