feat: 添加 /api/review-stats 端点和仪表盘实时数据集成
This commit is contained in:
@@ -198,3 +198,43 @@ func MonthlyStats(c *gin.Context) {
|
||||
Data: stats,
|
||||
})
|
||||
}
|
||||
|
||||
// ReviewStats 获取待复核数据统计
|
||||
func ReviewStats(c *gin.Context) {
|
||||
repo := repository.GetRepository()
|
||||
|
||||
// 从MongoDB查询所有需要复核的账单
|
||||
bills, err := repo.GetBillsNeedReview()
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, model.ReviewResponse{
|
||||
Result: false,
|
||||
Message: "查询失败: " + err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
highCount := 0
|
||||
lowCount := 0
|
||||
totalCount := 0
|
||||
|
||||
// 统计各等级的复核记录
|
||||
for _, bill := range bills {
|
||||
totalCount++
|
||||
if bill.ReviewLevel == "HIGH" {
|
||||
highCount++
|
||||
} else if bill.ReviewLevel == "LOW" {
|
||||
lowCount++
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(http.StatusOK, model.ReviewResponse{
|
||||
Result: true,
|
||||
Message: "获取成功",
|
||||
Data: &model.ReviewData{
|
||||
Total: totalCount,
|
||||
High: highCount,
|
||||
Low: lowCount,
|
||||
Records: nil, // 统计接口不返回具体记录
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user