// Code generated by ent, DO NOT EDIT. package ent import ( "fmt" "strings" "time" "wechat-api/ent/chatsession" "entgo.io/ent" "entgo.io/ent/dialect/sql" ) // ChatSession is the model entity for the ChatSession schema. type ChatSession 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"` // Delete Time | 删除日期 DeletedAt time.Time `json:"deleted_at,omitempty"` // 名称 Name string `json:"name,omitempty"` // 用户ID UserID uint64 `json:"user_id,omitempty"` // 聊天ID BotID uint64 `json:"bot_id,omitempty"` // 类型:1-微信 2-小程序card 3-智能体 BotType uint8 `json:"bot_type,omitempty"` selectValues sql.SelectValues } // scanValues returns the types for scanning values from sql.Rows. func (*ChatSession) scanValues(columns []string) ([]any, error) { values := make([]any, len(columns)) for i := range columns { switch columns[i] { case chatsession.FieldID, chatsession.FieldUserID, chatsession.FieldBotID, chatsession.FieldBotType: values[i] = new(sql.NullInt64) case chatsession.FieldName: values[i] = new(sql.NullString) case chatsession.FieldCreatedAt, chatsession.FieldUpdatedAt, chatsession.FieldDeletedAt: 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 ChatSession fields. func (cs *ChatSession) 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 chatsession.FieldID: value, ok := values[i].(*sql.NullInt64) if !ok { return fmt.Errorf("unexpected type %T for field id", value) } cs.ID = uint64(value.Int64) case chatsession.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 { cs.CreatedAt = value.Time } case chatsession.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 { cs.UpdatedAt = value.Time } case chatsession.FieldDeletedAt: if value, ok := values[i].(*sql.NullTime); !ok { return fmt.Errorf("unexpected type %T for field deleted_at", values[i]) } else if value.Valid { cs.DeletedAt = value.Time } case chatsession.FieldName: if value, ok := values[i].(*sql.NullString); !ok { return fmt.Errorf("unexpected type %T for field name", values[i]) } else if value.Valid { cs.Name = value.String } case chatsession.FieldUserID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field user_id", values[i]) } else if value.Valid { cs.UserID = uint64(value.Int64) } case chatsession.FieldBotID: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field bot_id", values[i]) } else if value.Valid { cs.BotID = uint64(value.Int64) } case chatsession.FieldBotType: if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field bot_type", values[i]) } else if value.Valid { cs.BotType = uint8(value.Int64) } default: cs.selectValues.Set(columns[i], values[i]) } } return nil } // Value returns the ent.Value that was dynamically selected and assigned to the ChatSession. // This includes values selected through modifiers, order, etc. func (cs *ChatSession) Value(name string) (ent.Value, error) { return cs.selectValues.Get(name) } // Update returns a builder for updating this ChatSession. // Note that you need to call ChatSession.Unwrap() before calling this method if this ChatSession // was returned from a transaction, and the transaction was committed or rolled back. func (cs *ChatSession) Update() *ChatSessionUpdateOne { return NewChatSessionClient(cs.config).UpdateOne(cs) } // Unwrap unwraps the ChatSession 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 (cs *ChatSession) Unwrap() *ChatSession { _tx, ok := cs.config.driver.(*txDriver) if !ok { panic("ent: ChatSession is not a transactional entity") } cs.config.driver = _tx.drv return cs } // String implements the fmt.Stringer. func (cs *ChatSession) String() string { var builder strings.Builder builder.WriteString("ChatSession(") builder.WriteString(fmt.Sprintf("id=%v, ", cs.ID)) builder.WriteString("created_at=") builder.WriteString(cs.CreatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("updated_at=") builder.WriteString(cs.UpdatedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("deleted_at=") builder.WriteString(cs.DeletedAt.Format(time.ANSIC)) builder.WriteString(", ") builder.WriteString("name=") builder.WriteString(cs.Name) builder.WriteString(", ") builder.WriteString("user_id=") builder.WriteString(fmt.Sprintf("%v", cs.UserID)) builder.WriteString(", ") builder.WriteString("bot_id=") builder.WriteString(fmt.Sprintf("%v", cs.BotID)) builder.WriteString(", ") builder.WriteString("bot_type=") builder.WriteString(fmt.Sprintf("%v", cs.BotType)) builder.WriteByte(')') return builder.String() } // ChatSessions is a parsable slice of ChatSession. type ChatSessions []*ChatSession