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:
@@ -0,0 +1,28 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"github.com/yuxingu/digital-psychology/apps/api/internal/model"
|
||||
)
|
||||
|
||||
// RelationRepo persists relation insights.
|
||||
type RelationRepo struct {
|
||||
Pool *pgxpool.Pool
|
||||
}
|
||||
|
||||
// Create inserts a relation insight row.
|
||||
func (r *RelationRepo) Create(ctx context.Context, userID, aID, bID uuid.UUID, summary json.RawMessage, reportID uuid.UUID) (*model.RelationInsight, error) {
|
||||
row := &model.RelationInsight{}
|
||||
err := r.Pool.QueryRow(ctx, `
|
||||
INSERT INTO relation_insights(user_id, profile_a_id, profile_b_id, summary, report_id)
|
||||
VALUES ($1,$2,$3,$4,$5)
|
||||
RETURNING id, user_id, profile_a_id, profile_b_id, summary, report_id, created_at`,
|
||||
userID, aID, bID, summary, reportID,
|
||||
).Scan(&row.ID, &row.UserID, &row.ProfileAID, &row.ProfileBID, &row.Summary, &row.ReportID, &row.CreatedAt)
|
||||
return row, err
|
||||
}
|
||||
Reference in New Issue
Block a user