Regenerating entity, and changes in all files

This commit is contained in:
2023-04-27 12:03:53 +02:00
parent 9aa7fb0682
commit 69a0e6d271
14 changed files with 126 additions and 131 deletions

View File

@@ -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());

View File

@@ -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());

View File

@@ -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 {