feat(server): 装配 notices(路由替换空壳+reward/pay 注入)+ 发版联动插 version 公告

main.go 挂载 notices.Store/Handler:注入 rewardSvc/payWebhook 到账通知钩子,
/v1/notices 路由由 accountAPI 空壳换成真实 List/MarkRead,删除 account.go
的 TODO 空壳方法。补齐 pangolin-nodectl 到编译/部署产物链
(compile-backend.sh + deploy-server.sh),release-client.sh 在
version.yaml 推送成功后追加一步用 nodectl 插入 version 类型站内公告
(失败不阻断发版)。
This commit is contained in:
wangjia
2026-07-13 14:09:54 +08:00
parent 78fd600522
commit 2b4350cfc4
5 changed files with 33 additions and 19 deletions
+9 -1
View File
@@ -33,6 +33,7 @@ import (
"github.com/wangjia/pangolin/server/internal/httpapi"
"github.com/wangjia/pangolin/server/internal/mtls"
"github.com/wangjia/pangolin/server/internal/nodes"
"github.com/wangjia/pangolin/server/internal/notices"
"github.com/wangjia/pangolin/server/internal/pay"
agentv1 "github.com/wangjia/pangolin/server/internal/pb/agentv1"
"github.com/wangjia/pangolin/server/internal/provision"
@@ -350,6 +351,11 @@ func mountV1(r chi.Router, sqlDB *sql.DB, rdb *redis.Client, nodeSvc *nodes.Serv
authSvc.SetReferralHook(rewardSvc)
}
// ── Notices(站内通知;reward/pay 到账钩子注入)────────────────────────────
noticesStore := notices.NewStore(sqlDB)
noticesHandler := notices.NewHandler(noticesStore)
rewardSvc.SetNoticer(noticesStore)
// ── Pay(pay v2 统一支付网关;PAY_BASE_URL 未配则整组不挂载)──────────────
var payHandler *pay.Handler
var payWebhook *pay.WebhookHandler
@@ -365,6 +371,7 @@ func mountV1(r chi.Router, sqlDB *sql.DB, rdb *redis.Client, nodeSvc *nodes.Serv
payWebhook = pay.NewWebhookHandler(payStore, codesSvc, sqlDB, rdb,
paySystem, paySecret, 5*time.Minute, 15*time.Minute)
payWebhook.SetRewarder(rewardSvc)
payWebhook.SetNoticer(noticesStore)
} else {
log.Printf("PAY_BASE_URL 未配置 — /v1/pay 支付端点不挂载")
}
@@ -482,7 +489,8 @@ func mountV1(r chi.Router, sqlDB *sql.DB, rdb *redis.Client, nodeSvc *nodes.Serv
protected.Get("/usage/devices", deviceUsageHandler.ServeHTTP)
protected.Post("/ads/unlock", adsHandler.ServeHTTP)
protected.Get("/plans", accountAPI.ListPlans)
protected.Get("/notices", accountAPI.ListNotices)
protected.Get("/notices", noticesHandler.List)
protected.Post("/notices/read", noticesHandler.MarkRead)
if payHandler != nil {
protected.Get("/pay/catalog", payHandler.Catalog)
protected.Get("/pay/orders", payHandler.List)
-9
View File
@@ -214,12 +214,3 @@ func (a *AccountAPI) ListPlans(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
_ = json.NewEncoder(w).Encode(map[string]any{"plans": plans})
}
// ─── GET /v1/notices ─────────────────────────────────────────────────────────
// ListNotices handles GET /v1/notices. Returns an empty list for the MVP.
// TODO(Task7): 由 notices.Handler 替换后删除(main.go 路由挂载在 Task 7 统一装配)。
func (a *AccountAPI) ListNotices(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
_ = json.NewEncoder(w).Encode(map[string]any{"notices": []any{}})
}