123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- // Code generated by ent, DO NOT EDIT.
- package ent
- import (
- "fmt"
- "strings"
- "time"
- "wechat-api/ent/chatrecords"
- "entgo.io/ent"
- "entgo.io/ent/dialect/sql"
- )
- // ChatRecords is the model entity for the ChatRecords schema.
- type ChatRecords 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"`
- // 内容
- Content string `json:"content,omitempty"`
- // 内容类型:1-提问 2-回答
- ContentType uint8 `json:"content_type,omitempty"`
- // 会话ID
- SessionID uint64 `json:"session_id,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 (*ChatRecords) scanValues(columns []string) ([]any, error) {
- values := make([]any, len(columns))
- for i := range columns {
- switch columns[i] {
- case chatrecords.FieldID, chatrecords.FieldContentType, chatrecords.FieldSessionID, chatrecords.FieldUserID, chatrecords.FieldBotID, chatrecords.FieldBotType:
- values[i] = new(sql.NullInt64)
- case chatrecords.FieldContent:
- values[i] = new(sql.NullString)
- case chatrecords.FieldCreatedAt, chatrecords.FieldUpdatedAt, chatrecords.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 ChatRecords fields.
- func (cr *ChatRecords) 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 chatrecords.FieldID:
- value, ok := values[i].(*sql.NullInt64)
- if !ok {
- return fmt.Errorf("unexpected type %T for field id", value)
- }
- cr.ID = uint64(value.Int64)
- case chatrecords.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 {
- cr.CreatedAt = value.Time
- }
- case chatrecords.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 {
- cr.UpdatedAt = value.Time
- }
- case chatrecords.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 {
- cr.DeletedAt = value.Time
- }
- case chatrecords.FieldContent:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field content", values[i])
- } else if value.Valid {
- cr.Content = value.String
- }
- case chatrecords.FieldContentType:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field content_type", values[i])
- } else if value.Valid {
- cr.ContentType = uint8(value.Int64)
- }
- case chatrecords.FieldSessionID:
- if value, ok := values[i].(*sql.NullInt64); !ok {
- return fmt.Errorf("unexpected type %T for field session_id", values[i])
- } else if value.Valid {
- cr.SessionID = uint64(value.Int64)
- }
- case chatrecords.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 {
- cr.UserID = uint64(value.Int64)
- }
- case chatrecords.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 {
- cr.BotID = uint64(value.Int64)
- }
- case chatrecords.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 {
- cr.BotType = uint8(value.Int64)
- }
- default:
- cr.selectValues.Set(columns[i], values[i])
- }
- }
- return nil
- }
- // Value returns the ent.Value that was dynamically selected and assigned to the ChatRecords.
- // This includes values selected through modifiers, order, etc.
- func (cr *ChatRecords) Value(name string) (ent.Value, error) {
- return cr.selectValues.Get(name)
- }
- // Update returns a builder for updating this ChatRecords.
- // Note that you need to call ChatRecords.Unwrap() before calling this method if this ChatRecords
- // was returned from a transaction, and the transaction was committed or rolled back.
- func (cr *ChatRecords) Update() *ChatRecordsUpdateOne {
- return NewChatRecordsClient(cr.config).UpdateOne(cr)
- }
- // Unwrap unwraps the ChatRecords 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 (cr *ChatRecords) Unwrap() *ChatRecords {
- _tx, ok := cr.config.driver.(*txDriver)
- if !ok {
- panic("ent: ChatRecords is not a transactional entity")
- }
- cr.config.driver = _tx.drv
- return cr
- }
- // String implements the fmt.Stringer.
- func (cr *ChatRecords) String() string {
- var builder strings.Builder
- builder.WriteString("ChatRecords(")
- builder.WriteString(fmt.Sprintf("id=%v, ", cr.ID))
- builder.WriteString("created_at=")
- builder.WriteString(cr.CreatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("updated_at=")
- builder.WriteString(cr.UpdatedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("deleted_at=")
- builder.WriteString(cr.DeletedAt.Format(time.ANSIC))
- builder.WriteString(", ")
- builder.WriteString("content=")
- builder.WriteString(cr.Content)
- builder.WriteString(", ")
- builder.WriteString("content_type=")
- builder.WriteString(fmt.Sprintf("%v", cr.ContentType))
- builder.WriteString(", ")
- builder.WriteString("session_id=")
- builder.WriteString(fmt.Sprintf("%v", cr.SessionID))
- builder.WriteString(", ")
- builder.WriteString("user_id=")
- builder.WriteString(fmt.Sprintf("%v", cr.UserID))
- builder.WriteString(", ")
- builder.WriteString("bot_id=")
- builder.WriteString(fmt.Sprintf("%v", cr.BotID))
- builder.WriteString(", ")
- builder.WriteString("bot_type=")
- builder.WriteString(fmt.Sprintf("%v", cr.BotType))
- builder.WriteByte(')')
- return builder.String()
- }
- // ChatRecordsSlice is a parsable slice of ChatRecords.
- type ChatRecordsSlice []*ChatRecords
|