151 lines
4.4 KiB
Go
151 lines
4.4 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"fmt"
|
|
"home-vue-go/internal/ent/visit"
|
|
"strings"
|
|
"time"
|
|
|
|
"entgo.io/ent"
|
|
"entgo.io/ent/dialect/sql"
|
|
)
|
|
|
|
// Visit is the model entity for the Visit schema.
|
|
type Visit struct {
|
|
config `json:"-"`
|
|
// ID of the ent.
|
|
ID int `json:"id,omitempty"`
|
|
// 访问路径
|
|
Path string `json:"path,omitempty"`
|
|
// 访问IP
|
|
IP string `json:"ip,omitempty"`
|
|
// 用户代理
|
|
UserAgent string `json:"user_agent,omitempty"`
|
|
// 来源页面
|
|
Referer string `json:"referer,omitempty"`
|
|
// 访问时间
|
|
VisitTime time.Time `json:"visit_time,omitempty"`
|
|
selectValues sql.SelectValues
|
|
}
|
|
|
|
// scanValues returns the types for scanning values from sql.Rows.
|
|
func (*Visit) scanValues(columns []string) ([]any, error) {
|
|
values := make([]any, len(columns))
|
|
for i := range columns {
|
|
switch columns[i] {
|
|
case visit.FieldID:
|
|
values[i] = new(sql.NullInt64)
|
|
case visit.FieldPath, visit.FieldIP, visit.FieldUserAgent, visit.FieldReferer:
|
|
values[i] = new(sql.NullString)
|
|
case visit.FieldVisitTime:
|
|
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 Visit fields.
|
|
func (_m *Visit) 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 visit.FieldID:
|
|
value, ok := values[i].(*sql.NullInt64)
|
|
if !ok {
|
|
return fmt.Errorf("unexpected type %T for field id", value)
|
|
}
|
|
_m.ID = int(value.Int64)
|
|
case visit.FieldPath:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field path", values[i])
|
|
} else if value.Valid {
|
|
_m.Path = value.String
|
|
}
|
|
case visit.FieldIP:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field ip", values[i])
|
|
} else if value.Valid {
|
|
_m.IP = value.String
|
|
}
|
|
case visit.FieldUserAgent:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field user_agent", values[i])
|
|
} else if value.Valid {
|
|
_m.UserAgent = value.String
|
|
}
|
|
case visit.FieldReferer:
|
|
if value, ok := values[i].(*sql.NullString); !ok {
|
|
return fmt.Errorf("unexpected type %T for field referer", values[i])
|
|
} else if value.Valid {
|
|
_m.Referer = value.String
|
|
}
|
|
case visit.FieldVisitTime:
|
|
if value, ok := values[i].(*sql.NullTime); !ok {
|
|
return fmt.Errorf("unexpected type %T for field visit_time", values[i])
|
|
} else if value.Valid {
|
|
_m.VisitTime = value.Time
|
|
}
|
|
default:
|
|
_m.selectValues.Set(columns[i], values[i])
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Value returns the ent.Value that was dynamically selected and assigned to the Visit.
|
|
// This includes values selected through modifiers, order, etc.
|
|
func (_m *Visit) Value(name string) (ent.Value, error) {
|
|
return _m.selectValues.Get(name)
|
|
}
|
|
|
|
// Update returns a builder for updating this Visit.
|
|
// Note that you need to call Visit.Unwrap() before calling this method if this Visit
|
|
// was returned from a transaction, and the transaction was committed or rolled back.
|
|
func (_m *Visit) Update() *VisitUpdateOne {
|
|
return NewVisitClient(_m.config).UpdateOne(_m)
|
|
}
|
|
|
|
// Unwrap unwraps the Visit 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 (_m *Visit) Unwrap() *Visit {
|
|
_tx, ok := _m.config.driver.(*txDriver)
|
|
if !ok {
|
|
panic("ent: Visit is not a transactional entity")
|
|
}
|
|
_m.config.driver = _tx.drv
|
|
return _m
|
|
}
|
|
|
|
// String implements the fmt.Stringer.
|
|
func (_m *Visit) String() string {
|
|
var builder strings.Builder
|
|
builder.WriteString("Visit(")
|
|
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
|
builder.WriteString("path=")
|
|
builder.WriteString(_m.Path)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("ip=")
|
|
builder.WriteString(_m.IP)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("user_agent=")
|
|
builder.WriteString(_m.UserAgent)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("referer=")
|
|
builder.WriteString(_m.Referer)
|
|
builder.WriteString(", ")
|
|
builder.WriteString("visit_time=")
|
|
builder.WriteString(_m.VisitTime.Format(time.ANSIC))
|
|
builder.WriteByte(')')
|
|
return builder.String()
|
|
}
|
|
|
|
// Visits is a parsable slice of Visit.
|
|
type Visits []*Visit
|