Changeset ceaed42 for trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/PlannerServiceImpl.java
- Timestamp:
- 11/11/21 12:59:26 (3 years ago)
- Branches:
- master
- Children:
- 59329aa
- Parents:
- 6c1585f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/PlannerServiceImpl.java
r6c1585f rceaed42 22 22 private final JpaPlannerRepository plannerRepository; 23 23 private final JpaLocationRepository locationRepository; 24 private final LocationService locationService;25 24 26 public PlannerServiceImpl(JpaPlannerRepository plannerRepository, JpaLocationRepository locationRepository , LocationService locationService) {25 public PlannerServiceImpl(JpaPlannerRepository plannerRepository, JpaLocationRepository locationRepository) { 27 26 this.plannerRepository = plannerRepository; 28 27 this.locationRepository = locationRepository; 29 this.locationService = locationService;30 28 } 31 29 … … 40 38 } 41 39 42 @Override43 public Planner addLocationToPlanner(Long plannerId, Long locationId) {44 Location location = this.locationService.findById(locationId)45 .orElseThrow(() -> new LocationNotFoundException(locationId));46 Planner planner = this.plannerRepository.getById(plannerId);47 planner.getLocationList().add(location);48 return this.plannerRepository.save(planner);49 }50 40 51 41 @Override … … 84 74 planner.setName(plannerDto.getName()); 85 75 planner.setDescription(plannerDto.getDescription()); 86 76 /* 87 77 List<Location> locationList = new ArrayList<>(); 88 78 for(Long location : plannerDto.getLocationList()){ … … 92 82 } 93 83 planner.setLocationList(locationList); 84 85 */ 94 86 return Optional.of(this.plannerRepository.save(planner)); 95 87 }
Note:
See TracChangeset
for help on using the changeset viewer.