add trip controller and service skelletons
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package SuMoC.backend.controller;
|
||||
|
||||
|
||||
import SuMoC.backend.models.Trip;
|
||||
import SuMoC.backend.security.services.TripService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/trip")
|
||||
public class TripController {
|
||||
private TripService tripService;
|
||||
|
||||
@Autowired
|
||||
public TripController(TripService tripService) {
|
||||
this.tripService = tripService;
|
||||
}
|
||||
|
||||
@Operation(summary = "User uploads a new trip from the App.")
|
||||
@PostMapping
|
||||
public ResponseEntity<Void> uploadTrip() {
|
||||
// TODO implement upload trip
|
||||
throw new NotImplementedException();
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
|
||||
// TODO might be userfull when user switched devices? discuss in team - low priority
|
||||
public ResponseEntity<List<Trip>> getAllUserTrips() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -88,6 +88,7 @@ public class SecurityConfiguration {
|
||||
auth.requestMatchers("/auth/user/**").permitAll();
|
||||
auth.requestMatchers("/admin/**").hasRole("ADMIN"); //looks for "ROLE_ADMIN" //alternative: hasAuthoritiy("ADMIN")
|
||||
auth.requestMatchers("/user/**").hasAnyRole("ADMIN", "USER");
|
||||
auth.requestMatchers("/trip/**").hasAnyRole( "USER", "ADMIN");
|
||||
auth.requestMatchers(AUTH_WHITELIST).permitAll();
|
||||
//auth.requestMatchers("/error").permitAll();
|
||||
auth.anyRequest().authenticated();
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package SuMoC.backend.security.services;
|
||||
|
||||
|
||||
import SuMoC.backend.repositories.TripRepository;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class TripService {
|
||||
private TripRepository tripRepository;
|
||||
|
||||
@Autowired
|
||||
public TripService(TripRepository tripRepository) {this.tripRepository = tripRepository;}
|
||||
}
|
||||
Reference in New Issue
Block a user