Regenerating entity, and changes in all files
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
package ch.progetto152;
|
||||
|
||||
import ch.progetto152.controller.Controller;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
public class Progetto152Application {
|
||||
@@ -12,6 +10,4 @@ public class Progetto152Application {
|
||||
SpringApplication.run(Progetto152Application.class, args);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ch.progetto152.controller;
|
||||
|
||||
import ch.progetto152.entity.Location;
|
||||
import ch.progetto152.entity.LocationEntity;
|
||||
import ch.progetto152.services.LocationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -20,14 +20,14 @@ public class LocationController {
|
||||
}
|
||||
|
||||
@GetMapping("/get/all")
|
||||
public ResponseEntity<List<Location>> getAllLocations() {
|
||||
List<Location> Locations = locationService.getAllLocations();
|
||||
public ResponseEntity<List<LocationEntity>> getAllLocations() {
|
||||
List<LocationEntity> Locations = locationService.getAllLocations();
|
||||
return new ResponseEntity<>(Locations, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
public ResponseEntity<Location> getLocationById(@PathVariable("id") Long id) {
|
||||
Location location = locationService.getLocationByIdService(id);
|
||||
public ResponseEntity<LocationEntity> getLocationById(@PathVariable("id") Long id) {
|
||||
LocationEntity location = locationService.getLocationByIdService(id);
|
||||
if (location != null) {
|
||||
return new ResponseEntity<>(location, HttpStatus.OK);
|
||||
} else {
|
||||
@@ -36,8 +36,8 @@ public class LocationController {
|
||||
}
|
||||
|
||||
@GetMapping("/get/name/{name}")
|
||||
public ResponseEntity<Location> getLocationByName(@PathVariable("name") String name) {
|
||||
Location location = locationService.getLocationByNameService(name);
|
||||
public ResponseEntity<LocationEntity> getLocationByName(@PathVariable("name") String name) {
|
||||
LocationEntity location = locationService.getLocationByNameService(name);
|
||||
if (location != null) {
|
||||
return new ResponseEntity<>(location, HttpStatus.OK);
|
||||
} else {
|
||||
@@ -46,14 +46,14 @@ public class LocationController {
|
||||
}
|
||||
|
||||
@PostMapping("/create/{id}")
|
||||
public ResponseEntity<Location> createLocation(@RequestBody Location location) {
|
||||
Location createdLocation = locationService.createLocation(location);
|
||||
public ResponseEntity<LocationEntity> createLocation(@RequestBody LocationEntity location) {
|
||||
LocationEntity createdLocation = locationService.createLocation(location);
|
||||
return new ResponseEntity<>(createdLocation, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/put/{id}")
|
||||
public ResponseEntity<Location> updateLocation(@PathVariable("id") Long id, @RequestBody Location location) {
|
||||
Location location1 = locationService.updateLocation(id, location);
|
||||
public ResponseEntity<LocationEntity> updateLocation(@PathVariable("id") Long id, @RequestBody LocationEntity location) {
|
||||
LocationEntity location1 = locationService.updateLocation(id, location);
|
||||
if (location1 != null) {
|
||||
return new ResponseEntity<>(location1, HttpStatus.OK);
|
||||
} else {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ch.progetto152.controller;
|
||||
|
||||
|
||||
import ch.progetto152.entity.User;
|
||||
import ch.progetto152.entity.UserEntity;
|
||||
import ch.progetto152.services.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -14,7 +14,6 @@ import java.util.List;
|
||||
@RequestMapping("/api/users")
|
||||
public class UserController {
|
||||
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
@Autowired
|
||||
@@ -23,14 +22,14 @@ public class UserController {
|
||||
}
|
||||
|
||||
@GetMapping("/get/all")
|
||||
public ResponseEntity<List<User>> getAllUsers() {
|
||||
List<User> users = userService.getAllUsers();
|
||||
public ResponseEntity<List<UserEntity>> getAllUsers() {
|
||||
List<UserEntity> users = userService.getAllUsers();
|
||||
return new ResponseEntity<>(users, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
public ResponseEntity<User> getUserById(@PathVariable("id") Long id) {
|
||||
User user = userService.getUserByIdService(id);
|
||||
public ResponseEntity<UserEntity> getUserById(@PathVariable("id") Long id) {
|
||||
UserEntity user = userService.getUserByIdService(id);
|
||||
if (user != null) {
|
||||
return new ResponseEntity<>(user, HttpStatus.OK);
|
||||
} else {
|
||||
@@ -39,8 +38,8 @@ public class UserController {
|
||||
}
|
||||
|
||||
@GetMapping("/get/name/{name}")
|
||||
public ResponseEntity<User> getUserByName(@PathVariable("name") String name) {
|
||||
User user = userService.getUserByNameService(name);
|
||||
public ResponseEntity<UserEntity> getUserByName(@PathVariable("name") String name) {
|
||||
UserEntity user = userService.getUserByNameService(name);
|
||||
if (user != null) {
|
||||
return new ResponseEntity<>(user, HttpStatus.OK);
|
||||
} else {
|
||||
@@ -49,8 +48,8 @@ public class UserController {
|
||||
}
|
||||
|
||||
@GetMapping("/get/username/{username}")
|
||||
public ResponseEntity<User> getUserByUsername(@PathVariable("username") String username) {
|
||||
User user = userService.getUserByUsernameService(username);
|
||||
public ResponseEntity<UserEntity> getUserByUsername(@PathVariable("username") String username) {
|
||||
UserEntity user = userService.getUserByUsernameService(username);
|
||||
if (user != null) {
|
||||
return new ResponseEntity<>(user, HttpStatus.OK);
|
||||
} else {
|
||||
@@ -59,14 +58,14 @@ public class UserController {
|
||||
}
|
||||
|
||||
@PostMapping("/create/{id}")
|
||||
public ResponseEntity<User> createUser(@RequestBody User user) {
|
||||
User createdUser = userService.createUser(user);
|
||||
public ResponseEntity<UserEntity> createUser(@RequestBody UserEntity user) {
|
||||
UserEntity createdUser = userService.createUser(user);
|
||||
return new ResponseEntity<>(createdUser, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/put/{id}")
|
||||
public ResponseEntity<User> updateUser(@PathVariable("id") Long id, @RequestBody User user) {
|
||||
User updatedUser = userService.updateUser(id, user);
|
||||
public ResponseEntity<UserEntity> updateUser(@PathVariable("id") Long id, @RequestBody UserEntity user) {
|
||||
UserEntity updatedUser = userService.updateUser(id, user);
|
||||
if (updatedUser != null) {
|
||||
return new ResponseEntity<>(updatedUser, HttpStatus.OK);
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ch.progetto152.controller;
|
||||
|
||||
import ch.progetto152.entity.Waypoints;
|
||||
import ch.progetto152.entity.WaypointsEntity;
|
||||
import ch.progetto152.services.WaypointService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -20,14 +20,14 @@ public class WaypointController {
|
||||
}
|
||||
|
||||
@GetMapping("/get/all")
|
||||
public ResponseEntity<List<Waypoints>> getAllWaypoints() {
|
||||
List<Waypoints> waypoint = waypointService.getAllWaypoints();
|
||||
public ResponseEntity<List<WaypointsEntity>> getAllWaypoints() {
|
||||
List<WaypointsEntity> waypoint = waypointService.getAllWaypoints();
|
||||
return new ResponseEntity<>(waypoint, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/get/{id}")
|
||||
public ResponseEntity<Waypoints> getWaypointById(@PathVariable("id") Long id) {
|
||||
Waypoints waypoint = waypointService.getWaypointByIdService(id);
|
||||
public ResponseEntity<WaypointsEntity> getWaypointById(@PathVariable("id") Long id) {
|
||||
WaypointsEntity waypoint = waypointService.getWaypointByIdService(id);
|
||||
if (waypoint != null) {
|
||||
return new ResponseEntity<>(waypoint, HttpStatus.OK);
|
||||
} else {
|
||||
@@ -36,8 +36,8 @@ public class WaypointController {
|
||||
}
|
||||
|
||||
@GetMapping("/get/name/{name}")
|
||||
public ResponseEntity<Waypoints> getWaypointByName(@PathVariable("name") String name) {
|
||||
Waypoints waypoint = waypointService.getWaypointByNameService(name);
|
||||
public ResponseEntity<WaypointsEntity> getWaypointByName(@PathVariable("name") String name) {
|
||||
WaypointsEntity waypoint = waypointService.getWaypointByNameService(name);
|
||||
if (waypoint != null) {
|
||||
return new ResponseEntity<>(waypoint, HttpStatus.OK);
|
||||
} else {
|
||||
@@ -46,14 +46,14 @@ public class WaypointController {
|
||||
}
|
||||
|
||||
@PostMapping("/create/{id}")
|
||||
public ResponseEntity<Waypoints> createWaypoint(@RequestBody Waypoints waypoint) {
|
||||
Waypoints createdWaypoint = waypointService.createWaypoint(waypoint);
|
||||
public ResponseEntity<WaypointsEntity> createWaypoint(@RequestBody WaypointsEntity waypoint) {
|
||||
WaypointsEntity createdWaypoint = waypointService.createWaypoint(waypoint);
|
||||
return new ResponseEntity<>(createdWaypoint, HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@PutMapping("/put/{id}")
|
||||
public ResponseEntity<Waypoints> updateWaypoint(@PathVariable("id") Long id, @RequestBody Waypoints waypoint) {
|
||||
Waypoints updatedWaypoint = waypointService.updateWaypoint(id, waypoint);
|
||||
public ResponseEntity<WaypointsEntity> updateWaypoint(@PathVariable("id") Long id, @RequestBody WaypointsEntity waypoint) {
|
||||
WaypointsEntity updatedWaypoint = waypointService.updateWaypoint(id, waypoint);
|
||||
if (updatedWaypoint != null) {
|
||||
return new ResponseEntity<>(updatedWaypoint, HttpStatus.OK);
|
||||
} else {
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package ch.progetto152.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "Location", schema = "Progetto152", catalog = "")
|
||||
public class Location {
|
||||
public class LocationEntity {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
private int id;
|
||||
@Basic
|
||||
@Column(name = "location")
|
||||
private String location;
|
||||
@Basic
|
||||
@@ -23,14 +21,6 @@ public class Location {
|
||||
@Column(name = "lon")
|
||||
private double lon;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLocation() {
|
||||
return location;
|
||||
}
|
||||
@@ -71,12 +61,12 @@ public class Location {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Location that = (Location) o;
|
||||
return id == that.id && Double.compare(that.lat, lat) == 0 && Double.compare(that.lon, lon) == 0 && Objects.equals(location, that.location) && Objects.equals(region, that.region);
|
||||
LocationEntity that = (LocationEntity) o;
|
||||
return Double.compare(that.lat, lat) == 0 && Double.compare(that.lon, lon) == 0 && Objects.equals(location, that.location) && Objects.equals(region, that.region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, location, region, lat, lon);
|
||||
return Objects.hash(location, region, lat, lon);
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,14 @@
|
||||
package ch.progetto152.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@Table
|
||||
public class User {
|
||||
@Id
|
||||
@Table(name = "User", schema = "Progetto152", catalog = "")
|
||||
public class UserEntity {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
private int id;
|
||||
@Basic
|
||||
@@ -27,9 +21,35 @@ public class User {
|
||||
@Column(name = "password")
|
||||
private String password;
|
||||
|
||||
public User(String name, String username, String password) {
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@@ -41,7 +61,7 @@ public class User {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User that = (User) o;
|
||||
UserEntity that = (UserEntity) o;
|
||||
return id == that.id && Objects.equals(name, that.name) && Objects.equals(username, that.username) && Objects.equals(password, that.password);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name = "Waypoints", schema = "Progetto152", catalog = "")
|
||||
public class Waypoints {
|
||||
public class WaypointsEntity {
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Id
|
||||
@Column(name = "id")
|
||||
@@ -27,8 +27,8 @@ public class Waypoints {
|
||||
@Column(name = "img")
|
||||
private String img;
|
||||
@Basic
|
||||
@Column(name = "LocationId")
|
||||
private int locationId;
|
||||
@Column(name = "locationName")
|
||||
private String locationName;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
@@ -78,12 +78,12 @@ public class Waypoints {
|
||||
this.img = img;
|
||||
}
|
||||
|
||||
public int getLocationId() {
|
||||
return locationId;
|
||||
public String getLocationName() {
|
||||
return locationName;
|
||||
}
|
||||
|
||||
public void setLocationId(int locationId) {
|
||||
this.locationId = locationId;
|
||||
public void setLocationName(String locationName) {
|
||||
this.locationName = locationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,12 +94,12 @@ public class Waypoints {
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Waypoints that = (Waypoints) o;
|
||||
return id == that.id && Double.compare(that.lat, lat) == 0 && Double.compare(that.lon, lon) == 0 && locationId == that.locationId && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(img, that.img);
|
||||
WaypointsEntity that = (WaypointsEntity) o;
|
||||
return id == that.id && Double.compare(that.lat, lat) == 0 && Double.compare(that.lon, lon) == 0 && Objects.equals(name, that.name) && Objects.equals(description, that.description) && Objects.equals(img, that.img) && Objects.equals(locationName, that.locationName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name, lat, lon, description, img, locationId);
|
||||
return Objects.hash(id, name, lat, lon, description, img, locationName);
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,16 @@ import jakarta.persistence.*;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
public class LocationVisited{
|
||||
|
||||
@Id
|
||||
@Table(name = "WaypointsVisited", schema = "Progetto152", catalog = "")
|
||||
public class WaypointsVisitedEntity {
|
||||
@Basic
|
||||
@Id
|
||||
@Column(name = "userId")
|
||||
private int userId;
|
||||
@Basic
|
||||
@Column(name = "locationid")
|
||||
private int locationid;
|
||||
@Id
|
||||
private Long id;
|
||||
@Column(name = "waypointId")
|
||||
private int waypointId;
|
||||
|
||||
public int getUserId() {
|
||||
return userId;
|
||||
@@ -25,12 +24,12 @@ public class LocationVisited{
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public int getLocationid() {
|
||||
return locationid;
|
||||
public int getWaypointId() {
|
||||
return waypointId;
|
||||
}
|
||||
|
||||
public void setLocationid(int locationid) {
|
||||
this.locationid = locationid;
|
||||
public void setWaypointId(int waypointId) {
|
||||
this.waypointId = waypointId;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,21 +40,12 @@ public class LocationVisited{
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
LocationVisited that = (LocationVisited) o;
|
||||
return userId == that.userId && locationid == that.locationid;
|
||||
WaypointsVisitedEntity that = (WaypointsVisitedEntity) o;
|
||||
return userId == that.userId && waypointId == that.waypointId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(userId, locationid);
|
||||
return Objects.hash(userId, waypointId);
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package ch.progetto152.repository;
|
||||
|
||||
import ch.progetto152.entity.Location;
|
||||
import ch.progetto152.entity.LocationEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface LocationRepository extends JpaRepository<Location, Long> {
|
||||
public interface LocationRepository extends JpaRepository<LocationEntity, Long> {
|
||||
|
||||
Optional<Location> findLocationByLocation(String name);
|
||||
Optional<LocationEntity> findLocationByLocation(String name);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package ch.progetto152.repository;
|
||||
|
||||
import ch.progetto152.entity.User;
|
||||
import ch.progetto152.entity.UserEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||
|
||||
Optional<User> findUserByName(String name);
|
||||
Optional<UserEntity> findUserByName(String name);
|
||||
|
||||
Optional<User> findUserByUsername(String username);
|
||||
Optional<UserEntity> findUserByUsername(String username);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package ch.progetto152.repository;
|
||||
|
||||
import ch.progetto152.entity.Waypoints;
|
||||
import ch.progetto152.entity.WaypointsEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface WaypointRepository extends JpaRepository<Waypoints, Long> {
|
||||
public interface WaypointRepository extends JpaRepository<WaypointsEntity, Long> {
|
||||
|
||||
Optional<Waypoints> findWaypointByName(String name);
|
||||
Optional<WaypointsEntity> findWaypointByName(String name);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ch.progetto152.services;
|
||||
|
||||
import ch.progetto152.entity.Location;
|
||||
import ch.progetto152.entity.LocationEntity;
|
||||
import ch.progetto152.repository.LocationRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -17,24 +17,24 @@ public class LocationService {
|
||||
this.locationRepository = locationRepository;
|
||||
}
|
||||
|
||||
public List<Location> getAllLocations() {
|
||||
public List<LocationEntity> getAllLocations() {
|
||||
return locationRepository.findAll();
|
||||
}
|
||||
|
||||
public Location getLocationByIdService(Long id) {
|
||||
public LocationEntity getLocationByIdService(Long id) {
|
||||
return locationRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public Location getLocationByNameService(String name){
|
||||
public LocationEntity getLocationByNameService(String name){
|
||||
return locationRepository.findLocationByLocation(name).orElse(null);
|
||||
}
|
||||
|
||||
public Location createLocation(Location Location) {
|
||||
public LocationEntity createLocation(LocationEntity Location) {
|
||||
return locationRepository.save(Location);
|
||||
}
|
||||
|
||||
public Location updateLocation(Long id, Location Location) {
|
||||
Location location1 = getLocationByIdService(id);
|
||||
public LocationEntity updateLocation(Long id, LocationEntity Location) {
|
||||
LocationEntity location1 = getLocationByIdService(id);
|
||||
if (location1 != null) {
|
||||
location1.setLocation(Location.getLocation());
|
||||
location1.setRegion(Location.getRegion());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ch.progetto152.services;
|
||||
|
||||
|
||||
import ch.progetto152.entity.User;
|
||||
import ch.progetto152.entity.UserEntity;
|
||||
import ch.progetto152.repository.UserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -18,28 +18,28 @@ public class UserService {
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
|
||||
public List<User> getAllUsers() {
|
||||
public List<UserEntity> getAllUsers() {
|
||||
return userRepository.findAll();
|
||||
}
|
||||
|
||||
public User getUserByIdService(Long id) {
|
||||
public UserEntity getUserByIdService(Long id) {
|
||||
return userRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public User getUserByNameService(String name){
|
||||
public UserEntity getUserByNameService(String name){
|
||||
return userRepository.findUserByName(name).orElse(null);
|
||||
}
|
||||
|
||||
public User getUserByUsernameService(String username){
|
||||
public UserEntity getUserByUsernameService(String username){
|
||||
return userRepository.findUserByUsername(username).orElse(null);
|
||||
}
|
||||
|
||||
public User createUser(User user) {
|
||||
public UserEntity createUser(UserEntity user) {
|
||||
return userRepository.save(user);
|
||||
}
|
||||
|
||||
public User updateUser(Long id, User user) {
|
||||
User user1 = getUserByIdService(id);
|
||||
public UserEntity updateUser(Long id, UserEntity user) {
|
||||
UserEntity user1 = getUserByIdService(id);
|
||||
if (user1 != null) {
|
||||
user1.setName(user.getName());
|
||||
user1.setUsername(user.getUsername());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package ch.progetto152.services;
|
||||
|
||||
import ch.progetto152.entity.Waypoints;
|
||||
import ch.progetto152.entity.WaypointsEntity;
|
||||
import ch.progetto152.repository.WaypointRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -16,31 +16,31 @@ public class WaypointService {
|
||||
this.waypointRepository = waypointRepository;
|
||||
}
|
||||
|
||||
public List<Waypoints> getAllWaypoints() {
|
||||
public List<WaypointsEntity> getAllWaypoints() {
|
||||
return waypointRepository.findAll();
|
||||
}
|
||||
|
||||
public Waypoints getWaypointByIdService(Long id) {
|
||||
public WaypointsEntity getWaypointByIdService(Long id) {
|
||||
return waypointRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public Waypoints getWaypointByNameService(String name) {
|
||||
public WaypointsEntity getWaypointByNameService(String name) {
|
||||
return waypointRepository.findWaypointByName(name).orElse(null);
|
||||
}
|
||||
|
||||
public Waypoints createWaypoint(Waypoints waypoint) {
|
||||
public WaypointsEntity createWaypoint(WaypointsEntity waypoint) {
|
||||
return waypointRepository.save(waypoint);
|
||||
}
|
||||
|
||||
public Waypoints updateWaypoint(Long id, Waypoints waypoint) {
|
||||
Waypoints waypoint1 = getWaypointByIdService(id);
|
||||
public WaypointsEntity updateWaypoint(Long id, WaypointsEntity waypoint) {
|
||||
WaypointsEntity waypoint1 = getWaypointByIdService(id);
|
||||
if (waypoint1 != null) {
|
||||
waypoint1.setName(waypoint.getName());
|
||||
waypoint1.setLat(waypoint.getLat());
|
||||
waypoint1.setLon(waypoint.getLon());
|
||||
waypoint1.setDescription(waypoint.getDescription());
|
||||
waypoint1.setImg(waypoint.getImg());
|
||||
waypoint1.setLocationId(waypoint.getLocationId());
|
||||
waypoint1.setLocationName(waypoint.getLocationName());
|
||||
|
||||
return waypointRepository.save(waypoint1);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user