|  |  | @ -27,6 +27,10 @@ public class UserService { | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (user.getPassword() == null || user.getPassword().trim().isEmpty()) { |  |  |  |         if (user.getPassword() == null || user.getPassword().trim().isEmpty()) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             throw new InvalidInputException("密码不能为空"); |  |  |  |             throw new InvalidInputException("密码不能为空"); | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //比较两次输入的密码
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         if (!user.getPassword().equals(user.getConfirmPassword())) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             throw new InvalidInputException("两次输入的密码不一致"); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         //检测用户名是否存在
 |  |  |  |         //检测用户名是否存在
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         User existUser = userMapper.selectByUsername(user.getUsername()); |  |  |  |         User existUser = userMapper.selectByUsername(user.getUsername()); | 
			
		
	
	
		
		
			
				
					|  |  | @ -43,10 +47,10 @@ public class UserService { | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     //用户登录
 |  |  |  |     //用户登录
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     public User login(String username, String password) throws Exception { |  |  |  |     public User login(String username, String password) throws LoginFailedException { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         User user = userMapper.selectByUsername(username); |  |  |  |         User user = userMapper.selectByUsername(username); | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (user == null || !user.getPassword().equals(password)) { |  |  |  |         if (user == null || !passwordEncoder.matches(password, user.getPassword())) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             throw new Exception("登陆失败,账号或密码错误"); |  |  |  |             throw new LoginFailedException("登陆失败,账号或密码错误"); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |         return user; |  |  |  |         return user; | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |