feat: P1 合盘/星座/问答与测测完整设计包及模拟器取证工具
落地 synastry/star/ask API 与 H5 页面,补齐 cece-frontend-re complete-design 证据文档,并加入 Android 模拟器截图抓取脚本。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3,6 +3,7 @@ package profile
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -22,6 +23,8 @@ type CreateInput struct {
|
||||
DisplayName string
|
||||
BirthDate time.Time
|
||||
RelationType *string
|
||||
BirthTime *string
|
||||
BirthPlace *string
|
||||
}
|
||||
|
||||
// Create stores a profile for the user.
|
||||
@@ -40,10 +43,59 @@ func (s *Service) Create(ctx context.Context, userID uuid.UUID, in CreateInput)
|
||||
name = "TA"
|
||||
}
|
||||
}
|
||||
return s.Repo.Create(ctx, userID, in.Relation, name, in.BirthDate, in.RelationType)
|
||||
return s.Repo.Create(ctx, userID, in.Relation, name, in.BirthDate, in.RelationType, in.BirthTime, in.BirthPlace)
|
||||
}
|
||||
|
||||
// List returns user's profiles.
|
||||
func (s *Service) List(ctx context.Context, userID uuid.UUID) ([]model.Profile, error) {
|
||||
return s.Repo.ListByUser(ctx, userID)
|
||||
}
|
||||
|
||||
// UpdateInput for PATCH /profiles/:id.
|
||||
type UpdateInput struct {
|
||||
DisplayName string
|
||||
BirthDate time.Time
|
||||
RelationType *string
|
||||
BirthTime *string
|
||||
BirthPlace *string
|
||||
GeoLat *float64
|
||||
GeoLng *float64
|
||||
GeoVisible *bool
|
||||
}
|
||||
|
||||
// Update patches an owned profile.
|
||||
func (s *Service) Update(ctx context.Context, userID, profileID uuid.UUID, in UpdateInput) (*model.Profile, error) {
|
||||
cur, err := s.Repo.GetForUser(ctx, userID, profileID)
|
||||
if err != nil {
|
||||
return nil, errors.New("profile not found")
|
||||
}
|
||||
name := strings.TrimSpace(in.DisplayName)
|
||||
if name == "" {
|
||||
name = cur.DisplayName
|
||||
}
|
||||
birth := in.BirthDate
|
||||
if birth.IsZero() {
|
||||
birth = cur.BirthDate
|
||||
}
|
||||
rt := in.RelationType
|
||||
if rt == nil {
|
||||
rt = cur.RelationType
|
||||
}
|
||||
bt := in.BirthTime
|
||||
if bt == nil {
|
||||
bt = cur.BirthTime
|
||||
}
|
||||
bp := in.BirthPlace
|
||||
if bp == nil {
|
||||
bp = cur.BirthPlace
|
||||
}
|
||||
return s.Repo.UpdateForUser(ctx, userID, profileID, name, birth, rt, bt, bp, in.GeoLat, in.GeoLng, in.GeoVisible)
|
||||
}
|
||||
|
||||
// Delete soft-deletes an owned profile.
|
||||
func (s *Service) Delete(ctx context.Context, userID, profileID uuid.UUID) error {
|
||||
if _, err := s.Repo.GetForUser(ctx, userID, profileID); err != nil {
|
||||
return errors.New("profile not found")
|
||||
}
|
||||
return s.Repo.SoftDeleteForUser(ctx, userID, profileID)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user