|
@@ -93,7 +93,7 @@ public class UserCommonModuleServiceImpl extends ServiceImpl<UserCommonModuleMap
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public HttpRespMsg addCommonModules(String moduleIds,HttpServletRequest request) {
|
|
|
|
|
|
+ public HttpRespMsg addOrUpdateCommonModules(String moduleIds,HttpServletRequest request) {
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
User user= userMapper.selectById(request.getHeader("token"));
|
|
User user= userMapper.selectById(request.getHeader("token"));
|
|
if(null == user){
|
|
if(null == user){
|
|
@@ -106,30 +106,32 @@ public class UserCommonModuleServiceImpl extends ServiceImpl<UserCommonModuleMap
|
|
}
|
|
}
|
|
List<Integer> moduleIdList = Arrays.stream(moduleIds.split(",")).map(Integer::parseInt).collect(Collectors.toList());
|
|
List<Integer> moduleIdList = Arrays.stream(moduleIds.split(",")).map(Integer::parseInt).collect(Collectors.toList());
|
|
//是否已存在
|
|
//是否已存在
|
|
- Integer count = userCommonModuleMapper.selectCount(new LambdaQueryWrapper<UserCommonModule>()
|
|
|
|
- .in(UserCommonModule::getModuleId, moduleIdList)
|
|
|
|
- .eq(UserCommonModule::getUserId, user.getId())
|
|
|
|
- );
|
|
|
|
- if(count > 0){
|
|
|
|
- httpRespMsg.setError("已存在选中的常用模块");
|
|
|
|
- return httpRespMsg;
|
|
|
|
- }
|
|
|
|
|
|
+// Integer count = userCommonModuleMapper.selectCount(new LambdaQueryWrapper<UserCommonModule>()
|
|
|
|
+// .in(UserCommonModule::getModuleId, moduleIdList)
|
|
|
|
+// .eq(UserCommonModule::getUserId, user.getId())
|
|
|
|
+// );
|
|
|
|
+// if(count > 0){
|
|
|
|
+// httpRespMsg.setError("已存在选中的常用模块");
|
|
|
|
+// return httpRespMsg;
|
|
|
|
+// }
|
|
//是否有权限
|
|
//是否有权限
|
|
Integer roleModuleCount = sysRoleModuleMapper.selectCount(new LambdaQueryWrapper<SysRoleModule>()
|
|
Integer roleModuleCount = sysRoleModuleMapper.selectCount(new LambdaQueryWrapper<SysRoleModule>()
|
|
.in(SysRoleModule::getModuleId, moduleIdList)
|
|
.in(SysRoleModule::getModuleId, moduleIdList)
|
|
.eq(SysRoleModule::getRoleId, user.getRoleId())
|
|
.eq(SysRoleModule::getRoleId, user.getRoleId())
|
|
);
|
|
);
|
|
- if(roleModuleCount <= moduleIdList.size()){
|
|
|
|
|
|
+ if(roleModuleCount < moduleIdList.size()){
|
|
httpRespMsg.setError("无模块权限");
|
|
httpRespMsg.setError("无模块权限");
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
|
|
+ //12-20 修改为删除覆盖逻辑
|
|
//计算seq
|
|
//计算seq
|
|
- UserCommonModule lastModule = userCommonModuleMapper.selectOne(new LambdaQueryWrapper<UserCommonModule>()
|
|
|
|
- .eq(UserCommonModule::getUserId, user.getId())
|
|
|
|
- .orderByDesc(UserCommonModule::getSeq)
|
|
|
|
- .last("limit 1")
|
|
|
|
- );
|
|
|
|
- int index = null==lastModule?1:lastModule.getSeq()+1;
|
|
|
|
|
|
+// UserCommonModule lastModule = userCommonModuleMapper.selectOne(new LambdaQueryWrapper<UserCommonModule>()
|
|
|
|
+// .eq(UserCommonModule::getUserId, user.getId())
|
|
|
|
+// .orderByDesc(UserCommonModule::getSeq)
|
|
|
|
+// .last("limit 1")
|
|
|
|
+// );
|
|
|
|
+// int index = null==lastModule?1:lastModule.getSeq()+1;
|
|
|
|
+ int index = 1;
|
|
List<UserCommonModule> toAddList = new ArrayList<>();
|
|
List<UserCommonModule> toAddList = new ArrayList<>();
|
|
for (Integer moduleId : moduleIdList) {
|
|
for (Integer moduleId : moduleIdList) {
|
|
UserCommonModule entity = new UserCommonModule();
|
|
UserCommonModule entity = new UserCommonModule();
|
|
@@ -140,6 +142,9 @@ public class UserCommonModuleServiceImpl extends ServiceImpl<UserCommonModuleMap
|
|
toAddList.add(entity);
|
|
toAddList.add(entity);
|
|
index++;
|
|
index++;
|
|
}
|
|
}
|
|
|
|
+ userCommonModuleMapper.delete(new LambdaQueryWrapper<UserCommonModule>()
|
|
|
|
+ .eq(UserCommonModule::getUserId, user.getId())
|
|
|
|
+ );
|
|
userCommonModuleMapper.insertBatch(toAddList);
|
|
userCommonModuleMapper.insertBatch(toAddList);
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|