| | |
| | | package com.moral.service.impl;
|
| | |
|
| | | import com.alibaba.fastjson.JSON;
|
| | | import com.github.pagehelper.PageHelper;
|
| | | import com.moral.common.bean.Constants;
|
| | | import com.moral.common.bean.PageBean;
|
| | | import com.moral.common.exception.BusinessException;
|
| | | import com.moral.common.util.ExampleUtil;
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.entity.Organization;
|
| | |
| | | }else{
|
| | | organizationMapper.updateByPrimaryKey(organization);
|
| | | }
|
| | | //更新父组织关系
|
| | | addOrModifyOrgRelation(organization);
|
| | | if(organization.getId()!=null && !organization.getId().equals(organization.getParentId())){
|
| | | List<Integer> orgIds = organizationMapper.selectLowerOrgIds(organization.getId());
|
| | | boolean isChild = orgIds.stream().anyMatch(
|
| | | item -> {
|
| | | return item!=null && item.equals(organization.getParentId());
|
| | | }
|
| | | );
|
| | | // 非子孙组织才能设为父组织,避免闭环脏数据
|
| | | if(!isChild){
|
| | | //更新父组织关系
|
| | | addOrModifyOrgRelation(organization);
|
| | | }else{
|
| | | throw new BusinessException("cannot set the children as father,organization:"+ JSON.toJSONString(organization));
|
| | | }
|
| | | }else {
|
| | | throw new BusinessException("id of organization can't equal to it's parentId,organization:"+ JSON.toJSONString(organization));
|
| | | }
|
| | | }
|
| | | catch (Exception ex){
|
| | | throw ex;
|