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
+39
View File
@@ -0,0 +1,39 @@
package dto
// CreateOptionRequest ساخت یک گزینه‌ی جدید در یک دسته
type CreateOptionRequest struct {
Title string `json:"title" binding:"required,min=1,max=150"`
SortOrder int `json:"sort_order"`
}
// UpdateOptionRequest ویرایش یک گزینه
type UpdateOptionRequest struct {
Title *string `json:"title"`
SortOrder *int `json:"sort_order"`
IsActive *bool `json:"is_active"`
}
// UpdateCategoryRequest ویرایش تنظیمات یک دسته (مثلاً تغییر حداقل/حداکثر انتخاب)
type UpdateCategoryRequest struct {
Title *string `json:"title"`
MinSelect *int `json:"min_select"`
MaxSelect *int `json:"max_select"`
}
// CreateProfileQuestionRequest ساخت سوال جدید پروفایل
type CreateProfileQuestionRequest struct {
Text string `json:"text" binding:"required,min=3,max=255"`
SortOrder int `json:"sort_order"`
}
// UpdateProfileQuestionRequest ویرایش سوال پروفایل
type UpdateProfileQuestionRequest struct {
Text *string `json:"text"`
SortOrder *int `json:"sort_order"`
IsActive *bool `json:"is_active"`
}
// RejectUserRequest رد کردن درخواست عضویت یک کاربر توسط ادمین (دلیل الزامی است)
type RejectUserRequest struct {
Reason string `json:"reason" binding:"required,min=3,max=500"`
}
+47
View File
@@ -0,0 +1,47 @@
package dto
// RequestOTPRequest بدنه‌ی درخواست ارسال کد تایید
type RequestOTPRequest struct {
Phone string `json:"phone" binding:"required"`
}
// VerifyOTPRequest بدنه‌ی درخواست تایید کد
type VerifyOTPRequest struct {
Phone string `json:"phone" binding:"required"`
OTP string `json:"otp" binding:"required"`
}
// RefreshTokenRequest بدنه‌ی درخواست رفرش توکن
type RefreshTokenRequest struct {
RefreshToken string `json:"refresh_token" binding:"required"`
}
// TokenPair جفت توکن access/refresh
type TokenPair struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}
// AuthResponse پاسخ استاندارد بعد از ورود موفق
type AuthResponse struct {
Tokens TokenPair `json:"tokens"`
User UserProfile `json:"user"`
IsNewUser bool `json:"is_new_user"`
OnboardingDone bool `json:"onboarding_done"`
}
// UserProfile نمایش خلاصه‌ی پروفایل کاربر (بدون داده‌های حساس)
type UserProfile struct {
ID uint `json:"id"`
Phone string `json:"phone"`
FirstName string `json:"first_name,omitempty"`
Gender *string `json:"gender,omitempty"`
BirthDate *string `json:"birth_date,omitempty"`
HeightCM *int `json:"height_cm,omitempty"`
WeightKG *int `json:"weight_kg,omitempty"`
CurrentStep int `json:"current_step"`
IsOnboarded bool `json:"is_onboarded"`
ApprovalStatus string `json:"approval_status"`
RejectionReason *string `json:"rejection_reason,omitempty"`
IsAdmin bool `json:"is_admin"`
}
+72
View File
@@ -0,0 +1,72 @@
package dto
// DiscoverCandidate یک پروفایل پیشنهادی توی صفحه‌ی دوستیابی
type DiscoverCandidate struct {
ID uint `json:"id"`
FirstName string `json:"first_name"`
Age int `json:"age"`
Photos []string `json:"photos"`
DistanceKM *float64 `json:"distance_km,omitempty"`
Interests []string `json:"interests,omitempty"`
}
// SwipeRequest بدنه‌ی درخواست ثبت لایک/ردّ
type SwipeRequest struct {
Action string `json:"action" binding:"required,oneof=like pass superlike"`
}
// SwipeResponse نتیجه‌ی یک سواپ؛ اگه Matched=true باشه یعنی مچ تازه (یا از قبل) ساخته شده
type SwipeResponse struct {
Matched bool `json:"matched"`
Match *MatchView `json:"match,omitempty"`
}
// MatchView خلاصه‌ی یک مچ برای نمایش در لیست مچ‌ها/گفتگوها
type MatchView struct {
ID uint `json:"id"`
UserID uint `json:"user_id"`
FirstName string `json:"first_name"`
Photos []string `json:"photos"`
CreatedAt string `json:"created_at"`
LastMessage *string `json:"last_message,omitempty"`
LastAt *string `json:"last_at,omitempty"`
}
// MessageView یک پیام در یک گفتگو
type MessageView struct {
ID uint `json:"id"`
MatchID uint `json:"match_id"`
SenderID uint `json:"sender_id"`
Text string `json:"text"`
CreatedAt string `json:"created_at"`
IsMine bool `json:"is_mine"`
}
// SendMessageRequest بدنه‌ی درخواست ارسال پیام
type SendMessageRequest struct {
Text string `json:"text" binding:"required,min=1,max=2000"`
}
// CandidateAnswer پاسخ یک سوال پروفایل، برای نمایش عمومی
type CandidateAnswer struct {
Question string `json:"question"`
Answer string `json:"answer"`
}
// CandidateDetail پروفایل کامل یک کاربر دیگه (برای نمایش صفحه‌ی جزئیات پروفایل)
type CandidateDetail struct {
ID uint `json:"id"`
FirstName string `json:"first_name"`
Age int `json:"age"`
Photos []string `json:"photos"`
DistanceKM *float64 `json:"distance_km,omitempty"`
HeightCM *int `json:"height_cm,omitempty"`
WeightKG *int `json:"weight_kg,omitempty"`
Education string `json:"education,omitempty"`
FieldOfStudy string `json:"field_of_study,omitempty"`
Occupations []string `json:"occupations,omitempty"`
Interests []string `json:"interests,omitempty"`
ImportantInRelationship []string `json:"important_in_relationship,omitempty"`
LookingFor string `json:"looking_for,omitempty"`
Answers []CandidateAnswer `json:"profile_answers,omitempty"`
}
+56
View File
@@ -0,0 +1,56 @@
package dto
// BasicInfoRequest مرحله ۱: جنسیت، اسم کوچک، تاریخ تولد
type BasicInfoRequest struct {
Gender string `json:"gender" binding:"required,oneof=male female"`
FirstName string `json:"first_name" binding:"required,min=2,max=50"`
// فرمت: YYYY-MM-DD
BirthDate string `json:"birth_date" binding:"required"`
}
// BodyInfoRequest مرحله ۲: قد و وزن
type BodyInfoRequest struct {
HeightCM int `json:"height_cm" binding:"required,min=100,max=250"`
WeightKG int `json:"weight_kg" binding:"required,min=30,max=250"`
}
// ProfileQuestionAnswerInput یک جفت (سوال انتخاب‌شده، پاسخ) از سوالات پروفایل
type ProfileQuestionAnswerInput struct {
QuestionID uint `json:"question_id" binding:"required"`
Answer string `json:"answer" binding:"required,min=1,max=1000"`
}
// ProfileQuestionsRequest مرحله ۳: دقیقاً ۳ سوال انتخابی همراه با پاسخ
type ProfileQuestionsRequest struct {
Answers []ProfileQuestionAnswerInput `json:"answers" binding:"required,len=3,dive"`
}
// EducationRequest مرحله ۴: سطح تحصیلات + رشته تحصیلی (هر دو از لیست‌های ادمین)
type EducationRequest struct {
EducationLevelOptionID uint `json:"education_level_option_id" binding:"required"`
FieldOfStudyOptionID uint `json:"field_of_study_option_id" binding:"required"`
}
// OptionSelectionRequest برای مراحلی که فقط یک لیست از option_id ارسال می‌شود
// (کارها، اهمیت‌های رابطه، علاقه‌مندی‌ها، دنبال چی می‌گردی)
type OptionSelectionRequest struct {
OptionIDs []uint `json:"option_ids" binding:"required,min=1,dive"`
}
// OnboardingStatusResponse وضعیت فعلی آنبوردینگ کاربر
type OnboardingStatusResponse struct {
CurrentStep int `json:"current_step"`
CurrentStepKey string `json:"current_step_key"`
IsOnboarded bool `json:"is_onboarded"`
// ApprovalStatus بعد از تکمیل آنبوردینگ معنا پیدا می‌کنه: pending/approved/rejected.
// وقتی pending هست، اپ باید صفحه‌ی «در انتظار تایید ادمین» رو نشون بده.
ApprovalStatus string `json:"approval_status"`
RejectionReason *string `json:"rejection_reason,omitempty"`
Steps []StepView `json:"steps"`
}
type StepView struct {
Step int `json:"step"`
Key string `json:"key"`
Done bool `json:"done"`
}
+7
View File
@@ -0,0 +1,7 @@
package dto
// UpdateLocationRequest به‌روزرسانی موقعیت مکانی کاربر (برای محاسبه‌ی فاصله‌ی تقریبی)
type UpdateLocationRequest struct {
Latitude float64 `json:"latitude" binding:"required"`
Longitude float64 `json:"longitude" binding:"required"`
}