diff --git a/internal/api/api.go b/internal/api/api.go index 1ad7adb..68e0e71 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -63,7 +63,7 @@ type API struct { // 初始化Gin引擎和相关配置 func NewAPI(cfg *config.Config, userRepo repository.UserRepo, operationHistoryRepo repository.OperationHistoryRepo, deviceControlRepo repository.DeviceControlRepo, deviceRepo repository.DeviceRepo, websocketService *service.WebSocketService) *API { // 设置Gin为发布模式 - gin.SetMode(gin.ReleaseMode) + gin.SetMode(gin.DebugMode) // 创建Gin引擎实例 engine := gin.New() diff --git a/internal/controller/user/user.go b/internal/controller/user/user.go index 1ad4f9e..d91cc9c 100644 --- a/internal/controller/user/user.go +++ b/internal/controller/user/user.go @@ -65,16 +65,8 @@ func (c *Controller) Register(ctx *gin.Context) { return } - // 对密码进行哈希处理 - hashedPassword, err := bcrypt.GenerateFromPassword([]byte(req.Password), bcrypt.DefaultCost) - if err != nil { - c.logger.Error("密码哈希处理失败: " + err.Error()) - controller.SendErrorResponse(ctx, controller.InternalServerErrorCode, "用户注册失败") - return - } - // 创建用户 - user, err := c.userRepo.CreateUser(req.Username, string(hashedPassword)) + user, err := c.userRepo.CreateUser(req.Username, req.Password) if err != nil { c.logger.Error("创建用户失败: " + err.Error()) controller.SendErrorResponse(ctx, controller.InternalServerErrorCode, "用户注册失败") diff --git a/internal/storage/db/storage.go b/internal/storage/db/storage.go index f023e53..5c8f8d5 100644 --- a/internal/storage/db/storage.go +++ b/internal/storage/db/storage.go @@ -24,5 +24,6 @@ type Storage interface { // 根据配置返回相应的存储实现 func NewStorage(connectionString string, maxOpenConns, maxIdleConns, connMaxLifetime int) Storage { // 当前默认返回PostgreSQL存储实现 - return NewPostgresStorage(connectionString, maxOpenConns, maxIdleConns, connMaxLifetime) + s := NewPostgresStorage(connectionString, maxOpenConns, maxIdleConns, connMaxLifetime) + return s }