【添加】角色 增/改/删 接口处理完毕
This commit is contained in:
+20
-6
@@ -3,7 +3,7 @@ package com.jero.modules.docking.iam.controller;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.jero.modules.docking.iam.dto.bpmc.BpmcAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.bpmc.*;
|
||||
import com.jero.modules.docking.iam.dto.IamCommonAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamOrgAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamUserAcceptDto;
|
||||
@@ -248,7 +248,7 @@ public class SyncIamController {
|
||||
* 通过type字段来区分
|
||||
*/
|
||||
@PostMapping({"/OrgDeleteService"})
|
||||
public BpmcResponseDto bpmcCreate(@RequestBody BpmcAcceptDto bpmcAcceptDto){
|
||||
public BpmcResponseDto bpmcCreate(@RequestBody BpmcAcceptDto bpmcAcceptDto) throws JsonProcessingException {
|
||||
if (StrUtil.isEmpty(bpmcAcceptDto.getType())){
|
||||
return BpmcResponseDto.error("接口类型(type)未传参,请检查");
|
||||
}
|
||||
@@ -271,21 +271,35 @@ public class SyncIamController {
|
||||
return BpmcResponseDto.error("签名校验不通过,请检查");
|
||||
}
|
||||
|
||||
BpmcResponseDto bpmcResponseDto = BpmcResponseDto.success();
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
// 分接口类型分别处理
|
||||
if (bpmcAcceptDto.getType().equals(DockingConstant.BPMC_TYPE_ROLE)){
|
||||
|
||||
RoleDto roleDto = objectMapper.readValue(bpmcAcceptDto.getEntity(), RoleDto.class);
|
||||
// 根据新增/编辑/删除调用不同的业务处理代码
|
||||
if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_ADD)){
|
||||
bpmcResponseDto = this.syncIamService.roleCreateService(roleDto);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_UPDATE)) {
|
||||
bpmcResponseDto = this.syncIamService.roleUpdateService(roleDto);
|
||||
} else if (bpmcAcceptDto.getAction().equals(DockingConstant.BPMC_ACTION_DELETE)) {
|
||||
bpmcResponseDto = this.syncIamService.roleDeleteService(roleDto);
|
||||
}
|
||||
}
|
||||
|
||||
if (bpmcAcceptDto.getType().equals(DockingConstant.BPMC_TYPE_RESOURCE)){
|
||||
|
||||
ResourceDto resourceDto = objectMapper.readValue(bpmcAcceptDto.getEntity(), ResourceDto.class);
|
||||
// 根据新增/编辑/删除调用不同的业务处理代码
|
||||
}
|
||||
|
||||
if (bpmcAcceptDto.getType().equals(DockingConstant.BPMC_TYPE_USER_ROLE)){
|
||||
|
||||
UserRoleDto userRoleDto = objectMapper.readValue(bpmcAcceptDto.getEntity(), UserRoleDto.class);
|
||||
// 根据新增/编辑/删除调用不同的业务处理代码
|
||||
}
|
||||
|
||||
if (bpmcAcceptDto.getType().equals(DockingConstant.BPMC_TYPE_ROLE_RESOURCE)){
|
||||
|
||||
RoleResourceDto roleResourceDto = objectMapper.readValue(bpmcAcceptDto.getEntity(), RoleResourceDto.class);
|
||||
// 根据新增/编辑/删除调用不同的业务处理代码
|
||||
}
|
||||
|
||||
return BpmcResponseDto.success();
|
||||
|
||||
+86
@@ -16,6 +16,7 @@ import com.jero.modules.docking.iam.annotation.IamProperty;
|
||||
import com.jero.modules.docking.iam.dto.IamCommonAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamOrgAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.IamUserAcceptDto;
|
||||
import com.jero.modules.docking.iam.dto.bpmc.RoleDto;
|
||||
import com.jero.modules.docking.iam.dto.response.*;
|
||||
import com.jero.modules.docking.iam.exception.IamGlobalException;
|
||||
import com.jero.modules.docking.iam.po.MessageHeader;
|
||||
@@ -23,8 +24,10 @@ import com.jero.modules.docking.iam.po.SendPoSystemPo;
|
||||
import com.jero.modules.docking.iam.po.SendReturnsPo;
|
||||
import com.jero.modules.docking.utils.DockingConstant;
|
||||
import com.jero.modules.system.entity.SysDepart;
|
||||
import com.jero.modules.system.entity.SysRole;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.service.ISysDepartService;
|
||||
import com.jero.modules.system.service.ISysRoleService;
|
||||
import com.jero.modules.system.service.ISysUserService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@@ -59,6 +62,9 @@ public class SyncIamService {
|
||||
@Resource
|
||||
private ISysDepartService sysDepartService;
|
||||
|
||||
@Resource
|
||||
private ISysRoleService sysRoleService;
|
||||
|
||||
/**
|
||||
* 校验IAM调用时的账号密码是否正确
|
||||
* 校验通过了正常走后续,不通过直接返回
|
||||
@@ -586,4 +592,84 @@ public class SyncIamService {
|
||||
return sendPoSystemPo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色创建
|
||||
*/
|
||||
public BpmcResponseDto roleCreateService(RoleDto roleDto){
|
||||
try {
|
||||
SysRole sysRole = new SysRole();
|
||||
sysRole.setId(roleDto.getId());
|
||||
sysRole.setRoleName(roleDto.getName());
|
||||
sysRole.setRoleCode(roleDto.getCode());
|
||||
sysRole.setDescription(roleDto.getDescription());
|
||||
sysRole.setCreateBy(DockingConstant.IAM_SYSTEM_NAME);
|
||||
sysRole.setCreateTime(roleDto.getCreateTime());
|
||||
sysRole.setUpdateBy(DockingConstant.IAM_SYSTEM_NAME);
|
||||
sysRole.setUpdateTime(roleDto.getModifyTime());
|
||||
|
||||
sysRoleService.save(sysRole);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return BpmcResponseDto.error(e.getMessage());
|
||||
}
|
||||
|
||||
return BpmcResponseDto.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色更新
|
||||
*/
|
||||
public BpmcResponseDto roleUpdateService(RoleDto roleDto){
|
||||
try {
|
||||
if (StrUtil.isEmpty(roleDto.getId())){
|
||||
return BpmcResponseDto.error("角色id为空,无法更新");
|
||||
}
|
||||
|
||||
SysRole sysRole = sysRoleService.getById(roleDto.getId());
|
||||
|
||||
if (StrUtil.isNotEmpty(roleDto.getName())){
|
||||
sysRole.setRoleName(roleDto.getName());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(roleDto.getCode())){
|
||||
sysRole.setRoleCode(roleDto.getCode());
|
||||
}
|
||||
|
||||
if (StrUtil.isNotEmpty(roleDto.getDescription())){
|
||||
sysRole.setDescription(roleDto.getDescription());
|
||||
}
|
||||
|
||||
sysRole.setUpdateBy(DockingConstant.IAM_SYSTEM_NAME);
|
||||
|
||||
if (roleDto.getModifyTime() != null){
|
||||
sysRole.setUpdateTime(roleDto.getModifyTime());
|
||||
}
|
||||
|
||||
sysRoleService.updateById(sysRole);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return BpmcResponseDto.error(e.getMessage());
|
||||
}
|
||||
|
||||
return BpmcResponseDto.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 角色删除
|
||||
*/
|
||||
public BpmcResponseDto roleDeleteService(RoleDto roleDto){
|
||||
try {
|
||||
if (StrUtil.isEmpty(roleDto.getId())){
|
||||
return BpmcResponseDto.error("角色id为空,无法删除");
|
||||
}
|
||||
|
||||
sysRoleService.deleteRole(roleDto.getId());
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return BpmcResponseDto.error(e.getMessage());
|
||||
}
|
||||
|
||||
return BpmcResponseDto.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+14
@@ -55,4 +55,18 @@ public class DockingConstant {
|
||||
*/
|
||||
public static String BPMC_TYPE_ROLE_RESOURCE = "R_AR_AM";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,操作类型:新增
|
||||
*/
|
||||
public static String BPMC_ACTION_ADD = "add";
|
||||
/**
|
||||
* 竹云统一认证平台,操作类型:更新
|
||||
*/
|
||||
public static String BPMC_ACTION_UPDATE = "update";
|
||||
|
||||
/**
|
||||
* 竹云统一认证平台,操作类型:删除
|
||||
*/
|
||||
public static String BPMC_ACTION_DELETE = "delete";
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user