chatrecords.go 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/chatrecords"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. )
  11. // ChatRecords is the model entity for the ChatRecords schema.
  12. type ChatRecords 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. // 内容
  23. Content string `json:"content,omitempty"`
  24. // 内容类型:1-提问 2-回答
  25. ContentType uint8 `json:"content_type,omitempty"`
  26. // 会话ID
  27. SessionID uint64 `json:"session_id,omitempty"`
  28. // 用户ID
  29. UserID uint64 `json:"user_id,omitempty"`
  30. // 聊天ID
  31. BotID uint64 `json:"bot_id,omitempty"`
  32. // 类型:1-微信 2-小程序card 3-智能体
  33. BotType uint8 `json:"bot_type,omitempty"`
  34. selectValues sql.SelectValues
  35. }
  36. // scanValues returns the types for scanning values from sql.Rows.
  37. func (*ChatRecords) scanValues(columns []string) ([]any, error) {
  38. values := make([]any, len(columns))
  39. for i := range columns {
  40. switch columns[i] {
  41. case chatrecords.FieldID, chatrecords.FieldContentType, chatrecords.FieldSessionID, chatrecords.FieldUserID, chatrecords.FieldBotID, chatrecords.FieldBotType:
  42. values[i] = new(sql.NullInt64)
  43. case chatrecords.FieldContent:
  44. values[i] = new(sql.NullString)
  45. case chatrecords.FieldCreatedAt, chatrecords.FieldUpdatedAt, chatrecords.FieldDeletedAt:
  46. values[i] = new(sql.NullTime)
  47. default:
  48. values[i] = new(sql.UnknownType)
  49. }
  50. }
  51. return values, nil
  52. }
  53. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  54. // to the ChatRecords fields.
  55. func (cr *ChatRecords) assignValues(columns []string, values []any) error {
  56. if m, n := len(values), len(columns); m < n {
  57. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  58. }
  59. for i := range columns {
  60. switch columns[i] {
  61. case chatrecords.FieldID:
  62. value, ok := values[i].(*sql.NullInt64)
  63. if !ok {
  64. return fmt.Errorf("unexpected type %T for field id", value)
  65. }
  66. cr.ID = uint64(value.Int64)
  67. case chatrecords.FieldCreatedAt:
  68. if value, ok := values[i].(*sql.NullTime); !ok {
  69. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  70. } else if value.Valid {
  71. cr.CreatedAt = value.Time
  72. }
  73. case chatrecords.FieldUpdatedAt:
  74. if value, ok := values[i].(*sql.NullTime); !ok {
  75. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  76. } else if value.Valid {
  77. cr.UpdatedAt = value.Time
  78. }
  79. case chatrecords.FieldDeletedAt:
  80. if value, ok := values[i].(*sql.NullTime); !ok {
  81. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  82. } else if value.Valid {
  83. cr.DeletedAt = value.Time
  84. }
  85. case chatrecords.FieldContent:
  86. if value, ok := values[i].(*sql.NullString); !ok {
  87. return fmt.Errorf("unexpected type %T for field content", values[i])
  88. } else if value.Valid {
  89. cr.Content = value.String
  90. }
  91. case chatrecords.FieldContentType:
  92. if value, ok := values[i].(*sql.NullInt64); !ok {
  93. return fmt.Errorf("unexpected type %T for field content_type", values[i])
  94. } else if value.Valid {
  95. cr.ContentType = uint8(value.Int64)
  96. }
  97. case chatrecords.FieldSessionID:
  98. if value, ok := values[i].(*sql.NullInt64); !ok {
  99. return fmt.Errorf("unexpected type %T for field session_id", values[i])
  100. } else if value.Valid {
  101. cr.SessionID = uint64(value.Int64)
  102. }
  103. case chatrecords.FieldUserID:
  104. if value, ok := values[i].(*sql.NullInt64); !ok {
  105. return fmt.Errorf("unexpected type %T for field user_id", values[i])
  106. } else if value.Valid {
  107. cr.UserID = uint64(value.Int64)
  108. }
  109. case chatrecords.FieldBotID:
  110. if value, ok := values[i].(*sql.NullInt64); !ok {
  111. return fmt.Errorf("unexpected type %T for field bot_id", values[i])
  112. } else if value.Valid {
  113. cr.BotID = uint64(value.Int64)
  114. }
  115. case chatrecords.FieldBotType:
  116. if value, ok := values[i].(*sql.NullInt64); !ok {
  117. return fmt.Errorf("unexpected type %T for field bot_type", values[i])
  118. } else if value.Valid {
  119. cr.BotType = uint8(value.Int64)
  120. }
  121. default:
  122. cr.selectValues.Set(columns[i], values[i])
  123. }
  124. }
  125. return nil
  126. }
  127. // Value returns the ent.Value that was dynamically selected and assigned to the ChatRecords.
  128. // This includes values selected through modifiers, order, etc.
  129. func (cr *ChatRecords) Value(name string) (ent.Value, error) {
  130. return cr.selectValues.Get(name)
  131. }
  132. // Update returns a builder for updating this ChatRecords.
  133. // Note that you need to call ChatRecords.Unwrap() before calling this method if this ChatRecords
  134. // was returned from a transaction, and the transaction was committed or rolled back.
  135. func (cr *ChatRecords) Update() *ChatRecordsUpdateOne {
  136. return NewChatRecordsClient(cr.config).UpdateOne(cr)
  137. }
  138. // Unwrap unwraps the ChatRecords entity that was returned from a transaction after it was closed,
  139. // so that all future queries will be executed through the driver which created the transaction.
  140. func (cr *ChatRecords) Unwrap() *ChatRecords {
  141. _tx, ok := cr.config.driver.(*txDriver)
  142. if !ok {
  143. panic("ent: ChatRecords is not a transactional entity")
  144. }
  145. cr.config.driver = _tx.drv
  146. return cr
  147. }
  148. // String implements the fmt.Stringer.
  149. func (cr *ChatRecords) String() string {
  150. var builder strings.Builder
  151. builder.WriteString("ChatRecords(")
  152. builder.WriteString(fmt.Sprintf("id=%v, ", cr.ID))
  153. builder.WriteString("created_at=")
  154. builder.WriteString(cr.CreatedAt.Format(time.ANSIC))
  155. builder.WriteString(", ")
  156. builder.WriteString("updated_at=")
  157. builder.WriteString(cr.UpdatedAt.Format(time.ANSIC))
  158. builder.WriteString(", ")
  159. builder.WriteString("deleted_at=")
  160. builder.WriteString(cr.DeletedAt.Format(time.ANSIC))
  161. builder.WriteString(", ")
  162. builder.WriteString("content=")
  163. builder.WriteString(cr.Content)
  164. builder.WriteString(", ")
  165. builder.WriteString("content_type=")
  166. builder.WriteString(fmt.Sprintf("%v", cr.ContentType))
  167. builder.WriteString(", ")
  168. builder.WriteString("session_id=")
  169. builder.WriteString(fmt.Sprintf("%v", cr.SessionID))
  170. builder.WriteString(", ")
  171. builder.WriteString("user_id=")
  172. builder.WriteString(fmt.Sprintf("%v", cr.UserID))
  173. builder.WriteString(", ")
  174. builder.WriteString("bot_id=")
  175. builder.WriteString(fmt.Sprintf("%v", cr.BotID))
  176. builder.WriteString(", ")
  177. builder.WriteString("bot_type=")
  178. builder.WriteString(fmt.Sprintf("%v", cr.BotType))
  179. builder.WriteByte(')')
  180. return builder.String()
  181. }
  182. // ChatRecordsSlice is a parsable slice of ChatRecords.
  183. type ChatRecordsSlice []*ChatRecords