labellog.go 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/labellog"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. )
  11. // LabelLog is the model entity for the LabelLog schema.
  12. type LabelLog 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. // 标签名称
  21. LabelName string `json:"label_name,omitempty"`
  22. // 三方平台标签id
  23. LabelID int `json:"label_id,omitempty"`
  24. // 微信ID
  25. WxID string `json:"wx_id,omitempty"`
  26. // 机构 ID
  27. OrganizationID uint64 `json:"organization_id,omitempty"`
  28. selectValues sql.SelectValues
  29. }
  30. // scanValues returns the types for scanning values from sql.Rows.
  31. func (*LabelLog) scanValues(columns []string) ([]any, error) {
  32. values := make([]any, len(columns))
  33. for i := range columns {
  34. switch columns[i] {
  35. case labellog.FieldID, labellog.FieldLabelID, labellog.FieldOrganizationID:
  36. values[i] = new(sql.NullInt64)
  37. case labellog.FieldLabelName, labellog.FieldWxID:
  38. values[i] = new(sql.NullString)
  39. case labellog.FieldCreatedAt, labellog.FieldUpdatedAt:
  40. values[i] = new(sql.NullTime)
  41. default:
  42. values[i] = new(sql.UnknownType)
  43. }
  44. }
  45. return values, nil
  46. }
  47. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  48. // to the LabelLog fields.
  49. func (ll *LabelLog) assignValues(columns []string, values []any) error {
  50. if m, n := len(values), len(columns); m < n {
  51. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  52. }
  53. for i := range columns {
  54. switch columns[i] {
  55. case labellog.FieldID:
  56. value, ok := values[i].(*sql.NullInt64)
  57. if !ok {
  58. return fmt.Errorf("unexpected type %T for field id", value)
  59. }
  60. ll.ID = uint64(value.Int64)
  61. case labellog.FieldCreatedAt:
  62. if value, ok := values[i].(*sql.NullTime); !ok {
  63. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  64. } else if value.Valid {
  65. ll.CreatedAt = value.Time
  66. }
  67. case labellog.FieldUpdatedAt:
  68. if value, ok := values[i].(*sql.NullTime); !ok {
  69. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  70. } else if value.Valid {
  71. ll.UpdatedAt = value.Time
  72. }
  73. case labellog.FieldLabelName:
  74. if value, ok := values[i].(*sql.NullString); !ok {
  75. return fmt.Errorf("unexpected type %T for field label_name", values[i])
  76. } else if value.Valid {
  77. ll.LabelName = value.String
  78. }
  79. case labellog.FieldLabelID:
  80. if value, ok := values[i].(*sql.NullInt64); !ok {
  81. return fmt.Errorf("unexpected type %T for field label_id", values[i])
  82. } else if value.Valid {
  83. ll.LabelID = int(value.Int64)
  84. }
  85. case labellog.FieldWxID:
  86. if value, ok := values[i].(*sql.NullString); !ok {
  87. return fmt.Errorf("unexpected type %T for field wx_id", values[i])
  88. } else if value.Valid {
  89. ll.WxID = value.String
  90. }
  91. case labellog.FieldOrganizationID:
  92. if value, ok := values[i].(*sql.NullInt64); !ok {
  93. return fmt.Errorf("unexpected type %T for field organization_id", values[i])
  94. } else if value.Valid {
  95. ll.OrganizationID = uint64(value.Int64)
  96. }
  97. default:
  98. ll.selectValues.Set(columns[i], values[i])
  99. }
  100. }
  101. return nil
  102. }
  103. // Value returns the ent.Value that was dynamically selected and assigned to the LabelLog.
  104. // This includes values selected through modifiers, order, etc.
  105. func (ll *LabelLog) Value(name string) (ent.Value, error) {
  106. return ll.selectValues.Get(name)
  107. }
  108. // Update returns a builder for updating this LabelLog.
  109. // Note that you need to call LabelLog.Unwrap() before calling this method if this LabelLog
  110. // was returned from a transaction, and the transaction was committed or rolled back.
  111. func (ll *LabelLog) Update() *LabelLogUpdateOne {
  112. return NewLabelLogClient(ll.config).UpdateOne(ll)
  113. }
  114. // Unwrap unwraps the LabelLog entity that was returned from a transaction after it was closed,
  115. // so that all future queries will be executed through the driver which created the transaction.
  116. func (ll *LabelLog) Unwrap() *LabelLog {
  117. _tx, ok := ll.config.driver.(*txDriver)
  118. if !ok {
  119. panic("ent: LabelLog is not a transactional entity")
  120. }
  121. ll.config.driver = _tx.drv
  122. return ll
  123. }
  124. // String implements the fmt.Stringer.
  125. func (ll *LabelLog) String() string {
  126. var builder strings.Builder
  127. builder.WriteString("LabelLog(")
  128. builder.WriteString(fmt.Sprintf("id=%v, ", ll.ID))
  129. builder.WriteString("created_at=")
  130. builder.WriteString(ll.CreatedAt.Format(time.ANSIC))
  131. builder.WriteString(", ")
  132. builder.WriteString("updated_at=")
  133. builder.WriteString(ll.UpdatedAt.Format(time.ANSIC))
  134. builder.WriteString(", ")
  135. builder.WriteString("label_name=")
  136. builder.WriteString(ll.LabelName)
  137. builder.WriteString(", ")
  138. builder.WriteString("label_id=")
  139. builder.WriteString(fmt.Sprintf("%v", ll.LabelID))
  140. builder.WriteString(", ")
  141. builder.WriteString("wx_id=")
  142. builder.WriteString(ll.WxID)
  143. builder.WriteString(", ")
  144. builder.WriteString("organization_id=")
  145. builder.WriteString(fmt.Sprintf("%v", ll.OrganizationID))
  146. builder.WriteByte(')')
  147. return builder.String()
  148. }
  149. // LabelLogs is a parsable slice of LabelLog.
  150. type LabelLogs []*LabelLog