// 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"` // ResponseChatItemID holds the value of the "response_chat_item_id" field. ResponseChatItemID string `json:"response_chat_item_id,omitempty"` // organization_id | 租户ID OrganizationID uint64 `json:"organization_id,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"` // callback_url | 异步执行回调地址 CallbackURL string `json:"callback_url,omitempty"` // callback返回结构字符串 CallbackResponseRaw string `json:"callback_response_raw,omitempty"` // 所用大模型 Model string `json:"model,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.FieldOrganizationID, compapiasynctask.FieldTaskStatus, compapiasynctask.FieldRetryCount: values[i] = new(sql.NullInt64) 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: 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.FieldResponseChatItemID: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field response_chat_item_id", values[i]) } else if value.Valid { ca.ResponseChatItemID = value.String } case compapiasynctask.FieldOrganizationID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field organization_id", values[i]) } else if value.Valid { ca.OrganizationID = uint64(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.FieldCallbackResponseRaw: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field callback_response_raw", values[i]) } else if value.Valid { ca.CallbackResponseRaw = value.String } case compapiasynctask.FieldModel: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field model", values[i]) } else if value.Valid { ca.Model = 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("response_chat_item_id=") builder.WriteString(ca.ResponseChatItemID) builder.WriteString(", ") builder.WriteString("organization_id=") builder.WriteString(fmt.Sprintf("%v", ca.OrganizationID)) 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("callback_response_raw=") builder.WriteString(ca.CallbackResponseRaw) builder.WriteString(", ") builder.WriteString("model=") builder.WriteString(ca.Model) 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