You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
package auth |
|
|
|
import ( |
|
"log" |
|
|
|
"gofaster/internal/auth/controller" |
|
"gofaster/internal/auth/repository" |
|
"gofaster/internal/auth/service" |
|
"gofaster/internal/core" |
|
"gofaster/internal/shared/database" |
|
) |
|
|
|
// Module 认证模块 |
|
type Module struct { |
|
userController *controller.UserController |
|
authController *controller.AuthController |
|
passwordController *controller.PasswordController |
|
} |
|
|
|
// NewModule 创建新的认证模块 |
|
func NewModule() *Module { |
|
return &Module{} |
|
} |
|
|
|
// Start 启动模块 |
|
func (m *Module) Start(cfg interface{}, db *database.Database) error { |
|
// 初始化仓库 |
|
userRepo := repository.NewUserRepository(db.DB) |
|
passwordPolicyRepo := repository.NewPasswordPolicyRepository(db.DB) |
|
passwordHistoryRepo := repository.NewPasswordHistoryRepository(db.DB) |
|
passwordResetRepo := repository.NewPasswordResetRepository(db.DB) |
|
|
|
// 初始化服务 |
|
userService := service.NewUserService(userRepo) |
|
authService := service.NewAuthService(userRepo) |
|
passwordService := service.NewPasswordService( |
|
userRepo, |
|
passwordPolicyRepo, |
|
passwordHistoryRepo, |
|
passwordResetRepo, |
|
) |
|
|
|
// 初始化控制器 |
|
m.userController = controller.NewUserController(userService) |
|
m.authController = controller.NewAuthController(authService) |
|
m.passwordController = controller.NewPasswordController(passwordService, userService) |
|
|
|
log.Printf("✅ 认证模块初始化完成") |
|
return nil |
|
} |
|
|
|
// Stop 停止模块 |
|
func (m *Module) Stop() error { |
|
return nil |
|
} |
|
|
|
// RegisterRoutes 注册路由 |
|
func (m *Module) RegisterRoutes(router interface{}) { |
|
// 这里应该注册具体的路由 |
|
// 暂时留空,由具体的路由文件处理 |
|
} |
|
|
|
// GetName 获取模块名称 |
|
func (m *Module) GetName() string { |
|
return "auth" |
|
}
|
|
|