|
@@ -104,6 +104,7 @@ public class SysUserController {
|
|
|
private final SysUserManager userManager;
|
|
|
|
|
|
private static final List<Integer> SALESMAN_ROLE_ID = ListUtil.of(5, 6);
|
|
|
+ private static final List<Integer> ADMIN_ROLE_ID = ListUtil.of(1, 2, 7, 19, 27, 34, 35, 44, 45, 46, 47, 48, 49);
|
|
|
|
|
|
/**
|
|
|
* 判断可以登陆的角色
|
|
@@ -131,6 +132,25 @@ public class SysUserController {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断可以登录小程序的角色
|
|
|
+ * 只有单纯是1, 2, 7, 19, 27, 34, 35, 44, 45, 46, 47, 48, 49的角色才不能登陆
|
|
|
+ *
|
|
|
+ * @param roles 角色合集
|
|
|
+ * @return 判断结果
|
|
|
+ */
|
|
|
+ private boolean allowAdminRole2LoginApp(Integer[] roles) {
|
|
|
+
|
|
|
+ if (ArrayUtil.isEmpty(roles)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Integer> roleIds = Arrays.stream(roles).collect(Collectors.toSet());
|
|
|
+
|
|
|
+
|
|
|
+ return !CollUtil.containsAny(roleIds, ADMIN_ROLE_ID);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 用户管理-认证
|
|
|
*
|
|
@@ -261,12 +281,12 @@ public class SysUserController {
|
|
|
|
|
|
}
|
|
|
|
|
|
- // 移动端登录:管理员和业务员均可登录
|
|
|
+ // 移动端登录
|
|
|
private R<UserInfo> appUserInfo(List<SysUser> users) {
|
|
|
|
|
|
SysUser sysUser = users.get(0);
|
|
|
UserInfo userInfo = userService.findUserInfo(sysUser);
|
|
|
- return R.ok(userInfo);
|
|
|
+ return allowAdminRole2LoginApp(userInfo.getRoles()) ? R.ok(userInfo) : R.failed(null, String.format("用户信息错误 %s", sysUser.getUsername()));
|
|
|
|
|
|
}
|
|
|
|
|
@@ -345,16 +365,16 @@ public class SysUserController {
|
|
|
|
|
|
// 校验验证码是否准确
|
|
|
final String key = USER_FORGET_PWD_KEY + userPwd.getUserName();
|
|
|
- if (Boolean.TRUE.equals(redisTemplate.hasKey(key))){
|
|
|
+ if (Boolean.TRUE.equals(redisTemplate.hasKey(key))) {
|
|
|
Object o = redisTemplate.opsForValue().get(key);
|
|
|
- if (Objects.isNull(o)){
|
|
|
- throw new RuntimeException("验证码不存在或者已过期");
|
|
|
- }
|
|
|
- String code = (String) o;
|
|
|
+ if (Objects.isNull(o)) {
|
|
|
+ throw new RuntimeException("验证码不存在或者已过期");
|
|
|
+ }
|
|
|
+ String code = (String) o;
|
|
|
|
|
|
- if (!StrUtil.equals(code, userPwd.getCode())){
|
|
|
- throw new RuntimeException("验证码错误");
|
|
|
- }
|
|
|
+ if (!StrUtil.equals(code, userPwd.getCode())) {
|
|
|
+ throw new RuntimeException("验证码错误");
|
|
|
+ }
|
|
|
|
|
|
} else {
|
|
|
throw new RuntimeException("验证码不存在或者已过期");
|
|
@@ -740,8 +760,8 @@ public class SysUserController {
|
|
|
|
|
|
Map<String, List<CommonUserDTO>> collect = commonUserExcelModelList.stream()
|
|
|
.filter(commonUserExcelModel -> StrUtil.isNotBlank(commonUserExcelModel.getUsername())).map(commonUserExcelModel ->
|
|
|
- BeanUtil.copyProperties(commonUserExcelModel, CommonUserDTO.class)
|
|
|
- ).collect(Collectors.groupingBy(CommonUserDTO::getUsername));
|
|
|
+ BeanUtil.copyProperties(commonUserExcelModel, CommonUserDTO.class)
|
|
|
+ ).collect(Collectors.groupingBy(CommonUserDTO::getUsername));
|
|
|
|
|
|
|
|
|
// 实际的处理业务
|
|
@@ -776,8 +796,8 @@ public class SysUserController {
|
|
|
public R<?> updateUser(@Valid @RequestBody UserDTO userDto) {
|
|
|
|
|
|
|
|
|
- if (CollUtil.containsAny(userDto.getRole(), SALESMAN_ROLE_ID)){
|
|
|
- return R.failed("当前业务规定不支持修改(全职/兼职)业务员信息");
|
|
|
+ if (CollUtil.containsAny(userDto.getRole(), SALESMAN_ROLE_ID)) {
|
|
|
+ return R.failed("当前业务规定不支持修改(全职/兼职)业务员信息");
|
|
|
}
|
|
|
|
|
|
SysDept sysDept = sysDeptService.getById(userDto.getDeptId());
|