123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "wechat-api/ent/compapiasynctask"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- // CompapiAsynctask is the model entity for the CompapiAsynctask schema.
- type CompapiAsynctask struct {
- config `json:"-"`
- // ID of the ent.
- ID uint64 `json:"id,omitempty"`
- // Create Time | 创建日期
- CreatedAt time.Time `json:"created_at,omitempty"`
- // Update Time | 修改日期
- UpdatedAt time.Time `json:"updated_at,omitempty"`
- // 发起请求者的授权token
- AuthToken string `json:"auth_token,omitempty"`
- // 请求目标类型
- EventType string `json:"event_type,omitempty"`
- // 会话ID
- ChatID string `json:"chat_id,omitempty"`
- // workId在字典中的索引值
- WorkidIdx int8 `json:"workid_idx,omitempty"`
- // 待请求的大模型服务地址
- OpenaiBase string `json:"openai_base,omitempty"`
- // 待请求的大模型服务密钥授权token
- OpenaiKey string `json:"openai_key,omitempty"`
- // 请求参数结构字符串
- RequestRaw string `json:"request_raw,omitempty"`
- // 请求响应结构字符串
- ResponseRaw string `json:"response_raw,omitempty"`
- // 异步执行回调地址
- CallbackURL string `json:"callback_url,omitempty"`
- // callback_status | 任务完成状态 10 任务就绪 20 请求API完成 30 请求回调完成 60 任务暂停 70 任务失败
- TaskStatus int8 `json:"task_status,omitempty"`
- // retry count | 重试次数
- RetryCount int8 `json:"retry_count,omitempty"`
- // 最后一次出错信息
- LastError string `json:"last_error,omitempty"`
- selectValues sql.SelectValues
- }
- // scanValues returns the types for scanning values from sql.Rows.
- func (*CompapiAsynctask) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case compapiasynctask.FieldID, compapiasynctask.FieldWorkidIdx, compapiasynctask.FieldTaskStatus, compapiasynctask.FieldRetryCount:
- values[i] = new(sql.NullInt64)
- case compapiasynctask.FieldAuthToken, compapiasynctask.FieldEventType, compapiasynctask.FieldChatID, compapiasynctask.FieldOpenaiBase, compapiasynctask.FieldOpenaiKey, compapiasynctask.FieldRequestRaw, compapiasynctask.FieldResponseRaw, compapiasynctask.FieldCallbackURL, compapiasynctask.FieldLastError:
- values[i] = new(sql.NullString)
- case compapiasynctask.FieldCreatedAt, compapiasynctask.FieldUpdatedAt:
- values[i] = new(sql.NullTime)
- default:
- values[i] = new(sql.UnknownType)
- }
- }
- return values, nil
- }
- // assignValues assigns the values that were returned from sql.Rows (after scanning)
- // to the CompapiAsynctask fields.
- func (ca *CompapiAsynctask) assignValues(columns []string, values []any) error {
- if m, n := len(values), len(columns); m < n {
- return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
- }
- for i := range columns {
- switch columns[i] {
- case compapiasynctask.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- ca.ID = uint64(value.Int64)
- case compapiasynctask.FieldCreatedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field created_at", values[i])
- } else if value.Valid {
- ca.CreatedAt = value.Time
- }
- case compapiasynctask.FieldUpdatedAt:
- if value, ok := values[i].(*sql.NullTime); !ok {
- return fmt.Errorf("unexpected type %T for field updated_at", values[i])
- } else if value.Valid {
- ca.UpdatedAt = value.Time
- }
- case compapiasynctask.FieldAuthToken:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field auth_token", values[i])
- } else if value.Valid {
- ca.AuthToken = value.String
- }
- case compapiasynctask.FieldEventType:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field event_type", values[i])
- } else if value.Valid {
- ca.EventType = value.String
- }
- case compapiasynctask.FieldChatID:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field chat_id", values[i])
- } else if value.Valid {
- ca.ChatID = value.String
- }
- case compapiasynctask.FieldWorkidIdx:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field workid_idx", values[i])
- } else if value.Valid {
- ca.WorkidIdx = int8(value.Int64)
- }
- case compapiasynctask.FieldOpenaiBase:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field openai_base", values[i])
- } else if value.Valid {
- ca.OpenaiBase = value.String
- }
- case compapiasynctask.FieldOpenaiKey:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field openai_key", values[i])
- } else if value.Valid {
- ca.OpenaiKey = value.String
- }
- case compapiasynctask.FieldRequestRaw:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field request_raw", values[i])
- } else if value.Valid {
- ca.RequestRaw = value.String
- }
- case compapiasynctask.FieldResponseRaw:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field response_raw", values[i])
- } else if value.Valid {
- ca.ResponseRaw = value.String
- }
- case compapiasynctask.FieldCallbackURL:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field callback_url", values[i])
- } else if value.Valid {
- ca.CallbackURL = value.String
- }
- case compapiasynctask.FieldTaskStatus:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field task_status", values[i])
- } else if value.Valid {
- ca.TaskStatus = int8(value.Int64)
- }
- case compapiasynctask.FieldRetryCount:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field retry_count", values[i])
- } else if value.Valid {
- ca.RetryCount = int8(value.Int64)
- }
- case compapiasynctask.FieldLastError:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field last_error", values[i])
- } else if value.Valid {
- ca.LastError = value.String
- }
- default:
- ca.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the CompapiAsynctask.
- // This includes values selected through modifiers, order, etc.
- func (ca *CompapiAsynctask) Value(name string) (ent.Value, error) {
- return ca.selectValues.Get(name)
- }
- // Update returns a builder for updating this CompapiAsynctask.
- // Note that you need to call CompapiAsynctask.Unwrap() before calling this method if this CompapiAsynctask
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (ca *CompapiAsynctask) Update() *CompapiAsynctaskUpdateOne {
- return NewCompapiAsynctaskClient(ca.config).UpdateOne(ca)
- }
- // Unwrap unwraps the CompapiAsynctask entity that was returned from a transaction after it was closed,
- // so that all future queries will be executed through the driver which created the transaction.
- func (ca *CompapiAsynctask) Unwrap() *CompapiAsynctask {
- _tx, ok := ca.config.driver.(*txDriver)
- if !ok {
- panic("ent: CompapiAsynctask is not a transactional entity")
- }
- ca.config.driver = _tx.drv
- return ca
- }
- // String implements the fmt.Stringer.
- func (ca *CompapiAsynctask) String() string {
- var builder strings.Builder
- builder.WriteString("CompapiAsynctask(")
- builder.WriteString(fmt.Sprintf("id=%v, ", ca.ID))
- builder.WriteString("created_at=")
- builder.WriteString(ca.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(ca.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("auth_token=")
- builder.WriteString(ca.AuthToken)
- builder.WriteString(", ")
- builder.WriteString("event_type=")
- builder.WriteString(ca.EventType)
- builder.WriteString(", ")
- builder.WriteString("chat_id=")
- builder.WriteString(ca.ChatID)
- builder.WriteString(", ")
- builder.WriteString("workid_idx=")
- builder.WriteString(fmt.Sprintf("%v", ca.WorkidIdx))
- builder.WriteString(", ")
- builder.WriteString("openai_base=")
- builder.WriteString(ca.OpenaiBase)
- builder.WriteString(", ")
- builder.WriteString("openai_key=")
- builder.WriteString(ca.OpenaiKey)
- builder.WriteString(", ")
- builder.WriteString("request_raw=")
- builder.WriteString(ca.RequestRaw)
- builder.WriteString(", ")
- builder.WriteString("response_raw=")
- builder.WriteString(ca.ResponseRaw)
- builder.WriteString(", ")
- builder.WriteString("callback_url=")
- builder.WriteString(ca.CallbackURL)
- builder.WriteString(", ")
- builder.WriteString("task_status=")
- builder.WriteString(fmt.Sprintf("%v", ca.TaskStatus))
- builder.WriteString(", ")
- builder.WriteString("retry_count=")
- builder.WriteString(fmt.Sprintf("%v", ca.RetryCount))
- builder.WriteString(", ")
- builder.WriteString("last_error=")
- builder.WriteString(ca.LastError)
- builder.WriteByte(')')
- return builder.String()
- }
- // CompapiAsynctasks is a parsable slice of CompapiAsynctask.
- type CompapiAsynctasks []*CompapiAsynctask
|