All checks were successful
Server CI/CD / deploy (push) Successful in 1m36s
- unsafe 타입 단언 → safe assertion (chain handler 11곳, auth Logout) - Repository 에러 시 nil 반환으로 통일 (chain, auth, announcement) - string ID → uint 파싱으로 타입 안전성 확보 (auth, announcement) - CORS AllowHeaders에 Idempotency-Key, X-API-Key 추가 - /verify 엔드포인트 rate limiter 적용 - Redis 호출에 context timeout 적용 (auth, idempotency 미들웨어) - chain handler 에러 응답에서 내부 정보 노출 방지 - f.Close() 에러 검사 추가 (download service 2곳) - 공지사항 Delete 404 응답 추가 - 회원가입 롤백 시 Delete 에러 로깅 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
659 B
Go
32 lines
659 B
Go
package chain
|
|
|
|
import "gorm.io/gorm"
|
|
|
|
type Repository struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewRepository(db *gorm.DB) *Repository {
|
|
return &Repository{db: db}
|
|
}
|
|
|
|
func (r *Repository) Create(w *UserWallet) error {
|
|
return r.db.Create(w).Error
|
|
}
|
|
|
|
func (r *Repository) FindByUserID(userID uint) (*UserWallet, error) {
|
|
var w UserWallet
|
|
if err := r.db.Where("user_id = ?", userID).First(&w).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &w, nil
|
|
}
|
|
|
|
func (r *Repository) FindByPubKeyHex(pubKeyHex string) (*UserWallet, error) {
|
|
var w UserWallet
|
|
if err := r.db.Where("pub_key_hex = ?", pubKeyHex).First(&w).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &w, nil
|
|
}
|