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