|
@@ -28,6 +28,7 @@ import org.jeecg.modules.interlockUser.entity.InterlockUser;
|
|
|
import org.jeecg.modules.interlockUser.entity.InterlockUserAdd;
|
|
|
import org.jeecg.modules.interlockUser.service.IInterlockUserService;
|
|
|
import org.jeecg.modules.interlockUser.service.impl.InterlockUserServiceImpl;
|
|
|
+import org.jeecg.modules.iotedgeCollectData.service.IIotedgeCollectDataService;
|
|
|
import org.jeecg.modules.iotedgeCollectData.service.RestClientService;
|
|
|
import org.jeecg.modules.iotedgeConfig.service.IIotedgeConfigService;
|
|
|
import org.jeecg.modules.iotedgeConfig.util.ConfigInfo;
|
|
@@ -94,6 +95,14 @@ public class SSOLoginLogoutController {
|
|
|
@Autowired
|
|
|
private ISysUserRoleService sysUserRoleService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private IIotedgeCollectDataService iotedgeCollectDataService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private RestClientService restClientService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* sso校验token
|
|
@@ -323,6 +332,16 @@ public class SSOLoginLogoutController {
|
|
|
@RequestMapping(value = "/interlockLogin", method = RequestMethod.POST)
|
|
|
public Result<JSONObject> interlockLogin(HttpServletRequest request, HttpServletResponse response, @RequestBody SysLoginModel sysLoginModel){
|
|
|
|
|
|
+ String elToken = "";
|
|
|
+ Cookie[] cookies = request.getCookies();
|
|
|
+ if (cookies != null) {
|
|
|
+ for (Cookie cookie : cookies) {
|
|
|
+ if (cookie.getName().equals("EIToken")) {
|
|
|
+ elToken = cookie.getValue();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
Result<JSONObject> result = new Result<JSONObject>();
|
|
|
String username = sysLoginModel.getUsername();
|
|
|
String password = sysLoginModel.getPassword();
|
|
@@ -359,11 +378,11 @@ public class SSOLoginLogoutController {
|
|
|
// TODO 已经单点登录成功了的用户如果在本系统不存在,新增用户?
|
|
|
log.info("用户在本系统不存在,新增该用户");
|
|
|
JSONObject addJSONObject = toAddInterlockUserJSONObject(username, ssoRole);
|
|
|
- addInterlockUser(addJSONObject);
|
|
|
+ addInterlockUser(addJSONObject,elToken);
|
|
|
}else{
|
|
|
if(ssoRole.equals("globalAdmin")){//已经存在的用户如果是系统管理员,更新用户、用户角色以及权限表
|
|
|
if(!interlockUser.getRole().equals("0")){
|
|
|
- editInterlockAdminUser(interlockUser);
|
|
|
+ editInterlockAdminUser(interlockUser,elToken);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -386,7 +405,7 @@ public class SSOLoginLogoutController {
|
|
|
jsonObject.put("ssoRole", ssoRole);
|
|
|
return jsonObject;
|
|
|
}
|
|
|
- private void addInterlockUser(JSONObject jsonObject){
|
|
|
+ private void addInterlockUser(JSONObject jsonObject,String elToken){
|
|
|
try{
|
|
|
//创建一个用户类用来存放新增用户的信息;
|
|
|
InterlockUser interlockUser = new InterlockUser();
|
|
@@ -422,13 +441,16 @@ public class SSOLoginLogoutController {
|
|
|
List<InterlockSystemLimit> interlockSystemLimitList = interlockSystemLimitService.getInterlockPtSystemLimitList(username, userId);
|
|
|
interlockSystemLimitService.saveBatch(interlockSystemLimitList);
|
|
|
}
|
|
|
+
|
|
|
+ iotedgeCollectDataService.addIoTedgeUser(username,ssoRole,interlockUser,elToken);
|
|
|
+
|
|
|
baseCommonService.addLog("添加用户,username: " + username, CommonConstant.LOG_TYPE_2, 2);
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void editInterlockAdminUser(InterlockUser interlockUser){
|
|
|
+ private void editInterlockAdminUser(InterlockUser interlockUser,String elToken){
|
|
|
try{
|
|
|
//更新用户信息
|
|
|
interlockUser.setRole("0");//系统管理员
|
|
@@ -444,6 +466,9 @@ public class SSOLoginLogoutController {
|
|
|
interlockSystemLimitService.remove(new QueryWrapper<InterlockSystemLimit>().lambda().eq(InterlockSystemLimit::getInterlockUserId, userId));
|
|
|
List<InterlockSystemLimit> interlockSystemLimitList = interlockSystemLimitService.getInterlockAdminSystemLimitList(interlockUser.getUsername(), userId);
|
|
|
interlockSystemLimitService.saveBatch(interlockSystemLimitList);
|
|
|
+
|
|
|
+ restClientService.setUserRole(interlockUser.getIotUserid(),"","systemAdmin",elToken);
|
|
|
+
|
|
|
baseCommonService.addLog("修改用户,username: " + interlockUser.getUsername(), CommonConstant.LOG_TYPE_2, 2);
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage(), e);
|