39f3774940
统一 sources/templates/channels/rules 列表为分页响应,避免配置增多时全量返回;按钉钉 access_token 限制每分钟发送并在超限时等待下一分钟,降低触发官方封禁风险。 Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
774 B
Go
39 lines
774 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"aiaa-notification-service/internal/store"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type MessageLogHandler struct {
|
|
store *store.Store
|
|
}
|
|
|
|
func NewMessageLogHandler(s *store.Store) *MessageLogHandler {
|
|
return &MessageLogHandler{store: s}
|
|
}
|
|
|
|
func (h *MessageLogHandler) List(c *gin.Context) {
|
|
var filter store.MessageLogFilter
|
|
if err := c.ShouldBindQuery(&filter); err != nil {
|
|
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
filter.Normalize()
|
|
|
|
logs, total, err := h.store.ListMessageLogs(c.Request.Context(), filter)
|
|
if err != nil {
|
|
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
|
return
|
|
}
|
|
|
|
c.JSON(http.StatusOK, gin.H{
|
|
"data": logs,
|
|
"total": total,
|
|
"page": filter.Page,
|
|
})
|
|
}
|