From cf5609de3fe8fee86eba276f724928bd336cc828 Mon Sep 17 00:00:00 2001 From: Shulpov Victor Date: Sun, 29 Oct 2023 23:13:39 +0700 Subject: [PATCH] refactor: change package structure for all --- .../shulpov/spots_app/SpotsApplication.java | 6 +-- .../auth_management/token/TokenType.java | 6 --- .../LoginPasswordAuthenticationProvider.java | 4 +- .../controllers/AuthenticationController.java | 18 ++++----- .../exceptions/RegisterErrorException.java | 2 +- .../filters/JwtAuthenticationFilter.java | 4 +- .../requests/AuthenticationRequest.java | 2 +- .../requests/RegisterRequest.java | 2 +- .../responses/AuthenticationResponse.java | 2 +- .../responses/LogoutMessageResponse.java | 2 +- .../responses/RegisterErrorResponse.java | 2 +- .../responses/RegisterResponse.java | 2 +- .../services/AuthenticationService.java | 30 +++++++------- .../services/JwtService.java | 2 +- .../tokens}/Token.java | 4 +- .../tokens}/TokenRepository.java | 4 +- .../tokens}/TokenService.java | 2 +- .../tokens/TokenType.java | 6 +++ .../validators/UserValidator.java | 7 ++-- .../{models => comments}/Comment.java | 5 ++- .../CommentController.java | 9 ++--- .../{dto => comments}/CommentDto.java | 3 +- .../{repo => comments}/CommentRepo.java | 5 +-- .../CommentService.java | 9 ++--- .../spots_app/configs/ApplicationConfig.java | 2 +- .../spots_app/configs/SecurityConfig.java | 4 +- .../ImageInfoController.java | 10 ++--- .../{repo => image_infos}/ImageInfoRepo.java | 7 +--- .../ImageInfoService.java | 12 +++--- .../{ => image_infos}/dto/ImageInfoDto.java | 2 +- .../{ => image_infos}/models/ImageInfo.java | 5 ++- .../spots_app/location/repo/CityRepo.java | 17 -------- .../controllers/CityController.java | 8 ++-- .../controllers/CountryController.java | 6 +-- .../controllers/RegionController.java | 8 ++-- .../{location => locations}/dto/CityDto.java | 2 +- .../dto/CountryDto.java | 2 +- .../dto/RegionDto.java | 2 +- .../{location => locations}/models/City.java | 6 +-- .../models/Country.java | 2 +- .../models/Region.java | 2 +- .../spots_app/locations/repo/CityRepo.java | 18 +++++++++ .../repo/CountryRepo.java | 4 +- .../repo/RegionRepo.java | 6 +-- .../services/CityService.java | 11 ++--- .../services/CountryService.java | 6 +-- .../services/RegionService.java | 8 ++-- .../responses/ValidationErrorResponse.java | 8 ++-- .../spot_references/models/SpaceType.java | 2 +- .../spot_references/models/SportType.java | 2 +- .../spot_references/models/SpotType.java | 2 +- .../SpotUserController.java | 17 ++++---- .../SpotUserRepo.java | 8 ++-- .../SpotUserService.java | 40 ++++++++++--------- .../dto/SpotUserDto.java | 2 +- .../models/SpotUser.java | 6 +-- .../models}/UserSpotPK.java | 2 +- .../SpotController.java | 11 +++-- .../spots_app/{repo => spots}/SpotRepo.java | 4 +- .../{services => spots}/SpotService.java | 8 ++-- .../spots_app/{ => spots}/dto/SpotDto.java | 4 +- .../spots_app/{ => spots}/models/Spot.java | 9 +++-- .../UserController.java | 7 ++-- .../{user => users}/UserRepository.java | 3 +- .../{services => users}/UserService.java | 6 +-- .../authorization}/Permission.java | 2 +- .../{user => users/authorization}/Role.java | 4 +- .../spots_app/{ => users}/dto/UserDto.java | 4 +- .../{ => users}/dto/UserWithoutSpotsDto.java | 5 ++- .../{user => users/models}/User.java | 14 ++++--- .../shulpov/spots_app/utils/DtoConverter.java | 29 +++++++++----- .../{ => utils}/file_manager/FileManager.java | 2 +- .../file_manager/ImageManager.java | 2 +- .../java/com/shulpov/spots_app/AuthTests.java | 8 ++-- 74 files changed, 256 insertions(+), 243 deletions(-) delete mode 100644 src/main/java/com/shulpov/spots_app/auth_management/token/TokenType.java rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/auth_providers/LoginPasswordAuthenticationProvider.java (95%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/controllers/AuthenticationController.java (89%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/exceptions/RegisterErrorException.java (87%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/filters/JwtAuthenticationFilter.java (95%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/requests/AuthenticationRequest.java (86%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/requests/RegisterRequest.java (95%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/responses/AuthenticationResponse.java (85%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/responses/LogoutMessageResponse.java (83%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/responses/RegisterErrorResponse.java (77%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/responses/RegisterResponse.java (87%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/services/AuthenticationService.java (88%) rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/services/JwtService.java (98%) rename src/main/java/com/shulpov/spots_app/{auth_management/token => authentication_management/tokens}/Token.java (80%) rename src/main/java/com/shulpov/spots_app/{auth_management/token => authentication_management/tokens}/TokenRepository.java (75%) rename src/main/java/com/shulpov/spots_app/{auth_management/token => authentication_management/tokens}/TokenService.java (93%) create mode 100644 src/main/java/com/shulpov/spots_app/authentication_management/tokens/TokenType.java rename src/main/java/com/shulpov/spots_app/{auth_management => authentication_management}/validators/UserValidator.java (95%) rename src/main/java/com/shulpov/spots_app/{models => comments}/Comment.java (92%) rename src/main/java/com/shulpov/spots_app/{controllers => comments}/CommentController.java (94%) rename src/main/java/com/shulpov/spots_app/{dto => comments}/CommentDto.java (92%) rename src/main/java/com/shulpov/spots_app/{repo => comments}/CommentRepo.java (68%) rename src/main/java/com/shulpov/spots_app/{services => comments}/CommentService.java (92%) rename src/main/java/com/shulpov/spots_app/{controllers => image_infos}/ImageInfoController.java (96%) rename src/main/java/com/shulpov/spots_app/{repo => image_infos}/ImageInfoRepo.java (77%) rename src/main/java/com/shulpov/spots_app/{services => image_infos}/ImageInfoService.java (96%) rename src/main/java/com/shulpov/spots_app/{ => image_infos}/dto/ImageInfoDto.java (93%) rename src/main/java/com/shulpov/spots_app/{ => image_infos}/models/ImageInfo.java (92%) delete mode 100644 src/main/java/com/shulpov/spots_app/location/repo/CityRepo.java rename src/main/java/com/shulpov/spots_app/{location => locations}/controllers/CityController.java (94%) rename src/main/java/com/shulpov/spots_app/{location => locations}/controllers/CountryController.java (91%) rename src/main/java/com/shulpov/spots_app/{location => locations}/controllers/RegionController.java (93%) rename src/main/java/com/shulpov/spots_app/{location => locations}/dto/CityDto.java (75%) rename src/main/java/com/shulpov/spots_app/{location => locations}/dto/CountryDto.java (75%) rename src/main/java/com/shulpov/spots_app/{location => locations}/dto/RegionDto.java (75%) rename src/main/java/com/shulpov/spots_app/{location => locations}/models/City.java (88%) rename src/main/java/com/shulpov/spots_app/{location => locations}/models/Country.java (92%) rename src/main/java/com/shulpov/spots_app/{location => locations}/models/Region.java (94%) create mode 100644 src/main/java/com/shulpov/spots_app/locations/repo/CityRepo.java rename src/main/java/com/shulpov/spots_app/{location => locations}/repo/CountryRepo.java (66%) rename src/main/java/com/shulpov/spots_app/{location => locations}/repo/RegionRepo.java (63%) rename src/main/java/com/shulpov/spots_app/{location => locations}/services/CityService.java (80%) rename src/main/java/com/shulpov/spots_app/{location => locations}/services/CountryService.java (84%) rename src/main/java/com/shulpov/spots_app/{location => locations}/services/RegionService.java (87%) rename src/main/java/com/shulpov/spots_app/{controllers => spot_user_infos}/SpotUserController.java (93%) rename src/main/java/com/shulpov/spots_app/{repo => spot_user_infos}/SpotUserRepo.java (87%) rename src/main/java/com/shulpov/spots_app/{services => spot_user_infos}/SpotUserService.java (79%) rename src/main/java/com/shulpov/spots_app/{ => spot_user_infos}/dto/SpotUserDto.java (93%) rename src/main/java/com/shulpov/spots_app/{ => spot_user_infos}/models/SpotUser.java (91%) rename src/main/java/com/shulpov/spots_app/{models/pk => spot_user_infos/models}/UserSpotPK.java (93%) rename src/main/java/com/shulpov/spots_app/{controllers => spots}/SpotController.java (94%) rename src/main/java/com/shulpov/spots_app/{repo => spots}/SpotRepo.java (86%) rename src/main/java/com/shulpov/spots_app/{services => spots}/SpotService.java (90%) rename src/main/java/com/shulpov/spots_app/{ => spots}/dto/SpotDto.java (96%) rename src/main/java/com/shulpov/spots_app/{ => spots}/models/Spot.java (94%) rename src/main/java/com/shulpov/spots_app/{controllers => users}/UserController.java (96%) rename src/main/java/com/shulpov/spots_app/{user => users}/UserRepository.java (81%) rename src/main/java/com/shulpov/spots_app/{services => users}/UserService.java (95%) rename src/main/java/com/shulpov/spots_app/{user => users/authorization}/Permission.java (90%) rename src/main/java/com/shulpov/spots_app/{user => users/authorization}/Role.java (91%) rename src/main/java/com/shulpov/spots_app/{ => users}/dto/UserDto.java (95%) rename src/main/java/com/shulpov/spots_app/{ => users}/dto/UserWithoutSpotsDto.java (73%) rename src/main/java/com/shulpov/spots_app/{user => users/models}/User.java (89%) rename src/main/java/com/shulpov/spots_app/{ => utils}/file_manager/FileManager.java (86%) rename src/main/java/com/shulpov/spots_app/{ => utils}/file_manager/ImageManager.java (98%) diff --git a/src/main/java/com/shulpov/spots_app/SpotsApplication.java b/src/main/java/com/shulpov/spots_app/SpotsApplication.java index 0533ac2..c7bb5b8 100644 --- a/src/main/java/com/shulpov/spots_app/SpotsApplication.java +++ b/src/main/java/com/shulpov/spots_app/SpotsApplication.java @@ -1,14 +1,10 @@ package com.shulpov.spots_app; -import com.shulpov.spots_app.user.UserRepository; -import org.modelmapper.ModelMapper; +import com.shulpov.spots_app.users.UserRepository; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; import java.net.*; import java.util.Arrays; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/token/TokenType.java b/src/main/java/com/shulpov/spots_app/auth_management/token/TokenType.java deleted file mode 100644 index 20dca27..0000000 --- a/src/main/java/com/shulpov/spots_app/auth_management/token/TokenType.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.shulpov.spots_app.auth_management.token; - -public enum TokenType { - // BEARER, - REFRESH -} diff --git a/src/main/java/com/shulpov/spots_app/auth_management/auth_providers/LoginPasswordAuthenticationProvider.java b/src/main/java/com/shulpov/spots_app/authentication_management/auth_providers/LoginPasswordAuthenticationProvider.java similarity index 95% rename from src/main/java/com/shulpov/spots_app/auth_management/auth_providers/LoginPasswordAuthenticationProvider.java rename to src/main/java/com/shulpov/spots_app/authentication_management/auth_providers/LoginPasswordAuthenticationProvider.java index 2f50aab..2001a85 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/auth_providers/LoginPasswordAuthenticationProvider.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/auth_providers/LoginPasswordAuthenticationProvider.java @@ -1,6 +1,6 @@ -package com.shulpov.spots_app.auth_management.auth_providers; +package com.shulpov.spots_app.authentication_management.auth_providers; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.users.models.User; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.AuthenticationProvider; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/controllers/AuthenticationController.java b/src/main/java/com/shulpov/spots_app/authentication_management/controllers/AuthenticationController.java similarity index 89% rename from src/main/java/com/shulpov/spots_app/auth_management/controllers/AuthenticationController.java rename to src/main/java/com/shulpov/spots_app/authentication_management/controllers/AuthenticationController.java index 812b9a3..f795fc9 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/controllers/AuthenticationController.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/controllers/AuthenticationController.java @@ -1,13 +1,13 @@ -package com.shulpov.spots_app.auth_management.controllers; +package com.shulpov.spots_app.authentication_management.controllers; -import com.shulpov.spots_app.auth_management.exceptions.RegisterErrorException; -import com.shulpov.spots_app.auth_management.requests.AuthenticationRequest; -import com.shulpov.spots_app.auth_management.requests.RegisterRequest; -import com.shulpov.spots_app.auth_management.responses.AuthenticationResponse; -import com.shulpov.spots_app.auth_management.responses.LogoutMessageResponse; -import com.shulpov.spots_app.auth_management.responses.RegisterErrorResponse; -import com.shulpov.spots_app.auth_management.responses.RegisterResponse; -import com.shulpov.spots_app.auth_management.services.AuthenticationService; +import com.shulpov.spots_app.authentication_management.exceptions.RegisterErrorException; +import com.shulpov.spots_app.authentication_management.requests.AuthenticationRequest; +import com.shulpov.spots_app.authentication_management.requests.RegisterRequest; +import com.shulpov.spots_app.authentication_management.responses.AuthenticationResponse; +import com.shulpov.spots_app.authentication_management.responses.LogoutMessageResponse; +import com.shulpov.spots_app.authentication_management.responses.RegisterErrorResponse; +import com.shulpov.spots_app.authentication_management.responses.RegisterResponse; +import com.shulpov.spots_app.authentication_management.services.AuthenticationService; import com.shulpov.spots_app.dto.FieldErrorDto; import com.shulpov.spots_app.responses.ErrorMessageResponse; import com.shulpov.spots_app.utils.DtoConverter; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/exceptions/RegisterErrorException.java b/src/main/java/com/shulpov/spots_app/authentication_management/exceptions/RegisterErrorException.java similarity index 87% rename from src/main/java/com/shulpov/spots_app/auth_management/exceptions/RegisterErrorException.java rename to src/main/java/com/shulpov/spots_app/authentication_management/exceptions/RegisterErrorException.java index faca5bc..78f053c 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/exceptions/RegisterErrorException.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/exceptions/RegisterErrorException.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.auth_management.exceptions; +package com.shulpov.spots_app.authentication_management.exceptions; import lombok.Getter; import org.springframework.validation.FieldError; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/filters/JwtAuthenticationFilter.java b/src/main/java/com/shulpov/spots_app/authentication_management/filters/JwtAuthenticationFilter.java similarity index 95% rename from src/main/java/com/shulpov/spots_app/auth_management/filters/JwtAuthenticationFilter.java rename to src/main/java/com/shulpov/spots_app/authentication_management/filters/JwtAuthenticationFilter.java index e2a666d..57b5a4e 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/filters/JwtAuthenticationFilter.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/filters/JwtAuthenticationFilter.java @@ -1,6 +1,6 @@ -package com.shulpov.spots_app.auth_management.filters; +package com.shulpov.spots_app.authentication_management.filters; -import com.shulpov.spots_app.auth_management.services.JwtService; +import com.shulpov.spots_app.authentication_management.services.JwtService; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/requests/AuthenticationRequest.java b/src/main/java/com/shulpov/spots_app/authentication_management/requests/AuthenticationRequest.java similarity index 86% rename from src/main/java/com/shulpov/spots_app/auth_management/requests/AuthenticationRequest.java rename to src/main/java/com/shulpov/spots_app/authentication_management/requests/AuthenticationRequest.java index 19ac245..36c45fc 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/requests/AuthenticationRequest.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/requests/AuthenticationRequest.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.auth_management.requests; +package com.shulpov.spots_app.authentication_management.requests; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/requests/RegisterRequest.java b/src/main/java/com/shulpov/spots_app/authentication_management/requests/RegisterRequest.java similarity index 95% rename from src/main/java/com/shulpov/spots_app/auth_management/requests/RegisterRequest.java rename to src/main/java/com/shulpov/spots_app/authentication_management/requests/RegisterRequest.java index 2ad96f5..f54ce95 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/requests/RegisterRequest.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/requests/RegisterRequest.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.auth_management.requests; +package com.shulpov.spots_app.authentication_management.requests; import jakarta.validation.constraints.*; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/responses/AuthenticationResponse.java b/src/main/java/com/shulpov/spots_app/authentication_management/responses/AuthenticationResponse.java similarity index 85% rename from src/main/java/com/shulpov/spots_app/auth_management/responses/AuthenticationResponse.java rename to src/main/java/com/shulpov/spots_app/authentication_management/responses/AuthenticationResponse.java index 97b7bf9..fab72bc 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/responses/AuthenticationResponse.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/responses/AuthenticationResponse.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.auth_management.responses; +package com.shulpov.spots_app.authentication_management.responses; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/responses/LogoutMessageResponse.java b/src/main/java/com/shulpov/spots_app/authentication_management/responses/LogoutMessageResponse.java similarity index 83% rename from src/main/java/com/shulpov/spots_app/auth_management/responses/LogoutMessageResponse.java rename to src/main/java/com/shulpov/spots_app/authentication_management/responses/LogoutMessageResponse.java index 4082c7f..a374856 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/responses/LogoutMessageResponse.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/responses/LogoutMessageResponse.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.auth_management.responses; +package com.shulpov.spots_app.authentication_management.responses; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.*; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/responses/RegisterErrorResponse.java b/src/main/java/com/shulpov/spots_app/authentication_management/responses/RegisterErrorResponse.java similarity index 77% rename from src/main/java/com/shulpov/spots_app/auth_management/responses/RegisterErrorResponse.java rename to src/main/java/com/shulpov/spots_app/authentication_management/responses/RegisterErrorResponse.java index 177a7bf..f953da9 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/responses/RegisterErrorResponse.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/responses/RegisterErrorResponse.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.auth_management.responses; +package com.shulpov.spots_app.authentication_management.responses; import com.shulpov.spots_app.responses.ValidationErrorResponse; import lombok.*; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/responses/RegisterResponse.java b/src/main/java/com/shulpov/spots_app/authentication_management/responses/RegisterResponse.java similarity index 87% rename from src/main/java/com/shulpov/spots_app/auth_management/responses/RegisterResponse.java rename to src/main/java/com/shulpov/spots_app/authentication_management/responses/RegisterResponse.java index f999200..d9ff10c 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/responses/RegisterResponse.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/responses/RegisterResponse.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.auth_management.responses; +package com.shulpov.spots_app.authentication_management.responses; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/services/AuthenticationService.java b/src/main/java/com/shulpov/spots_app/authentication_management/services/AuthenticationService.java similarity index 88% rename from src/main/java/com/shulpov/spots_app/auth_management/services/AuthenticationService.java rename to src/main/java/com/shulpov/spots_app/authentication_management/services/AuthenticationService.java index 3ed3a32..0ee4737 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/services/AuthenticationService.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/services/AuthenticationService.java @@ -1,19 +1,19 @@ -package com.shulpov.spots_app.auth_management.services; +package com.shulpov.spots_app.authentication_management.services; -import com.shulpov.spots_app.auth_management.exceptions.RegisterErrorException; -import com.shulpov.spots_app.auth_management.requests.AuthenticationRequest; -import com.shulpov.spots_app.auth_management.requests.RegisterRequest; -import com.shulpov.spots_app.auth_management.responses.AuthenticationResponse; -import com.shulpov.spots_app.auth_management.responses.LogoutMessageResponse; -import com.shulpov.spots_app.auth_management.responses.RegisterResponse; -import com.shulpov.spots_app.auth_management.token.Token; -import com.shulpov.spots_app.auth_management.token.TokenRepository; -import com.shulpov.spots_app.auth_management.token.TokenService; -import com.shulpov.spots_app.auth_management.token.TokenType; -import com.shulpov.spots_app.auth_management.validators.UserValidator; -import com.shulpov.spots_app.user.Role; -import com.shulpov.spots_app.user.User; -import com.shulpov.spots_app.user.UserRepository; +import com.shulpov.spots_app.authentication_management.exceptions.RegisterErrorException; +import com.shulpov.spots_app.authentication_management.requests.AuthenticationRequest; +import com.shulpov.spots_app.authentication_management.requests.RegisterRequest; +import com.shulpov.spots_app.authentication_management.responses.AuthenticationResponse; +import com.shulpov.spots_app.authentication_management.responses.LogoutMessageResponse; +import com.shulpov.spots_app.authentication_management.responses.RegisterResponse; +import com.shulpov.spots_app.authentication_management.tokens.Token; +import com.shulpov.spots_app.authentication_management.tokens.TokenRepository; +import com.shulpov.spots_app.authentication_management.tokens.TokenService; +import com.shulpov.spots_app.authentication_management.tokens.TokenType; +import com.shulpov.spots_app.authentication_management.validators.UserValidator; +import com.shulpov.spots_app.users.authorization.Role; +import com.shulpov.spots_app.users.models.User; +import com.shulpov.spots_app.users.UserRepository; import io.jsonwebtoken.JwtException; import lombok.RequiredArgsConstructor; import org.springframework.security.authentication.AuthenticationManager; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/services/JwtService.java b/src/main/java/com/shulpov/spots_app/authentication_management/services/JwtService.java similarity index 98% rename from src/main/java/com/shulpov/spots_app/auth_management/services/JwtService.java rename to src/main/java/com/shulpov/spots_app/authentication_management/services/JwtService.java index 5ad6446..06419a8 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/services/JwtService.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/services/JwtService.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.auth_management.services; +package com.shulpov.spots_app.authentication_management.services; import io.jsonwebtoken.*; import io.jsonwebtoken.io.Decoders; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/token/Token.java b/src/main/java/com/shulpov/spots_app/authentication_management/tokens/Token.java similarity index 80% rename from src/main/java/com/shulpov/spots_app/auth_management/token/Token.java rename to src/main/java/com/shulpov/spots_app/authentication_management/tokens/Token.java index 2c45a4b..ff5a9fe 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/token/Token.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/tokens/Token.java @@ -1,6 +1,6 @@ -package com.shulpov.spots_app.auth_management.token; +package com.shulpov.spots_app.authentication_management.tokens; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.users.models.User; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/token/TokenRepository.java b/src/main/java/com/shulpov/spots_app/authentication_management/tokens/TokenRepository.java similarity index 75% rename from src/main/java/com/shulpov/spots_app/auth_management/token/TokenRepository.java rename to src/main/java/com/shulpov/spots_app/authentication_management/tokens/TokenRepository.java index 53b5025..87daa28 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/token/TokenRepository.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/tokens/TokenRepository.java @@ -1,6 +1,6 @@ -package com.shulpov.spots_app.auth_management.token; +package com.shulpov.spots_app.authentication_management.tokens; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.users.models.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/shulpov/spots_app/auth_management/token/TokenService.java b/src/main/java/com/shulpov/spots_app/authentication_management/tokens/TokenService.java similarity index 93% rename from src/main/java/com/shulpov/spots_app/auth_management/token/TokenService.java rename to src/main/java/com/shulpov/spots_app/authentication_management/tokens/TokenService.java index 4184ed6..a82fd47 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/token/TokenService.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/tokens/TokenService.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.auth_management.token; +package com.shulpov.spots_app.authentication_management.tokens; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/shulpov/spots_app/authentication_management/tokens/TokenType.java b/src/main/java/com/shulpov/spots_app/authentication_management/tokens/TokenType.java new file mode 100644 index 0000000..eede07d --- /dev/null +++ b/src/main/java/com/shulpov/spots_app/authentication_management/tokens/TokenType.java @@ -0,0 +1,6 @@ +package com.shulpov.spots_app.authentication_management.tokens; + +public enum TokenType { + // BEARER, + REFRESH +} diff --git a/src/main/java/com/shulpov/spots_app/auth_management/validators/UserValidator.java b/src/main/java/com/shulpov/spots_app/authentication_management/validators/UserValidator.java similarity index 95% rename from src/main/java/com/shulpov/spots_app/auth_management/validators/UserValidator.java rename to src/main/java/com/shulpov/spots_app/authentication_management/validators/UserValidator.java index 88350a5..cb47deb 100644 --- a/src/main/java/com/shulpov/spots_app/auth_management/validators/UserValidator.java +++ b/src/main/java/com/shulpov/spots_app/authentication_management/validators/UserValidator.java @@ -1,11 +1,10 @@ -package com.shulpov.spots_app.auth_management.validators; +package com.shulpov.spots_app.authentication_management.validators; -import com.shulpov.spots_app.services.UserService; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.users.UserService; +import com.shulpov.spots_app.users.models.User; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.lang.NonNullApi; import org.springframework.stereotype.Component; import org.springframework.validation.Errors; import org.springframework.validation.Validator; diff --git a/src/main/java/com/shulpov/spots_app/models/Comment.java b/src/main/java/com/shulpov/spots_app/comments/Comment.java similarity index 92% rename from src/main/java/com/shulpov/spots_app/models/Comment.java rename to src/main/java/com/shulpov/spots_app/comments/Comment.java index 788e362..3d683e5 100644 --- a/src/main/java/com/shulpov/spots_app/models/Comment.java +++ b/src/main/java/com/shulpov/spots_app/comments/Comment.java @@ -1,6 +1,7 @@ -package com.shulpov.spots_app.models; +package com.shulpov.spots_app.comments; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.users.models.User; import jakarta.persistence.*; import jakarta.validation.constraints.Size; import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank; diff --git a/src/main/java/com/shulpov/spots_app/controllers/CommentController.java b/src/main/java/com/shulpov/spots_app/comments/CommentController.java similarity index 94% rename from src/main/java/com/shulpov/spots_app/controllers/CommentController.java rename to src/main/java/com/shulpov/spots_app/comments/CommentController.java index b540e5b..d7290ef 100644 --- a/src/main/java/com/shulpov/spots_app/controllers/CommentController.java +++ b/src/main/java/com/shulpov/spots_app/comments/CommentController.java @@ -1,10 +1,7 @@ -package com.shulpov.spots_app.controllers; +package com.shulpov.spots_app.comments; -import com.shulpov.spots_app.dto.CommentDto; -import com.shulpov.spots_app.models.Comment; -import com.shulpov.spots_app.user.User; -import com.shulpov.spots_app.services.CommentService; -import com.shulpov.spots_app.services.UserService; +import com.shulpov.spots_app.users.models.User; +import com.shulpov.spots_app.users.UserService; import com.shulpov.spots_app.utils.DtoConverter; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/shulpov/spots_app/dto/CommentDto.java b/src/main/java/com/shulpov/spots_app/comments/CommentDto.java similarity index 92% rename from src/main/java/com/shulpov/spots_app/dto/CommentDto.java rename to src/main/java/com/shulpov/spots_app/comments/CommentDto.java index 26bf367..b9bf8b8 100644 --- a/src/main/java/com/shulpov/spots_app/dto/CommentDto.java +++ b/src/main/java/com/shulpov/spots_app/comments/CommentDto.java @@ -1,5 +1,6 @@ -package com.shulpov.spots_app.dto; +package com.shulpov.spots_app.comments; +import com.shulpov.spots_app.users.dto.UserWithoutSpotsDto; import jakarta.validation.constraints.Size; import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank; diff --git a/src/main/java/com/shulpov/spots_app/repo/CommentRepo.java b/src/main/java/com/shulpov/spots_app/comments/CommentRepo.java similarity index 68% rename from src/main/java/com/shulpov/spots_app/repo/CommentRepo.java rename to src/main/java/com/shulpov/spots_app/comments/CommentRepo.java index 04842e6..32780f6 100644 --- a/src/main/java/com/shulpov/spots_app/repo/CommentRepo.java +++ b/src/main/java/com/shulpov/spots_app/comments/CommentRepo.java @@ -1,7 +1,6 @@ -package com.shulpov.spots_app.repo; +package com.shulpov.spots_app.comments; -import com.shulpov.spots_app.models.Comment; -import com.shulpov.spots_app.models.Spot; +import com.shulpov.spots_app.spots.models.Spot; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/shulpov/spots_app/services/CommentService.java b/src/main/java/com/shulpov/spots_app/comments/CommentService.java similarity index 92% rename from src/main/java/com/shulpov/spots_app/services/CommentService.java rename to src/main/java/com/shulpov/spots_app/comments/CommentService.java index 2ed64b5..63dbd3e 100644 --- a/src/main/java/com/shulpov/spots_app/services/CommentService.java +++ b/src/main/java/com/shulpov/spots_app/comments/CommentService.java @@ -1,9 +1,8 @@ -package com.shulpov.spots_app.services; +package com.shulpov.spots_app.comments; -import com.shulpov.spots_app.models.Comment; -import com.shulpov.spots_app.models.Spot; -import com.shulpov.spots_app.user.User; -import com.shulpov.spots_app.repo.CommentRepo; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.spots.SpotService; +import com.shulpov.spots_app.users.models.User; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; diff --git a/src/main/java/com/shulpov/spots_app/configs/ApplicationConfig.java b/src/main/java/com/shulpov/spots_app/configs/ApplicationConfig.java index 8a6a01e..8df7632 100644 --- a/src/main/java/com/shulpov/spots_app/configs/ApplicationConfig.java +++ b/src/main/java/com/shulpov/spots_app/configs/ApplicationConfig.java @@ -1,7 +1,7 @@ package com.shulpov.spots_app.configs; import com.fasterxml.jackson.databind.ObjectMapper; -import com.shulpov.spots_app.user.UserRepository; +import com.shulpov.spots_app.users.UserRepository; import lombok.RequiredArgsConstructor; import org.modelmapper.ModelMapper; import org.slf4j.Logger; diff --git a/src/main/java/com/shulpov/spots_app/configs/SecurityConfig.java b/src/main/java/com/shulpov/spots_app/configs/SecurityConfig.java index 4e5d37f..7302ac0 100644 --- a/src/main/java/com/shulpov/spots_app/configs/SecurityConfig.java +++ b/src/main/java/com/shulpov/spots_app/configs/SecurityConfig.java @@ -1,7 +1,7 @@ package com.shulpov.spots_app.configs; -import com.shulpov.spots_app.auth_management.auth_providers.LoginPasswordAuthenticationProvider; -import com.shulpov.spots_app.auth_management.filters.JwtAuthenticationFilter; +import com.shulpov.spots_app.authentication_management.auth_providers.LoginPasswordAuthenticationProvider; +import com.shulpov.spots_app.authentication_management.filters.JwtAuthenticationFilter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity; diff --git a/src/main/java/com/shulpov/spots_app/controllers/ImageInfoController.java b/src/main/java/com/shulpov/spots_app/image_infos/ImageInfoController.java similarity index 96% rename from src/main/java/com/shulpov/spots_app/controllers/ImageInfoController.java rename to src/main/java/com/shulpov/spots_app/image_infos/ImageInfoController.java index c92a6a3..841dcd1 100644 --- a/src/main/java/com/shulpov/spots_app/controllers/ImageInfoController.java +++ b/src/main/java/com/shulpov/spots_app/image_infos/ImageInfoController.java @@ -1,9 +1,8 @@ -package com.shulpov.spots_app.controllers; +package com.shulpov.spots_app.image_infos; -import com.shulpov.spots_app.models.ImageInfo; -import com.shulpov.spots_app.user.User; -import com.shulpov.spots_app.services.ImageInfoService; -import com.shulpov.spots_app.services.UserService; +import com.shulpov.spots_app.image_infos.models.ImageInfo; +import com.shulpov.spots_app.users.models.User; +import com.shulpov.spots_app.users.UserService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.slf4j.Logger; @@ -145,6 +144,7 @@ public ResponseEntity> deleteUserImage(@PathVariable("id") L } logger.atInfo().log("/delete-user-image/{}: user doesn't exist or userHasImageWithId=false", id); return new ResponseEntity<>( + //TODO обработать ошибку нормально, заменить ловлю обычного Exception Map.of("message","image with id=" + id + " for user=" + user.get().getName() + " not found"), HttpStatus.BAD_REQUEST); } catch (IOException e) { diff --git a/src/main/java/com/shulpov/spots_app/repo/ImageInfoRepo.java b/src/main/java/com/shulpov/spots_app/image_infos/ImageInfoRepo.java similarity index 77% rename from src/main/java/com/shulpov/spots_app/repo/ImageInfoRepo.java rename to src/main/java/com/shulpov/spots_app/image_infos/ImageInfoRepo.java index c21e4b8..4287b52 100644 --- a/src/main/java/com/shulpov/spots_app/repo/ImageInfoRepo.java +++ b/src/main/java/com/shulpov/spots_app/image_infos/ImageInfoRepo.java @@ -1,15 +1,12 @@ -package com.shulpov.spots_app.repo; +package com.shulpov.spots_app.image_infos; -import com.shulpov.spots_app.models.ImageInfo; -import com.shulpov.spots_app.models.Spot; +import com.shulpov.spots_app.image_infos.models.ImageInfo; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; -import java.util.List; - @Repository public interface ImageInfoRepo extends JpaRepository { diff --git a/src/main/java/com/shulpov/spots_app/services/ImageInfoService.java b/src/main/java/com/shulpov/spots_app/image_infos/ImageInfoService.java similarity index 96% rename from src/main/java/com/shulpov/spots_app/services/ImageInfoService.java rename to src/main/java/com/shulpov/spots_app/image_infos/ImageInfoService.java index 304c670..793b5ab 100644 --- a/src/main/java/com/shulpov/spots_app/services/ImageInfoService.java +++ b/src/main/java/com/shulpov/spots_app/image_infos/ImageInfoService.java @@ -1,10 +1,10 @@ -package com.shulpov.spots_app.services; +package com.shulpov.spots_app.image_infos; -import com.shulpov.spots_app.file_manager.FileManager; -import com.shulpov.spots_app.models.ImageInfo; -import com.shulpov.spots_app.models.Spot; -import com.shulpov.spots_app.user.User; -import com.shulpov.spots_app.repo.ImageInfoRepo; +import com.shulpov.spots_app.utils.file_manager.FileManager; +import com.shulpov.spots_app.image_infos.models.ImageInfo; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.spots.SpotService; +import com.shulpov.spots_app.users.models.User; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/com/shulpov/spots_app/dto/ImageInfoDto.java b/src/main/java/com/shulpov/spots_app/image_infos/dto/ImageInfoDto.java similarity index 93% rename from src/main/java/com/shulpov/spots_app/dto/ImageInfoDto.java rename to src/main/java/com/shulpov/spots_app/image_infos/dto/ImageInfoDto.java index 5970a31..277a572 100644 --- a/src/main/java/com/shulpov/spots_app/dto/ImageInfoDto.java +++ b/src/main/java/com/shulpov/spots_app/image_infos/dto/ImageInfoDto.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.dto; +package com.shulpov.spots_app.image_infos.dto; import java.util.Date; diff --git a/src/main/java/com/shulpov/spots_app/models/ImageInfo.java b/src/main/java/com/shulpov/spots_app/image_infos/models/ImageInfo.java similarity index 92% rename from src/main/java/com/shulpov/spots_app/models/ImageInfo.java rename to src/main/java/com/shulpov/spots_app/image_infos/models/ImageInfo.java index 65c44e7..d54d277 100644 --- a/src/main/java/com/shulpov/spots_app/models/ImageInfo.java +++ b/src/main/java/com/shulpov/spots_app/image_infos/models/ImageInfo.java @@ -1,6 +1,7 @@ -package com.shulpov.spots_app.models; +package com.shulpov.spots_app.image_infos.models; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.users.models.User; import jakarta.persistence.*; import java.util.Date; diff --git a/src/main/java/com/shulpov/spots_app/location/repo/CityRepo.java b/src/main/java/com/shulpov/spots_app/location/repo/CityRepo.java deleted file mode 100644 index 75f6d53..0000000 --- a/src/main/java/com/shulpov/spots_app/location/repo/CityRepo.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.shulpov.spots_app.location.repo; - -import com.shulpov.spots_app.location.models.City; -import com.shulpov.spots_app.location.models.Country; -import com.shulpov.spots_app.location.models.Region; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface CityRepo extends JpaRepository { - List findByRegion(Region region); - - List findByRegion_Country(Country country); - -} \ No newline at end of file diff --git a/src/main/java/com/shulpov/spots_app/location/controllers/CityController.java b/src/main/java/com/shulpov/spots_app/locations/controllers/CityController.java similarity index 94% rename from src/main/java/com/shulpov/spots_app/location/controllers/CityController.java rename to src/main/java/com/shulpov/spots_app/locations/controllers/CityController.java index 62c1c4c..14568a7 100644 --- a/src/main/java/com/shulpov/spots_app/location/controllers/CityController.java +++ b/src/main/java/com/shulpov/spots_app/locations/controllers/CityController.java @@ -1,8 +1,8 @@ -package com.shulpov.spots_app.location.controllers; +package com.shulpov.spots_app.locations.controllers; -import com.shulpov.spots_app.location.dto.CityDto; -import com.shulpov.spots_app.location.models.City; -import com.shulpov.spots_app.location.services.CityService; +import com.shulpov.spots_app.locations.dto.CityDto; +import com.shulpov.spots_app.locations.models.City; +import com.shulpov.spots_app.locations.services.CityService; import com.shulpov.spots_app.utils.DtoConverter; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/shulpov/spots_app/location/controllers/CountryController.java b/src/main/java/com/shulpov/spots_app/locations/controllers/CountryController.java similarity index 91% rename from src/main/java/com/shulpov/spots_app/location/controllers/CountryController.java rename to src/main/java/com/shulpov/spots_app/locations/controllers/CountryController.java index 6a86779..f6152b3 100644 --- a/src/main/java/com/shulpov/spots_app/location/controllers/CountryController.java +++ b/src/main/java/com/shulpov/spots_app/locations/controllers/CountryController.java @@ -1,7 +1,7 @@ -package com.shulpov.spots_app.location.controllers; +package com.shulpov.spots_app.locations.controllers; -import com.shulpov.spots_app.location.dto.CountryDto; -import com.shulpov.spots_app.location.services.CountryService; +import com.shulpov.spots_app.locations.dto.CountryDto; +import com.shulpov.spots_app.locations.services.CountryService; import com.shulpov.spots_app.utils.DtoConverter; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/shulpov/spots_app/location/controllers/RegionController.java b/src/main/java/com/shulpov/spots_app/locations/controllers/RegionController.java similarity index 93% rename from src/main/java/com/shulpov/spots_app/location/controllers/RegionController.java rename to src/main/java/com/shulpov/spots_app/locations/controllers/RegionController.java index fcde8da..447f18e 100644 --- a/src/main/java/com/shulpov/spots_app/location/controllers/RegionController.java +++ b/src/main/java/com/shulpov/spots_app/locations/controllers/RegionController.java @@ -1,8 +1,8 @@ -package com.shulpov.spots_app.location.controllers; +package com.shulpov.spots_app.locations.controllers; -import com.shulpov.spots_app.location.dto.RegionDto; -import com.shulpov.spots_app.location.models.Region; -import com.shulpov.spots_app.location.services.RegionService; +import com.shulpov.spots_app.locations.dto.RegionDto; +import com.shulpov.spots_app.locations.models.Region; +import com.shulpov.spots_app.locations.services.RegionService; import com.shulpov.spots_app.utils.DtoConverter; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/shulpov/spots_app/location/dto/CityDto.java b/src/main/java/com/shulpov/spots_app/locations/dto/CityDto.java similarity index 75% rename from src/main/java/com/shulpov/spots_app/location/dto/CityDto.java rename to src/main/java/com/shulpov/spots_app/locations/dto/CityDto.java index 4754ad2..b2d3629 100644 --- a/src/main/java/com/shulpov/spots_app/location/dto/CityDto.java +++ b/src/main/java/com/shulpov/spots_app/locations/dto/CityDto.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.location.dto; +package com.shulpov.spots_app.locations.dto; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/shulpov/spots_app/location/dto/CountryDto.java b/src/main/java/com/shulpov/spots_app/locations/dto/CountryDto.java similarity index 75% rename from src/main/java/com/shulpov/spots_app/location/dto/CountryDto.java rename to src/main/java/com/shulpov/spots_app/locations/dto/CountryDto.java index 50c37ef..96273a1 100644 --- a/src/main/java/com/shulpov/spots_app/location/dto/CountryDto.java +++ b/src/main/java/com/shulpov/spots_app/locations/dto/CountryDto.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.location.dto; +package com.shulpov.spots_app.locations.dto; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/shulpov/spots_app/location/dto/RegionDto.java b/src/main/java/com/shulpov/spots_app/locations/dto/RegionDto.java similarity index 75% rename from src/main/java/com/shulpov/spots_app/location/dto/RegionDto.java rename to src/main/java/com/shulpov/spots_app/locations/dto/RegionDto.java index 8e80d42..a8e3a58 100644 --- a/src/main/java/com/shulpov/spots_app/location/dto/RegionDto.java +++ b/src/main/java/com/shulpov/spots_app/locations/dto/RegionDto.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.location.dto; +package com.shulpov.spots_app.locations.dto; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/com/shulpov/spots_app/location/models/City.java b/src/main/java/com/shulpov/spots_app/locations/models/City.java similarity index 88% rename from src/main/java/com/shulpov/spots_app/location/models/City.java rename to src/main/java/com/shulpov/spots_app/locations/models/City.java index a1269c2..0093a49 100644 --- a/src/main/java/com/shulpov/spots_app/location/models/City.java +++ b/src/main/java/com/shulpov/spots_app/locations/models/City.java @@ -1,7 +1,7 @@ -package com.shulpov.spots_app.location.models; +package com.shulpov.spots_app.locations.models; -import com.shulpov.spots_app.models.Spot; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.users.models.User; import jakarta.persistence.*; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/shulpov/spots_app/location/models/Country.java b/src/main/java/com/shulpov/spots_app/locations/models/Country.java similarity index 92% rename from src/main/java/com/shulpov/spots_app/location/models/Country.java rename to src/main/java/com/shulpov/spots_app/locations/models/Country.java index 9f777ae..8fb185a 100644 --- a/src/main/java/com/shulpov/spots_app/location/models/Country.java +++ b/src/main/java/com/shulpov/spots_app/locations/models/Country.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.location.models; +package com.shulpov.spots_app.locations.models; import jakarta.persistence.*; import lombok.Builder; diff --git a/src/main/java/com/shulpov/spots_app/location/models/Region.java b/src/main/java/com/shulpov/spots_app/locations/models/Region.java similarity index 94% rename from src/main/java/com/shulpov/spots_app/location/models/Region.java rename to src/main/java/com/shulpov/spots_app/locations/models/Region.java index df2e653..d7c9e07 100644 --- a/src/main/java/com/shulpov/spots_app/location/models/Region.java +++ b/src/main/java/com/shulpov/spots_app/locations/models/Region.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.location.models; +package com.shulpov.spots_app.locations.models; import jakarta.persistence.*; import lombok.Builder; diff --git a/src/main/java/com/shulpov/spots_app/locations/repo/CityRepo.java b/src/main/java/com/shulpov/spots_app/locations/repo/CityRepo.java new file mode 100644 index 0000000..2fca2db --- /dev/null +++ b/src/main/java/com/shulpov/spots_app/locations/repo/CityRepo.java @@ -0,0 +1,18 @@ +package com.shulpov.spots_app.locations.repo; + +import com.shulpov.spots_app.locations.models.City; +import com.shulpov.spots_app.locations.models.Country; +import com.shulpov.spots_app.locations.models.Region; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface CityRepo extends JpaRepository { + List findByRegion(Region region); + + //hibernat'у нужно нижнее подчеркивание для того, чтобы не путать таблицу с полем (само генерится) + List findByRegion_Country(Country country); + +} \ No newline at end of file diff --git a/src/main/java/com/shulpov/spots_app/location/repo/CountryRepo.java b/src/main/java/com/shulpov/spots_app/locations/repo/CountryRepo.java similarity index 66% rename from src/main/java/com/shulpov/spots_app/location/repo/CountryRepo.java rename to src/main/java/com/shulpov/spots_app/locations/repo/CountryRepo.java index d44cd9d..c259846 100644 --- a/src/main/java/com/shulpov/spots_app/location/repo/CountryRepo.java +++ b/src/main/java/com/shulpov/spots_app/locations/repo/CountryRepo.java @@ -1,6 +1,6 @@ -package com.shulpov.spots_app.location.repo; +package com.shulpov.spots_app.locations.repo; -import com.shulpov.spots_app.location.models.Country; +import com.shulpov.spots_app.locations.models.Country; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/shulpov/spots_app/location/repo/RegionRepo.java b/src/main/java/com/shulpov/spots_app/locations/repo/RegionRepo.java similarity index 63% rename from src/main/java/com/shulpov/spots_app/location/repo/RegionRepo.java rename to src/main/java/com/shulpov/spots_app/locations/repo/RegionRepo.java index d034c32..08185fe 100644 --- a/src/main/java/com/shulpov/spots_app/location/repo/RegionRepo.java +++ b/src/main/java/com/shulpov/spots_app/locations/repo/RegionRepo.java @@ -1,7 +1,7 @@ -package com.shulpov.spots_app.location.repo; +package com.shulpov.spots_app.locations.repo; -import com.shulpov.spots_app.location.models.Country; -import com.shulpov.spots_app.location.models.Region; +import com.shulpov.spots_app.locations.models.Country; +import com.shulpov.spots_app.locations.models.Region; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/shulpov/spots_app/location/services/CityService.java b/src/main/java/com/shulpov/spots_app/locations/services/CityService.java similarity index 80% rename from src/main/java/com/shulpov/spots_app/location/services/CityService.java rename to src/main/java/com/shulpov/spots_app/locations/services/CityService.java index 515456c..d413a30 100644 --- a/src/main/java/com/shulpov/spots_app/location/services/CityService.java +++ b/src/main/java/com/shulpov/spots_app/locations/services/CityService.java @@ -1,9 +1,9 @@ -package com.shulpov.spots_app.location.services; +package com.shulpov.spots_app.locations.services; -import com.shulpov.spots_app.location.models.City; -import com.shulpov.spots_app.location.models.Country; -import com.shulpov.spots_app.location.models.Region; -import com.shulpov.spots_app.location.repo.CityRepo; +import com.shulpov.spots_app.locations.models.City; +import com.shulpov.spots_app.locations.models.Country; +import com.shulpov.spots_app.locations.models.Region; +import com.shulpov.spots_app.locations.repo.CityRepo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Scope; @@ -57,6 +57,7 @@ public List getByCountryId(Integer id) { logger.atInfo().log("getByCountryId id={}", id); Optional optCountry = countryService.getById(id); if (optCountry.isPresent()) { + //hibernat'у нужно нижнее подчеркивание для того, чтобы не путать таблицу с полем (само генерится) return cityRepo.findByRegion_Country(optCountry.get()); } else { throw new NotFoundException("Country not found"); diff --git a/src/main/java/com/shulpov/spots_app/location/services/CountryService.java b/src/main/java/com/shulpov/spots_app/locations/services/CountryService.java similarity index 84% rename from src/main/java/com/shulpov/spots_app/location/services/CountryService.java rename to src/main/java/com/shulpov/spots_app/locations/services/CountryService.java index 767a81e..bcb7d47 100644 --- a/src/main/java/com/shulpov/spots_app/location/services/CountryService.java +++ b/src/main/java/com/shulpov/spots_app/locations/services/CountryService.java @@ -1,7 +1,7 @@ -package com.shulpov.spots_app.location.services; +package com.shulpov.spots_app.locations.services; -import com.shulpov.spots_app.location.models.Country; -import com.shulpov.spots_app.location.repo.CountryRepo; +import com.shulpov.spots_app.locations.models.Country; +import com.shulpov.spots_app.locations.repo.CountryRepo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Scope; diff --git a/src/main/java/com/shulpov/spots_app/location/services/RegionService.java b/src/main/java/com/shulpov/spots_app/locations/services/RegionService.java similarity index 87% rename from src/main/java/com/shulpov/spots_app/location/services/RegionService.java rename to src/main/java/com/shulpov/spots_app/locations/services/RegionService.java index 2a29bca..906c7d1 100644 --- a/src/main/java/com/shulpov/spots_app/location/services/RegionService.java +++ b/src/main/java/com/shulpov/spots_app/locations/services/RegionService.java @@ -1,8 +1,8 @@ -package com.shulpov.spots_app.location.services; +package com.shulpov.spots_app.locations.services; -import com.shulpov.spots_app.location.models.Country; -import com.shulpov.spots_app.location.models.Region; -import com.shulpov.spots_app.location.repo.RegionRepo; +import com.shulpov.spots_app.locations.models.Country; +import com.shulpov.spots_app.locations.models.Region; +import com.shulpov.spots_app.locations.repo.RegionRepo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Scope; diff --git a/src/main/java/com/shulpov/spots_app/responses/ValidationErrorResponse.java b/src/main/java/com/shulpov/spots_app/responses/ValidationErrorResponse.java index 4e828fb..7e87351 100644 --- a/src/main/java/com/shulpov/spots_app/responses/ValidationErrorResponse.java +++ b/src/main/java/com/shulpov/spots_app/responses/ValidationErrorResponse.java @@ -2,10 +2,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.shulpov.spots_app.dto.FieldErrorDto; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import lombok.*; import java.util.List; @@ -13,7 +10,8 @@ * @author Shulpov Victor */ -@Data +@Getter +@Setter @Builder @AllArgsConstructor @NoArgsConstructor diff --git a/src/main/java/com/shulpov/spots_app/spot_references/models/SpaceType.java b/src/main/java/com/shulpov/spots_app/spot_references/models/SpaceType.java index bbdf83f..f763067 100644 --- a/src/main/java/com/shulpov/spots_app/spot_references/models/SpaceType.java +++ b/src/main/java/com/shulpov/spots_app/spot_references/models/SpaceType.java @@ -1,7 +1,7 @@ package com.shulpov.spots_app.spot_references.models; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.shulpov.spots_app.models.Spot; +import com.shulpov.spots_app.spots.models.Spot; import jakarta.persistence.*; import java.util.List; diff --git a/src/main/java/com/shulpov/spots_app/spot_references/models/SportType.java b/src/main/java/com/shulpov/spots_app/spot_references/models/SportType.java index 512c9b1..838ed2f 100644 --- a/src/main/java/com/shulpov/spots_app/spot_references/models/SportType.java +++ b/src/main/java/com/shulpov/spots_app/spot_references/models/SportType.java @@ -1,7 +1,7 @@ package com.shulpov.spots_app.spot_references.models; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.shulpov.spots_app.models.Spot; +import com.shulpov.spots_app.spots.models.Spot; import jakarta.persistence.*; import java.util.List; diff --git a/src/main/java/com/shulpov/spots_app/spot_references/models/SpotType.java b/src/main/java/com/shulpov/spots_app/spot_references/models/SpotType.java index 080c883..2c319d8 100644 --- a/src/main/java/com/shulpov/spots_app/spot_references/models/SpotType.java +++ b/src/main/java/com/shulpov/spots_app/spot_references/models/SpotType.java @@ -1,7 +1,7 @@ package com.shulpov.spots_app.spot_references.models; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.shulpov.spots_app.models.Spot; +import com.shulpov.spots_app.spots.models.Spot; import jakarta.persistence.*; import java.util.List; diff --git a/src/main/java/com/shulpov/spots_app/controllers/SpotUserController.java b/src/main/java/com/shulpov/spots_app/spot_user_infos/SpotUserController.java similarity index 93% rename from src/main/java/com/shulpov/spots_app/controllers/SpotUserController.java rename to src/main/java/com/shulpov/spots_app/spot_user_infos/SpotUserController.java index 53c9756..7e05da4 100644 --- a/src/main/java/com/shulpov/spots_app/controllers/SpotUserController.java +++ b/src/main/java/com/shulpov/spots_app/spot_user_infos/SpotUserController.java @@ -1,13 +1,12 @@ -package com.shulpov.spots_app.controllers; +package com.shulpov.spots_app.spot_user_infos; -import com.shulpov.spots_app.dto.SpotDto; -import com.shulpov.spots_app.dto.SpotUserDto; -import com.shulpov.spots_app.models.Spot; -import com.shulpov.spots_app.models.SpotUser; -import com.shulpov.spots_app.user.User; -import com.shulpov.spots_app.services.SpotService; -import com.shulpov.spots_app.services.SpotUserService; -import com.shulpov.spots_app.services.UserService; +import com.shulpov.spots_app.spot_user_infos.dto.SpotUserDto; +import com.shulpov.spots_app.spot_user_infos.models.SpotUser; +import com.shulpov.spots_app.spots.dto.SpotDto; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.users.models.User; +import com.shulpov.spots_app.spots.SpotService; +import com.shulpov.spots_app.users.UserService; import com.shulpov.spots_app.utils.DtoConverter; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/shulpov/spots_app/repo/SpotUserRepo.java b/src/main/java/com/shulpov/spots_app/spot_user_infos/SpotUserRepo.java similarity index 87% rename from src/main/java/com/shulpov/spots_app/repo/SpotUserRepo.java rename to src/main/java/com/shulpov/spots_app/spot_user_infos/SpotUserRepo.java index 32dfcf3..53d4c4e 100644 --- a/src/main/java/com/shulpov/spots_app/repo/SpotUserRepo.java +++ b/src/main/java/com/shulpov/spots_app/spot_user_infos/SpotUserRepo.java @@ -1,8 +1,8 @@ -package com.shulpov.spots_app.repo; +package com.shulpov.spots_app.spot_user_infos; -import com.shulpov.spots_app.models.Spot; -import com.shulpov.spots_app.models.SpotUser; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.spot_user_infos.models.SpotUser; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.users.models.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; diff --git a/src/main/java/com/shulpov/spots_app/services/SpotUserService.java b/src/main/java/com/shulpov/spots_app/spot_user_infos/SpotUserService.java similarity index 79% rename from src/main/java/com/shulpov/spots_app/services/SpotUserService.java rename to src/main/java/com/shulpov/spots_app/spot_user_infos/SpotUserService.java index d48a66d..7814a09 100644 --- a/src/main/java/com/shulpov/spots_app/services/SpotUserService.java +++ b/src/main/java/com/shulpov/spots_app/spot_user_infos/SpotUserService.java @@ -1,10 +1,9 @@ -package com.shulpov.spots_app.services; +package com.shulpov.spots_app.spot_user_infos; -import com.shulpov.spots_app.models.Spot; -import com.shulpov.spots_app.models.SpotUser; -import com.shulpov.spots_app.user.User; -import com.shulpov.spots_app.models.pk.UserSpotPK; -import com.shulpov.spots_app.repo.SpotUserRepo; +import com.shulpov.spots_app.spot_user_infos.models.SpotUser; +import com.shulpov.spots_app.spot_user_infos.models.UserSpotPK; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.users.models.User; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -20,6 +19,11 @@ @Transactional(readOnly = true) @Scope(value = "prototype") public class SpotUserService { + private static final String SPOT_ID_KEY = "spot_id"; + private static final String USER_ID_KEY = "user_id"; + private static final String IS_FAVORITE_KEY = "is_favorite"; + private static final String IS_LIKED_KEY = "is_liked"; + private final SpotUserRepo spotUserRepo; private final Logger logger = LoggerFactory.getLogger(SpotUserService.class); @Autowired @@ -37,9 +41,9 @@ public Map changeLikeState(Spot spot, User user) { SpotUser spotUser = spotUserOpt.get(); spotUser.setLiked(!spotUser.getLiked()); SpotUser newSpotUser = spotUserRepo.save(spotUser); - return Map.of("spotId", newSpotUser.getPostedSpot().getId(), - "userId", newSpotUser.getUserActor().getId(), - "isLiked", newSpotUser.getLiked()); + return Map.of(SPOT_ID_KEY, newSpotUser.getPostedSpot().getId(), + USER_ID_KEY, newSpotUser.getUserActor().getId(), + IS_LIKED_KEY, newSpotUser.getLiked()); } else { logger.atInfo().log("changeLikeState spot_id={} user_id={} create new instance", spot.getId(), user.getId()); SpotUser spotUser = new SpotUser(); @@ -49,9 +53,9 @@ public Map changeLikeState(Spot spot, User user) { spotUser.setLiked(true); spotUser.setFavorite(false); SpotUser newSpotUser = spotUserRepo.save(spotUser); - return Map.of("spotId", newSpotUser.getPostedSpot().getId(), - "userId", newSpotUser.getUserActor().getId(), - "isLiked", newSpotUser.getLiked()); + return Map.of(SPOT_ID_KEY, newSpotUser.getPostedSpot().getId(), + USER_ID_KEY, newSpotUser.getUserActor().getId(), + IS_LIKED_KEY, newSpotUser.getLiked()); } } @@ -65,9 +69,9 @@ public Map changeFavoriteState(Spot spot, User user) { SpotUser spotUser = spotUserOpt.get(); spotUser.setFavorite(!spotUser.getFavorite()); SpotUser newSpotUser = spotUserRepo.save(spotUser); - return Map.of("spotId", newSpotUser.getPostedSpot().getId(), - "userId", newSpotUser.getUserActor().getId(), - "isFavorite", newSpotUser.getFavorite()); + return Map.of(SPOT_ID_KEY, newSpotUser.getPostedSpot().getId(), + USER_ID_KEY, newSpotUser.getUserActor().getId(), + IS_FAVORITE_KEY, newSpotUser.getFavorite()); } else { logger.atInfo().log("changeFavoriteState spot_id={} user_id={} create new instance", spot.getId(), user.getId()); SpotUser spotUser = new SpotUser(); @@ -77,9 +81,9 @@ public Map changeFavoriteState(Spot spot, User user) { spotUser.setFavorite(true); spotUser.setLiked(false); SpotUser newSpotUser = spotUserRepo.save(spotUser); - return Map.of("spotId", newSpotUser.getPostedSpot().getId(), - "userId", newSpotUser.getUserActor().getId(), - "isFavorite", newSpotUser.getFavorite()); + return Map.of(SPOT_ID_KEY, newSpotUser.getPostedSpot().getId(), + USER_ID_KEY, newSpotUser.getUserActor().getId(), + IS_FAVORITE_KEY, newSpotUser.getFavorite()); } } diff --git a/src/main/java/com/shulpov/spots_app/dto/SpotUserDto.java b/src/main/java/com/shulpov/spots_app/spot_user_infos/dto/SpotUserDto.java similarity index 93% rename from src/main/java/com/shulpov/spots_app/dto/SpotUserDto.java rename to src/main/java/com/shulpov/spots_app/spot_user_infos/dto/SpotUserDto.java index c75c33a..9cd0a84 100644 --- a/src/main/java/com/shulpov/spots_app/dto/SpotUserDto.java +++ b/src/main/java/com/shulpov/spots_app/spot_user_infos/dto/SpotUserDto.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.dto; +package com.shulpov.spots_app.spot_user_infos.dto; public class SpotUserDto { diff --git a/src/main/java/com/shulpov/spots_app/models/SpotUser.java b/src/main/java/com/shulpov/spots_app/spot_user_infos/models/SpotUser.java similarity index 91% rename from src/main/java/com/shulpov/spots_app/models/SpotUser.java rename to src/main/java/com/shulpov/spots_app/spot_user_infos/models/SpotUser.java index a4990ed..b711c3a 100644 --- a/src/main/java/com/shulpov/spots_app/models/SpotUser.java +++ b/src/main/java/com/shulpov/spots_app/spot_user_infos/models/SpotUser.java @@ -1,7 +1,7 @@ -package com.shulpov.spots_app.models; +package com.shulpov.spots_app.spot_user_infos.models; -import com.shulpov.spots_app.models.pk.UserSpotPK; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.users.models.User; import jakarta.persistence.*; @Entity diff --git a/src/main/java/com/shulpov/spots_app/models/pk/UserSpotPK.java b/src/main/java/com/shulpov/spots_app/spot_user_infos/models/UserSpotPK.java similarity index 93% rename from src/main/java/com/shulpov/spots_app/models/pk/UserSpotPK.java rename to src/main/java/com/shulpov/spots_app/spot_user_infos/models/UserSpotPK.java index 592e15e..71ebae1 100644 --- a/src/main/java/com/shulpov/spots_app/models/pk/UserSpotPK.java +++ b/src/main/java/com/shulpov/spots_app/spot_user_infos/models/UserSpotPK.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.models.pk; +package com.shulpov.spots_app.spot_user_infos.models; import jakarta.persistence.Column; import jakarta.persistence.Embeddable; diff --git a/src/main/java/com/shulpov/spots_app/controllers/SpotController.java b/src/main/java/com/shulpov/spots_app/spots/SpotController.java similarity index 94% rename from src/main/java/com/shulpov/spots_app/controllers/SpotController.java rename to src/main/java/com/shulpov/spots_app/spots/SpotController.java index 1a2c4bd..22afd71 100644 --- a/src/main/java/com/shulpov/spots_app/controllers/SpotController.java +++ b/src/main/java/com/shulpov/spots_app/spots/SpotController.java @@ -1,12 +1,11 @@ -package com.shulpov.spots_app.controllers; +package com.shulpov.spots_app.spots; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.shulpov.spots_app.dto.SpotDto; -import com.shulpov.spots_app.models.Spot; -import com.shulpov.spots_app.user.User; -import com.shulpov.spots_app.services.SpotService; -import com.shulpov.spots_app.services.UserService; +import com.shulpov.spots_app.spots.dto.SpotDto; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.users.models.User; +import com.shulpov.spots_app.users.UserService; import com.shulpov.spots_app.utils.DtoConverter; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/shulpov/spots_app/repo/SpotRepo.java b/src/main/java/com/shulpov/spots_app/spots/SpotRepo.java similarity index 86% rename from src/main/java/com/shulpov/spots_app/repo/SpotRepo.java rename to src/main/java/com/shulpov/spots_app/spots/SpotRepo.java index b27c0a2..163dff9 100644 --- a/src/main/java/com/shulpov/spots_app/repo/SpotRepo.java +++ b/src/main/java/com/shulpov/spots_app/spots/SpotRepo.java @@ -1,6 +1,6 @@ -package com.shulpov.spots_app.repo; +package com.shulpov.spots_app.spots; -import com.shulpov.spots_app.models.Spot; +import com.shulpov.spots_app.spots.models.Spot; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/shulpov/spots_app/services/SpotService.java b/src/main/java/com/shulpov/spots_app/spots/SpotService.java similarity index 90% rename from src/main/java/com/shulpov/spots_app/services/SpotService.java rename to src/main/java/com/shulpov/spots_app/spots/SpotService.java index 4c51e01..aaa0a61 100644 --- a/src/main/java/com/shulpov/spots_app/services/SpotService.java +++ b/src/main/java/com/shulpov/spots_app/spots/SpotService.java @@ -1,9 +1,7 @@ -package com.shulpov.spots_app.services; +package com.shulpov.spots_app.spots; -import com.shulpov.spots_app.dto.SpotDto; -import com.shulpov.spots_app.models.Spot; -import com.shulpov.spots_app.repo.SpotRepo; -import com.shulpov.spots_app.utils.DtoConverter; +import com.shulpov.spots_app.image_infos.ImageInfoService; +import com.shulpov.spots_app.spots.models.Spot; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/com/shulpov/spots_app/dto/SpotDto.java b/src/main/java/com/shulpov/spots_app/spots/dto/SpotDto.java similarity index 96% rename from src/main/java/com/shulpov/spots_app/dto/SpotDto.java rename to src/main/java/com/shulpov/spots_app/spots/dto/SpotDto.java index 4dbbdc0..9e693a1 100644 --- a/src/main/java/com/shulpov/spots_app/dto/SpotDto.java +++ b/src/main/java/com/shulpov/spots_app/spots/dto/SpotDto.java @@ -1,6 +1,8 @@ -package com.shulpov.spots_app.dto; +package com.shulpov.spots_app.spots.dto; +import com.shulpov.spots_app.image_infos.dto.ImageInfoDto; + import java.io.Serializable; import java.util.Date; import java.util.List; diff --git a/src/main/java/com/shulpov/spots_app/models/Spot.java b/src/main/java/com/shulpov/spots_app/spots/models/Spot.java similarity index 94% rename from src/main/java/com/shulpov/spots_app/models/Spot.java rename to src/main/java/com/shulpov/spots_app/spots/models/Spot.java index d7ba09c..b93cb73 100644 --- a/src/main/java/com/shulpov/spots_app/models/Spot.java +++ b/src/main/java/com/shulpov/spots_app/spots/models/Spot.java @@ -1,10 +1,13 @@ -package com.shulpov.spots_app.models; +package com.shulpov.spots_app.spots.models; -import com.shulpov.spots_app.location.models.City; +import com.shulpov.spots_app.comments.Comment; +import com.shulpov.spots_app.locations.models.City; +import com.shulpov.spots_app.image_infos.models.ImageInfo; +import com.shulpov.spots_app.spot_user_infos.models.SpotUser; import com.shulpov.spots_app.spot_references.models.SpaceType; import com.shulpov.spots_app.spot_references.models.SportType; import com.shulpov.spots_app.spot_references.models.SpotType; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.users.models.User; import jakarta.persistence.*; import java.util.Date; diff --git a/src/main/java/com/shulpov/spots_app/controllers/UserController.java b/src/main/java/com/shulpov/spots_app/users/UserController.java similarity index 96% rename from src/main/java/com/shulpov/spots_app/controllers/UserController.java rename to src/main/java/com/shulpov/spots_app/users/UserController.java index 5d8c8a0..fc57cc2 100644 --- a/src/main/java/com/shulpov/spots_app/controllers/UserController.java +++ b/src/main/java/com/shulpov/spots_app/users/UserController.java @@ -1,8 +1,7 @@ -package com.shulpov.spots_app.controllers; +package com.shulpov.spots_app.users; -import com.shulpov.spots_app.dto.UserDto; -import com.shulpov.spots_app.user.User; -import com.shulpov.spots_app.services.UserService; +import com.shulpov.spots_app.users.dto.UserDto; +import com.shulpov.spots_app.users.models.User; import com.shulpov.spots_app.utils.DtoConverter; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; diff --git a/src/main/java/com/shulpov/spots_app/user/UserRepository.java b/src/main/java/com/shulpov/spots_app/users/UserRepository.java similarity index 81% rename from src/main/java/com/shulpov/spots_app/user/UserRepository.java rename to src/main/java/com/shulpov/spots_app/users/UserRepository.java index 0ff9d96..aaf4b5b 100644 --- a/src/main/java/com/shulpov/spots_app/user/UserRepository.java +++ b/src/main/java/com/shulpov/spots_app/users/UserRepository.java @@ -1,5 +1,6 @@ -package com.shulpov.spots_app.user; +package com.shulpov.spots_app.users; +import com.shulpov.spots_app.users.models.User; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/shulpov/spots_app/services/UserService.java b/src/main/java/com/shulpov/spots_app/users/UserService.java similarity index 95% rename from src/main/java/com/shulpov/spots_app/services/UserService.java rename to src/main/java/com/shulpov/spots_app/users/UserService.java index 5e8d8e2..cbd1926 100644 --- a/src/main/java/com/shulpov/spots_app/services/UserService.java +++ b/src/main/java/com/shulpov/spots_app/users/UserService.java @@ -1,7 +1,7 @@ -package com.shulpov.spots_app.services; +package com.shulpov.spots_app.users; -import com.shulpov.spots_app.user.User; -import com.shulpov.spots_app.user.UserRepository; +import com.shulpov.spots_app.image_infos.ImageInfoService; +import com.shulpov.spots_app.users.models.User; import org.hibernate.Hibernate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/shulpov/spots_app/user/Permission.java b/src/main/java/com/shulpov/spots_app/users/authorization/Permission.java similarity index 90% rename from src/main/java/com/shulpov/spots_app/user/Permission.java rename to src/main/java/com/shulpov/spots_app/users/authorization/Permission.java index ee0b149..f4ca49b 100644 --- a/src/main/java/com/shulpov/spots_app/user/Permission.java +++ b/src/main/java/com/shulpov/spots_app/users/authorization/Permission.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.user; +package com.shulpov.spots_app.users.authorization; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/shulpov/spots_app/user/Role.java b/src/main/java/com/shulpov/spots_app/users/authorization/Role.java similarity index 91% rename from src/main/java/com/shulpov/spots_app/user/Role.java rename to src/main/java/com/shulpov/spots_app/users/authorization/Role.java index 30c950e..593c0e4 100644 --- a/src/main/java/com/shulpov/spots_app/user/Role.java +++ b/src/main/java/com/shulpov/spots_app/users/authorization/Role.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.user; +package com.shulpov.spots_app.users.authorization; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -9,7 +9,7 @@ import java.util.Set; import java.util.stream.Collectors; -import static com.shulpov.spots_app.user.Permission.*; +import static com.shulpov.spots_app.users.authorization.Permission.*; @Getter @RequiredArgsConstructor diff --git a/src/main/java/com/shulpov/spots_app/dto/UserDto.java b/src/main/java/com/shulpov/spots_app/users/dto/UserDto.java similarity index 95% rename from src/main/java/com/shulpov/spots_app/dto/UserDto.java rename to src/main/java/com/shulpov/spots_app/users/dto/UserDto.java index bf0b5e4..1dd8ec1 100644 --- a/src/main/java/com/shulpov/spots_app/dto/UserDto.java +++ b/src/main/java/com/shulpov/spots_app/users/dto/UserDto.java @@ -1,5 +1,7 @@ -package com.shulpov.spots_app.dto; +package com.shulpov.spots_app.users.dto; +import com.shulpov.spots_app.image_infos.dto.ImageInfoDto; +import com.shulpov.spots_app.spots.dto.SpotDto; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotNull; diff --git a/src/main/java/com/shulpov/spots_app/dto/UserWithoutSpotsDto.java b/src/main/java/com/shulpov/spots_app/users/dto/UserWithoutSpotsDto.java similarity index 73% rename from src/main/java/com/shulpov/spots_app/dto/UserWithoutSpotsDto.java rename to src/main/java/com/shulpov/spots_app/users/dto/UserWithoutSpotsDto.java index 177b960..d614824 100644 --- a/src/main/java/com/shulpov/spots_app/dto/UserWithoutSpotsDto.java +++ b/src/main/java/com/shulpov/spots_app/users/dto/UserWithoutSpotsDto.java @@ -1,9 +1,12 @@ -package com.shulpov.spots_app.dto; +package com.shulpov.spots_app.users.dto; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.shulpov.spots_app.spots.dto.SpotDto; import java.util.List; + +//TODO переделать наследование, чтобы у наследника не урезался функционал, а добавлялся public class UserWithoutSpotsDto extends UserDto{ public UserWithoutSpotsDto(UserDto userDto) { this.name = userDto.getName(); diff --git a/src/main/java/com/shulpov/spots_app/user/User.java b/src/main/java/com/shulpov/spots_app/users/models/User.java similarity index 89% rename from src/main/java/com/shulpov/spots_app/user/User.java rename to src/main/java/com/shulpov/spots_app/users/models/User.java index 0fc1786..aa1fb4c 100644 --- a/src/main/java/com/shulpov/spots_app/user/User.java +++ b/src/main/java/com/shulpov/spots_app/users/models/User.java @@ -1,8 +1,12 @@ -package com.shulpov.spots_app.user; - -import com.shulpov.spots_app.auth_management.token.Token; -import com.shulpov.spots_app.location.models.City; -import com.shulpov.spots_app.models.*; +package com.shulpov.spots_app.users.models; + +import com.shulpov.spots_app.authentication_management.tokens.Token; +import com.shulpov.spots_app.comments.Comment; +import com.shulpov.spots_app.image_infos.models.ImageInfo; +import com.shulpov.spots_app.locations.models.City; +import com.shulpov.spots_app.spot_user_infos.models.SpotUser; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.users.authorization.Role; import jakarta.persistence.*; import lombok.*; import org.springframework.security.core.GrantedAuthority; diff --git a/src/main/java/com/shulpov/spots_app/utils/DtoConverter.java b/src/main/java/com/shulpov/spots_app/utils/DtoConverter.java index 44dbfb8..d00b3b9 100644 --- a/src/main/java/com/shulpov/spots_app/utils/DtoConverter.java +++ b/src/main/java/com/shulpov/spots_app/utils/DtoConverter.java @@ -1,14 +1,16 @@ package com.shulpov.spots_app.utils; +import com.shulpov.spots_app.comments.Comment; +import com.shulpov.spots_app.comments.CommentDto; import com.shulpov.spots_app.dto.*; -import com.shulpov.spots_app.location.dto.CityDto; -import com.shulpov.spots_app.location.dto.CountryDto; -import com.shulpov.spots_app.location.dto.RegionDto; -import com.shulpov.spots_app.location.models.City; -import com.shulpov.spots_app.location.models.Country; -import com.shulpov.spots_app.location.models.Region; -import com.shulpov.spots_app.models.*; -import com.shulpov.spots_app.services.*; +import com.shulpov.spots_app.image_infos.models.ImageInfo; +import com.shulpov.spots_app.image_infos.dto.ImageInfoDto; +import com.shulpov.spots_app.locations.dto.CityDto; +import com.shulpov.spots_app.locations.dto.CountryDto; +import com.shulpov.spots_app.locations.dto.RegionDto; +import com.shulpov.spots_app.locations.models.City; +import com.shulpov.spots_app.locations.models.Country; +import com.shulpov.spots_app.locations.models.Region; import com.shulpov.spots_app.spot_references.dto.SpaceTypeDto; import com.shulpov.spots_app.spot_references.dto.SportTypeDto; import com.shulpov.spots_app.spot_references.dto.SpotTypeDto; @@ -18,8 +20,15 @@ import com.shulpov.spots_app.spot_references.services.SpaceTypeService; import com.shulpov.spots_app.spot_references.services.SportTypeService; import com.shulpov.spots_app.spot_references.services.SpotTypeService; -import com.shulpov.spots_app.user.Role; -import com.shulpov.spots_app.user.User; +import com.shulpov.spots_app.spot_user_infos.models.SpotUser; +import com.shulpov.spots_app.spot_user_infos.dto.SpotUserDto; +import com.shulpov.spots_app.spot_user_infos.SpotUserService; +import com.shulpov.spots_app.spots.models.Spot; +import com.shulpov.spots_app.spots.dto.SpotDto; +import com.shulpov.spots_app.users.authorization.Role; +import com.shulpov.spots_app.users.models.User; +import com.shulpov.spots_app.users.dto.UserDto; +import com.shulpov.spots_app.users.dto.UserWithoutSpotsDto; import org.modelmapper.ModelMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/src/main/java/com/shulpov/spots_app/file_manager/FileManager.java b/src/main/java/com/shulpov/spots_app/utils/file_manager/FileManager.java similarity index 86% rename from src/main/java/com/shulpov/spots_app/file_manager/FileManager.java rename to src/main/java/com/shulpov/spots_app/utils/file_manager/FileManager.java index bf5d4a1..9b65ab5 100644 --- a/src/main/java/com/shulpov/spots_app/file_manager/FileManager.java +++ b/src/main/java/com/shulpov/spots_app/utils/file_manager/FileManager.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.file_manager; +package com.shulpov.spots_app.utils.file_manager; import org.springframework.core.io.Resource; diff --git a/src/main/java/com/shulpov/spots_app/file_manager/ImageManager.java b/src/main/java/com/shulpov/spots_app/utils/file_manager/ImageManager.java similarity index 98% rename from src/main/java/com/shulpov/spots_app/file_manager/ImageManager.java rename to src/main/java/com/shulpov/spots_app/utils/file_manager/ImageManager.java index 84a7610..26dc0ff 100644 --- a/src/main/java/com/shulpov/spots_app/file_manager/ImageManager.java +++ b/src/main/java/com/shulpov/spots_app/utils/file_manager/ImageManager.java @@ -1,4 +1,4 @@ -package com.shulpov.spots_app.file_manager; +package com.shulpov.spots_app.utils.file_manager; import org.springframework.core.io.Resource; import org.springframework.core.io.UrlResource; diff --git a/src/test/java/com/shulpov/spots_app/AuthTests.java b/src/test/java/com/shulpov/spots_app/AuthTests.java index 2bc4118..7af5c31 100644 --- a/src/test/java/com/shulpov/spots_app/AuthTests.java +++ b/src/test/java/com/shulpov/spots_app/AuthTests.java @@ -2,12 +2,12 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; -import com.shulpov.spots_app.auth_management.responses.AuthenticationResponse; -import com.shulpov.spots_app.auth_management.token.Token; -import com.shulpov.spots_app.auth_management.token.TokenService; +import com.shulpov.spots_app.authentication_management.responses.AuthenticationResponse; +import com.shulpov.spots_app.authentication_management.tokens.Token; +import com.shulpov.spots_app.authentication_management.tokens.TokenService; import com.shulpov.spots_app.db_cleaner.DBCleaner; import com.shulpov.spots_app.responses.ErrorMessageResponse; -import com.shulpov.spots_app.services.UserService; +import com.shulpov.spots_app.users.UserService; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll;