fix bug: NullPointerException occurred when failed to login

pull/2/head
johnniang 2018-04-29 02:05:54 +08:00
parent 2432b7cc24
commit 764b86e4ad
2 changed files with 8 additions and 7 deletions

3
.gitignore vendored
View File

@ -9,6 +9,7 @@ logs/
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
@ -27,4 +28,4 @@ nbdist/
### Mac
.DS_Store
*/.DS_Store
*/.DS_Store

View File

@ -40,7 +40,7 @@ public class UserServiceImpl implements UserService {
*/
@Override
public List<User> userLoginByName(String userName, String userPass) {
return userRepository.findByUserNameAndUserPass(userName,userPass);
return userRepository.findByUserNameAndUserPass(userName, userPass);
}
/**
@ -52,7 +52,7 @@ public class UserServiceImpl implements UserService {
*/
@Override
public List<User> userLoginByEmail(String userEmail, String userPass) {
return userRepository.findByUserEmailAndUserPass(userEmail,userPass);
return userRepository.findByUserEmailAndUserPass(userEmail, userPass);
}
/**
@ -63,9 +63,9 @@ public class UserServiceImpl implements UserService {
@Override
public User findUser() {
List<User> users = userRepository.findAll();
if(users.size()>0){
if (users != null && users.size() > 0) {
return users.get(0);
}else{
} else {
return new User();
}
}
@ -79,7 +79,7 @@ public class UserServiceImpl implements UserService {
*/
@Override
public User findByUserIdAndUserPass(Long userId, String userPass) {
return userRepository.findByUserIdAndUserPass(userId,userPass);
return userRepository.findByUserIdAndUserPass(userId, userPass);
}
/**
@ -115,7 +115,7 @@ public class UserServiceImpl implements UserService {
@Override
public Integer updateUserLoginError() {
User user = this.findUser();
user.setLoginError(user.getLoginError()+1);
user.setLoginError((user.getLoginError() == null ? 0 : user.getLoginError()) + 1);
userRepository.save(user);
return user.getLoginError();
}