creditbalance.go 5.9 KB

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