|
@@ -33,7 +33,7 @@ public class UserService {
|
|
|
if (!checkUsername(user.getUsername())) {
|
|
|
return -1L;
|
|
|
}
|
|
|
- if(CommonUtil.hasEmpty(user.getName(),user.getPhone(),user.getPassword())){
|
|
|
+ if (CommonUtil.hasEmpty(user.getName(), user.getPhone(), user.getPassword())) {
|
|
|
return -1L;
|
|
|
}
|
|
|
/* if(!checkPhone(user.getPhone())){
|
|
@@ -51,12 +51,15 @@ public class UserService {
|
|
|
return user.getId();
|
|
|
}
|
|
|
|
|
|
- public List<UserInfo> listUsers() {
|
|
|
+ public List<UserInfo> listUsers(String userType) {
|
|
|
Sort sort = new Sort(Sort.Direction.ASC, "name");
|
|
|
- return userRepo.findAll(sort);
|
|
|
+ if (StringUtils.isBlank(userType)) {
|
|
|
+ return userRepo.findAll(sort);
|
|
|
+ }
|
|
|
+ return userRepo.findByUserType(userType);
|
|
|
}
|
|
|
|
|
|
- public List<UserInfo> listByUids(Set<Long> uids){
|
|
|
+ public List<UserInfo> listByUids(Set<Long> uids) {
|
|
|
return userRepo.findAllById(uids);
|
|
|
}
|
|
|
|
|
@@ -98,9 +101,25 @@ public class UserService {
|
|
|
return userRepo.getOne(id);
|
|
|
}
|
|
|
|
|
|
- public boolean updatePassword(Long id,String password){
|
|
|
+ public boolean updatePassword(Long id, String password) {
|
|
|
UserInfo info = getSimpleUser(id);
|
|
|
info.setPassword(MD5Util.INSTANCE.md5(password));
|
|
|
return userRepo.save(info) != null;
|
|
|
}
|
|
|
+
|
|
|
+ public List<UserInfo> listStudent(String grade, String username) {
|
|
|
+ if (StringUtils.isNotBlank(username)) {
|
|
|
+ UserInfo userInfo = userRepo.findByUsername(username);
|
|
|
+ if(userInfo == null || !Constants.USER_TYPE_STUDENT.equals(userInfo.getUserType())){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ return new ArrayList<UserInfo>() {{
|
|
|
+ addUser(userInfo);
|
|
|
+ }};
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(grade)) {
|
|
|
+ return listUsers(Constants.USER_TYPE_STUDENT);
|
|
|
+ }
|
|
|
+ return userRepo.findByUserTypeAndGrade(Constants.USER_TYPE_STUDENT, grade);
|
|
|
+ }
|
|
|
}
|