feat(ops): ECR-007 行为分析与 ECR-008 内容运营后台
落地埋点 ingest/数据看板、首页宫格 CMS 与测评上下架;含账号引导、问答流式与免责声明去重,以及 review P1 审计同事务修复。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -14,8 +14,12 @@ import (
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/middleware"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/repository"
|
||||
adminsvc "github.com/yuxingu/digital-psychology/apps/api/internal/service/admin"
|
||||
analyticssvc "github.com/yuxingu/digital-psychology/apps/api/internal/service/analytics"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/service/ask"
|
||||
authsvc "github.com/yuxingu/digital-psychology/apps/api/internal/service/auth"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/service/bootstrap"
|
||||
companionsvc "github.com/yuxingu/digital-psychology/apps/api/internal/service/companion"
|
||||
homesvc "github.com/yuxingu/digital-psychology/apps/api/internal/service/home"
|
||||
imagecardsvc "github.com/yuxingu/digital-psychology/apps/api/internal/service/imagecard"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/service/membership"
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/service/profile"
|
||||
@@ -32,13 +36,16 @@ func NewRouter(pool *pgxpool.Pool, cfg config.Config) *gin.Engine {
|
||||
relationRepo := &repository.RelationRepo{Pool: pool}
|
||||
askRepo := &repository.AskRepo{Pool: pool}
|
||||
adminRepo := &repository.AdminRepo{Pool: pool}
|
||||
analyticsRepo := &repository.AnalyticsRepo{Pool: pool}
|
||||
authRepo := &repository.AuthRepo{Pool: pool}
|
||||
|
||||
var llm *deepseek.Client
|
||||
if cfg.DeepSeek.Enabled() {
|
||||
llm = deepseek.New(cfg.DeepSeek)
|
||||
}
|
||||
|
||||
profileSvc := &profile.Service{Repo: profileRepo}
|
||||
bootSvc := &bootstrap.Service{Profiles: profileRepo, Reports: reportRepo, Relations: relationRepo}
|
||||
profileSvc := &profile.Service{Repo: profileRepo, Reports: reportRepo, Bootstrap: bootSvc}
|
||||
reportSvc := &report.Service{
|
||||
Profiles: profileRepo,
|
||||
Reports: reportRepo,
|
||||
@@ -46,7 +53,8 @@ func NewRouter(pool *pgxpool.Pool, cfg config.Config) *gin.Engine {
|
||||
}
|
||||
membershipSvc := &membership.Service{Reports: reportRepo}
|
||||
relationSvc := &relation.Service{Profiles: profileRepo, Reports: reportRepo, Relations: relationRepo}
|
||||
scaleSvc := &scale.Service{Repo: &repository.ScaleRepo{Pool: pool}, Profiles: profileRepo}
|
||||
scaleRepo := &repository.ScaleRepo{Pool: pool}
|
||||
scaleSvc := &scale.Service{Repo: scaleRepo, Profiles: profileRepo}
|
||||
askSvc := &ask.Service{Profiles: profileRepo, Reports: reportRepo, Ask: askRepo, LLM: llm}
|
||||
companionSvc := &companionsvc.Service{Moods: &repository.MoodRepo{Pool: pool}}
|
||||
imageCardSvc := &imagecardsvc.Service{
|
||||
@@ -54,7 +62,12 @@ func NewRouter(pool *pgxpool.Pool, cfg config.Config) *gin.Engine {
|
||||
Reports: reportRepo,
|
||||
Quotas: &repository.ImageCardRepo{Pool: pool},
|
||||
}
|
||||
adminSvc := &adminsvc.Service{Repo: adminRepo, Reports: reportRepo}
|
||||
homeSvc := &homesvc.Service{Repo: &repository.HomeToolsRepo{Pool: pool}}
|
||||
analyticsSvc := &analyticssvc.Service{Repo: analyticsRepo}
|
||||
adminSvc := &adminsvc.Service{
|
||||
Repo: adminRepo, Reports: reportRepo, Home: homeSvc, Scales: scaleRepo,
|
||||
}
|
||||
authSvc := &authsvc.Service{Repo: authRepo}
|
||||
if err := adminSvc.EnsureBootstrap(context.Background(), adminsvc.BootstrapConfig{
|
||||
Username: cfg.Admin.BootstrapUsername,
|
||||
Password: cfg.Admin.BootstrapPassword,
|
||||
@@ -74,22 +87,28 @@ func NewRouter(pool *pgxpool.Pool, cfg config.Config) *gin.Engine {
|
||||
api.GET("/ping", func(c *gin.Context) {
|
||||
response.OK(c, gin.H{"pong": true})
|
||||
})
|
||||
(&handler.AdminHandler{Svc: adminSvc}).Register(api)
|
||||
(&handler.AdminHandler{Svc: adminSvc, Analytics: analyticsSvc}).Register(api)
|
||||
|
||||
authed := api.Group("")
|
||||
authed.Use(middleware.DeviceAuth(pool))
|
||||
(&handler.ProfileHandler{Svc: profileSvc}).Register(authed)
|
||||
(&handler.ReportHandler{Svc: reportSvc, Membership: membershipSvc}).Register(authed)
|
||||
(&handler.SynastryHandler{Svc: reportSvc}).Register(authed)
|
||||
(&handler.RelationHandler{Svc: relationSvc}).Register(authed)
|
||||
(&handler.ScaleHandler{Svc: scaleSvc}).Register(authed)
|
||||
(&handler.AskHandler{Svc: askSvc}).Register(authed)
|
||||
(&handler.CompanionHandler{Svc: companionSvc}).Register(authed)
|
||||
(&handler.ImageCardHandler{Svc: imageCardSvc}).Register(authed)
|
||||
(&handler.ExploreHandler{}).Register(authed)
|
||||
(&handler.AuthHandler{Svc: authSvc}).Register(authed)
|
||||
(&handler.AnalyticsHandler{Svc: analyticsSvc}).Register(authed)
|
||||
(&handler.HomeHandler{Svc: homeSvc}).Register(authed)
|
||||
|
||||
gated := authed.Group("")
|
||||
gated.Use(middleware.RequireRegistered(pool))
|
||||
(&handler.ProfileHandler{Svc: profileSvc}).Register(gated)
|
||||
(&handler.ReportHandler{Svc: reportSvc, Membership: membershipSvc}).Register(gated)
|
||||
(&handler.SynastryHandler{Svc: reportSvc}).Register(gated)
|
||||
(&handler.RelationHandler{Svc: relationSvc}).Register(gated)
|
||||
(&handler.ScaleHandler{Svc: scaleSvc}).Register(gated)
|
||||
(&handler.AskHandler{Svc: askSvc}).Register(gated)
|
||||
(&handler.CompanionHandler{Svc: companionSvc}).Register(gated)
|
||||
(&handler.ImageCardHandler{Svc: imageCardSvc}).Register(gated)
|
||||
(&handler.ExploreHandler{}).Register(gated)
|
||||
(&handler.GrowthHandler{
|
||||
Plans: &repository.GrowthRepo{Pool: pool},
|
||||
}).Register(authed)
|
||||
}).Register(gated)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user