修改bug#40302
This commit is contained in:
+29
-4
@@ -6,10 +6,14 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.exception.JeroBootException;
|
||||
import com.jero.modules.system.entity.SysRole;
|
||||
import com.jero.modules.system.entity.SysUserRole;
|
||||
import com.jero.modules.system.model.SysLoginVO;
|
||||
import com.jero.modules.system.service.*;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.constant.CacheConstant;
|
||||
@@ -23,10 +27,6 @@ import com.jero.common.util.encryption.EncryptedString;
|
||||
import com.jero.modules.system.entity.SysDepart;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.model.SysLoginModel;
|
||||
import com.jero.modules.system.service.ISysDepartService;
|
||||
import com.jero.modules.system.service.ISysDictService;
|
||||
import com.jero.modules.system.service.ISysLogService;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import com.jero.modules.system.util.RandImageUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -37,6 +37,7 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
@@ -63,6 +64,10 @@ public class LoginController {
|
||||
private BaseCommonService baseCommonService;
|
||||
@Resource
|
||||
private AuthenticationUtils authenticationUtils;
|
||||
@Resource
|
||||
private ISysRoleService sysRoleService;
|
||||
@Resource
|
||||
private ISysUserRoleService sysUserRoleService;
|
||||
|
||||
private static final String BASE_CHECK_CODES = "qwertyuiplkjhgfdsazxcvbnmQWERTYUPLKJHGFDSAZXCVBNM1234567890";
|
||||
/**
|
||||
@@ -161,6 +166,26 @@ public class LoginController {
|
||||
//update-begin--Author:wangshuai Date:20200714 for:登录日志没有记录人员
|
||||
LoginUser loginUser = new LoginUser();
|
||||
BeanUtils.copyProperties(sysUser, loginUser);
|
||||
// 新增用户角色code
|
||||
LambdaQueryWrapper<SysUserRole> querySysUserRole = new LambdaQueryWrapper();
|
||||
querySysUserRole.eq(SysUserRole::getUserId,sysUser.getId());
|
||||
List<SysUserRole> listSysUserRole = sysUserRoleService.list(querySysUserRole);
|
||||
if(!CollectionUtils.isEmpty(listSysUserRole)){
|
||||
List<String> listStr = listSysUserRole.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<SysRole> querySysRole = new LambdaQueryWrapper();
|
||||
querySysRole.in(SysRole::getId,listStr);
|
||||
List<SysRole> listSysRole = sysRoleService.list(querySysRole);
|
||||
if(!CollectionUtils.isEmpty(listSysRole)){
|
||||
StringBuilder sb = new StringBuilder();
|
||||
listSysRole.forEach(p->{
|
||||
sb.append(p.getRoleCode());
|
||||
if(listSysRole.indexOf(p) != (listSysRole.size() - 1)){
|
||||
sb.append(",");
|
||||
}
|
||||
});
|
||||
loginUser.setRoleCode(sb.toString());
|
||||
}
|
||||
}
|
||||
baseCommonService.addLog("账号: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null, loginUser);
|
||||
//update-end--Author:wangshuai Date:20200714 for:登录日志没有记录人员
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user