@Transactional(readOnly = false) public void save(Area area) { area.setParent(this.get(area.getParent().getId())); String oldParentIds = area.getParentIds(); // 获取修改前的parentIds,用于更新子节点的parentIds area.setParentIds(area.getParent().getParentIds() + area.getParent().getId() + ","); areaDao.clear(); areaDao.save(area); // 更新子节点 parentIds List<Area> list = areaDao.findByParentIdsLike("%," + area.getId() + ",%"); for (Area e : list) { e.setParentIds(e.getParentIds().replace(oldParentIds, area.getParentIds())); } areaDao.save(list); UserUtils.removeCache("areaList"); }
@Transactional(readOnly = false) public void delete(Long id) { areaDao.deleteById(id, "%," + id + ",%"); UserUtils.removeCache("areaList"); }
public Area get(Long id) { return areaDao.findOne(id); }