【添加】添加组织机构 编辑/删除 接口逻辑
This commit is contained in:
+49
-5
@@ -170,7 +170,7 @@ public class SyncIamController {
|
|||||||
// 校验身份认证,确保接口正确 必须调用!
|
// 校验身份认证,确保接口正确 必须调用!
|
||||||
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||||
|
|
||||||
// 处理业务逻辑,存储用户,返回用户id
|
// 处理业务逻辑,存储组织,返回组织id
|
||||||
IamOrgCreateResponse iamOrgCreateResponse = this.syncIamService.orgCreateService(orgAcceptDto);
|
IamOrgCreateResponse iamOrgCreateResponse = this.syncIamService.orgCreateService(orgAcceptDto);
|
||||||
|
|
||||||
// 处理统一响应PO层,并加密业务字段
|
// 处理统一响应PO层,并加密业务字段
|
||||||
@@ -181,15 +181,59 @@ public class SyncIamController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping({"/OrgUpdateService"})
|
@PostMapping({"/OrgUpdateService"})
|
||||||
public SendPoSystemPo orgUpdateService(@RequestBody AcceptPoSystemPo<IamUserAcceptDto> iamOrgInfo) {
|
public SendPoSystemPo orgUpdateService(@RequestBody AcceptPoSystemPo<IamUserAcceptDto> iamOrgInfo) throws JsonProcessingException {
|
||||||
SendPoSystemPo sendPoSystemPo = new SendPoSystemPo();
|
if (iamOrgInfo == null
|
||||||
|
|| iamOrgInfo.getMessageTabels() == null
|
||||||
|
|| iamOrgInfo.getMessageTabels().getHeader() == null
|
||||||
|
|| iamOrgInfo.getMessageTabels().getHeader().getData() == null){
|
||||||
|
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对核心数据解密
|
||||||
|
String bodyParam = iamOrgInfo.getMessageTabels().getHeader().getData();
|
||||||
|
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
IamOrgAcceptDto orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||||
|
|
||||||
|
// 校验身份认证,确保接口正确 必须调用!
|
||||||
|
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||||
|
|
||||||
|
// 处理业务逻辑,更新组织
|
||||||
|
IamCommonResponseDto iamCommonResponseDto = this.syncIamService.orgUpdateService(orgAcceptDto);
|
||||||
|
|
||||||
|
// 处理统一响应PO层,并加密业务字段
|
||||||
|
MessageHeader acceptMessageHeader = iamOrgInfo.getMessageHeader();
|
||||||
|
SendPoSystemPo sendPoSystemPo = this.syncIamService.handlerGloablResponse(acceptMessageHeader, iamCommonResponseDto);
|
||||||
|
|
||||||
return sendPoSystemPo;
|
return sendPoSystemPo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping({"/OrgDeleteService"})
|
@PostMapping({"/OrgDeleteService"})
|
||||||
public SendPoSystemPo orgDeleteService(@RequestBody AcceptPoSystemPo<IamUserAcceptDto> iamOrgInfo) {
|
public SendPoSystemPo orgDeleteService(@RequestBody AcceptPoSystemPo<IamUserAcceptDto> iamOrgInfo) throws JsonProcessingException {
|
||||||
SendPoSystemPo sendPoSystemPo = new SendPoSystemPo();
|
if (iamOrgInfo == null
|
||||||
|
|| iamOrgInfo.getMessageTabels() == null
|
||||||
|
|| iamOrgInfo.getMessageTabels().getHeader() == null
|
||||||
|
|| iamOrgInfo.getMessageTabels().getHeader().getData() == null){
|
||||||
|
throw new IamGlobalException(null, "参数传递错误,未收到参数");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对核心数据解密
|
||||||
|
String bodyParam = iamOrgInfo.getMessageTabels().getHeader().getData();
|
||||||
|
String bodyParamDecrypt = BamboocloudUtils.getPlaintext(bodyParam, DockingConstant.IAM_ENCRYPT_SECRET, DockingConstant.IAM_ENCRYPT_TYPE);
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
IamOrgAcceptDto orgAcceptDto = objectMapper.readValue(bodyParamDecrypt, IamOrgAcceptDto.class);
|
||||||
|
|
||||||
|
// 校验身份认证,确保接口正确 必须调用!
|
||||||
|
this.syncIamService.validateUserAndPwd(orgAcceptDto);
|
||||||
|
|
||||||
|
// 处理业务逻辑,更新组织
|
||||||
|
IamCommonResponseDto iamCommonResponseDto = this.syncIamService.orgDeleteService(orgAcceptDto);
|
||||||
|
|
||||||
|
// 处理统一响应PO层,并加密业务字段
|
||||||
|
MessageHeader acceptMessageHeader = iamOrgInfo.getMessageHeader();
|
||||||
|
SendPoSystemPo sendPoSystemPo = this.syncIamService.handlerGloablResponse(acceptMessageHeader, iamCommonResponseDto);
|
||||||
|
|
||||||
return sendPoSystemPo;
|
return sendPoSystemPo;
|
||||||
}
|
}
|
||||||
|
|||||||
+116
-2
@@ -223,6 +223,9 @@ public class SyncIamService {
|
|||||||
|
|
||||||
// 取出对应的SysUser数据,将iam的数据全部抓取进行判空赋值后存入
|
// 取出对应的SysUser数据,将iam的数据全部抓取进行判空赋值后存入
|
||||||
SysUser sysUser = this.sysUserService.getById(userAcceptDto.getBimUid());
|
SysUser sysUser = this.sysUserService.getById(userAcceptDto.getBimUid());
|
||||||
|
if (sysUser == null){
|
||||||
|
throw new IamGlobalException(userAcceptDto.getBimRequestId(), "未查询到id为(" + userAcceptDto.getBimUid() + ")用户,无法更新");
|
||||||
|
}
|
||||||
|
|
||||||
if (StrUtil.isNotEmpty(userAcceptDto.getSrmsUsername())){
|
if (StrUtil.isNotEmpty(userAcceptDto.getSrmsUsername())){
|
||||||
sysUser.setUsername(userAcceptDto.getSrmsUsername());
|
sysUser.setUsername(userAcceptDto.getSrmsUsername());
|
||||||
@@ -412,8 +415,15 @@ public class SyncIamService {
|
|||||||
|
|
||||||
sysDepart.setOrgType(orgAcceptDto.getSrmsType());
|
sysDepart.setOrgType(orgAcceptDto.getSrmsType());
|
||||||
sysDepart.setOrgCode(orgAcceptDto.getSrmsOrgCode());
|
sysDepart.setOrgCode(orgAcceptDto.getSrmsOrgCode());
|
||||||
sysDepart.setStatus(CommonConstant.STATUS_1);
|
|
||||||
sysDepart.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
if ("1".equals(orgAcceptDto.getSrmsStatus())){
|
||||||
|
sysDepart.setStatus(CommonConstant.STATUS_1);
|
||||||
|
sysDepart.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||||
|
} else {
|
||||||
|
sysDepart.setStatus(CommonConstant.STATUS_0);
|
||||||
|
sysDepart.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_1));
|
||||||
|
}
|
||||||
|
|
||||||
sysDepart.setCreateBy(DockingConstant.IAM_SYSTEM_NAME);
|
sysDepart.setCreateBy(DockingConstant.IAM_SYSTEM_NAME);
|
||||||
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsCreateTime())){
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsCreateTime())){
|
||||||
Date createTime = DateUtils.str2Date(orgAcceptDto.getSrmsCreateTime(), new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"));
|
Date createTime = DateUtils.str2Date(orgAcceptDto.getSrmsCreateTime(), new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"));
|
||||||
@@ -439,6 +449,110 @@ public class SyncIamService {
|
|||||||
return iamOrgCreateResponse;
|
return iamOrgCreateResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新组织机构
|
||||||
|
* @param orgAcceptDto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IamCommonResponseDto orgUpdateService(IamOrgAcceptDto orgAcceptDto){
|
||||||
|
if (orgAcceptDto == null || StrUtil.isEmpty(orgAcceptDto.getBimOrgId())){
|
||||||
|
throw new IamGlobalException(orgAcceptDto.getBimRequestId(), "机构id为空,无法进行组织信息更新");
|
||||||
|
}
|
||||||
|
|
||||||
|
IamCommonResponseDto iamCommonResponseDto = new IamCommonResponseDto();
|
||||||
|
iamCommonResponseDto.setBimRequestId(orgAcceptDto.getBimRequestId());
|
||||||
|
iamCommonResponseDto.setResultCode(DockingConstant.IAM_SUCCESS_RESULT_CODE);
|
||||||
|
iamCommonResponseDto.setMessage(DockingConstant.IAM_SUCCESS_MESSAGE);
|
||||||
|
|
||||||
|
// 将iam的数据转换成sysDepart数据存入数据库
|
||||||
|
SysDepart sysDepart = this.sysDepartService.getById(orgAcceptDto.getBimOrgId());
|
||||||
|
if (sysDepart == null){
|
||||||
|
throw new IamGlobalException(orgAcceptDto.getBimRequestId(), "未查询到id为(" + orgAcceptDto.getBimOrgId() + ")组织,无法更新");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsParentCode())){
|
||||||
|
sysDepart.setParentId(orgAcceptDto.getSrmsParentCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsDepartName())){
|
||||||
|
sysDepart.setDepartName(orgAcceptDto.getSrmsDepartName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsOrgCategory())){
|
||||||
|
// 1为单位,2为部门,转映射到 本系统内的数据 1公司,2组织机构,映射关系一致。如下代码是为了后续修改方便
|
||||||
|
if ("1".equals(orgAcceptDto.getSrmsOrgCategory())){
|
||||||
|
sysDepart.setOrgCategory("1");
|
||||||
|
} else {
|
||||||
|
sysDepart.setOrgCategory("2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsType())){
|
||||||
|
sysDepart.setOrgType(orgAcceptDto.getSrmsType());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsOrgCode())){
|
||||||
|
sysDepart.setOrgCode(orgAcceptDto.getSrmsOrgCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsStatus())){
|
||||||
|
if ("1".equals(orgAcceptDto.getSrmsStatus())){
|
||||||
|
sysDepart.setStatus(CommonConstant.STATUS_1);
|
||||||
|
sysDepart.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||||
|
} else {
|
||||||
|
sysDepart.setStatus(CommonConstant.STATUS_0);
|
||||||
|
sysDepart.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sysDepart.setUpdateBy(DockingConstant.IAM_SYSTEM_NAME);
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsUpdateTime())){
|
||||||
|
Date updateTime = DateUtils.str2Date(orgAcceptDto.getSrmsUpdateTime(), new SimpleDateFormat("YYYY-MM-dd HH:mm:ss"));
|
||||||
|
sysDepart.setCreateTime(updateTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsCompany())){
|
||||||
|
sysDepart.setCompany(orgAcceptDto.getSrmsCompany());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsHeadOfDepartment())){
|
||||||
|
sysDepart.setHeadOfDepartment(orgAcceptDto.getSrmsHeadOfDepartment());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsLeadersInCharge())){
|
||||||
|
sysDepart.setLeadersInCharge(orgAcceptDto.getSrmsLeadersInCharge());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrUtil.isNotEmpty(orgAcceptDto.getSrmsDeputyLeader())){
|
||||||
|
sysDepart.setDeputyLeader(orgAcceptDto.getSrmsDeputyLeader());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 存储到组织机构表中
|
||||||
|
this.sysDepartService.updateById(sysDepart);
|
||||||
|
|
||||||
|
return iamCommonResponseDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除组织机构
|
||||||
|
* @param orgAcceptDto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public IamCommonResponseDto orgDeleteService(IamOrgAcceptDto orgAcceptDto){
|
||||||
|
if (orgAcceptDto == null || StrUtil.isEmpty(orgAcceptDto.getBimOrgId())){
|
||||||
|
throw new IamGlobalException(orgAcceptDto.getBimRequestId(), "用户id(bimUid)为空,无法进行组织删除");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.sysDepartService.delete(orgAcceptDto.getBimOrgId());
|
||||||
|
|
||||||
|
IamCommonResponseDto iamCommonResponseDto = new IamCommonResponseDto();
|
||||||
|
iamCommonResponseDto.setBimRequestId(orgAcceptDto.getBimRequestId());
|
||||||
|
iamCommonResponseDto.setResultCode(DockingConstant.IAM_SUCCESS_RESULT_CODE);
|
||||||
|
iamCommonResponseDto.setMessage(DockingConstant.IAM_SUCCESS_MESSAGE);
|
||||||
|
|
||||||
|
return iamCommonResponseDto;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理统一响应PO层,并加密业务字段
|
* 处理统一响应PO层,并加密业务字段
|
||||||
* @param acceptMessageHeader
|
* @param acceptMessageHeader
|
||||||
|
|||||||
Reference in New Issue
Block a user