Files
backend/internal/repository/yggdrasil_repository.go
lan 034e02e93a feat: Enhance dependency injection and service integration
- Updated main.go to initialize email service and include it in the dependency injection container.
- Refactored handlers to utilize context in service method calls, improving consistency and error handling.
- Introduced new service options for upload, security, and captcha services, enhancing modularity and testability.
- Removed unused repository implementations to streamline the codebase.

This commit continues the effort to improve the architecture by ensuring all services are properly injected and utilized across the application.
2025-12-02 22:52:33 +08:00

33 lines
752 B
Go

package repository
import (
"carrotskin/internal/model"
"gorm.io/gorm"
)
// yggdrasilRepository YggdrasilRepository的实现
type yggdrasilRepository struct {
db *gorm.DB
}
// NewYggdrasilRepository 创建YggdrasilRepository实例
func NewYggdrasilRepository(db *gorm.DB) YggdrasilRepository {
return &yggdrasilRepository{db: db}
}
func (r *yggdrasilRepository) GetPasswordByID(id int64) (string, error) {
var yggdrasil model.Yggdrasil
err := r.db.Where("id = ?", id).First(&yggdrasil).Error
if err != nil {
return "", err
}
return yggdrasil.Password, nil
}
func (r *yggdrasilRepository) ResetPassword(id int64, password string) error {
return r.db.Model(&model.Yggdrasil{}).Where("id = ?", id).Update("password", password).Error
}