|
@@ -6,6 +6,7 @@ import com.yaoxiang.diagnosis.util.CommonUtil;
|
|
|
import com.yaoxiang.diagnosis.util.MD5Util;
|
|
|
import com.yaoxiang.diagnosis.config.Constants;
|
|
|
import com.yaoxiang.diagnosis.entity.UserInfo;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.data.domain.Sort;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -33,7 +34,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.getUsername(), user.getPassword())) {
|
|
|
return -1L;
|
|
|
}
|
|
|
/* if(!checkPhone(user.getPhone())){
|
|
@@ -44,6 +45,10 @@ public class UserService {
|
|
|
String salt = "";
|
|
|
user.setSalt(salt);
|
|
|
user.setLocked(false);
|
|
|
+ //简单判断长度为11,认为是手机号码
|
|
|
+ if (user.getUsername().length() == 11) {
|
|
|
+ user.setPhone(user.getUsername());
|
|
|
+ }
|
|
|
user.setPassword(MD5Util.INSTANCE.md5(user.getPassword() + salt));
|
|
|
user.setLevel(1);
|
|
|
user.setId(null);
|
|
@@ -110,7 +115,7 @@ public class UserService {
|
|
|
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())){
|
|
|
+ if (userInfo == null || !Constants.USER_TYPE_STUDENT.equals(userInfo.getUserType())) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
return new ArrayList<UserInfo>() {{
|