|
@@ -59,12 +59,14 @@ import com.diagbot.vo.UserExportVO;
|
|
|
import com.diagbot.vo.UserInfoAuditVO;
|
|
|
import com.diagbot.vo.UserInfoOrganizationsVO;
|
|
|
import com.diagbot.vo.UserSaveVO;
|
|
|
+import com.diagbot.vo.UsernameVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.crypto.factory.PasswordEncoderFactories;
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.security.oauth2.common.OAuth2AccessToken;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.Serializable;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
@@ -72,8 +74,6 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-
|
|
|
/**
|
|
|
* @Description: 用户业务层
|
|
|
* @author: gaodm
|
|
@@ -120,7 +120,7 @@ public class UserFacade extends UserServiceImpl {
|
|
|
throw new CommonException(ServiceErrorCode.USER_EXIST);
|
|
|
}
|
|
|
if (!RegexValidateUtil.checkMobileNumber(userSaveVO.getUsername())) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请输入正确的手机号!");
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请输入正确的手机号");
|
|
|
}
|
|
|
|
|
|
//TODO 测试注释了图形验证和短信验证,后面要开启
|
|
@@ -143,6 +143,28 @@ public class UserFacade extends UserServiceImpl {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 校验用户(手机号)是否注册
|
|
|
+ *
|
|
|
+ * @param usernameVO 参数
|
|
|
+ * @return 返回状态
|
|
|
+ */
|
|
|
+ public Boolean verifyUser(UsernameVO usernameVO) {
|
|
|
+ String username = usernameVO.getUsername();
|
|
|
+ if(StringUtil.isEmpty(username)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请输入手机号");
|
|
|
+ }
|
|
|
+ if(!RegexValidateUtil.checkMobileNumber(username)) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请输入正确的手机号");
|
|
|
+ }
|
|
|
+ User bean = findByName(username);
|
|
|
+ if (bean != null) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该手机已注册");
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* @param page 分页参数
|
|
|
* @param userSaveVO 参数
|
|
@@ -205,13 +227,13 @@ public class UserFacade extends UserServiceImpl {
|
|
|
orgId = org.getId();
|
|
|
} else {
|
|
|
orgId = list.get(0).getId();
|
|
|
- //查询机构下是否已存在用户信息,如已存在,就抛异常,需求待核实
|
|
|
+ //查询机构下是否已存在用户信息,如已存在,就抛异常,需求核实2018.10.16
|
|
|
Map paramMap1 = new HashMap();
|
|
|
paramMap1.put("organization_id", orgId);
|
|
|
paramMap1.put("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
List<UserOrganization> res1 = userOrganizationFacade.selectByMap(paramMap1);
|
|
|
if (ListUtil.isNotEmpty(res1)) {
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该机构下已存在用户,不能再添加别的用户!");
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "该机构下已存在用户,不能再添加别的用户");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -320,11 +342,11 @@ public class UserFacade extends UserServiceImpl {
|
|
|
JwtDTO data = new JwtDTO();
|
|
|
if (StringUtil.isBlank(username)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "请输入手机号!");
|
|
|
+ "请输入手机号");
|
|
|
}
|
|
|
if (StringUtil.isBlank(password)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "请输入密码!");
|
|
|
+ "请输入密码");
|
|
|
}
|
|
|
User user = this.findByName(username);
|
|
|
if (null == user) {
|
|
@@ -355,7 +377,7 @@ public class UserFacade extends UserServiceImpl {
|
|
|
JwtDTO data = new JwtDTO();
|
|
|
if (StringUtil.isBlank(refreshToken)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "刷新令牌不能为空!");
|
|
|
+ "刷新令牌不能为空");
|
|
|
}
|
|
|
|
|
|
JWT jwt = authServiceClient.refreshToken("Basic dWFhLXNlcnZpY2U6MTIzNDU2", "refresh_token", refreshToken);
|
|
@@ -377,7 +399,7 @@ public class UserFacade extends UserServiceImpl {
|
|
|
public OAuth2AccessToken checkToken(String token) {
|
|
|
if (StringUtil.isBlank(token)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "令牌不能为空!");
|
|
|
+ "令牌不能为空");
|
|
|
}
|
|
|
|
|
|
OAuth2AccessToken jwt = authServiceClient.checkToken("Basic dWFhLXNlcnZpY2U6MTIzNDU2", token);
|
|
@@ -465,11 +487,11 @@ public class UserFacade extends UserServiceImpl {
|
|
|
public RespDTO resetPassword(String username, String password, String diffPassword) {
|
|
|
if (StringUtil.isBlank(username)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "请输入手机号!");
|
|
|
+ "请输入手机号");
|
|
|
}
|
|
|
if (StringUtil.isBlank(password)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "请输入密码!");
|
|
|
+ "请输入密码");
|
|
|
}
|
|
|
User user = this.findByName(username);
|
|
|
if (null == user) {
|
|
@@ -478,7 +500,7 @@ public class UserFacade extends UserServiceImpl {
|
|
|
PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
|
|
if (!StringUtil.isBlank(diffPassword) && "Y".equals(diffPassword)) {
|
|
|
if (passwordEncoder.matches(password, user.getPassword())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "修改后密码不能与修改前相同!");
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "修改后密码不能与修改前相同");
|
|
|
}
|
|
|
}
|
|
|
String entryPassword = passwordEncoder.encode(password);
|
|
@@ -499,15 +521,15 @@ public class UserFacade extends UserServiceImpl {
|
|
|
public Boolean modifyPassword(String password, String modifyPassword) {
|
|
|
if (StringUtil.isBlank(password)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "请输入密码!");
|
|
|
+ "请输入密码");
|
|
|
}
|
|
|
if (StringUtil.isBlank(modifyPassword)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "请输入新密码!");
|
|
|
+ "请输入新密码");
|
|
|
}
|
|
|
if(password.equals(modifyPassword)) {
|
|
|
throw new CommonException(CommonErrorCode.PARAM_IS_NULL,
|
|
|
- "原密码和新密码不能相同!");
|
|
|
+ "原密码和新密码不能相同");
|
|
|
}
|
|
|
Long userId = Long.parseLong(UserUtils.getCurrentPrincipleID());
|
|
|
User user = this.getById(userId);
|
|
@@ -518,7 +540,7 @@ public class UserFacade extends UserServiceImpl {
|
|
|
|
|
|
PasswordEncoder passwordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder();
|
|
|
if (!passwordEncoder.matches(password, user.getPassword())) {
|
|
|
- throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "原密码错误!");
|
|
|
+ throw new CommonException(CommonErrorCode.PARAM_IS_ERROR, "原密码错误");
|
|
|
}
|
|
|
|
|
|
String entryPassword = passwordEncoder.encode(modifyPassword);
|