compapiasynctask.go 11 KB

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