Search in sources :

Example 1 with AreaTreeVO

use of com.bc.pmpheep.back.vo.AreaTreeVO in project pmph by BCSquad.

the class AreaSeviceTest method testGetAreaChirldren.

@Test
public void testGetAreaChirldren() {
    Area area = addArea();
    List<AreaTreeVO> listAreaTreeVOs = areaService.getAreaChirldren(area.getId());
    Assert.assertNotNull("有子节点", listAreaTreeVOs);
}
Also used : Area(com.bc.pmpheep.back.po.Area) AreaTreeVO(com.bc.pmpheep.back.vo.AreaTreeVO) Test(org.junit.Test) BaseTest(com.bc.pmpheep.test.BaseTest)

Example 2 with AreaTreeVO

use of com.bc.pmpheep.back.vo.AreaTreeVO in project pmph by BCSquad.

the class AreaServiceImpl method getAreaTreeVO.

@Override
public List<AreaTreeVO> getAreaTreeVO(Long parentId) throws CheckedServiceException {
    if (null == parentId) {
        throw new CheckedServiceException(CheckedExceptionBusiness.AREA, CheckedExceptionResult.NULL_PARAM, "参数为空");
    }
    Long id = parentId;
    AreaTreeVO areaTreeVO = new AreaTreeVO(id);
    this.getAreaTree(areaTreeVO, new ArrayList<Long>());
    return areaTreeVO.getChirldren();
}
Also used : CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) AreaTreeVO(com.bc.pmpheep.back.vo.AreaTreeVO)

Example 3 with AreaTreeVO

use of com.bc.pmpheep.back.vo.AreaTreeVO in project pmph by BCSquad.

the class AreaServiceImpl method deleteAreaBatch.

@Override
public Integer deleteAreaBatch(Long id) throws CheckedServiceException {
    if (null == id) {
        throw new CheckedServiceException(CheckedExceptionBusiness.AREA, CheckedExceptionResult.NULL_PARAM, "ID为空");
    }
    if (0 < areaDao.getOrgId(id)) {
        throw new CheckedServiceException(CheckedExceptionBusiness.AREA, CheckedExceptionResult.NULL_PARAM, "区域在机构区域已使用");
    }
    List<Long> ids = new ArrayList<Long>();
    ids.add(id);
    getAreaTree(new AreaTreeVO(id), ids);
    return areaDao.deleteAreaBatch(ids);
}
Also used : ArrayList(java.util.ArrayList) CheckedServiceException(com.bc.pmpheep.service.exception.CheckedServiceException) AreaTreeVO(com.bc.pmpheep.back.vo.AreaTreeVO)

Example 4 with AreaTreeVO

use of com.bc.pmpheep.back.vo.AreaTreeVO in project pmph by BCSquad.

the class AreaServiceImpl method getAreaTree.

/**
 **************************
 * 下面是必须的辅助方法
 ******************************************
 */
/**
 * 得到parentId的树 和树的所有id
 *
 * @author Mryang
 * @createDate 2017年9月25日 下午2:05:27
 * @param areaTreeVO
 *            带parentId
 * @param ids
 */
public void getAreaTree(AreaTreeVO areaTreeVO, List<Long> ids) {
    List<AreaTreeVO> areaVOList = areaDao.getAreaByParentId(areaTreeVO.getId());
    if (null != areaVOList && areaVOList.size() > 0) {
        areaTreeVO.setChirldren(areaVOList);
        areaTreeVO.setIsLeaf(false);
        for (AreaTreeVO areaTreeVOChirld : areaVOList) {
            ids.add(areaTreeVOChirld.getId());
            getAreaTree(areaTreeVOChirld, ids);
        }
    }
}
Also used : AreaTreeVO(com.bc.pmpheep.back.vo.AreaTreeVO)

Aggregations

AreaTreeVO (com.bc.pmpheep.back.vo.AreaTreeVO)4 CheckedServiceException (com.bc.pmpheep.service.exception.CheckedServiceException)2 Area (com.bc.pmpheep.back.po.Area)1 BaseTest (com.bc.pmpheep.test.BaseTest)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1