message.go 1013 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package ticket
  2. import (
  3. "github.com/ClickHouse/clickhouse-go/v2/lib/driver"
  4. "google.golang.org/protobuf/types/known/timestamppb"
  5. "time"
  6. )
  7. func (x *Message) Scan(row driver.Rows) error {
  8. var (
  9. typ int32
  10. date time.Time
  11. aIds []string
  12. aFilenames []string
  13. aTypes []string
  14. aEncodings []string
  15. aBuckets []string
  16. aKeys []string
  17. err error
  18. )
  19. if err = row.Scan(
  20. &x.MessageId,
  21. &x.TicketId,
  22. &x.Role,
  23. &typ,
  24. &x.Content,
  25. &date,
  26. &x.Raw,
  27. &x.Flags,
  28. &x.Headers,
  29. &x.Meta,
  30. &aIds, &aFilenames, &aTypes, &aEncodings, &aBuckets, &aKeys,
  31. ); err != nil {
  32. return err
  33. }
  34. x.Type = Message_Type(typ)
  35. x.Date = timestamppb.New(date)
  36. x.Attachments = make([]*Attachment, len(aIds))
  37. for i := range aIds {
  38. x.Attachments[i] = &Attachment{
  39. Id: aIds[i],
  40. Filename: aFilenames[i],
  41. ContentType: aTypes[i],
  42. ContentEncoding: aEncodings[i],
  43. Bucket: aBuckets[i],
  44. Key: aKeys[i],
  45. }
  46. }
  47. return nil
  48. }