compapiasynctask.go 9.1 KB

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