src/main/java/com/moral/common/aop/ControllerAOP.java
@@ -53,7 +53,10 @@ Method currentMethod = target.getClass().getMethod(msig.getName(), msig.getParameterTypes()); Type type = currentMethod.getGenericReturnType(); String message = e.getMessage(); Map<String, Object> resultMap = new HashMap<String, Object>(); if (e instanceof BusinessException) { log.error(e.getMessage()); resultMap.put("msg", message); } else if (e instanceof ValidateException) { } else { log.error(pjp.getSignature() + " error: " + e.toString(), e); @@ -66,7 +69,6 @@ } else if (type == ResultBean.class) { return new ResultBean(e); } else if (type == Map.class) { Map<String, Object> resultMap = new HashMap<String, Object>(); resultMap.put("msg", message); return resultMap; } else if (type == Void.TYPE) { src/main/java/com/moral/entity/Organization.java
@@ -3,6 +3,8 @@ import java.util.Date; import java.util.Map; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Transient; @@ -15,6 +17,7 @@ * @mbggenerated Thu Dec 07 15:18:16 CST 2017 */ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; /** src/main/java/com/moral/service/impl/OrganizationServiceImpl.java
@@ -1,8 +1,10 @@ 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; @@ -88,8 +90,23 @@ }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;