labeltagging.go 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "encoding/json"
  5. "fmt"
  6. "strings"
  7. "time"
  8. "wechat-api/ent/labeltagging"
  9. "entgo.io/ent"
  10. "entgo.io/ent/dialect/sql"
  11. )
  12. // LabelTagging is the model entity for the LabelTagging schema.
  13. type LabelTagging struct {
  14. config `json:"-"`
  15. // ID of the ent.
  16. ID uint64 `json:"id,omitempty"`
  17. // Create Time | 创建日期
  18. CreatedAt time.Time `json:"created_at,omitempty"`
  19. // Update Time | 修改日期
  20. UpdatedAt time.Time `json:"updated_at,omitempty"`
  21. // Status 1: normal 2: ban | 状态 1 正常 2 禁用
  22. Status uint8 `json:"status,omitempty"`
  23. // Delete Time | 删除日期
  24. DeletedAt time.Time `json:"deleted_at,omitempty"`
  25. // 机构 ID
  26. OrganizationID uint64 `json:"organization_id,omitempty"`
  27. // 标签类型:1好友,2群组,3公众号,4企业微信联系人
  28. Type int `json:"type,omitempty"`
  29. // 关键词
  30. Conditions string `json:"conditions,omitempty"`
  31. // 命中后需要打的标签
  32. ActionLabelAdd []uint64 `json:"action_label_add,omitempty"`
  33. // 命中后需要移除的标签
  34. ActionLabelDel []uint64 `json:"action_label_del,omitempty"`
  35. selectValues sql.SelectValues
  36. }
  37. // scanValues returns the types for scanning values from sql.Rows.
  38. func (*LabelTagging) scanValues(columns []string) ([]any, error) {
  39. values := make([]any, len(columns))
  40. for i := range columns {
  41. switch columns[i] {
  42. case labeltagging.FieldActionLabelAdd, labeltagging.FieldActionLabelDel:
  43. values[i] = new([]byte)
  44. case labeltagging.FieldID, labeltagging.FieldStatus, labeltagging.FieldOrganizationID, labeltagging.FieldType:
  45. values[i] = new(sql.NullInt64)
  46. case labeltagging.FieldConditions:
  47. values[i] = new(sql.NullString)
  48. case labeltagging.FieldCreatedAt, labeltagging.FieldUpdatedAt, labeltagging.FieldDeletedAt:
  49. values[i] = new(sql.NullTime)
  50. default:
  51. values[i] = new(sql.UnknownType)
  52. }
  53. }
  54. return values, nil
  55. }
  56. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  57. // to the LabelTagging fields.
  58. func (lt *LabelTagging) assignValues(columns []string, values []any) error {
  59. if m, n := len(values), len(columns); m < n {
  60. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  61. }
  62. for i := range columns {
  63. switch columns[i] {
  64. case labeltagging.FieldID:
  65. value, ok := values[i].(*sql.NullInt64)
  66. if !ok {
  67. return fmt.Errorf("unexpected type %T for field id", value)
  68. }
  69. lt.ID = uint64(value.Int64)
  70. case labeltagging.FieldCreatedAt:
  71. if value, ok := values[i].(*sql.NullTime); !ok {
  72. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  73. } else if value.Valid {
  74. lt.CreatedAt = value.Time
  75. }
  76. case labeltagging.FieldUpdatedAt:
  77. if value, ok := values[i].(*sql.NullTime); !ok {
  78. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  79. } else if value.Valid {
  80. lt.UpdatedAt = value.Time
  81. }
  82. case labeltagging.FieldStatus:
  83. if value, ok := values[i].(*sql.NullInt64); !ok {
  84. return fmt.Errorf("unexpected type %T for field status", values[i])
  85. } else if value.Valid {
  86. lt.Status = uint8(value.Int64)
  87. }
  88. case labeltagging.FieldDeletedAt:
  89. if value, ok := values[i].(*sql.NullTime); !ok {
  90. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  91. } else if value.Valid {
  92. lt.DeletedAt = value.Time
  93. }
  94. case labeltagging.FieldOrganizationID:
  95. if value, ok := values[i].(*sql.NullInt64); !ok {
  96. return fmt.Errorf("unexpected type %T for field organization_id", values[i])
  97. } else if value.Valid {
  98. lt.OrganizationID = uint64(value.Int64)
  99. }
  100. case labeltagging.FieldType:
  101. if value, ok := values[i].(*sql.NullInt64); !ok {
  102. return fmt.Errorf("unexpected type %T for field type", values[i])
  103. } else if value.Valid {
  104. lt.Type = int(value.Int64)
  105. }
  106. case labeltagging.FieldConditions:
  107. if value, ok := values[i].(*sql.NullString); !ok {
  108. return fmt.Errorf("unexpected type %T for field conditions", values[i])
  109. } else if value.Valid {
  110. lt.Conditions = value.String
  111. }
  112. case labeltagging.FieldActionLabelAdd:
  113. if value, ok := values[i].(*[]byte); !ok {
  114. return fmt.Errorf("unexpected type %T for field action_label_add", values[i])
  115. } else if value != nil && len(*value) > 0 {
  116. if err := json.Unmarshal(*value, &lt.ActionLabelAdd); err != nil {
  117. return fmt.Errorf("unmarshal field action_label_add: %w", err)
  118. }
  119. }
  120. case labeltagging.FieldActionLabelDel:
  121. if value, ok := values[i].(*[]byte); !ok {
  122. return fmt.Errorf("unexpected type %T for field action_label_del", values[i])
  123. } else if value != nil && len(*value) > 0 {
  124. if err := json.Unmarshal(*value, &lt.ActionLabelDel); err != nil {
  125. return fmt.Errorf("unmarshal field action_label_del: %w", err)
  126. }
  127. }
  128. default:
  129. lt.selectValues.Set(columns[i], values[i])
  130. }
  131. }
  132. return nil
  133. }
  134. // Value returns the ent.Value that was dynamically selected and assigned to the LabelTagging.
  135. // This includes values selected through modifiers, order, etc.
  136. func (lt *LabelTagging) Value(name string) (ent.Value, error) {
  137. return lt.selectValues.Get(name)
  138. }
  139. // Update returns a builder for updating this LabelTagging.
  140. // Note that you need to call LabelTagging.Unwrap() before calling this method if this LabelTagging
  141. // was returned from a transaction, and the transaction was committed or rolled back.
  142. func (lt *LabelTagging) Update() *LabelTaggingUpdateOne {
  143. return NewLabelTaggingClient(lt.config).UpdateOne(lt)
  144. }
  145. // Unwrap unwraps the LabelTagging entity that was returned from a transaction after it was closed,
  146. // so that all future queries will be executed through the driver which created the transaction.
  147. func (lt *LabelTagging) Unwrap() *LabelTagging {
  148. _tx, ok := lt.config.driver.(*txDriver)
  149. if !ok {
  150. panic("ent: LabelTagging is not a transactional entity")
  151. }
  152. lt.config.driver = _tx.drv
  153. return lt
  154. }
  155. // String implements the fmt.Stringer.
  156. func (lt *LabelTagging) String() string {
  157. var builder strings.Builder
  158. builder.WriteString("LabelTagging(")
  159. builder.WriteString(fmt.Sprintf("id=%v, ", lt.ID))
  160. builder.WriteString("created_at=")
  161. builder.WriteString(lt.CreatedAt.Format(time.ANSIC))
  162. builder.WriteString(", ")
  163. builder.WriteString("updated_at=")
  164. builder.WriteString(lt.UpdatedAt.Format(time.ANSIC))
  165. builder.WriteString(", ")
  166. builder.WriteString("status=")
  167. builder.WriteString(fmt.Sprintf("%v", lt.Status))
  168. builder.WriteString(", ")
  169. builder.WriteString("deleted_at=")
  170. builder.WriteString(lt.DeletedAt.Format(time.ANSIC))
  171. builder.WriteString(", ")
  172. builder.WriteString("organization_id=")
  173. builder.WriteString(fmt.Sprintf("%v", lt.OrganizationID))
  174. builder.WriteString(", ")
  175. builder.WriteString("type=")
  176. builder.WriteString(fmt.Sprintf("%v", lt.Type))
  177. builder.WriteString(", ")
  178. builder.WriteString("conditions=")
  179. builder.WriteString(lt.Conditions)
  180. builder.WriteString(", ")
  181. builder.WriteString("action_label_add=")
  182. builder.WriteString(fmt.Sprintf("%v", lt.ActionLabelAdd))
  183. builder.WriteString(", ")
  184. builder.WriteString("action_label_del=")
  185. builder.WriteString(fmt.Sprintf("%v", lt.ActionLabelDel))
  186. builder.WriteByte(')')
  187. return builder.String()
  188. }
  189. // LabelTaggings is a parsable slice of LabelTagging.
  190. type LabelTaggings []*LabelTagging