parent
ada27c3185
commit
51c7e78405
|
@ -106,11 +106,6 @@ public class RaxDaoAuthenticationProvider extends AbstractUserDetailsAuthenticat
|
||||||
|
|
||||||
String grantType = WebUtils.getRequest().get().getParameter(OAuth2ParameterNames.GRANT_TYPE);
|
String grantType = WebUtils.getRequest().get().getParameter(OAuth2ParameterNames.GRANT_TYPE);
|
||||||
String clientId = WebUtils.getRequest().get().getParameter(OAuth2ParameterNames.CLIENT_ID);
|
String clientId = WebUtils.getRequest().get().getParameter(OAuth2ParameterNames.CLIENT_ID);
|
||||||
Long hospitalId = Long.valueOf(WebUtils.getRequest().get().getParameter("hospitalId"));
|
|
||||||
|
|
||||||
if (hospitalId == null) {
|
|
||||||
throw new InternalAuthenticationServiceException("hospitalId is empty");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StrUtil.isBlank(clientId)) {
|
if (StrUtil.isBlank(clientId)) {
|
||||||
clientId = basicConvert.convert(request).getName();
|
clientId = basicConvert.convert(request).getName();
|
||||||
|
@ -130,7 +125,7 @@ public class RaxDaoAuthenticationProvider extends AbstractUserDetailsAuthenticat
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
UserDetails loadedUser = optional.get().loadUserByUsername(username, hospitalId);
|
UserDetails loadedUser = optional.get().loadUserByUsername(username);
|
||||||
if (loadedUser == null) {
|
if (loadedUser == null) {
|
||||||
throw new InternalAuthenticationServiceException(
|
throw new InternalAuthenticationServiceException(
|
||||||
"UserDetailsService returned null, which is an interface contract violation");
|
"UserDetailsService returned null, which is an interface contract violation");
|
||||||
|
|
|
@ -86,9 +86,4 @@ public class RaxAppUserDetailsServiceImpl implements RaxUserDetailsService {
|
||||||
return SecurityConstants.MOBILE.equals(grantType);
|
return SecurityConstants.MOBILE.equals(grantType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserDetails loadUserByUsername(String phone, Long hospitalId) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public interface RaxUserDetailsService extends UserDetailsService, Ordered {
|
||||||
StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL), user.getName(), authorities);
|
StrUtil.equals(user.getLockFlag(), CommonConstants.STATUS_NORMAL), user.getName(), authorities);
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDetails loadUserByUsername(String username, Long hospitalId);
|
UserDetails loadUserByUsername(String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户实体查询
|
* 通过用户实体查询
|
||||||
|
@ -79,7 +79,7 @@ public interface RaxUserDetailsService extends UserDetailsService, Ordered {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
default UserDetails loadUserByUser(RaxUser raxUser) {
|
default UserDetails loadUserByUser(RaxUser raxUser) {
|
||||||
return this.loadUserByUsername(raxUser.getUsername(), raxUser.getHospitalId());
|
return this.loadUserByUsername(raxUser.getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class RaxUserDetailsServiceImpl implements RaxUserDetailsService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public UserDetails loadUserByUsername(String username, Long hospitalId) {
|
public UserDetails loadUserByUsername(String username) {
|
||||||
Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
|
Cache cache = cacheManager.getCache(CacheConstants.USER_DETAILS);
|
||||||
if (cache != null && cache.get(username) != null) {
|
if (cache != null && cache.get(username) != null) {
|
||||||
return (RaxUser) cache.get(username).get();
|
return (RaxUser) cache.get(username).get();
|
||||||
|
@ -60,7 +60,6 @@ public class RaxUserDetailsServiceImpl implements RaxUserDetailsService {
|
||||||
|
|
||||||
UserDTO userDTO = new UserDTO();
|
UserDTO userDTO = new UserDTO();
|
||||||
userDTO.setUsername(username);
|
userDTO.setUsername(username);
|
||||||
userDTO.setHospitalId(hospitalId);
|
|
||||||
R<UserInfo> result = remoteUserService.info(userDTO, SecurityConstants.FROM_IN);
|
R<UserInfo> result = remoteUserService.info(userDTO, SecurityConstants.FROM_IN);
|
||||||
UserDetails userDetails = getUserDetails(result);
|
UserDetails userDetails = getUserDetails(result);
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
|
@ -74,8 +73,4 @@ public class RaxUserDetailsServiceImpl implements RaxUserDetailsService {
|
||||||
return Integer.MIN_VALUE;
|
return Integer.MIN_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,12 +61,11 @@ public class SysUserController {
|
||||||
*/
|
*/
|
||||||
@Inner
|
@Inner
|
||||||
@GetMapping(value = {"/info/query"})
|
@GetMapping(value = {"/info/query"})
|
||||||
public R info(@RequestParam(required = false) String username, @RequestParam(required = false) String phone, @RequestParam(required = false) String hospitalId) {
|
public R info(@RequestParam(required = false) String username, @RequestParam(required = false) String phone) {
|
||||||
SysUser user = userService.getOne(Wrappers.<SysUser>query()
|
SysUser user = userService.getOne(Wrappers.<SysUser>query()
|
||||||
.lambda()
|
.lambda()
|
||||||
.eq(StrUtil.isNotBlank(username), SysUser::getUsername, username)
|
.eq(StrUtil.isNotBlank(username), SysUser::getUsername, username)
|
||||||
.eq(StrUtil.isNotBlank(phone), SysUser::getPhone, phone)
|
.eq(StrUtil.isNotBlank(phone), SysUser::getPhone, phone));
|
||||||
.eq(StringUtils.hasText(hospitalId), SysUser::getHospitalId, hospitalId));
|
|
||||||
SysUser user1 = userService.getOne(Wrappers.<SysUser>query()
|
SysUser user1 = userService.getOne(Wrappers.<SysUser>query()
|
||||||
.lambda()
|
.lambda()
|
||||||
.eq(StrUtil.isNotBlank(username), SysUser::getUsername, username)
|
.eq(StrUtil.isNotBlank(username), SysUser::getUsername, username)
|
||||||
|
@ -84,14 +83,14 @@ public class SysUserController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isAdmin) {
|
if (isAdmin) {
|
||||||
sysHospitalService.changeHospital(hospitalId, String.valueOf(user1.getUserId()));
|
sysHospitalService.changeHospital("", String.valueOf(user1.getUserId()));
|
||||||
return R.ok(userService.findUserInfo(user1));
|
return R.ok(userService.findUserInfo(user1));
|
||||||
} else {
|
} else {
|
||||||
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, username));
|
return R.failed(MsgUtils.getMessage(ErrorCodes.SYS_USER_USERINFO_EMPTY, username));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sysHospitalService.changeHospital(hospitalId, String.valueOf(user.getUserId()));
|
sysHospitalService.changeHospital(String.valueOf(user.getHospitalId()), String.valueOf(user.getUserId()));
|
||||||
return R.ok(userService.findUserInfo(user));
|
return R.ok(userService.findUserInfo(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,9 @@ public class SysHospitalServiceImpl extends ServiceImpl<SysHospitalMapper, SysHo
|
||||||
queryWrapper.orderByDesc("create_time");
|
queryWrapper.orderByDesc("create_time");
|
||||||
queryWrapper.select(new String[]{"id", "name", "code", "status", "domain", "province", "city"});
|
queryWrapper.select(new String[]{"id", "name", "code", "status", "domain", "province", "city"});
|
||||||
sysHospitals = sysHospitalMapper.selectMaps(queryWrapper);
|
sysHospitals = sysHospitalMapper.selectMaps(queryWrapper);
|
||||||
|
SysHospital hospital = new SysHospital();
|
||||||
|
hospital.setName("无");
|
||||||
|
sysHospitals.add(0, hospital);
|
||||||
} else {
|
} else {
|
||||||
QueryWrapper<SysHospital> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<SysHospital> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("id", raxUser.getHospitalId());
|
queryWrapper.eq("id", raxUser.getHospitalId());
|
||||||
|
@ -133,11 +136,9 @@ public class SysHospitalServiceImpl extends ServiceImpl<SysHospitalMapper, SysHo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean changeHospital(String id, String userId) {
|
public boolean changeHospital(String id, String userId) {
|
||||||
if (StringUtils.hasText(id)) {
|
|
||||||
redisTemplate.opsForValue().set(CacheConstants.CURRENT_HOSPITAL + ":" + userId, id);
|
redisTemplate.opsForValue().set(CacheConstants.CURRENT_HOSPITAL + ":" + userId, id);
|
||||||
sysHospitalMapper.delCurrentHospital(userId);
|
sysHospitalMapper.delCurrentHospital(userId);
|
||||||
sysHospitalMapper.insertHospitalManager(id, userId);
|
sysHospitalMapper.insertHospitalManager(id, userId);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -340,18 +340,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
}
|
}
|
||||||
|
|
||||||
// 判断输入的部门名称列表是否合法
|
// 判断输入的部门名称列表是否合法
|
||||||
List<String> postNameList = StrUtil.split(excel.getPostNameList(), StrUtil.COMMA);
|
// List<String> postNameList = StrUtil.split(excel.getPostNameList(), StrUtil.COMMA);
|
||||||
List<SysPost> postCollList = postList.stream()
|
// List<SysPost> postCollList = postList.stream()
|
||||||
.filter(post -> postNameList.stream().anyMatch(name -> post.getPostName().equals(name)))
|
// .filter(post -> postNameList.stream().anyMatch(name -> post.getPostName().equals(name)))
|
||||||
.collect(Collectors.toList());
|
// .collect(Collectors.toList());
|
||||||
|
//
|
||||||
if (postCollList.size() != postNameList.size()) {
|
// if (postCollList.size() != postNameList.size()) {
|
||||||
errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_POST_POSTNAME_INEXISTENCE, excel.getPostNameList()));
|
// errorMsg.add(MsgUtils.getMessage(ErrorCodes.SYS_POST_POSTNAME_INEXISTENCE, excel.getPostNameList()));
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 数据合法情况
|
// 数据合法情况
|
||||||
if (CollUtil.isEmpty(errorMsg)) {
|
if (CollUtil.isEmpty(errorMsg)) {
|
||||||
insertExcelUser(excel, deptOptional, roleCollList, postCollList);
|
insertExcelUser(excel, deptOptional, roleCollList, null);
|
||||||
} else {
|
} else {
|
||||||
// 数据不合法情况
|
// 数据不合法情况
|
||||||
errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
|
errorMessageList.add(new ErrorMessage(excel.getLineNum(), errorMsg));
|
||||||
|
@ -381,8 +381,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||||
// 根据部门名称查询部门ID
|
// 根据部门名称查询部门ID
|
||||||
userDTO.setDeptId(deptOptional.get().getDeptId());
|
userDTO.setDeptId(deptOptional.get().getDeptId());
|
||||||
// 插入岗位名称
|
// 插入岗位名称
|
||||||
List<Long> postIdList = postCollList.stream().map(SysPost::getPostId).collect(Collectors.toList());
|
// List<Long> postIdList = postCollList.stream().map(SysPost::getPostId).collect(Collectors.toList());
|
||||||
userDTO.setPost(postIdList);
|
// userDTO.setPost(postIdList);
|
||||||
// 根据角色名称查询角色ID
|
// 根据角色名称查询角色ID
|
||||||
List<Long> roleIdList = roleCollList.stream().map(SysRole::getRoleId).collect(Collectors.toList());
|
List<Long> roleIdList = roleCollList.stream().map(SysRole::getRoleId).collect(Collectors.toList());
|
||||||
userDTO.setRole(roleIdList);
|
userDTO.setRole(roleIdList);
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user