feat(admin): 用户管理增强 - CSV 批量导入用户、批量状态/组操作、登录审计日志
Build and Deploy / build-and-deploy (push) Canceled after 0s
Build and Deploy / build-and-deploy (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// LoginAudit holds the schema definition for the LoginAudit entity.
|
||||
type LoginAudit struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
func (LoginAudit) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.Int("user_id").
|
||||
Optional().
|
||||
Nillable(),
|
||||
field.String("ip").
|
||||
MaxLen(64).
|
||||
Default(""),
|
||||
field.String("user_agent").
|
||||
MaxLen(512).
|
||||
Default(""),
|
||||
field.Enum("status").
|
||||
Values("success", "fail").
|
||||
Default("fail"),
|
||||
field.String("fail_reason").
|
||||
MaxLen(255).
|
||||
Optional().
|
||||
Nillable(),
|
||||
field.String("location_iso").
|
||||
MaxLen(8).
|
||||
Optional().
|
||||
Nillable(),
|
||||
field.String("location_province").
|
||||
MaxLen(64).
|
||||
Optional().
|
||||
Nillable(),
|
||||
field.String("location_city").
|
||||
MaxLen(64).
|
||||
Optional().
|
||||
Nillable(),
|
||||
field.Time("logout_at").
|
||||
Optional().
|
||||
Nillable(),
|
||||
field.Int("session_seconds").
|
||||
Optional().
|
||||
Nillable().
|
||||
Default(0),
|
||||
field.String("username_tried").
|
||||
MaxLen(100).
|
||||
Optional().
|
||||
Nillable(),
|
||||
}
|
||||
}
|
||||
|
||||
func (LoginAudit) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("user", User.Type).
|
||||
Ref("login_audits").
|
||||
Field("user_id").
|
||||
Unique(),
|
||||
}
|
||||
}
|
||||
|
||||
func (LoginAudit) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
CommonMixin{},
|
||||
}
|
||||
}
|
||||
|
||||
func (LoginAudit) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("user_id"),
|
||||
index.Fields("ip"),
|
||||
index.Fields("status"),
|
||||
index.Fields("created_at"),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user