Changeset bdd6491 for trip-planner/src
- Timestamp:
- 12/28/21 08:56:55 (3 years ago)
- Branches:
- master
- Children:
- b738035
- Parents:
- 84d0fbb
- Location:
- trip-planner/src
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner/src/main/java/finki/diplomska/tripplanner/TripPlannerApplication.java
r84d0fbb rbdd6491 21 21 } 22 22 23 24 23 public static void main(String[] args) { 25 24 SpringApplication.run(TripPlannerApplication.class, args); -
trip-planner/src/main/java/finki/diplomska/tripplanner/models/Location.java
r84d0fbb rbdd6491 35 35 36 36 private int duration; 37 38 private String trivia; 37 39 38 40 @Lob -
trip-planner/src/main/java/finki/diplomska/tripplanner/models/Planner.java
r84d0fbb rbdd6491 26 26 private String description; 27 27 28 @ManyToMany 28 @ManyToMany() 29 29 @JoinTable( 30 30 name = "planners_contain", -
trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaLocationRepository.java
r84d0fbb rbdd6491 108 108 "WHERE lb.id_category=4", nativeQuery = true) 109 109 List<Location> getVillages(); 110 110 111 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaPlannerRepository.java
r84d0fbb rbdd6491 15 15 @Query(value = "SELECT * FROM planners AS p left JOIN users AS u ON p.user_id = u.id WHERE u.username like :username", nativeQuery = true) 16 16 List<Planner> getPlannersByUser(@Param("username") String username ); 17 18 @Query(value = "delete from planners_contain WHERE planners_contain.id_location = :locationId", nativeQuery = true) 19 void deleteLocationFromPlanner(@Param("locationId") Long locationId); 17 20 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConfig.java
r84d0fbb rbdd6491 76 76 .antMatchers(SIGN_UP_URLS).permitAll() 77 77 .antMatchers(MARIADB_URL).permitAll() 78 .antMatchers("/api/weekend").permitAll() 79 .antMatchers("/api/villages").permitAll() 78 80 .anyRequest().authenticated(); 79 81 http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class); -
trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConstants.java
r84d0fbb rbdd6491 7 7 public static final String TOKEN_PREFIX= "Bearer "; 8 8 public static final String HEADER_STRING = "Authorization"; 9 public static final long EXPIRATION_TIME = 3000_000; //30 seconds9 public static final long EXPIRATION_TIME = 3000_000; //30 min 10 10 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/PlannerService.java
r84d0fbb rbdd6491 17 17 Planner editPlannerWithRequestParams(Long id, String description, String name, List<Location> locationList); 18 18 Optional<Planner> newPlanner(PlannerDto plannerDto, String username); 19 void deletePlannerById(Long id); 20 void deleteLocationFromPlanner(Long locationId); 19 21 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/LocationServiceImpl.java
r84d0fbb rbdd6491 183 183 return this.locationRepository.getAllLocationIdsForPlanner(plannerId); 184 184 } 185 186 187 185 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/PlannerServiceImpl.java
r84d0fbb rbdd6491 13 13 import org.springframework.stereotype.Service; 14 14 15 import javax.jws.soap.SOAPBinding;16 15 import java.util.List; 17 16 import java.util.Optional; … … 63 62 64 63 @Override 64 public void deletePlannerById(Long id) { 65 this.plannerRepository.deleteById(id); 66 } 67 68 @Override 69 public void deleteLocationFromPlanner(Long locationId) { 70 this.plannerRepository.deleteLocationFromPlanner(locationId); 71 } 72 73 @Override 65 74 public Planner createPlannerWithRequestParams(String plandesc,String planname, List<Location> locationList) { 66 75 Planner planner = Planner.createNewPlanner(plandesc, planname, locationList); -
trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/LocationRestController.java
r84d0fbb rbdd6491 5 5 import finki.diplomska.tripplanner.service.LocationService; 6 6 import finki.diplomska.tripplanner.service.PlannerService; 7 import org.springframework.data.repository.query.Param;8 7 import org.springframework.http.ResponseEntity; 9 8 import org.springframework.web.bind.annotation.*; … … 77 76 return this.locationService.getAllLocationIdsForPlanner(plannerId); 78 77 } 78 79 79 } -
trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/PlannerRestController.java
r84d0fbb rbdd6491 84 84 } 85 85 86 @DeleteMapping("/delete/{id}") 87 public ResponseEntity deleteById(@PathVariable Long id) { 88 this.plannerService.deletePlannerById(id); 89 return this.plannerService.findById(id) 90 .map(planner -> ResponseEntity.ok().body(planner)) 91 .orElseGet(()-> ResponseEntity.notFound().build()); 92 } 86 93 94 95 @DeleteMapping(value = "/delete-from-planner") 96 public ResponseEntity deleteLocationFromPlanner(@PathVariable Long locationId){ 97 this.plannerService.deleteLocationFromPlanner(locationId); 98 return this.locationService.findById(locationId) 99 .map(location -> ResponseEntity.ok().body(location)) 100 .orElseGet(()-> ResponseEntity.notFound().build()); 101 } 87 102 } -
trip-planner/src/test/api.http
r84d0fbb rbdd6491 92 92 GET http://localhost:8080/api/planners/user 93 93 Content-Type: application/json 94 95 ### 96 DELETE http://localhost:8080/api/delete/19 97 Content-Type: application/json
Note:
See TracChangeset
for help on using the changeset viewer.