add hotapi
This commit is contained in:
@@ -51,7 +51,7 @@ var (
|
||||
ErrSuccess = &JiguangError{Code: 0, Message: "请求成功"}
|
||||
|
||||
// 参数错误
|
||||
ErrParamInvalid = &JiguangError{Code: 400, Message: "请求参数不正确"}
|
||||
ErrParamInvalid = &JiguangError{Code: 400, Message: "请求参数不正确,QCXGGB2Q查询为空"}
|
||||
ErrMethodInvalid = &JiguangError{Code: 405, Message: "请求方法不正确"}
|
||||
ErrParamFormInvalid = &JiguangError{Code: 906, Message: "请求参数形式不正确"}
|
||||
ErrBodyIncomplete = &JiguangError{Code: 914, Message: "Body 请求参数不完整"}
|
||||
|
||||
@@ -11,6 +11,12 @@ import (
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// ApiPopularityRankingItem API受欢迎榜单项
|
||||
type ApiPopularityRankingItem struct {
|
||||
Name string `json:"name" comment:"产品名称"`
|
||||
Code string `json:"code" comment:"产品编码"`
|
||||
}
|
||||
|
||||
// StatisticsHandler 统计处理器
|
||||
type StatisticsHandler struct {
|
||||
statisticsAppService statistics.StatisticsApplicationService
|
||||
@@ -1499,4 +1505,49 @@ func (h *StatisticsHandler) AdminGetTodayCertifiedEnterprises(c *gin.Context) {
|
||||
}
|
||||
|
||||
h.responseBuilder.Success(c, result.Data, "获取今日认证企业列表成功")
|
||||
}
|
||||
|
||||
// GetPublicApiPopularityRanking 获取API受欢迎程度排行榜(公开接口)
|
||||
// @Summary 获取API受欢迎程度排行榜
|
||||
// @Description 获取API受欢迎程度排行榜,仅返回产品名称和编码,默认统计日度数据
|
||||
// @Tags 统计公开接口
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param period query string false "时间周期" Enums(today,month,total) default(today)
|
||||
// @Param limit query int false "返回数量" default(10)
|
||||
// @Success 200 {object} interfaces.APIResponse{data=[]ApiPopularityRankingItem} "获取成功"
|
||||
// @Failure 400 {object} interfaces.APIResponse "请求参数错误"
|
||||
// @Failure 500 {object} interfaces.APIResponse "服务器内部错误"
|
||||
// @Router /api/v1/statistics/api-popularity-ranking [get]
|
||||
func (h *StatisticsHandler) GetPublicApiPopularityRanking(c *gin.Context) {
|
||||
period := c.DefaultQuery("period", "today") // 默认日度
|
||||
limit := h.getIntQuery(c, "limit", 10) // 默认10条
|
||||
|
||||
// 调用应用服务获取API受欢迎程度排行榜
|
||||
result, err := h.statisticsAppService.AdminGetApiPopularityRanking(c.Request.Context(), period, limit)
|
||||
if err != nil {
|
||||
h.logger.Error("获取API受欢迎程度排行榜失败", zap.Error(err))
|
||||
h.responseBuilder.InternalError(c, "获取API受欢迎程度排行榜失败")
|
||||
return
|
||||
}
|
||||
|
||||
// 转换数据,只保留产品名称和编码
|
||||
if rankings, ok := result.Data.([]interface{}); ok {
|
||||
var publicRankings []ApiPopularityRankingItem
|
||||
for _, ranking := range rankings {
|
||||
if rankingMap, ok := ranking.(map[string]interface{}); ok {
|
||||
if product, productOk := rankingMap["product"].(map[string]interface{}); productOk {
|
||||
item := ApiPopularityRankingItem{
|
||||
Name: product["name"].(string),
|
||||
Code: product["code"].(string),
|
||||
}
|
||||
publicRankings = append(publicRankings, item)
|
||||
}
|
||||
}
|
||||
}
|
||||
h.responseBuilder.Success(c, publicRankings, "获取API受欢迎程度排行榜成功")
|
||||
return
|
||||
}
|
||||
|
||||
h.responseBuilder.Success(c, []ApiPopularityRankingItem{}, "获取API受欢迎程度排行榜成功")
|
||||
}
|
||||
@@ -77,12 +77,12 @@ func (r *ArticleRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
adminArticleGroup.DELETE("/:id", r.handler.DeleteArticle) // 删除文章
|
||||
|
||||
// 文章状态管理
|
||||
adminArticleGroup.POST("/:id/publish", r.handler.PublishArticle) // 发布文章
|
||||
adminArticleGroup.POST("/:id/schedule-publish", r.handler.SchedulePublishArticle) // 定时发布文章
|
||||
adminArticleGroup.POST("/:id/publish", r.handler.PublishArticle) // 发布文章
|
||||
adminArticleGroup.POST("/:id/schedule-publish", r.handler.SchedulePublishArticle) // 定时发布文章
|
||||
adminArticleGroup.POST("/:id/update-schedule-publish", r.handler.UpdateSchedulePublishArticle) // 修改定时发布时间
|
||||
adminArticleGroup.POST("/:id/cancel-schedule", r.handler.CancelSchedulePublishArticle) // 取消定时发布
|
||||
adminArticleGroup.POST("/:id/archive", r.handler.ArchiveArticle) // 归档文章
|
||||
adminArticleGroup.PUT("/:id/featured", r.handler.SetFeatured) // 设置推荐状态
|
||||
adminArticleGroup.POST("/:id/cancel-schedule", r.handler.CancelSchedulePublishArticle) // 取消定时发布
|
||||
adminArticleGroup.POST("/:id/archive", r.handler.ArchiveArticle) // 归档文章
|
||||
adminArticleGroup.PUT("/:id/featured", r.handler.SetFeatured) // 设置推荐状态
|
||||
}
|
||||
|
||||
// 管理员分类管理路由
|
||||
|
||||
@@ -45,6 +45,9 @@ func (r *StatisticsRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
{
|
||||
// 获取公开统计信息
|
||||
statistics.GET("/public", r.statisticsHandler.GetPublicStatistics)
|
||||
|
||||
// 获取API受欢迎榜单(公开接口)
|
||||
statistics.GET("/api-popularity-ranking", r.statisticsHandler.GetPublicApiPopularityRanking)
|
||||
}
|
||||
|
||||
// 用户统计接口 - 需要认证
|
||||
@@ -57,7 +60,7 @@ func (r *StatisticsRoutes) Register(router *sharedhttp.GinRouter) {
|
||||
userStats.GET("/api-calls", r.statisticsHandler.GetApiCallsStatistics)
|
||||
userStats.GET("/consumption", r.statisticsHandler.GetConsumptionStatistics)
|
||||
userStats.GET("/recharge", r.statisticsHandler.GetRechargeStatistics)
|
||||
|
||||
|
||||
// 获取最新产品推荐
|
||||
userStats.GET("/latest-products", r.statisticsHandler.GetLatestProducts)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user