feat: 数据概览/操作日志/批量操作 + 首页合格档案数
后台新增「数据概览」(商品/合格/按状态/品牌/分类/待审核) 与「操作日志」(全局审计分页);商品列表支持多选批量改状态/分类。公开首页标题改为「天工」并展示合格档案数;新增公开接口 /api/v1/stats 与后台 /api/stats、/api/audit、/api/products/bulk。合格口径=quality_score≥0.6 且在用。 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -29,6 +29,24 @@ func (s *Store) Ping(ctx context.Context) error {
|
||||
return s.pool.Ping(ctx)
|
||||
}
|
||||
|
||||
// PublicStats summarizes the public catalog for the homepage.
|
||||
type PublicStats struct {
|
||||
Total int `json:"total"`
|
||||
Qualified int `json:"qualified"`
|
||||
MinScore float64 `json:"min_score"`
|
||||
}
|
||||
|
||||
// Stats returns active-product totals and the number of qualified records whose
|
||||
// quality_score meets minScore.
|
||||
func (s *Store) Stats(ctx context.Context, minScore float64) (PublicStats, error) {
|
||||
st := PublicStats{MinScore: minScore}
|
||||
err := s.pool.QueryRow(ctx, `
|
||||
SELECT count(*) FILTER (WHERE status = 'active'),
|
||||
count(*) FILTER (WHERE status = 'active' AND quality_score >= $1)
|
||||
FROM product`, minScore).Scan(&st.Total, &st.Qualified)
|
||||
return st, err
|
||||
}
|
||||
|
||||
// Barcode is one GS1 trade item number attached to a product.
|
||||
type Barcode struct {
|
||||
GTIN string `json:"gtin"`
|
||||
|
||||
Reference in New Issue
Block a user