wxcardvisit.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/wxcardvisit"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. )
  11. // WxCardVisit is the model entity for the WxCardVisit schema.
  12. type WxCardVisit struct {
  13. config `json:"-"`
  14. // ID of the ent.
  15. ID uint64 `json:"id,omitempty"`
  16. // Create Time | 创建日期
  17. CreatedAt time.Time `json:"created_at,omitempty"`
  18. // Update Time | 修改日期
  19. UpdatedAt time.Time `json:"updated_at,omitempty"`
  20. // Delete Time | 删除日期
  21. DeletedAt time.Time `json:"deleted_at,omitempty"`
  22. // user表ID
  23. UserID uint64 `json:"user_id,omitempty"`
  24. // 被访ID
  25. BotID uint64 `json:"bot_id,omitempty"`
  26. // 类型:1-微信 2-小程序 3-智能体
  27. BotType uint8 `json:"bot_type,omitempty"`
  28. selectValues sql.SelectValues
  29. }
  30. // scanValues returns the types for scanning values from sql.Rows.
  31. func (*WxCardVisit) scanValues(columns []string) ([]any, error) {
  32. values := make([]any, len(columns))
  33. for i := range columns {
  34. switch columns[i] {
  35. case wxcardvisit.FieldID, wxcardvisit.FieldUserID, wxcardvisit.FieldBotID, wxcardvisit.FieldBotType:
  36. values[i] = new(sql.NullInt64)
  37. case wxcardvisit.FieldCreatedAt, wxcardvisit.FieldUpdatedAt, wxcardvisit.FieldDeletedAt:
  38. values[i] = new(sql.NullTime)
  39. default:
  40. values[i] = new(sql.UnknownType)
  41. }
  42. }
  43. return values, nil
  44. }
  45. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  46. // to the WxCardVisit fields.
  47. func (wcv *WxCardVisit) assignValues(columns []string, values []any) error {
  48. if m, n := len(values), len(columns); m < n {
  49. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  50. }
  51. for i := range columns {
  52. switch columns[i] {
  53. case wxcardvisit.FieldID:
  54. value, ok := values[i].(*sql.NullInt64)
  55. if !ok {
  56. return fmt.Errorf("unexpected type %T for field id", value)
  57. }
  58. wcv.ID = uint64(value.Int64)
  59. case wxcardvisit.FieldCreatedAt:
  60. if value, ok := values[i].(*sql.NullTime); !ok {
  61. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  62. } else if value.Valid {
  63. wcv.CreatedAt = value.Time
  64. }
  65. case wxcardvisit.FieldUpdatedAt:
  66. if value, ok := values[i].(*sql.NullTime); !ok {
  67. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  68. } else if value.Valid {
  69. wcv.UpdatedAt = value.Time
  70. }
  71. case wxcardvisit.FieldDeletedAt:
  72. if value, ok := values[i].(*sql.NullTime); !ok {
  73. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  74. } else if value.Valid {
  75. wcv.DeletedAt = value.Time
  76. }
  77. case wxcardvisit.FieldUserID:
  78. if value, ok := values[i].(*sql.NullInt64); !ok {
  79. return fmt.Errorf("unexpected type %T for field user_id", values[i])
  80. } else if value.Valid {
  81. wcv.UserID = uint64(value.Int64)
  82. }
  83. case wxcardvisit.FieldBotID:
  84. if value, ok := values[i].(*sql.NullInt64); !ok {
  85. return fmt.Errorf("unexpected type %T for field bot_id", values[i])
  86. } else if value.Valid {
  87. wcv.BotID = uint64(value.Int64)
  88. }
  89. case wxcardvisit.FieldBotType:
  90. if value, ok := values[i].(*sql.NullInt64); !ok {
  91. return fmt.Errorf("unexpected type %T for field bot_type", values[i])
  92. } else if value.Valid {
  93. wcv.BotType = uint8(value.Int64)
  94. }
  95. default:
  96. wcv.selectValues.Set(columns[i], values[i])
  97. }
  98. }
  99. return nil
  100. }
  101. // Value returns the ent.Value that was dynamically selected and assigned to the WxCardVisit.
  102. // This includes values selected through modifiers, order, etc.
  103. func (wcv *WxCardVisit) Value(name string) (ent.Value, error) {
  104. return wcv.selectValues.Get(name)
  105. }
  106. // Update returns a builder for updating this WxCardVisit.
  107. // Note that you need to call WxCardVisit.Unwrap() before calling this method if this WxCardVisit
  108. // was returned from a transaction, and the transaction was committed or rolled back.
  109. func (wcv *WxCardVisit) Update() *WxCardVisitUpdateOne {
  110. return NewWxCardVisitClient(wcv.config).UpdateOne(wcv)
  111. }
  112. // Unwrap unwraps the WxCardVisit entity that was returned from a transaction after it was closed,
  113. // so that all future queries will be executed through the driver which created the transaction.
  114. func (wcv *WxCardVisit) Unwrap() *WxCardVisit {
  115. _tx, ok := wcv.config.driver.(*txDriver)
  116. if !ok {
  117. panic("ent: WxCardVisit is not a transactional entity")
  118. }
  119. wcv.config.driver = _tx.drv
  120. return wcv
  121. }
  122. // String implements the fmt.Stringer.
  123. func (wcv *WxCardVisit) String() string {
  124. var builder strings.Builder
  125. builder.WriteString("WxCardVisit(")
  126. builder.WriteString(fmt.Sprintf("id=%v, ", wcv.ID))
  127. builder.WriteString("created_at=")
  128. builder.WriteString(wcv.CreatedAt.Format(time.ANSIC))
  129. builder.WriteString(", ")
  130. builder.WriteString("updated_at=")
  131. builder.WriteString(wcv.UpdatedAt.Format(time.ANSIC))
  132. builder.WriteString(", ")
  133. builder.WriteString("deleted_at=")
  134. builder.WriteString(wcv.DeletedAt.Format(time.ANSIC))
  135. builder.WriteString(", ")
  136. builder.WriteString("user_id=")
  137. builder.WriteString(fmt.Sprintf("%v", wcv.UserID))
  138. builder.WriteString(", ")
  139. builder.WriteString("bot_id=")
  140. builder.WriteString(fmt.Sprintf("%v", wcv.BotID))
  141. builder.WriteString(", ")
  142. builder.WriteString("bot_type=")
  143. builder.WriteString(fmt.Sprintf("%v", wcv.BotType))
  144. builder.WriteByte(')')
  145. return builder.String()
  146. }
  147. // WxCardVisits is a parsable slice of WxCardVisit.
  148. type WxCardVisits []*WxCardVisit