xunjiservice.go 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/agent"
  8. "wechat-api/ent/xunjiservice"
  9. "entgo.io/ent"
  10. "entgo.io/ent/dialect/sql"
  11. )
  12. // XunjiService is the model entity for the XunjiService schema.
  13. type XunjiService 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. // Xunji表ID
  26. XunjiID uint64 `json:"xunji_id,omitempty"`
  27. // 智能体ID
  28. AgentID uint64 `json:"agent_id,omitempty"`
  29. // organization_id | 租户ID
  30. OrganizationID uint64 `json:"organization_id,omitempty"`
  31. // 微信ID
  32. Wxid string `json:"wxid,omitempty"`
  33. // 大模型服务地址
  34. APIBase string `json:"api_base,omitempty"`
  35. // 大模型服务密钥
  36. APIKey string `json:"api_key,omitempty"`
  37. // Edges holds the relations/edges for other nodes in the graph.
  38. // The values are being populated by the XunjiServiceQuery when eager-loading is set.
  39. Edges XunjiServiceEdges `json:"edges"`
  40. selectValues sql.SelectValues
  41. }
  42. // XunjiServiceEdges holds the relations/edges for other nodes in the graph.
  43. type XunjiServiceEdges struct {
  44. // Agent holds the value of the agent edge.
  45. Agent *Agent `json:"agent,omitempty"`
  46. // loadedTypes holds the information for reporting if a
  47. // type was loaded (or requested) in eager-loading or not.
  48. loadedTypes [1]bool
  49. }
  50. // AgentOrErr returns the Agent value or an error if the edge
  51. // was not loaded in eager-loading, or loaded but was not found.
  52. func (e XunjiServiceEdges) AgentOrErr() (*Agent, error) {
  53. if e.Agent != nil {
  54. return e.Agent, nil
  55. } else if e.loadedTypes[0] {
  56. return nil, &NotFoundError{label: agent.Label}
  57. }
  58. return nil, &NotLoadedError{edge: "agent"}
  59. }
  60. // scanValues returns the types for scanning values from sql.Rows.
  61. func (*XunjiService) scanValues(columns []string) ([]any, error) {
  62. values := make([]any, len(columns))
  63. for i := range columns {
  64. switch columns[i] {
  65. case xunjiservice.FieldID, xunjiservice.FieldStatus, xunjiservice.FieldXunjiID, xunjiservice.FieldAgentID, xunjiservice.FieldOrganizationID:
  66. values[i] = new(sql.NullInt64)
  67. case xunjiservice.FieldWxid, xunjiservice.FieldAPIBase, xunjiservice.FieldAPIKey:
  68. values[i] = new(sql.NullString)
  69. case xunjiservice.FieldCreatedAt, xunjiservice.FieldUpdatedAt, xunjiservice.FieldDeletedAt:
  70. values[i] = new(sql.NullTime)
  71. default:
  72. values[i] = new(sql.UnknownType)
  73. }
  74. }
  75. return values, nil
  76. }
  77. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  78. // to the XunjiService fields.
  79. func (xs *XunjiService) assignValues(columns []string, values []any) error {
  80. if m, n := len(values), len(columns); m < n {
  81. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  82. }
  83. for i := range columns {
  84. switch columns[i] {
  85. case xunjiservice.FieldID:
  86. value, ok := values[i].(*sql.NullInt64)
  87. if !ok {
  88. return fmt.Errorf("unexpected type %T for field id", value)
  89. }
  90. xs.ID = uint64(value.Int64)
  91. case xunjiservice.FieldCreatedAt:
  92. if value, ok := values[i].(*sql.NullTime); !ok {
  93. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  94. } else if value.Valid {
  95. xs.CreatedAt = value.Time
  96. }
  97. case xunjiservice.FieldUpdatedAt:
  98. if value, ok := values[i].(*sql.NullTime); !ok {
  99. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  100. } else if value.Valid {
  101. xs.UpdatedAt = value.Time
  102. }
  103. case xunjiservice.FieldStatus:
  104. if value, ok := values[i].(*sql.NullInt64); !ok {
  105. return fmt.Errorf("unexpected type %T for field status", values[i])
  106. } else if value.Valid {
  107. xs.Status = uint8(value.Int64)
  108. }
  109. case xunjiservice.FieldDeletedAt:
  110. if value, ok := values[i].(*sql.NullTime); !ok {
  111. return fmt.Errorf("unexpected type %T for field deleted_at", values[i])
  112. } else if value.Valid {
  113. xs.DeletedAt = value.Time
  114. }
  115. case xunjiservice.FieldXunjiID:
  116. if value, ok := values[i].(*sql.NullInt64); !ok {
  117. return fmt.Errorf("unexpected type %T for field xunji_id", values[i])
  118. } else if value.Valid {
  119. xs.XunjiID = uint64(value.Int64)
  120. }
  121. case xunjiservice.FieldAgentID:
  122. if value, ok := values[i].(*sql.NullInt64); !ok {
  123. return fmt.Errorf("unexpected type %T for field agent_id", values[i])
  124. } else if value.Valid {
  125. xs.AgentID = uint64(value.Int64)
  126. }
  127. case xunjiservice.FieldOrganizationID:
  128. if value, ok := values[i].(*sql.NullInt64); !ok {
  129. return fmt.Errorf("unexpected type %T for field organization_id", values[i])
  130. } else if value.Valid {
  131. xs.OrganizationID = uint64(value.Int64)
  132. }
  133. case xunjiservice.FieldWxid:
  134. if value, ok := values[i].(*sql.NullString); !ok {
  135. return fmt.Errorf("unexpected type %T for field wxid", values[i])
  136. } else if value.Valid {
  137. xs.Wxid = value.String
  138. }
  139. case xunjiservice.FieldAPIBase:
  140. if value, ok := values[i].(*sql.NullString); !ok {
  141. return fmt.Errorf("unexpected type %T for field api_base", values[i])
  142. } else if value.Valid {
  143. xs.APIBase = value.String
  144. }
  145. case xunjiservice.FieldAPIKey:
  146. if value, ok := values[i].(*sql.NullString); !ok {
  147. return fmt.Errorf("unexpected type %T for field api_key", values[i])
  148. } else if value.Valid {
  149. xs.APIKey = value.String
  150. }
  151. default:
  152. xs.selectValues.Set(columns[i], values[i])
  153. }
  154. }
  155. return nil
  156. }
  157. // Value returns the ent.Value that was dynamically selected and assigned to the XunjiService.
  158. // This includes values selected through modifiers, order, etc.
  159. func (xs *XunjiService) Value(name string) (ent.Value, error) {
  160. return xs.selectValues.Get(name)
  161. }
  162. // QueryAgent queries the "agent" edge of the XunjiService entity.
  163. func (xs *XunjiService) QueryAgent() *AgentQuery {
  164. return NewXunjiServiceClient(xs.config).QueryAgent(xs)
  165. }
  166. // Update returns a builder for updating this XunjiService.
  167. // Note that you need to call XunjiService.Unwrap() before calling this method if this XunjiService
  168. // was returned from a transaction, and the transaction was committed or rolled back.
  169. func (xs *XunjiService) Update() *XunjiServiceUpdateOne {
  170. return NewXunjiServiceClient(xs.config).UpdateOne(xs)
  171. }
  172. // Unwrap unwraps the XunjiService entity that was returned from a transaction after it was closed,
  173. // so that all future queries will be executed through the driver which created the transaction.
  174. func (xs *XunjiService) Unwrap() *XunjiService {
  175. _tx, ok := xs.config.driver.(*txDriver)
  176. if !ok {
  177. panic("ent: XunjiService is not a transactional entity")
  178. }
  179. xs.config.driver = _tx.drv
  180. return xs
  181. }
  182. // String implements the fmt.Stringer.
  183. func (xs *XunjiService) String() string {
  184. var builder strings.Builder
  185. builder.WriteString("XunjiService(")
  186. builder.WriteString(fmt.Sprintf("id=%v, ", xs.ID))
  187. builder.WriteString("created_at=")
  188. builder.WriteString(xs.CreatedAt.Format(time.ANSIC))
  189. builder.WriteString(", ")
  190. builder.WriteString("updated_at=")
  191. builder.WriteString(xs.UpdatedAt.Format(time.ANSIC))
  192. builder.WriteString(", ")
  193. builder.WriteString("status=")
  194. builder.WriteString(fmt.Sprintf("%v", xs.Status))
  195. builder.WriteString(", ")
  196. builder.WriteString("deleted_at=")
  197. builder.WriteString(xs.DeletedAt.Format(time.ANSIC))
  198. builder.WriteString(", ")
  199. builder.WriteString("xunji_id=")
  200. builder.WriteString(fmt.Sprintf("%v", xs.XunjiID))
  201. builder.WriteString(", ")
  202. builder.WriteString("agent_id=")
  203. builder.WriteString(fmt.Sprintf("%v", xs.AgentID))
  204. builder.WriteString(", ")
  205. builder.WriteString("organization_id=")
  206. builder.WriteString(fmt.Sprintf("%v", xs.OrganizationID))
  207. builder.WriteString(", ")
  208. builder.WriteString("wxid=")
  209. builder.WriteString(xs.Wxid)
  210. builder.WriteString(", ")
  211. builder.WriteString("api_base=")
  212. builder.WriteString(xs.APIBase)
  213. builder.WriteString(", ")
  214. builder.WriteString("api_key=")
  215. builder.WriteString(xs.APIKey)
  216. builder.WriteByte(')')
  217. return builder.String()
  218. }
  219. // XunjiServices is a parsable slice of XunjiService.
  220. type XunjiServices []*XunjiService