feat(ECR-011): 昵称、首页贴士与档案 Self 唯一/合盘交叉校验
ci / h5 (push) Canceled after 0s
ci / api (push) Canceled after 0s
ci / ess-docs (push) Canceled after 0s

每账号仅一条 self(migration 40902);合盘只选 TA;账号昵称可改;首页穿衣/颜色/养生贴士。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-12 22:05:00 +08:00
co-authored by Cursor
parent 5ceb3ce749
commit 13860bf1ef
67 changed files with 1936 additions and 275 deletions
@@ -97,6 +97,14 @@ func (r *AuthRepo) CreateUserWithPhone(ctx context.Context, phone, hash, nicknam
return id, err
}
// UpdateNickname sets users.nickname (non-empty).
func (r *AuthRepo) UpdateNickname(ctx context.Context, userID uuid.UUID, nickname string) error {
_, err := r.Pool.Exec(ctx, `
UPDATE users SET nickname=$2, updated_at=now()
WHERE id=$1 AND deleted_at IS NULL`, userID, nickname)
return err
}
// TouchPassword updates stored password hash (open-login record).
func (r *AuthRepo) TouchPassword(ctx context.Context, userID uuid.UUID, hash string) error {
_, err := r.Pool.Exec(ctx, `
@@ -34,6 +34,15 @@ func scanProfile(scan func(dest ...any) error) (*model.Profile, error) {
return p, nil
}
// CountActiveSelf returns non-deleted self profiles for the user.
func (r *ProfileRepo) CountActiveSelf(ctx context.Context, userID uuid.UUID) (int, error) {
var n int
err := r.Pool.QueryRow(ctx, `
SELECT COUNT(*) FROM profiles
WHERE user_id=$1 AND relation='self' AND deleted_at IS NULL`, userID).Scan(&n)
return n, err
}
// Create inserts a profile.
func (r *ProfileRepo) Create(ctx context.Context, userID uuid.UUID, relation, name string, birth time.Time, relationType *string, birthTime *string, birthPlace *string) (*model.Profile, error) {
row := r.Pool.QueryRow(ctx, `