compapiasynctask.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "fmt"
  5. "strings"
  6. "time"
  7. "wechat-api/ent/compapiasynctask"
  8. "entgo.io/ent"
  9. "entgo.io/ent/dialect/sql"
  10. )
  11. // CompapiAsynctask is the model entity for the CompapiAsynctask schema.
  12. type CompapiAsynctask 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. // 发起请求者的授权token
  21. AuthToken string `json:"auth_token,omitempty"`
  22. // 请求目标类型
  23. EventType string `json:"event_type,omitempty"`
  24. // 会话ID
  25. ChatID string `json:"chat_id,omitempty"`
  26. // organization_id | 租户ID
  27. OrganizationID uint64 `json:"organization_id,omitempty"`
  28. // 待请求的大模型服务地址
  29. OpenaiBase string `json:"openai_base,omitempty"`
  30. // 待请求的大模型服务密钥授权token
  31. OpenaiKey string `json:"openai_key,omitempty"`
  32. // 请求参数结构字符串
  33. RequestRaw string `json:"request_raw,omitempty"`
  34. // 请求响应结构字符串
  35. ResponseRaw string `json:"response_raw,omitempty"`
  36. // callback_url | 异步执行回调地址
  37. CallbackURL string `json:"callback_url,omitempty"`
  38. // callback返回结构字符串
  39. CallbackResponseRaw string `json:"callback_response_raw,omitempty"`
  40. // 所用大模型
  41. Model string `json:"model,omitempty"`
  42. // callback_status | 任务完成状态 10 任务就绪 20 请求API完成 30 请求回调完成 60 任务暂停 70 任务失败
  43. TaskStatus int8 `json:"task_status,omitempty"`
  44. // retry count | 重试次数
  45. RetryCount int8 `json:"retry_count,omitempty"`
  46. // 最后一次出错信息
  47. LastError string `json:"last_error,omitempty"`
  48. selectValues sql.SelectValues
  49. }
  50. // scanValues returns the types for scanning values from sql.Rows.
  51. func (*CompapiAsynctask) scanValues(columns []string) ([]any, error) {
  52. values := make([]any, len(columns))
  53. for i := range columns {
  54. switch columns[i] {
  55. case compapiasynctask.FieldID, compapiasynctask.FieldOrganizationID, compapiasynctask.FieldTaskStatus, compapiasynctask.FieldRetryCount:
  56. values[i] = new(sql.NullInt64)
  57. case compapiasynctask.FieldAuthToken, compapiasynctask.FieldEventType, compapiasynctask.FieldChatID, compapiasynctask.FieldOpenaiBase, compapiasynctask.FieldOpenaiKey, compapiasynctask.FieldRequestRaw, compapiasynctask.FieldResponseRaw, compapiasynctask.FieldCallbackURL, compapiasynctask.FieldCallbackResponseRaw, compapiasynctask.FieldModel, compapiasynctask.FieldLastError:
  58. values[i] = new(sql.NullString)
  59. case compapiasynctask.FieldCreatedAt, compapiasynctask.FieldUpdatedAt:
  60. values[i] = new(sql.NullTime)
  61. default:
  62. values[i] = new(sql.UnknownType)
  63. }
  64. }
  65. return values, nil
  66. }
  67. // assignValues assigns the values that were returned from sql.Rows (after scanning)
  68. // to the CompapiAsynctask fields.
  69. func (ca *CompapiAsynctask) assignValues(columns []string, values []any) error {
  70. if m, n := len(values), len(columns); m < n {
  71. return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
  72. }
  73. for i := range columns {
  74. switch columns[i] {
  75. case compapiasynctask.FieldID:
  76. value, ok := values[i].(*sql.NullInt64)
  77. if !ok {
  78. return fmt.Errorf("unexpected type %T for field id", value)
  79. }
  80. ca.ID = uint64(value.Int64)
  81. case compapiasynctask.FieldCreatedAt:
  82. if value, ok := values[i].(*sql.NullTime); !ok {
  83. return fmt.Errorf("unexpected type %T for field created_at", values[i])
  84. } else if value.Valid {
  85. ca.CreatedAt = value.Time
  86. }
  87. case compapiasynctask.FieldUpdatedAt:
  88. if value, ok := values[i].(*sql.NullTime); !ok {
  89. return fmt.Errorf("unexpected type %T for field updated_at", values[i])
  90. } else if value.Valid {
  91. ca.UpdatedAt = value.Time
  92. }
  93. case compapiasynctask.FieldAuthToken:
  94. if value, ok := values[i].(*sql.NullString); !ok {
  95. return fmt.Errorf("unexpected type %T for field auth_token", values[i])
  96. } else if value.Valid {
  97. ca.AuthToken = value.String
  98. }
  99. case compapiasynctask.FieldEventType:
  100. if value, ok := values[i].(*sql.NullString); !ok {
  101. return fmt.Errorf("unexpected type %T for field event_type", values[i])
  102. } else if value.Valid {
  103. ca.EventType = value.String
  104. }
  105. case compapiasynctask.FieldChatID:
  106. if value, ok := values[i].(*sql.NullString); !ok {
  107. return fmt.Errorf("unexpected type %T for field chat_id", values[i])
  108. } else if value.Valid {
  109. ca.ChatID = value.String
  110. }
  111. case compapiasynctask.FieldOrganizationID:
  112. if value, ok := values[i].(*sql.NullInt64); !ok {
  113. return fmt.Errorf("unexpected type %T for field organization_id", values[i])
  114. } else if value.Valid {
  115. ca.OrganizationID = uint64(value.Int64)
  116. }
  117. case compapiasynctask.FieldOpenaiBase:
  118. if value, ok := values[i].(*sql.NullString); !ok {
  119. return fmt.Errorf("unexpected type %T for field openai_base", values[i])
  120. } else if value.Valid {
  121. ca.OpenaiBase = value.String
  122. }
  123. case compapiasynctask.FieldOpenaiKey:
  124. if value, ok := values[i].(*sql.NullString); !ok {
  125. return fmt.Errorf("unexpected type %T for field openai_key", values[i])
  126. } else if value.Valid {
  127. ca.OpenaiKey = value.String
  128. }
  129. case compapiasynctask.FieldRequestRaw:
  130. if value, ok := values[i].(*sql.NullString); !ok {
  131. return fmt.Errorf("unexpected type %T for field request_raw", values[i])
  132. } else if value.Valid {
  133. ca.RequestRaw = value.String
  134. }
  135. case compapiasynctask.FieldResponseRaw:
  136. if value, ok := values[i].(*sql.NullString); !ok {
  137. return fmt.Errorf("unexpected type %T for field response_raw", values[i])
  138. } else if value.Valid {
  139. ca.ResponseRaw = value.String
  140. }
  141. case compapiasynctask.FieldCallbackURL:
  142. if value, ok := values[i].(*sql.NullString); !ok {
  143. return fmt.Errorf("unexpected type %T for field callback_url", values[i])
  144. } else if value.Valid {
  145. ca.CallbackURL = value.String
  146. }
  147. case compapiasynctask.FieldCallbackResponseRaw:
  148. if value, ok := values[i].(*sql.NullString); !ok {
  149. return fmt.Errorf("unexpected type %T for field callback_response_raw", values[i])
  150. } else if value.Valid {
  151. ca.CallbackResponseRaw = value.String
  152. }
  153. case compapiasynctask.FieldModel:
  154. if value, ok := values[i].(*sql.NullString); !ok {
  155. return fmt.Errorf("unexpected type %T for field model", values[i])
  156. } else if value.Valid {
  157. ca.Model = value.String
  158. }
  159. case compapiasynctask.FieldTaskStatus:
  160. if value, ok := values[i].(*sql.NullInt64); !ok {
  161. return fmt.Errorf("unexpected type %T for field task_status", values[i])
  162. } else if value.Valid {
  163. ca.TaskStatus = int8(value.Int64)
  164. }
  165. case compapiasynctask.FieldRetryCount:
  166. if value, ok := values[i].(*sql.NullInt64); !ok {
  167. return fmt.Errorf("unexpected type %T for field retry_count", values[i])
  168. } else if value.Valid {
  169. ca.RetryCount = int8(value.Int64)
  170. }
  171. case compapiasynctask.FieldLastError:
  172. if value, ok := values[i].(*sql.NullString); !ok {
  173. return fmt.Errorf("unexpected type %T for field last_error", values[i])
  174. } else if value.Valid {
  175. ca.LastError = value.String
  176. }
  177. default:
  178. ca.selectValues.Set(columns[i], values[i])
  179. }
  180. }
  181. return nil
  182. }
  183. // Value returns the ent.Value that was dynamically selected and assigned to the CompapiAsynctask.
  184. // This includes values selected through modifiers, order, etc.
  185. func (ca *CompapiAsynctask) Value(name string) (ent.Value, error) {
  186. return ca.selectValues.Get(name)
  187. }
  188. // Update returns a builder for updating this CompapiAsynctask.
  189. // Note that you need to call CompapiAsynctask.Unwrap() before calling this method if this CompapiAsynctask
  190. // was returned from a transaction, and the transaction was committed or rolled back.
  191. func (ca *CompapiAsynctask) Update() *CompapiAsynctaskUpdateOne {
  192. return NewCompapiAsynctaskClient(ca.config).UpdateOne(ca)
  193. }
  194. // Unwrap unwraps the CompapiAsynctask entity that was returned from a transaction after it was closed,
  195. // so that all future queries will be executed through the driver which created the transaction.
  196. func (ca *CompapiAsynctask) Unwrap() *CompapiAsynctask {
  197. _tx, ok := ca.config.driver.(*txDriver)
  198. if !ok {
  199. panic("ent: CompapiAsynctask is not a transactional entity")
  200. }
  201. ca.config.driver = _tx.drv
  202. return ca
  203. }
  204. // String implements the fmt.Stringer.
  205. func (ca *CompapiAsynctask) String() string {
  206. var builder strings.Builder
  207. builder.WriteString("CompapiAsynctask(")
  208. builder.WriteString(fmt.Sprintf("id=%v, ", ca.ID))
  209. builder.WriteString("created_at=")
  210. builder.WriteString(ca.CreatedAt.Format(time.ANSIC))
  211. builder.WriteString(", ")
  212. builder.WriteString("updated_at=")
  213. builder.WriteString(ca.UpdatedAt.Format(time.ANSIC))
  214. builder.WriteString(", ")
  215. builder.WriteString("auth_token=")
  216. builder.WriteString(ca.AuthToken)
  217. builder.WriteString(", ")
  218. builder.WriteString("event_type=")
  219. builder.WriteString(ca.EventType)
  220. builder.WriteString(", ")
  221. builder.WriteString("chat_id=")
  222. builder.WriteString(ca.ChatID)
  223. builder.WriteString(", ")
  224. builder.WriteString("organization_id=")
  225. builder.WriteString(fmt.Sprintf("%v", ca.OrganizationID))
  226. builder.WriteString(", ")
  227. builder.WriteString("openai_base=")
  228. builder.WriteString(ca.OpenaiBase)
  229. builder.WriteString(", ")
  230. builder.WriteString("openai_key=")
  231. builder.WriteString(ca.OpenaiKey)
  232. builder.WriteString(", ")
  233. builder.WriteString("request_raw=")
  234. builder.WriteString(ca.RequestRaw)
  235. builder.WriteString(", ")
  236. builder.WriteString("response_raw=")
  237. builder.WriteString(ca.ResponseRaw)
  238. builder.WriteString(", ")
  239. builder.WriteString("callback_url=")
  240. builder.WriteString(ca.CallbackURL)
  241. builder.WriteString(", ")
  242. builder.WriteString("callback_response_raw=")
  243. builder.WriteString(ca.CallbackResponseRaw)
  244. builder.WriteString(", ")
  245. builder.WriteString("model=")
  246. builder.WriteString(ca.Model)
  247. builder.WriteString(", ")
  248. builder.WriteString("task_status=")
  249. builder.WriteString(fmt.Sprintf("%v", ca.TaskStatus))
  250. builder.WriteString(", ")
  251. builder.WriteString("retry_count=")
  252. builder.WriteString(fmt.Sprintf("%v", ca.RetryCount))
  253. builder.WriteString(", ")
  254. builder.WriteString("last_error=")
  255. builder.WriteString(ca.LastError)
  256. builder.WriteByte(')')
  257. return builder.String()
  258. }
  259. // CompapiAsynctasks is a parsable slice of CompapiAsynctask.
  260. type CompapiAsynctasks []*CompapiAsynctask