feat(admin): 用户管理增强 - CSV 批量导入用户、批量状态/组操作、登录审计日志
Build and Deploy / build-and-deploy (push) Canceled after 0s

This commit is contained in:
2026-09-13 12:09:55 +08:00
parent 32959c7330
commit 62e2250202
10 changed files with 884 additions and 0 deletions
+81
View File
@@ -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"),
}
}
+1
View File
@@ -54,6 +54,7 @@ func (User) Edges() []ent.Edge {
edge.To("fsevents", FsEvent.Type),
edge.To("entities", Entity.Type),
edge.To("oauth_grants", OAuthGrant.Type),
edge.To("login_audits", LoginAudit.Type),
}
}