paymentauditlog.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "entgo.io/ent"
  8. "entgo.io/ent/dialect/sql"
  9. "github.com/Wei-Shaw/sub2api/ent/paymentauditlog"
  10. )
  11. // PaymentAuditLog is the model entity for the PaymentAuditLog schema.
  12. type PaymentAuditLog struct {
  13. config `json:"-"`
  14. // ID of the ent.
  15. ID int64 `json:"id,omitempty"`
  16. // OrderID holds the value of the "order_id" field.
  17. OrderID string `json:"order_id,omitempty"`
  18. // Action holds the value of the "action" field.
  19. Action string `json:"action,omitempty"`
  20. // Detail holds the value of the "detail" field.
  21. Detail string `json:"detail,omitempty"`
  22. // Operator holds the value of the "operator" field.
  23. Operator string `json:"operator,omitempty"`
  24. // CreatedAt holds the value of the "created_at" field.
  25. CreatedAt time.Time `json:"created_at,omitempty"`
  26. selectValues sql.SelectValues
  27. }
  28. // scanValues returns the types for scanning values from sql.Rows.
  29. func (*PaymentAuditLog) scanValues(columns []string) ([]any, error) {
  30. values := make([]any, len(columns))
  31. for i := range columns {
  32. switch columns[i] {
  33. case paymentauditlog.FieldID:
  34. values[i] = new(sql.NullInt64)
  35. case paymentauditlog.FieldOrderID, paymentauditlog.FieldAction, paymentauditlog.FieldDetail, paymentauditlog.FieldOperator:
  36. values[i] = new(sql.NullString)
  37. case paymentauditlog.FieldCreatedAt:
  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 PaymentAuditLog fields.
  47. func (_m *PaymentAuditLog) 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 paymentauditlog.FieldID:
  54. value, ok := values[i].(*sql.NullInt64)
  55. if !ok {
  56. return fmt.Errorf("unexpected type %T for field id", value)
  57. }
  58. _m.ID = int64(value.Int64)
  59. case paymentauditlog.FieldOrderID:
  60. if value, ok := values[i].(*sql.NullString); !ok {
  61. return fmt.Errorf("unexpected type %T for field order_id", values[i])
  62. } else if value.Valid {
  63. _m.OrderID = value.String
  64. }
  65. case paymentauditlog.FieldAction:
  66. if value, ok := values[i].(*sql.NullString); !ok {
  67. return fmt.Errorf("unexpected type %T for field action", values[i])
  68. } else if value.Valid {
  69. _m.Action = value.String
  70. }
  71. case paymentauditlog.FieldDetail:
  72. if value, ok := values[i].(*sql.NullString); !ok {
  73. return fmt.Errorf("unexpected type %T for field detail", values[i])
  74. } else if value.Valid {
  75. _m.Detail = value.String
  76. }
  77. case paymentauditlog.FieldOperator:
  78. if value, ok := values[i].(*sql.NullString); !ok {
  79. return fmt.Errorf("unexpected type %T for field operator", values[i])
  80. } else if value.Valid {
  81. _m.Operator = value.String
  82. }
  83. case paymentauditlog.FieldCreatedAt:
  84. if value, ok := values[i].(*sql.NullTime); !ok {
  85. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  86. } else if value.Valid {
  87. _m.CreatedAt = value.Time
  88. }
  89. default:
  90. _m.selectValues.Set(columns[i], values[i])
  91. }
  92. }
  93. return nil
  94. }
  95. // Value returns the ent.Value that was dynamically selected and assigned to the PaymentAuditLog.
  96. // This includes values selected through modifiers, order, etc.
  97. func (_m *PaymentAuditLog) Value(name string) (ent.Value, error) {
  98. return _m.selectValues.Get(name)
  99. }
  100. // Update returns a builder for updating this PaymentAuditLog.
  101. // Note that you need to call PaymentAuditLog.Unwrap() before calling this method if this PaymentAuditLog
  102. // was returned from a transaction, and the transaction was committed or rolled back.
  103. func (_m *PaymentAuditLog) Update() *PaymentAuditLogUpdateOne {
  104. return NewPaymentAuditLogClient(_m.config).UpdateOne(_m)
  105. }
  106. // Unwrap unwraps the PaymentAuditLog entity that was returned from a transaction after it was closed,
  107. // so that all future queries will be executed through the driver which created the transaction.
  108. func (_m *PaymentAuditLog) Unwrap() *PaymentAuditLog {
  109. _tx, ok := _m.config.driver.(*txDriver)
  110. if !ok {
  111. panic("ent: PaymentAuditLog is not a transactional entity")
  112. }
  113. _m.config.driver = _tx.drv
  114. return _m
  115. }
  116. // String implements the fmt.Stringer.
  117. func (_m *PaymentAuditLog) String() string {
  118. var builder strings.Builder
  119. builder.WriteString("PaymentAuditLog(")
  120. builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
  121. builder.WriteString("order_id=")
  122. builder.WriteString(_m.OrderID)
  123. builder.WriteString(", ")
  124. builder.WriteString("action=")
  125. builder.WriteString(_m.Action)
  126. builder.WriteString(", ")
  127. builder.WriteString("detail=")
  128. builder.WriteString(_m.Detail)
  129. builder.WriteString(", ")
  130. builder.WriteString("operator=")
  131. builder.WriteString(_m.Operator)
  132. builder.WriteString(", ")
  133. builder.WriteString("created_at=")
  134. builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
  135. builder.WriteByte(')')
  136. return builder.String()
  137. }
  138. // PaymentAuditLogs is a parsable slice of PaymentAuditLog.
  139. type PaymentAuditLogs []*PaymentAuditLog