template-monorepo/internal/model/member/repository/profile_memory.go

45 lines
1.1 KiB
Go

package repository
import (
"context"
"sync"
domrepo "gateway/internal/model/member/domain/repository"
)
// MemoryProfileRepository is an in-memory ProfileRepository for tests and local dev until P4 Mongo entity exists.
type MemoryProfileRepository struct {
mu sync.RWMutex
emails map[string]string // tenant:uid -> email
phones map[string]string
}
func NewMemoryProfileRepository() *MemoryProfileRepository {
return &MemoryProfileRepository{
emails: make(map[string]string),
phones: make(map[string]string),
}
}
func profileKey(tenantID, uid string) string {
return tenantID + ":" + uid
}
func (r *MemoryProfileRepository) SetBusinessEmailVerified(ctx context.Context, tenantID, uid, email string) error {
_ = ctx
r.mu.Lock()
defer r.mu.Unlock()
r.emails[profileKey(tenantID, uid)] = email
return nil
}
func (r *MemoryProfileRepository) SetBusinessPhoneVerified(ctx context.Context, tenantID, uid, phone string) error {
_ = ctx
r.mu.Lock()
defer r.mu.Unlock()
r.phones[profileKey(tenantID, uid)] = phone
return nil
}
var _ domrepo.ProfileRepository = (*MemoryProfileRepository)(nil)