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.
This commit is contained in:
@@ -2,18 +2,31 @@ package repository
|
||||
|
||||
import (
|
||||
"carrotskin/internal/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func GetYggdrasilPasswordById(id int64) (string, error) {
|
||||
// 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 := getDB().Where("id = ?", id).First(&yggdrasil).Error
|
||||
err := r.db.Where("id = ?", id).First(&yggdrasil).Error
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return yggdrasil.Password, nil
|
||||
}
|
||||
|
||||
// ResetYggdrasilPassword 重置Yggdrasil密码
|
||||
func ResetYggdrasilPassword(userId int64, newPassword string) error {
|
||||
return getDB().Model(&model.Yggdrasil{}).Where("id = ?", userId).Update("password", newPassword).Error
|
||||
}
|
||||
func (r *yggdrasilRepository) ResetPassword(id int64, password string) error {
|
||||
return r.db.Model(&model.Yggdrasil{}).Where("id = ?", id).Update("password", password).Error
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user