feat(ECR-011): 昵称、首页贴士与档案 Self 唯一/合盘交叉校验
每账号仅一条 self(migration 40902);合盘只选 TA;账号昵称可改;首页穿衣/颜色/养生贴士。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -30,6 +30,9 @@ type CreateInput struct {
|
||||
BirthPlace *string
|
||||
}
|
||||
|
||||
// ErrSelfExists is returned when creating a second self profile.
|
||||
var ErrSelfExists = errors.New("self profile already exists")
|
||||
|
||||
// Create stores a profile for the user.
|
||||
func (s *Service) Create(ctx context.Context, userID uuid.UUID, in CreateInput) (*model.Profile, error) {
|
||||
if in.Relation != "self" && in.Relation != "other" {
|
||||
@@ -38,6 +41,15 @@ func (s *Service) Create(ctx context.Context, userID uuid.UUID, in CreateInput)
|
||||
if in.BirthDate.IsZero() {
|
||||
return nil, errors.New("birth_date required")
|
||||
}
|
||||
if in.Relation == "self" {
|
||||
n, err := s.Repo.CountActiveSelf(ctx, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if n > 0 {
|
||||
return nil, ErrSelfExists
|
||||
}
|
||||
}
|
||||
name := in.DisplayName
|
||||
if name == "" {
|
||||
if in.Relation == "self" {
|
||||
|
||||
Reference in New Issue
Block a user