fix(iam): 完善对接

This commit is contained in:
yjz
2023-11-21 18:30:28 +08:00
parent f7000760e4
commit 993d0389d6
2 changed files with 173 additions and 211 deletions
@@ -44,6 +44,11 @@ public class ResourceDto {
*/ */
private String redirect; private String redirect;
/**
* 路径
*/
private String url;
/** /**
* 类型(0:一级菜单; 1:子菜单:2:按钮权限) * 类型(0:一级菜单; 1:子菜单:2:按钮权限)
*/ */
@@ -578,7 +578,6 @@ public class SyncIamService {
* 角色创建 * 角色创建
*/ */
public BpmcResponseDto roleCreateService(RoleDto roleDto){ public BpmcResponseDto roleCreateService(RoleDto roleDto){
try {
SysRole sysRole = new SysRole(); SysRole sysRole = new SysRole();
sysRole.setId(roleDto.getId()); sysRole.setId(roleDto.getId());
sysRole.setRoleName(roleDto.getName()); sysRole.setRoleName(roleDto.getName());
@@ -591,11 +590,6 @@ public class SyncIamService {
sysRole.setAppId(roleDto.getAppId()); sysRole.setAppId(roleDto.getAppId());
sysRoleService.save(sysRole); sysRoleService.save(sysRole);
} catch (Exception e){
e.printStackTrace();
return BpmcResponseDto.error(e.getMessage());
}
return BpmcResponseDto.success(); return BpmcResponseDto.success();
} }
@@ -603,7 +597,6 @@ public class SyncIamService {
* 角色更新 * 角色更新
*/ */
public BpmcResponseDto roleUpdateService(RoleDto roleDto){ public BpmcResponseDto roleUpdateService(RoleDto roleDto){
try {
if (CharSequenceUtil.isEmpty(roleDto.getId())){ if (CharSequenceUtil.isEmpty(roleDto.getId())){
return BpmcResponseDto.error("角色id为空,无法更新"); return BpmcResponseDto.error("角色id为空,无法更新");
} }
@@ -639,10 +632,6 @@ public class SyncIamService {
} }
sysRoleService.updateById(sysRole); sysRoleService.updateById(sysRole);
} catch (Exception e){
e.printStackTrace();
return BpmcResponseDto.error(e.getMessage());
}
return BpmcResponseDto.success(); return BpmcResponseDto.success();
} }
@@ -651,16 +640,11 @@ public class SyncIamService {
* 角色删除 * 角色删除
*/ */
public BpmcResponseDto roleDeleteService(RoleDto roleDto){ public BpmcResponseDto roleDeleteService(RoleDto roleDto){
try {
if (CharSequenceUtil.isEmpty(roleDto.getId())){ if (CharSequenceUtil.isEmpty(roleDto.getId())){
return BpmcResponseDto.error("角色id为空,无法删除"); return BpmcResponseDto.error("角色id为空,无法删除");
} }
sysRoleService.deleteRole(roleDto.getId()); sysRoleService.deleteRole(roleDto.getId());
} catch (Exception e){
e.printStackTrace();
return BpmcResponseDto.error(e.getMessage());
}
return BpmcResponseDto.success(); return BpmcResponseDto.success();
} }
@@ -669,7 +653,6 @@ public class SyncIamService {
* 菜单创建 * 菜单创建
*/ */
public BpmcResponseDto resourceCreateService(ResourceDto resourceDto){ public BpmcResponseDto resourceCreateService(ResourceDto resourceDto){
try {
SysPermission sysPermission = new SysPermission(); SysPermission sysPermission = new SysPermission();
sysPermission.setId(resourceDto.getId()); sysPermission.setId(resourceDto.getId());
if (StringUtils.isNotBlank(resourceDto.getParentId())){ if (StringUtils.isNotBlank(resourceDto.getParentId())){
@@ -682,8 +665,11 @@ public class SyncIamService {
sysPermission.setPerms(resourceDto.getCode()); sysPermission.setPerms(resourceDto.getCode());
} }
sysPermission.setComponent(resourceDto.getComponent()); // 组件的路径 sysPermission.setComponent(resourceDto.getComponent()); // 组件的路径
if (StringUtils.isNotBlank(resourceDto.getRedirect())){ if (CharSequenceUtil.isNotEmpty(resourceDto.getRedirect())){
sysPermission.setUrl(resourceDto.getRedirect()); // 地址栏显示的路径 sysPermission.setRedirect(resourceDto.getRedirect()); // 地址栏显示的路径
}
if (CharSequenceUtil.isNotEmpty(resourceDto.getUrl())){
sysPermission.setUrl(resourceDto.getUrl()); // 路径
} }
sysPermission.setAppId(resourceDto.getAppId()); // appId sysPermission.setAppId(resourceDto.getAppId()); // appId
if (!Objects.isNull(resourceDto.getSort())){ if (!Objects.isNull(resourceDto.getSort())){
@@ -728,10 +714,6 @@ public class SyncIamService {
sysPermission.setInternalOrExternal(resourceDto.getInternal_or_external() == 0 ? false : true); sysPermission.setInternalOrExternal(resourceDto.getInternal_or_external() == 0 ? false : true);
sysPermissionService.addPermission(sysPermission); sysPermissionService.addPermission(sysPermission);
} catch (Exception e){
e.printStackTrace();
return BpmcResponseDto.error(e.getMessage());
}
return BpmcResponseDto.success(); return BpmcResponseDto.success();
} }
@@ -769,7 +751,11 @@ public class SyncIamService {
} }
if (CharSequenceUtil.isNotEmpty(resourceDto.getRedirect())){ if (CharSequenceUtil.isNotEmpty(resourceDto.getRedirect())){
sysPermission.setUrl(resourceDto.getRedirect()); // 地址栏显示的路径 sysPermission.setRedirect(resourceDto.getRedirect()); // 地址栏显示的路径
}
if (CharSequenceUtil.isNotEmpty(resourceDto.getUrl())){
sysPermission.setUrl(resourceDto.getUrl()); // 路径
} }
if (resourceDto.getSort() != null){ if (resourceDto.getSort() != null){
@@ -822,17 +808,10 @@ public class SyncIamService {
* 菜单删除(真实删除) * 菜单删除(真实删除)
*/ */
public BpmcResponseDto resourceDeleteService(ResourceDto resourceDto){ public BpmcResponseDto resourceDeleteService(ResourceDto resourceDto){
try {
if (CharSequenceUtil.isEmpty(resourceDto.getId())){ if (CharSequenceUtil.isEmpty(resourceDto.getId())){
return BpmcResponseDto.error("菜单id为空,无法删除"); return BpmcResponseDto.error("菜单id为空,无法删除");
} }
sysPermissionService.deletePermission(resourceDto.getId()); sysPermissionService.deletePermission(resourceDto.getId());
} catch (Exception e){
e.printStackTrace();
return BpmcResponseDto.error(e.getMessage());
}
return BpmcResponseDto.success(); return BpmcResponseDto.success();
} }
@@ -840,7 +819,6 @@ public class SyncIamService {
* 用户角色关联 创建(批量) * 用户角色关联 创建(批量)
*/ */
public BpmcResponseDto userRoleCreateService(List<UserRoleDto> userRoleDtoList){ public BpmcResponseDto userRoleCreateService(List<UserRoleDto> userRoleDtoList){
try {
List<SysUserRole> userRoleList = new ArrayList<>(); List<SysUserRole> userRoleList = new ArrayList<>();
for (UserRoleDto userRoleDto : userRoleDtoList){ for (UserRoleDto userRoleDto : userRoleDtoList){
@@ -868,10 +846,6 @@ public class SyncIamService {
} }
} }
this.sysUserRoleService.saveBatch(userRoleList); this.sysUserRoleService.saveBatch(userRoleList);
} catch (Exception e){
e.printStackTrace();
return BpmcResponseDto.error(e.getMessage());
}
return BpmcResponseDto.success(); return BpmcResponseDto.success();
} }
@@ -880,9 +854,8 @@ public class SyncIamService {
* 用户角色关联 刪除(批量) * 用户角色关联 刪除(批量)
*/ */
public BpmcResponseDto userRoleDeleteService(List<UserRoleDto> userRoleDtoList){ public BpmcResponseDto userRoleDeleteService(List<UserRoleDto> userRoleDtoList){
try {
for (UserRoleDto userRoleDto : userRoleDtoList){ for (UserRoleDto userRoleDto : userRoleDtoList){
QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<SysUserRole>(); QueryWrapper<SysUserRole> queryWrapper = new QueryWrapper<>();
// 根据 accountCode 字段(即用户名username) 从数据库里查出来用户id,在给到sysUserRole // 根据 accountCode 字段(即用户名username) 从数据库里查出来用户id,在给到sysUserRole
LoginUser userInfo = sysBaseAPI.getUserByName(userRoleDto.getAccountCode()); LoginUser userInfo = sysBaseAPI.getUserByName(userRoleDto.getAccountCode());
if (userInfo == null){ if (userInfo == null){
@@ -894,11 +867,6 @@ public class SyncIamService {
this.sysUserRoleService.remove(queryWrapper); this.sysUserRoleService.remove(queryWrapper);
} }
} catch (Exception e){
e.printStackTrace();
return BpmcResponseDto.error(e.getMessage());
}
return BpmcResponseDto.success(); return BpmcResponseDto.success();
} }
@@ -906,7 +874,6 @@ public class SyncIamService {
* 角色菜单关联 创建(批量) * 角色菜单关联 创建(批量)
*/ */
public BpmcResponseDto roleResourceCreateService(List<RoleResourceDto> roleResourceDtoList){ public BpmcResponseDto roleResourceCreateService(List<RoleResourceDto> roleResourceDtoList){
try {
List<SysRolePermission> sysRolePermissionList = new ArrayList<>(); List<SysRolePermission> sysRolePermissionList = new ArrayList<>();
for (RoleResourceDto roleResourceDto : roleResourceDtoList){ for (RoleResourceDto roleResourceDto : roleResourceDtoList){
@@ -923,11 +890,6 @@ public class SyncIamService {
sysRolePermissionList.add(sysRolePermission); sysRolePermissionList.add(sysRolePermission);
} }
this.sysRolePermissionService.saveBatch(sysRolePermissionList); this.sysRolePermissionService.saveBatch(sysRolePermissionList);
} catch (Exception e){
e.printStackTrace();
return BpmcResponseDto.error(e.getMessage());
}
return BpmcResponseDto.success(); return BpmcResponseDto.success();
} }
@@ -935,7 +897,6 @@ public class SyncIamService {
* 用户角色关联 刪除(批量) * 用户角色关联 刪除(批量)
*/ */
public BpmcResponseDto roleResourceDeleteService(List<RoleResourceDto> roleResourceDtoList){ public BpmcResponseDto roleResourceDeleteService(List<RoleResourceDto> roleResourceDtoList){
try {
for (RoleResourceDto roleResourceDto : roleResourceDtoList){ for (RoleResourceDto roleResourceDto : roleResourceDtoList){
QueryWrapper<SysRolePermission> queryWrapper = new QueryWrapper<>(); QueryWrapper<SysRolePermission> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("permission_id", roleResourceDto.getAmId()); queryWrapper.eq("permission_id", roleResourceDto.getAmId());
@@ -943,10 +904,6 @@ public class SyncIamService {
this.sysRolePermissionService.remove(queryWrapper); this.sysRolePermissionService.remove(queryWrapper);
} }
} catch (Exception e){
e.printStackTrace();
return BpmcResponseDto.error(e.getMessage());
}
return BpmcResponseDto.success(); return BpmcResponseDto.success();
} }