mingyang-admin-iot-app/rpc/ent/userloginlog.go

290 lines
11 KiB
Go

// Code generated by ent, DO NOT EDIT.
package ent
import (
"encoding/json"
"fmt"
"mingyang-admin-app-rpc/ent/userloginlog"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
)
// user_login_logs Table | 用户登录信息表
type UserLoginLog 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"`
// Status 1: normal 2: ban | 状态 1 正常 2 禁用
Status uint8 `json:"status,omitempty"`
// Tenant ID | 租户 ID
TenantID uint64 `json:"tenant_id,omitempty"`
// Delete Time | 删除日期
DeletedAt time.Time `json:"deleted_at,omitempty"`
// 用户ID
UserID uint64 `json:"user_id,omitempty"`
// LoginTime holds the value of the "login_time" field.
LoginTime time.Time `json:"login_time,omitempty"`
// LoginIP holds the value of the "login_ip" field.
LoginIP string `json:"login_ip,omitempty"`
// LoginLocation holds the value of the "login_location" field.
LoginLocation string `json:"login_location,omitempty"`
// LoginType holds the value of the "login_type" field.
LoginType userloginlog.LoginType `json:"login_type,omitempty"`
// LoginPlatform holds the value of the "login_platform" field.
LoginPlatform userloginlog.LoginPlatform `json:"login_platform,omitempty"`
// 登录结果,是否成功
LoginResult bool `json:"login_result,omitempty"`
// FailureReason holds the value of the "failure_reason" field.
FailureReason string `json:"failure_reason,omitempty"`
// SessionID holds the value of the "session_id" field.
SessionID string `json:"session_id,omitempty"`
// LatencyMs holds the value of the "latency_ms" field.
LatencyMs int `json:"latency_ms,omitempty"`
// auth_id
AuthID uint64 `json:"auth_id,omitempty"`
// AdditionalData holds the value of the "additional_data" field.
AdditionalData map[string]interface{} `json:"additional_data,omitempty"`
selectValues sql.SelectValues
}
// scanValues returns the types for scanning values from sql.Rows.
func (*UserLoginLog) scanValues(columns []string) ([]any, error) {
values := make([]any, len(columns))
for i := range columns {
switch columns[i] {
case userloginlog.FieldAdditionalData:
values[i] = new([]byte)
case userloginlog.FieldLoginResult:
values[i] = new(sql.NullBool)
case userloginlog.FieldID, userloginlog.FieldStatus, userloginlog.FieldTenantID, userloginlog.FieldUserID, userloginlog.FieldLatencyMs, userloginlog.FieldAuthID:
values[i] = new(sql.NullInt64)
case userloginlog.FieldLoginIP, userloginlog.FieldLoginLocation, userloginlog.FieldLoginType, userloginlog.FieldLoginPlatform, userloginlog.FieldFailureReason, userloginlog.FieldSessionID:
values[i] = new(sql.NullString)
case userloginlog.FieldCreatedAt, userloginlog.FieldUpdatedAt, userloginlog.FieldDeletedAt, userloginlog.FieldLoginTime:
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 UserLoginLog fields.
func (_m *UserLoginLog) 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 userloginlog.FieldID:
value, ok := values[i].(*sql.NullInt64)
if !ok {
return fmt.Errorf("unexpected type %T for field id", value)
}
_m.ID = uint64(value.Int64)
case userloginlog.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 {
_m.CreatedAt = value.Time
}
case userloginlog.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 {
_m.UpdatedAt = value.Time
}
case userloginlog.FieldStatus:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field status", values[i])
} else if value.Valid {
_m.Status = uint8(value.Int64)
}
case userloginlog.FieldTenantID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field tenant_id", values[i])
} else if value.Valid {
_m.TenantID = uint64(value.Int64)
}
case userloginlog.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 {
_m.DeletedAt = value.Time
}
case userloginlog.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 {
_m.UserID = uint64(value.Int64)
}
case userloginlog.FieldLoginTime:
if value, ok := values[i].(*sql.NullTime); !ok {
return fmt.Errorf("unexpected type %T for field login_time", values[i])
} else if value.Valid {
_m.LoginTime = value.Time
}
case userloginlog.FieldLoginIP:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field login_ip", values[i])
} else if value.Valid {
_m.LoginIP = value.String
}
case userloginlog.FieldLoginLocation:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field login_location", values[i])
} else if value.Valid {
_m.LoginLocation = value.String
}
case userloginlog.FieldLoginType:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field login_type", values[i])
} else if value.Valid {
_m.LoginType = userloginlog.LoginType(value.String)
}
case userloginlog.FieldLoginPlatform:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field login_platform", values[i])
} else if value.Valid {
_m.LoginPlatform = userloginlog.LoginPlatform(value.String)
}
case userloginlog.FieldLoginResult:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field login_result", values[i])
} else if value.Valid {
_m.LoginResult = value.Bool
}
case userloginlog.FieldFailureReason:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field failure_reason", values[i])
} else if value.Valid {
_m.FailureReason = value.String
}
case userloginlog.FieldSessionID:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field session_id", values[i])
} else if value.Valid {
_m.SessionID = value.String
}
case userloginlog.FieldLatencyMs:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field latency_ms", values[i])
} else if value.Valid {
_m.LatencyMs = int(value.Int64)
}
case userloginlog.FieldAuthID:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field auth_id", values[i])
} else if value.Valid {
_m.AuthID = uint64(value.Int64)
}
case userloginlog.FieldAdditionalData:
if value, ok := values[i].(*[]byte); !ok {
return fmt.Errorf("unexpected type %T for field additional_data", values[i])
} else if value != nil && len(*value) > 0 {
if err := json.Unmarshal(*value, &_m.AdditionalData); err != nil {
return fmt.Errorf("unmarshal field additional_data: %w", err)
}
}
default:
_m.selectValues.Set(columns[i], values[i])
}
}
return nil
}
// Value returns the ent.Value that was dynamically selected and assigned to the UserLoginLog.
// This includes values selected through modifiers, order, etc.
func (_m *UserLoginLog) Value(name string) (ent.Value, error) {
return _m.selectValues.Get(name)
}
// Update returns a builder for updating this UserLoginLog.
// Note that you need to call UserLoginLog.Unwrap() before calling this method if this UserLoginLog
// was returned from a transaction, and the transaction was committed or rolled back.
func (_m *UserLoginLog) Update() *UserLoginLogUpdateOne {
return NewUserLoginLogClient(_m.config).UpdateOne(_m)
}
// Unwrap unwraps the UserLoginLog 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 *UserLoginLog) Unwrap() *UserLoginLog {
_tx, ok := _m.config.driver.(*txDriver)
if !ok {
panic("ent: UserLoginLog is not a transactional entity")
}
_m.config.driver = _tx.drv
return _m
}
// String implements the fmt.Stringer.
func (_m *UserLoginLog) String() string {
var builder strings.Builder
builder.WriteString("UserLoginLog(")
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
builder.WriteString("created_at=")
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("updated_at=")
builder.WriteString(_m.UpdatedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("status=")
builder.WriteString(fmt.Sprintf("%v", _m.Status))
builder.WriteString(", ")
builder.WriteString("tenant_id=")
builder.WriteString(fmt.Sprintf("%v", _m.TenantID))
builder.WriteString(", ")
builder.WriteString("deleted_at=")
builder.WriteString(_m.DeletedAt.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("user_id=")
builder.WriteString(fmt.Sprintf("%v", _m.UserID))
builder.WriteString(", ")
builder.WriteString("login_time=")
builder.WriteString(_m.LoginTime.Format(time.ANSIC))
builder.WriteString(", ")
builder.WriteString("login_ip=")
builder.WriteString(_m.LoginIP)
builder.WriteString(", ")
builder.WriteString("login_location=")
builder.WriteString(_m.LoginLocation)
builder.WriteString(", ")
builder.WriteString("login_type=")
builder.WriteString(fmt.Sprintf("%v", _m.LoginType))
builder.WriteString(", ")
builder.WriteString("login_platform=")
builder.WriteString(fmt.Sprintf("%v", _m.LoginPlatform))
builder.WriteString(", ")
builder.WriteString("login_result=")
builder.WriteString(fmt.Sprintf("%v", _m.LoginResult))
builder.WriteString(", ")
builder.WriteString("failure_reason=")
builder.WriteString(_m.FailureReason)
builder.WriteString(", ")
builder.WriteString("session_id=")
builder.WriteString(_m.SessionID)
builder.WriteString(", ")
builder.WriteString("latency_ms=")
builder.WriteString(fmt.Sprintf("%v", _m.LatencyMs))
builder.WriteString(", ")
builder.WriteString("auth_id=")
builder.WriteString(fmt.Sprintf("%v", _m.AuthID))
builder.WriteString(", ")
builder.WriteString("additional_data=")
builder.WriteString(fmt.Sprintf("%v", _m.AdditionalData))
builder.WriteByte(')')
return builder.String()
}
// UserLoginLogs is a parsable slice of UserLoginLog.
type UserLoginLogs []*UserLoginLog