/** * 验证area的level和上级区域level是否匹配 * * @param area * @return */ private void validate(Area area) { Area upperArea = area.getUpperArea(); AreaLevel level = area.getLevel(); if (upperArea == null || level == null) return; if (!upperArea.getLevel().isUpperLevelTo(level)) { throw new RuntimeException("区域等级和上级区域无法匹配"); } }
@Override public Area postUpdate(AreaInputArgs i, Area d) { String levelId = i.getLevelId(); if (StringUtils.isNotBlank(levelId)) { AreaLevel level = areaLevelRepository.findOne(levelId); d.setLevel(level); } String upperAreaId = i.getUpperAreaId(); if (StringUtils.isNotBlank(upperAreaId)) { Area upperArea = areaRepository.findOne(upperAreaId); d.setUpperArea(upperArea); } validate(d); return d; }