feat(admin): 完善站点设置、内容回收站与后台菜单分组
新增站点设置与内容管理(含已删除恢复/清除),用户页改用独有运营指标,并按概览/内容/成员与经济/站点重组侧栏。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -59,12 +59,17 @@ type AdminUserItem struct {
|
||||
LastLoginAt *time.Time `json:"last_login_at"`
|
||||
}
|
||||
|
||||
// AdminUserSummary 列表顶部汇总(总数/管理团队/封禁/今日新增)
|
||||
// AdminUserSummary 列表顶部汇总
|
||||
// - online / in_cooldown / active_7d / failed_logins_24h:用户页独有运营指标
|
||||
// - total / admins / banned:筛选 Tab 角标(不在顶部卡片展示,避免与仪表盘重复)
|
||||
type AdminUserSummary struct {
|
||||
Total int64 `json:"total"`
|
||||
Admins int64 `json:"admins"`
|
||||
Banned int64 `json:"banned"`
|
||||
TodayNew int64 `json:"today_new"`
|
||||
Online int64 `json:"online"`
|
||||
InCooldown int64 `json:"in_cooldown"`
|
||||
Active7d int64 `json:"active_7d"`
|
||||
FailedLogins24h int64 `json:"failed_logins_24h"`
|
||||
Total int64 `json:"total"`
|
||||
Admins int64 `json:"admins"`
|
||||
Banned int64 `json:"banned"`
|
||||
}
|
||||
|
||||
// staffRoles 管理团队角色集合
|
||||
@@ -131,14 +136,31 @@ func (s *AdminUserService) List(q AdminUserListQuery) (*AdminUserListResult, err
|
||||
|
||||
items := s.toItems(users)
|
||||
|
||||
// 汇总数据(不受筛选条件影响,始终反映全站)
|
||||
// 汇总:用户页独有指标(避免与仪表盘站点总量重复)
|
||||
now := time.Now()
|
||||
dayStart := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location())
|
||||
onlineSince := now.Add(-onlineThreshold)
|
||||
hours, _ := (&SettingService{db: s.db}).PostCooldownHours()
|
||||
activeSince := now.Add(-7 * 24 * time.Hour)
|
||||
failSince := now.Add(-24 * time.Hour)
|
||||
summary := AdminUserSummary{}
|
||||
s.db.Model(&model.User{}).
|
||||
Where("banned = ? AND last_seen_at IS NOT NULL AND last_seen_at >= ?", false, onlineSince).
|
||||
Count(&summary.Online)
|
||||
if hours > 0 {
|
||||
cooldownSince := now.Add(-time.Duration(hours) * time.Hour)
|
||||
s.db.Model(&model.User{}).
|
||||
Where("banned = ? AND role = ? AND created_at >= ?", false, model.RoleUser, cooldownSince).
|
||||
Count(&summary.InCooldown)
|
||||
}
|
||||
s.db.Model(&model.User{}).
|
||||
Where("last_seen_at IS NOT NULL AND last_seen_at >= ?", activeSince).
|
||||
Count(&summary.Active7d)
|
||||
s.db.Model(&model.LoginLog{}).
|
||||
Where("success = ? AND created_at >= ?", false, failSince).
|
||||
Count(&summary.FailedLogins24h)
|
||||
s.db.Model(&model.User{}).Count(&summary.Total)
|
||||
s.db.Model(&model.User{}).Where("role IN ?", staffRoles).Count(&summary.Admins)
|
||||
s.db.Model(&model.User{}).Where("banned = ?", true).Count(&summary.Banned)
|
||||
s.db.Model(&model.User{}).Where("created_at >= ?", dayStart).Count(&summary.TodayNew)
|
||||
|
||||
return &AdminUserListResult{
|
||||
Users: items,
|
||||
|
||||
Reference in New Issue
Block a user