feat: add RelationInsight API and wire H5 relation/profile pages

Second P1 growth engine: compare two profiles, gate full tips behind
deep-access mock payment, and list personal archives on /profile.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-02 16:28:10 +08:00
co-authored by Cursor
parent 0f320e040b
commit 14b836f53b
12 changed files with 465 additions and 14 deletions
+10 -6
View File
@@ -16,6 +16,7 @@ import (
"github.com/yuxingu/digital-psychology/apps/api/internal/middleware"
"github.com/yuxingu/digital-psychology/apps/api/internal/repository"
"github.com/yuxingu/digital-psychology/apps/api/internal/service/profile"
"github.com/yuxingu/digital-psychology/apps/api/internal/service/relation"
"github.com/yuxingu/digital-psychology/apps/api/internal/service/report"
"github.com/yuxingu/digital-psychology/apps/api/pkg/response"
)
@@ -32,7 +33,7 @@ func main() {
pool, err := db.Connect(ctx, cfg.DatabaseURL)
if err != nil {
log.Printf("database unavailable: %v", err)
log.Printf("hint: docker compose -f deploy/docker-compose.yml up -d")
log.Printf("hint: npm run deps:up (docker-compose.dev.yml)")
os.Exit(1)
}
defer pool.Close()
@@ -46,11 +47,13 @@ func main() {
os.Exit(1)
}
profileSvc := &profile.Service{Repo: &repository.ProfileRepo{Pool: pool}}
reportSvc := &report.Service{
Profiles: &repository.ProfileRepo{Pool: pool},
Reports: &repository.ReportRepo{Pool: pool},
}
profileRepo := &repository.ProfileRepo{Pool: pool}
reportRepo := &repository.ReportRepo{Pool: pool}
relationRepo := &repository.RelationRepo{Pool: pool}
profileSvc := &profile.Service{Repo: profileRepo}
reportSvc := &report.Service{Profiles: profileRepo, Reports: reportRepo}
relationSvc := &relation.Service{Profiles: profileRepo, Reports: reportRepo, Relations: relationRepo}
r := gin.New()
r.Use(gin.Recovery(), gin.Logger(), middleware.RequestID())
@@ -69,6 +72,7 @@ func main() {
authed.Use(middleware.DeviceAuth(pool))
(&handler.ProfileHandler{Svc: profileSvc}).Register(authed)
(&handler.ReportHandler{Svc: reportSvc}).Register(authed)
(&handler.RelationHandler{Svc: relationSvc}).Register(authed)
log.Printf("yuxingu api listening on %s env=%s", cfg.HTTPAddr, cfg.AppEnv)
if err := r.Run(cfg.HTTPAddr); err != nil {