feat: 管理首页帖子总数统计(总数/已发布/待审核)
- PostRepo 新增 CountPostsByStatus 和 CountPending 方法 - Service 层定义 postAdminStatStore 接口 (ISP) - AdminService 注入 postRepo,新增 PostStats 结构体和 GetPostStats 方法 - AdminController.Dashboard 调用 GetPostStats 并传参到模板 - Dashboard 帖子卡片显示总数 + 已发布 + 待审核(橙色徽章) - DI 层将 AdminController 创建从 buildDepsCore 移至 buildDeps,以便注入 postRepo
This commit is contained in:
@ -29,10 +29,17 @@ func (ac *AdminController) Dashboard(c *gin.Context) {
|
||||
if err != nil {
|
||||
totalUsers = 0
|
||||
}
|
||||
postStats, err := ac.adminService.GetPostStats()
|
||||
if err != nil {
|
||||
postStats = &service.PostStats{}
|
||||
}
|
||||
storeMetrics := ac.adminService.GetStoreMetrics()
|
||||
c.HTML(http.StatusOK, "admin/dashboard/index.html", common.BuildAdminPageData(c, gin.H{
|
||||
"Title": "管理首页",
|
||||
"TotalUsers": totalUsers,
|
||||
"PostTotal": postStats.Total,
|
||||
"PostApproved": postStats.Approved,
|
||||
"PostPending": postStats.Pending,
|
||||
"StoreType": storeMetrics.Type,
|
||||
"StoreHealthy": storeMetrics.Healthy,
|
||||
"StoreDegraded": storeMetrics.Degraded,
|
||||
|
||||
Reference in New Issue
Block a user