|
@@ -3,6 +3,7 @@ package org.jeecg.modules.ssoClient.controller;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
@@ -359,6 +360,12 @@ public class SSOLoginLogoutController {
|
|
log.info("用户在本系统不存在,新增该用户");
|
|
log.info("用户在本系统不存在,新增该用户");
|
|
JSONObject addJSONObject = toAddInterlockUserJSONObject(username, ssoRole);
|
|
JSONObject addJSONObject = toAddInterlockUserJSONObject(username, ssoRole);
|
|
addInterlockUser(addJSONObject);
|
|
addInterlockUser(addJSONObject);
|
|
|
|
+ }else{
|
|
|
|
+ if(ssoRole.equals("globalAdmin")){//已经存在的用户如果是系统管理员,更新用户、用户角色以及权限表
|
|
|
|
+ if(!interlockUser.getRole().equals("0")){
|
|
|
|
+ editInterlockAdminUser(interlockUser);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// SysUser sysUser1 = sysUserService.getUserAll(username);
|
|
// SysUser sysUser1 = sysUserService.getUserAll(username);
|
|
@@ -409,7 +416,10 @@ public class SSOLoginLogoutController {
|
|
//创建一个用户权限列表,用来存放系统权限信息 填充权限信息列表
|
|
//创建一个用户权限列表,用来存放系统权限信息 填充权限信息列表
|
|
//系统管理员获取全部权限,否则无任何权限
|
|
//系统管理员获取全部权限,否则无任何权限
|
|
if(isAdmin.equals("1")){
|
|
if(isAdmin.equals("1")){
|
|
- List<InterlockSystemLimit> interlockSystemLimitList = interlockSystemLimitService.getInterlockSystemLimitList(username, userId);
|
|
|
|
|
|
+ List<InterlockSystemLimit> interlockSystemLimitList = interlockSystemLimitService.getInterlockAdminSystemLimitList(username, userId);
|
|
|
|
+ interlockSystemLimitService.saveBatch(interlockSystemLimitList);
|
|
|
|
+ }else{
|
|
|
|
+ List<InterlockSystemLimit> interlockSystemLimitList = interlockSystemLimitService.getInterlockPtSystemLimitList(username, userId);
|
|
interlockSystemLimitService.saveBatch(interlockSystemLimitList);
|
|
interlockSystemLimitService.saveBatch(interlockSystemLimitList);
|
|
}
|
|
}
|
|
baseCommonService.addLog("添加用户,username: " + username, CommonConstant.LOG_TYPE_2, 2);
|
|
baseCommonService.addLog("添加用户,username: " + username, CommonConstant.LOG_TYPE_2, 2);
|
|
@@ -418,6 +428,28 @@ public class SSOLoginLogoutController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void editInterlockAdminUser(InterlockUser interlockUser){
|
|
|
|
+ try{
|
|
|
|
+ //更新用户信息
|
|
|
|
+ interlockUser.setRole("0");//系统管理员
|
|
|
|
+ interlockUserService.updateById(interlockUser);
|
|
|
|
+ String userId = interlockUser.getId();
|
|
|
|
+
|
|
|
|
+ //先删后加 用户角色表
|
|
|
|
+ sysUserRoleService.remove(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, userId));
|
|
|
|
+ SysUserRole userRole = new SysUserRole(userId, "1820384671259701250");
|
|
|
|
+ sysUserRoleService.save(userRole);
|
|
|
|
+
|
|
|
|
+ //先删后加 系统权限表
|
|
|
|
+ interlockSystemLimitService.remove(new QueryWrapper<InterlockSystemLimit>().lambda().eq(InterlockSystemLimit::getInterlockUserId, userId));
|
|
|
|
+ List<InterlockSystemLimit> interlockSystemLimitList = interlockSystemLimitService.getInterlockAdminSystemLimitList(interlockUser.getUsername(), userId);
|
|
|
|
+ interlockSystemLimitService.saveBatch(interlockSystemLimitList);
|
|
|
|
+ baseCommonService.addLog("修改用户,username: " + interlockUser.getUsername(), CommonConstant.LOG_TYPE_2, 2);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(e.getMessage(), e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private JSONObject toAddJSONObject(String username, String password){
|
|
private JSONObject toAddJSONObject(String username, String password){
|
|
JSONObject jsonObject = new JSONObject();
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("workNo", "");
|
|
jsonObject.put("workNo", "");
|