feat: 部署初版测试
Some checks failed
Extension Build & Release / build (push) Failing after 1m5s
Backend Deploy (Go + Docker) / deploy (push) Failing after 1m40s
Web Console Deploy (Vue 3 + Vite) / deploy (push) Has been cancelled

This commit is contained in:
zs
2026-03-02 21:25:21 +08:00
parent db3abb3174
commit 8cf6cb944b
97 changed files with 10250 additions and 209 deletions

View File

@@ -0,0 +1,48 @@
package handler
import (
"encoding/json"
"net/http"
"github.com/zs/InsightReply/internal/repository"
)
type TweetHandler struct {
repo *repository.TweetRepository
}
func NewTweetHandler(repo *repository.TweetRepository) *TweetHandler {
return &TweetHandler{repo: repo}
}
// GetHotTweets returns the top heating tweets spanning across all tracking targets
func (h *TweetHandler) GetHotTweets(w http.ResponseWriter, r *http.Request) {
// Standardize to take the top 50 hottest tweets that haven't been manually marked as processed
tweets, err := h.repo.GetTopHeatingTweets(50)
if err != nil {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusInternalServerError)
json.NewEncoder(w).Encode(map[string]interface{}{"error": "failed to retrieve hot tweets"})
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(tweets)
}
// SearchTweets provides the multi-rule filtering API for Epic 5
func (h *TweetHandler) GetSearchTweets(w http.ResponseWriter, r *http.Request) {
keyword := r.URL.Query().Get("keyword")
handle := r.URL.Query().Get("handle")
tweets, err := h.repo.SearchTweets(keyword, handle, 50)
if err != nil {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusInternalServerError)
json.NewEncoder(w).Encode(map[string]interface{}{"error": "failed to search tweets"})
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(tweets)
}