- /health + /ready 엔드포인트 추가 (DB/Redis 상태 확인) - RequestID 미들웨어 + 구조화 JSON 로깅 - 체인 트랜잭션 per-user rate limit (20 req/min) - DB 커넥션 풀 설정 (MaxOpen 25, MaxIdle 10, MaxLifetime 5m) - Graceful Shutdown 시 Redis/MySQL 연결 정리 - Dockerfile HEALTHCHECK 추가 - CI에 go vet + 빌드 검증 단계 추가 (deploy 전 실행) - 보스 레이드 클라이언트 입장 API (JWT 인증) - Player 프로필 모듈 추가 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42 lines
1.1 KiB
Go
42 lines
1.1 KiB
Go
package player
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
type Repository struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewRepository(db *gorm.DB) *Repository {
|
|
return &Repository{db: db}
|
|
}
|
|
|
|
func (r *Repository) Create(profile *PlayerProfile) error {
|
|
return r.db.Create(profile).Error
|
|
}
|
|
|
|
func (r *Repository) FindByUserID(userID uint) (*PlayerProfile, error) {
|
|
var profile PlayerProfile
|
|
if err := r.db.Where("user_id = ?", userID).First(&profile).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &profile, nil
|
|
}
|
|
|
|
func (r *Repository) Update(profile *PlayerProfile) error {
|
|
return r.db.Save(profile).Error
|
|
}
|
|
|
|
func (r *Repository) UpdateStats(userID uint, updates map[string]interface{}) error {
|
|
return r.db.Model(&PlayerProfile{}).Where("user_id = ?", userID).Updates(updates).Error
|
|
}
|
|
|
|
func (r *Repository) FindByUsername(username string) (*PlayerProfile, error) {
|
|
var profile PlayerProfile
|
|
if err := r.db.Joins("JOIN users ON users.id = player_profiles.user_id").
|
|
Where("users.username = ? AND users.deleted_at IS NULL", username).
|
|
First(&profile).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &profile, nil
|
|
}
|