feat: enhance superadmin dashboard overview
This commit is contained in:
@@ -50,6 +50,20 @@ func (c *contents) ListTenantContents(ctx fiber.Ctx, tenantID int64, filter *dto
|
||||
return services.Super.ListContents(ctx, filter)
|
||||
}
|
||||
|
||||
// Content statistics
|
||||
//
|
||||
// @Router /super/v1/contents/statistics [get]
|
||||
// @Summary Content statistics
|
||||
// @Description Content statistics
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.SuperContentStatisticsResponse
|
||||
// @Bind filter query
|
||||
func (c *contents) Statistics(ctx fiber.Ctx, filter *dto.SuperContentStatisticsFilter) (*dto.SuperContentStatisticsResponse, error) {
|
||||
return services.Super.ContentStatistics(ctx, filter)
|
||||
}
|
||||
|
||||
// Update content status
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID<int>/contents/:contentID<int>/status [patch]
|
||||
|
||||
@@ -131,6 +131,18 @@ type SuperContentListFilter struct {
|
||||
Desc *string `query:"desc"`
|
||||
}
|
||||
|
||||
// SuperContentStatisticsFilter 超管内容统计查询条件。
|
||||
type SuperContentStatisticsFilter struct {
|
||||
// TenantID 租户ID(不传代表全平台)。
|
||||
TenantID *int64 `query:"tenant_id"`
|
||||
// StartAt 统计开始时间(RFC3339,可选;默认当前时间往前 7 天)。
|
||||
StartAt *string `query:"start_at"`
|
||||
// EndAt 统计结束时间(RFC3339,可选;默认当前时间)。
|
||||
EndAt *string `query:"end_at"`
|
||||
// Granularity 统计粒度(day;目前仅支持 day)。
|
||||
Granularity *string `query:"granularity"`
|
||||
}
|
||||
|
||||
type SuperOrderListFilter struct {
|
||||
requests.Pagination
|
||||
// ID 订单ID,精确匹配。
|
||||
@@ -635,3 +647,19 @@ type AdminContentOwnerLite struct {
|
||||
// Status 用户状态。
|
||||
Status consts.UserStatus `json:"status"`
|
||||
}
|
||||
|
||||
// SuperContentStatisticsResponse 超管内容统计响应。
|
||||
type SuperContentStatisticsResponse struct {
|
||||
// TotalCount 内容总量。
|
||||
TotalCount int64 `json:"total_count"`
|
||||
// Trend 按天新增内容趋势。
|
||||
Trend []SuperContentTrendItem `json:"trend"`
|
||||
}
|
||||
|
||||
// SuperContentTrendItem 内容新增趋势条目。
|
||||
type SuperContentTrendItem struct {
|
||||
// Date 日期(YYYY-MM-DD)。
|
||||
Date string `json:"date"`
|
||||
// CreatedCount 当日新增内容数量。
|
||||
CreatedCount int64 `json:"created_count"`
|
||||
}
|
||||
|
||||
@@ -58,6 +58,11 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
r.contents.List,
|
||||
Query[dto.SuperContentListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/contents/statistics -> contents.Statistics")
|
||||
router.Get("/super/v1/contents/statistics"[len(r.Path()):], DataFunc1(
|
||||
r.contents.Statistics,
|
||||
Query[dto.SuperContentStatisticsFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /super/v1/tenants/:tenantID<int>/contents -> contents.ListTenantContents")
|
||||
router.Get("/super/v1/tenants/:tenantID<int>/contents"[len(r.Path()):], DataFunc2(
|
||||
r.contents.ListTenantContents,
|
||||
|
||||
Reference in New Issue
Block a user