Initial commit: dating app backend (Go/Gin/GORM/Postgres)

Phone+OTP auth, staged onboarding, admin approval workflow, and a
full discovery/swipe/match/chat system with photo upload and
approximate distance (haversine) based on user location.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 23:23:47 +03:30
commit 2823fb45f5
49 changed files with 4582 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package repository
import (
"errors"
"gorm.io/gorm"
"dating-app/internal/models"
)
type SwipeRepository struct {
db *gorm.DB
}
func NewSwipeRepository(db *gorm.DB) *SwipeRepository {
return &SwipeRepository{db: db}
}
func (r *SwipeRepository) Create(swipe *models.Swipe) error {
return r.db.Create(swipe).Error
}
// HasLiked یعنی swiperID قبلاً swipedID رو لایک/سوپرلایک کرده
func (r *SwipeRepository) HasLiked(swiperID, swipedID uint) (bool, error) {
var swipe models.Swipe
err := r.db.
Where("swiper_id = ? AND swiped_id = ? AND action IN ?", swiperID, swipedID, []models.SwipeAction{models.SwipeLike, models.SwipeSuperlike}).
First(&swipe).Error
if errors.Is(err, gorm.ErrRecordNotFound) {
return false, nil
}
if err != nil {
return false, err
}
return true, nil
}
func (r *SwipeRepository) Exists(swiperID, swipedID uint) (bool, error) {
var count int64
err := r.db.Model(&models.Swipe{}).Where("swiper_id = ? AND swiped_id = ?", swiperID, swipedID).Count(&count).Error
return count > 0, err
}