package com.moral.service.impl; import static com.moral.common.bean.Constants.IS_DELETE_FALSE; import java.util.HashSet; import java.util.List; import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.moral.entity.Organization; import com.moral.entity.OrganizationRelation; import com.moral.entity.OrganizationRelationExample; import com.moral.mapper.OrganizationMapper; import com.moral.mapper.OrganizationRelationMapper; import com.moral.service.OrganizationService; @Service public class OrganizationServiceImpl implements OrganizationService { @Autowired private OrganizationMapper organizationMapper; @Autowired private OrganizationRelationMapper organizationRelationMapper; @Override public Set getChildOrganizationIds(Integer orgId){ Set orgIds = new HashSet(); orgIds.add(orgId); OrganizationRelationExample example = new OrganizationRelationExample(); example.or().andParentIdEqualTo(orgId); Organization organization = organizationMapper.selectByPrimaryKey(orgId); if (IS_DELETE_FALSE.equals(organization.getIsDelete())) { List organizationRelations = organizationRelationMapper.selectByExample(example); for (OrganizationRelation organizationRelation : organizationRelations) { Set organizationIds = getChildOrganizationIds(organizationRelation.getParentId()); orgIds.addAll(organizationIds); } } return orgIds; } }