| | |
| | |
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.moral.common.util.ValidateUtil;
|
| | | import com.moral.entity.Organization;
|
| | | import com.moral.entity.OrganizationRelation;
|
| | | import com.moral.mapper.OrganizationMapper;
|
| | | import com.moral.mapper.OrganizationRelationMapper;
|
| | | import com.moral.service.OrganizationService;
|
| | |
|
| | | import tk.mybatis.mapper.entity.Example;
|
| | |
|
| | | @Service
|
| | | public class OrganizationServiceImpl implements OrganizationService {
|
| | |
| | | public Set<Integer> getChildOrganizationIds(Integer orgId){
|
| | | Set<Integer> orgIds = new HashSet<Integer>();
|
| | | orgIds.add(orgId);
|
| | | Example example = new Example(OrganizationRelation.class);
|
| | | example.or().andEqualTo("parentId",orgId);
|
| | | OrganizationRelation relation = new OrganizationRelation();
|
| | | relation.setParentId(orgId);
|
| | | Organization organization = organizationMapper.selectByPrimaryKey(orgId);
|
| | | if (IS_DELETE_FALSE.equals(organization.getIsDelete())) {
|
| | | List<OrganizationRelation> organizationRelations = organizationRelationMapper.selectByExample(example);
|
| | | List<OrganizationRelation> organizationRelations = organizationRelationMapper.select(relation);
|
| | | for (OrganizationRelation organizationRelation : organizationRelations) {
|
| | | Set<Integer> organizationIds = getChildOrganizationIds(organizationRelation.getParentId());
|
| | | orgIds.addAll(organizationIds);
|
| | |
| | | return orgIds;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<Organization> getOrganizationsByAreaName(Map<String, Object> parameters) {
|
| | | ValidateUtil.notNull(parameters.get("areaName"), "param.is.null");
|
| | | List<Organization> organizations = organizationMapper.getOrganizationsByAreaName(parameters);
|
| | | return organizations;
|
| | | }
|
| | |
|
| | | }
|