diff --git a/Backend/src/main/java/com/mobilecomputing/pecunia/controller/TestController.java b/Backend/src/main/java/com/mobilecomputing/pecunia/controller/TestController.java deleted file mode 100644 index e56ebebf2067c706a79b55dd4b3353d368bd8337..0000000000000000000000000000000000000000 --- a/Backend/src/main/java/com/mobilecomputing/pecunia/controller/TestController.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mobilecomputing.pecunia.controller; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping(value = "/api", method = RequestMethod.GET) -public class TestController { - @GetMapping - public String test(){ - return "hello World"; - } -} diff --git a/Backend/src/main/java/com/mobilecomputing/pecunia/controller/TripController.java b/Backend/src/main/java/com/mobilecomputing/pecunia/controller/TripController.java new file mode 100644 index 0000000000000000000000000000000000000000..e573d9aedf4a21caf9be8a0ce15b1f0d801725aa --- /dev/null +++ b/Backend/src/main/java/com/mobilecomputing/pecunia/controller/TripController.java @@ -0,0 +1,28 @@ +package com.mobilecomputing.pecunia.controller; + +import com.mobilecomputing.pecunia.repository.TripRepository; +import org.bson.types.ObjectId; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping(value = "/trip", method = RequestMethod.GET) +public class TripController { + + @Autowired + TripRepository tripRepository; + + @GetMapping("/getTripById") + public String getTripById(@RequestParam String id){ + + return String.valueOf(tripRepository.findById(new ObjectId(id))); + } + + @GetMapping("/getAllTrips") + public String getAllTrips(){ + tripRepository.findAll().forEach(trip->{ + System.out.println(trip.toString()); + }); + return "to do"; + } +} diff --git a/Backend/src/main/java/com/mobilecomputing/pecunia/controller/UserController.java b/Backend/src/main/java/com/mobilecomputing/pecunia/controller/UserController.java new file mode 100644 index 0000000000000000000000000000000000000000..d472e1bc851a2d3f56f367915d45b5654bb9d6e4 --- /dev/null +++ b/Backend/src/main/java/com/mobilecomputing/pecunia/controller/UserController.java @@ -0,0 +1,47 @@ +package com.mobilecomputing.pecunia.controller; + +import com.mobilecomputing.pecunia.model.User; +import com.mobilecomputing.pecunia.repository.UserRepository; +import org.bson.types.ObjectId; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping(value = "/user", method = RequestMethod.GET) +public class UserController { + @Autowired + UserRepository userRepository; + + @GetMapping("/getById") + public String getUserById(@RequestParam String id){ + return String.valueOf(userRepository.findById(new ObjectId(id))); + } + + @GetMapping("/getAll") + public String getAllUsers(){ + String response =""; + userRepository.findAll().forEach(user -> { + System.out.println(user.toString()); + }); + return String.valueOf(userRepository.findAll()); + } + + @PostMapping("/registrateUser") + public String registrateUser(@RequestParam String eMail, @RequestParam String name, @RequestParam String surname, + @RequestParam String password){ + User user = new User(); + user.seteMail(eMail); // überprüfen ob email schon vergeben ist + user.setName(name); + user.setSurname(surname); + user.setPassword(password); + + userRepository.save(user); + return "ok?"; + } + + @DeleteMapping("/deleteUser") + public void deleteUser(@RequestParam String eMail){ + userRepository.deleteById(new ObjectId(eMail)); + } +} diff --git a/Backend/src/main/java/com/mobilecomputing/pecunia/model/Trip.java b/Backend/src/main/java/com/mobilecomputing/pecunia/model/Trip.java new file mode 100644 index 0000000000000000000000000000000000000000..6132067564dad02121bae4db983ec44f6712dbe6 --- /dev/null +++ b/Backend/src/main/java/com/mobilecomputing/pecunia/model/Trip.java @@ -0,0 +1,63 @@ +package com.mobilecomputing.pecunia.model; + +import org.springframework.data.annotation.Id; + +import java.util.Date; +import java.util.List; + +public class Trip { + @Id + private String tripId; + private String tripName; + private Date startOfTrip; + private Date endOfTrip; + private List<User> tripParticipants; + + public Trip(String tripId, String tripName, Date startOfTrip, Date endOfTrip, List<User> tripParticipants) { + this.tripId = tripId; + this.tripName = tripName; + this.startOfTrip = startOfTrip; + this.endOfTrip = endOfTrip; + this.tripParticipants = tripParticipants; + } + + public String getTripId() { + return tripId; + } + + public void setTripId(String tripId) { + this.tripId = tripId; + } + + public String getTripName() { + return tripName; + } + + public void setTripName(String tripName) { + this.tripName = tripName; + } + + public Date getStartOfTrip() { + return startOfTrip; + } + + public void setStartOfTrip(Date startOfTrip) { + this.startOfTrip = startOfTrip; + } + + public Date getEndOfTrip() { + return endOfTrip; + } + + public void setEndOfTrip(Date endOfTrip) { + this.endOfTrip = endOfTrip; + } + + public List<User> getTripParticipants() { + return tripParticipants; + } + + public void setTripParticipants(List<User> tripParticipants) { + this.tripParticipants = tripParticipants; + } +} diff --git a/Backend/src/main/java/com/mobilecomputing/pecunia/model/User.java b/Backend/src/main/java/com/mobilecomputing/pecunia/model/User.java new file mode 100644 index 0000000000000000000000000000000000000000..f04c9946c69fdbce2be2c487c507c220c45bc4e6 --- /dev/null +++ b/Backend/src/main/java/com/mobilecomputing/pecunia/model/User.java @@ -0,0 +1,54 @@ +package com.mobilecomputing.pecunia.model; + +import org.springframework.data.annotation.Id; + +public class User { + + @Id + private String eMail; + private String name; + private String surname; + private String password; + + public String geteMail() { + return eMail; + } + + public void seteMail(String eMail) { + this.eMail = eMail; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSurname() { + return surname; + } + + public void setSurname(String surname) { + this.surname = surname; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public String toString() { + return "User{" + + "eMail='" + eMail + '\'' + + ", name='" + name + '\'' + + ", surname='" + surname + '\'' + + ", password='" + password + '\'' + + '}'; + } +} diff --git a/Backend/src/main/java/com/mobilecomputing/pecunia/repository/TripRepository.java b/Backend/src/main/java/com/mobilecomputing/pecunia/repository/TripRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..e540fa0d3b60d2d067d824be04d258e6dcfb8979 --- /dev/null +++ b/Backend/src/main/java/com/mobilecomputing/pecunia/repository/TripRepository.java @@ -0,0 +1,9 @@ +package com.mobilecomputing.pecunia.repository; + +import com.mobilecomputing.pecunia.model.Trip; +import org.bson.types.ObjectId; +import org.springframework.data.repository.CrudRepository; + +public interface TripRepository extends CrudRepository<Trip, ObjectId> { + +} diff --git a/Backend/src/main/java/com/mobilecomputing/pecunia/repository/UserRepository.java b/Backend/src/main/java/com/mobilecomputing/pecunia/repository/UserRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..ccc2662873d7d4e8aaaca4265101594a9016300c --- /dev/null +++ b/Backend/src/main/java/com/mobilecomputing/pecunia/repository/UserRepository.java @@ -0,0 +1,9 @@ +package com.mobilecomputing.pecunia.repository; + +import com.mobilecomputing.pecunia.model.Trip; +import com.mobilecomputing.pecunia.model.User; +import org.bson.types.ObjectId; +import org.springframework.data.repository.CrudRepository; + +public interface UserRepository extends CrudRepository<User, ObjectId> { +} diff --git a/Frontend/.idea/gradle.xml b/Frontend/.idea/gradle.xml index 440480e56200ca31ad07e453df640cdd2a3e93d4..5cd135a064522bbb757161b1eee5a7d65de1989e 100644 --- a/Frontend/.idea/gradle.xml +++ b/Frontend/.idea/gradle.xml @@ -1,5 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> + <component name="GradleMigrationSettings" migrationVersion="1" /> <component name="GradleSettings"> <option name="linkedExternalProjectsSettings"> <GradleProjectSettings>