xunji.go 6.6 KB

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