feat: add send_stats table
This commit is contained in:
@@ -41,6 +41,14 @@ func GetStatisticData(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
appG.CResponse(http.StatusOK, "获取渠道统计成功", data)
|
||||
case "send_stats":
|
||||
// 新增:基于 send_stats 表的统计数据
|
||||
data, err := msgService.GetSendStatsData()
|
||||
if err != nil {
|
||||
appG.CResponse(http.StatusInternalServerError, fmt.Sprintf("获取发送统计失败!原因:%s", err), nil)
|
||||
return
|
||||
}
|
||||
appG.CResponse(http.StatusOK, "获取发送统计成功", data)
|
||||
default:
|
||||
// 默认返回完整统计数据(保持向后兼容)
|
||||
data, err := msgService.GetStatisticData()
|
||||
@@ -52,3 +60,28 @@ func GetStatisticData(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetSendStatsByTask 获取指定任务的发送统计数据
|
||||
func GetSendStatsByTask(c *gin.Context) {
|
||||
var (
|
||||
appG = app.Gin{C: c}
|
||||
)
|
||||
|
||||
taskID := c.Query("task_id")
|
||||
if taskID == "" {
|
||||
appG.CResponse(http.StatusBadRequest, "任务ID不能为空", nil)
|
||||
return
|
||||
}
|
||||
|
||||
msgService := statistic_service.StatisticService{
|
||||
TaskID: taskID,
|
||||
}
|
||||
|
||||
data, err := msgService.GetSendStatsByTask()
|
||||
if err != nil {
|
||||
appG.CResponse(http.StatusInternalServerError, fmt.Sprintf("获取任务统计失败!原因:%s", err), nil)
|
||||
return
|
||||
}
|
||||
|
||||
appG.CResponse(http.StatusOK, "获取任务统计成功", data)
|
||||
}
|
||||
|
||||
|
||||
@@ -88,6 +88,7 @@ func InitRouter(f embed.FS) *gin.Engine {
|
||||
|
||||
// statistic
|
||||
apiV1.GET("/statistic", v1.GetStatisticData)
|
||||
apiV1.GET("/statistic/task", v1.GetSendStatsByTask)
|
||||
|
||||
// cronMessage
|
||||
apiV1.POST("/cronmessages/addone", v1.AddCronMsgTask)
|
||||
|
||||
Reference in New Issue
Block a user