Refactor employee management

This commit is contained in:
Frudrax Cheng
2026-05-28 10:05:59 +08:00
parent f394d3a8bd
commit d3ee215f61
17 changed files with 5391 additions and 174 deletions
+24 -12
View File
@@ -23,6 +23,12 @@ func (s *AuthService) ValidateUser(username string, password string) (*models.Us
if result.Error != nil {
return nil, errors.New("用户名或密码不正确")
}
if user.Role != "admin" && user.Role != "technician" {
return nil, errors.New("用户名或密码不正确")
}
if user.Password == "" {
return nil, errors.New("用户名或密码不正确")
}
err := bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
if err != nil {
@@ -56,12 +62,15 @@ func (s *AuthService) GetProfile(userId uint) (*models.UserDTO, error) {
}
return &models.UserDTO{
ID: user.ID,
Username: user.Username,
Name: user.Name,
Email: user.Email,
Role: user.Role,
CreatedAt: user.CreatedAt,
ID: user.ID,
Username: user.Username,
Name: user.Name,
Email: user.Email,
Phone: user.Phone,
EmployeeNo: user.EmployeeNo,
Position: user.Position,
Role: user.Role,
CreatedAt: user.CreatedAt,
}, nil
}
@@ -109,11 +118,14 @@ func (s *AuthService) UpdateProfile(userId uint, name string, email string) (*mo
}
return &models.UserDTO{
ID: user.ID,
Username: user.Username,
Name: user.Name,
Email: user.Email,
Role: user.Role,
CreatedAt: user.CreatedAt,
ID: user.ID,
Username: user.Username,
Name: user.Name,
Email: user.Email,
Phone: user.Phone,
EmployeeNo: user.EmployeeNo,
Position: user.Position,
Role: user.Role,
CreatedAt: user.CreatedAt,
}, nil
}