|
@@ -32,8 +32,6 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.annotation.IdType;
|
|
|
-import com.baomidou.mybatisplus.annotation.TableId;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
@@ -64,6 +62,7 @@ import com.diagbot.enums.StatusEnum;
|
|
|
import com.diagbot.exception.CommonErrorCode;
|
|
|
import com.diagbot.exception.CommonException;
|
|
|
import com.diagbot.exception.ServiceErrorCode;
|
|
|
+import com.diagbot.service.SysUserHospitalService;
|
|
|
import com.diagbot.service.impl.SysUserDeptServiceImpl;
|
|
|
import com.diagbot.service.impl.SysUserRoleServiceImpl;
|
|
|
import com.diagbot.service.impl.SysUserServiceImpl;
|
|
@@ -106,6 +105,9 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
@Qualifier("sysUserRoleServiceImpl")
|
|
|
private SysUserRoleServiceImpl sysUserRoleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysUserHospitalService sysUserHospitalService;
|
|
|
+
|
|
|
@Autowired
|
|
|
@Qualifier("sysUserDeptServiceImpl")
|
|
|
private SysUserDeptServiceImpl sysUserDeptService;
|
|
@@ -116,8 +118,6 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
@Autowired
|
|
|
private SysRoleFacade sysRoleFacade;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SysUserHospitalFacade sysUserHospitalFacade;
|
|
|
@Autowired
|
|
|
private SysUserRoleFacade sysUserRoleFacade;
|
|
|
@Autowired
|
|
@@ -182,22 +182,13 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
// 创建 GET 请求对象
|
|
|
HttpGet httpGet = new HttpGet("https://wsyy.wzhospital.cn:8443/authentication/v1/login/getTokenUser");
|
|
|
httpGet.addHeader("token", userLoginVO.getAuthToken());
|
|
|
- // 调用 HttpClient 的 execute 方法执行请求
|
|
|
CloseableHttpResponse response = HttpClients.createDefault().execute(httpGet);
|
|
|
- // 获取请求状态
|
|
|
- int code = response.getCode();
|
|
|
- // 如果请求成功
|
|
|
- if(code == HttpStatus.SC_OK){
|
|
|
+ if(response.getCode() == HttpStatus.SC_OK){
|
|
|
String result = EntityUtils.toString(response.getEntity());
|
|
|
JSONObject json = JSON.parseObject(result);
|
|
|
|
|
|
String userId = json.getJSONObject("data").getInteger("yongHuID")+"_"+json.getJSONObject("data").getString("xingMing");
|
|
|
|
|
|
- sys_user
|
|
|
- sys_user_role
|
|
|
- sys_user_hospital
|
|
|
-
|
|
|
-
|
|
|
QueryWrapper<SysUser> userQueryWrapper = new QueryWrapper<>();
|
|
|
userQueryWrapper.eq("username", userId);
|
|
|
SysUser user = this.getOne(userQueryWrapper, false);
|
|
@@ -208,13 +199,14 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
new_user.setCreator("0");
|
|
|
new_user.setUsername(userId);
|
|
|
new_user.setLinkman(json.getJSONObject("data").getString("xingMing"));
|
|
|
+ new_user.setPassword("{bcrypt}$2a$10$qhV.bPLz1xsjQKQc35Ohz.oMU2y.lffnogvLEK69u3Z1rbLpQVFh2");
|
|
|
new_user.setType(0);
|
|
|
new_user.setStatus(1);
|
|
|
+ new_user.setRemark(JSON.toJSONString(json.getJSONObject("data")));
|
|
|
save(new_user);
|
|
|
-
|
|
|
user = new_user;
|
|
|
- //关联角色
|
|
|
|
|
|
+ //关联角色
|
|
|
SysUserRole sur = new SysUserRole();
|
|
|
sur.setIsDeleted("N");
|
|
|
sur.setCreator("0");
|
|
@@ -224,38 +216,15 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
|
|
|
//关联医院
|
|
|
SysUserHospital suh = new SysUserHospital();
|
|
|
- suh.setIsDeleted();
|
|
|
-
|
|
|
- /**
|
|
|
- * 是否删除,N:未删除,Y:删除
|
|
|
- */
|
|
|
- private String isDeleted;
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 用户主键
|
|
|
- */
|
|
|
- private Long userId;
|
|
|
-
|
|
|
- /**
|
|
|
- * 医院ID
|
|
|
- */
|
|
|
- private Long hospitalId;
|
|
|
-
|
|
|
- /**
|
|
|
- * 备注
|
|
|
- */
|
|
|
- private String remark;
|
|
|
-
|
|
|
-
|
|
|
+ suh.setIsDeleted("N");
|
|
|
+ suh.setUserId(new_user.getId());
|
|
|
+ suh.setHospitalId(13L);
|
|
|
+ sysUserHospitalService.save(suh);
|
|
|
}else {
|
|
|
- //设置部门
|
|
|
- user.setRemark(result);
|
|
|
- }
|
|
|
- JWT jwt = authServiceClient.getToken("Basic dWFhLXNlcnZpY2U6MTIzNDU2","password", userLoginVO.getUsername(), "");
|
|
|
- if (null == jwt) {
|
|
|
- throw new CommonException(ServiceErrorCode.GET_TOKEN_FAIL);
|
|
|
+ user.setRemark(JSON.toJSONString(json.getJSONObject("data")));
|
|
|
+ updateById(user);
|
|
|
}
|
|
|
+ JWT jwt = authServiceClient.getToken("Basic dWFhLXNlcnZpY2U6MTIzNDU2","password", user.getUsername(), DigestUtils.md5DigestAsHex("a123456".getBytes()));
|
|
|
data.setAccessToken(jwt.getAccess_token());
|
|
|
data.setRefreshToken(jwt.getRefresh_token());
|
|
|
data.setType(user.getType());
|
|
@@ -280,20 +249,7 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
//每次登录在redis缓存该用户登录成功的token;缓存时间为token有效时间
|
|
|
long accessTokenTime = sysDictionaryFacade.getAccessTokenOutTime();
|
|
|
redisUtils.set("user:refreshToken:outTime_" + user.getId(), accessTokenTime, accessTokenTime);
|
|
|
- // 获取用户医院id
|
|
|
- // String hospitalID = SysUserUtils.getCurrentHospitalID();
|
|
|
- Long id = user.getId();
|
|
|
- QueryWrapper<SysUserHospital> UserHospitalQueryWrapper = new QueryWrapper<>();
|
|
|
- UserHospitalQueryWrapper.eq("user_id", id).eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
- SysUserHospital userHospital = sysUserHospitalFacade.getOne(UserHospitalQueryWrapper, false);
|
|
|
- Long hospitalId = userHospital.getHospitalId();
|
|
|
- String idStr = String.valueOf(hospitalId);
|
|
|
- Boolean passwordRegular = passwordRegular(userLoginVO.getPassword(), idStr);
|
|
|
- if (!passwordRegular) {
|
|
|
- data.setPasswordComplexity("未修改初始密码,请及时修改密码");
|
|
|
- }
|
|
|
return data;
|
|
|
- //查找是否有这个用户
|
|
|
}
|
|
|
}catch(Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -375,7 +331,7 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
UserHospitalQueryWrapper
|
|
|
.eq("user_id", id)
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
- SysUserHospital userHospital = sysUserHospitalFacade.getOne(UserHospitalQueryWrapper, false);
|
|
|
+ SysUserHospital userHospital = sysUserHospitalService.getOne(UserHospitalQueryWrapper, false);
|
|
|
Long hospitalId = userHospital.getHospitalId();
|
|
|
String idStr = String.valueOf(hospitalId);
|
|
|
Boolean passwordRegular = passwordRegular(userLoginVO.getPassword(), idStr);
|
|
@@ -916,7 +872,7 @@ public class SysUserFacade extends SysUserServiceImpl {
|
|
|
*/
|
|
|
private void checkUser(Long userId) {
|
|
|
//确认用户是否是管理员统一医院下的用户
|
|
|
- Integer cnt = sysUserHospitalFacade.count(new QueryWrapper<SysUserHospital>()
|
|
|
+ Integer cnt = sysUserHospitalService.count(new QueryWrapper<SysUserHospital>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
.eq("user_id", userId)
|
|
|
.eq("hospital_id", SysUserUtils.getCurrentHospitalID())
|