Public Access
Refactor package structure: domain -> modules
Move domain packages into a new modules.* hierarchy and rename controller packages to api.* across login, registration, and user modules. Update package declarations and imports (including shared.api DTOs and JwtService -> modules login TokenGenerator), adjust tests and persistence/mapper paths accordingly, and apply minor formatting fixes (missing EOF newlines). This reorganizes the project to better separate API surface and module boundaries.
This commit is contained in:
1 parent
815347325a
commit
fd390ac072
73 files changed
+574
-569
No files matched your search
@@ -8,4 +8,4 @@ public class AuthServiceApplication {
|
||||
static void main(String[] args) {
|
||||
SpringApplication.run(AuthServiceApplication.class, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,4 @@ import org.springframework.scheduling.annotation.EnableAsync;
|
||||
@EnableAsync
|
||||
public class AsyncConfig {
|
||||
// This class enables Spring's @Async annotation functionality globally
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,4 @@ public class CacheConfig {
|
||||
.expireAfterAccess(10, TimeUnit.MINUTES)
|
||||
.recordStats();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,4 +34,4 @@ public class DevCacheConfig {
|
||||
.expireAfterAccess(1, TimeUnit.SECONDS)
|
||||
.recordStats();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,4 +21,4 @@ public class ObservabilityConfig {
|
||||
public TimedAspect timedAspect(MeterRegistry registry) {
|
||||
return new TimedAspect(registry);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,4 +65,4 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
|
||||
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,4 +12,4 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class JwtConfig {
|
||||
|
||||
private String secret;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package auth_service.configuration.security;
|
||||
|
||||
import auth_service.domain.login.service.TokenGenerator;
|
||||
import auth_service.modules.login.service.TokenGenerator;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.security.Keys;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -77,4 +77,4 @@ public class JwtService implements TokenGenerator {
|
||||
byte[] keyBytes = secretKey.getBytes(StandardCharsets.UTF_8);
|
||||
return Keys.hmacShaKeyFor(keyBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,4 +91,4 @@ public class SecurityConfig {
|
||||
|
||||
return http.build();
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,9 +1,9 @@
|
||||
package auth_service.domain.login.controller;
|
||||
package auth_service.modules.login.api;
|
||||
|
||||
import auth_service.domain.login.controller.dto.request.LoginRequest;
|
||||
import auth_service.domain.login.controller.dto.response.LoginResponse;
|
||||
import auth_service.domain.login.controller.mapper.ApiMapper;
|
||||
import auth_service.domain.login.service.LoginService;
|
||||
import auth_service.modules.login.api.dto.request.LoginRequest;
|
||||
import auth_service.modules.login.api.dto.response.LoginResponse;
|
||||
import auth_service.modules.login.api.mapper.ApiMapper;
|
||||
import auth_service.modules.login.service.LoginService;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* Controller handling authentication requests.
|
||||
* API handling authentication requests.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/auth")
|
||||
@@ -36,4 +36,4 @@ public class LoginController {
|
||||
var token = loginService.login(user);
|
||||
return ResponseEntity.ok(new LoginResponse("Login successful", token));
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
package auth_service.domain.login.controller;
|
||||
package auth_service.modules.login.api;
|
||||
|
||||
import auth_service.shared.controller.dto.response.ErrorResponse;
|
||||
import auth_service.domain.login.exception.InvalidCredentialsException;
|
||||
import auth_service.domain.login.exception.UserNotFoundException;
|
||||
import auth_service.shared.api.dto.response.ErrorResponse;
|
||||
import auth_service.modules.login.exception.InvalidCredentialsException;
|
||||
import auth_service.modules.login.exception.UserNotFoundException;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@@ -39,4 +39,4 @@ public class LoginExceptionController {
|
||||
var body = new ErrorResponse("INVALID_CREDENTIALS", ex.getMessage());
|
||||
return response(body, HttpStatus.UNAUTHORIZED);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.login.controller.dto.request;
|
||||
package auth_service.modules.login.api.dto.request;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -7,4 +7,4 @@ import jakarta.validation.constraints.NotNull;
|
||||
* DTO (Data Transfer Object) representing the incoming login request.
|
||||
*/
|
||||
public record LoginRequest(@NotNull String email, @NotNull @NotBlank String password) {
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
package auth_service.domain.login.controller.dto.response;
|
||||
package auth_service.modules.login.api.dto.response;
|
||||
|
||||
/**
|
||||
* DTO representing the outgoing login response.
|
||||
* The email will be null if the login fails.
|
||||
*/
|
||||
public record LoginResponse(String message, String token) {
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.login.controller.mapper;
|
||||
package auth_service.modules.login.api.mapper;
|
||||
|
||||
import auth_service.domain.login.controller.dto.request.LoginRequest;
|
||||
import auth_service.domain.login.model.User;
|
||||
import auth_service.modules.login.api.dto.request.LoginRequest;
|
||||
import auth_service.modules.login.model.User;
|
||||
|
||||
public abstract class ApiMapper {
|
||||
private ApiMapper() {
|
||||
@@ -10,4 +10,4 @@ public abstract class ApiMapper {
|
||||
public static User toModel(LoginRequest loginRequest) {
|
||||
return User.builder().email(loginRequest.email()).password(loginRequest.password()).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.login.exception;
|
||||
package auth_service.modules.login.exception;
|
||||
|
||||
public class InvalidCredentialsException extends RuntimeException {
|
||||
public InvalidCredentialsException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.login.exception;
|
||||
package auth_service.modules.login.exception;
|
||||
|
||||
public class UserNotFoundException extends RuntimeException {
|
||||
public UserNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.login.model;
|
||||
package auth_service.modules.login.model;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -9,4 +9,4 @@ public class User {
|
||||
private long id;
|
||||
private String email;
|
||||
private String password;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package auth_service.domain.login.persistence;
|
||||
package auth_service.modules.login.persistence;
|
||||
|
||||
import auth_service.domain.login.model.User;
|
||||
import auth_service.modules.login.model.User;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -17,4 +17,4 @@ public interface MinimalUserRepository {
|
||||
Optional<User> findByEmail(String email);
|
||||
|
||||
void updateLoginDate(long userId);
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,8 +1,8 @@
|
||||
package auth_service.domain.login.persistence;
|
||||
package auth_service.modules.login.persistence;
|
||||
|
||||
import auth_service.domain.login.model.User;
|
||||
import auth_service.domain.login.persistence.entities.MinimalUserEntity;
|
||||
import auth_service.domain.login.persistence.mapper.EntityMapper;
|
||||
import auth_service.modules.login.model.User;
|
||||
import auth_service.modules.login.persistence.entities.MinimalUserEntity;
|
||||
import auth_service.modules.login.persistence.mapper.EntityMapper;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
@@ -44,4 +44,4 @@ public class MinimalUserRepositoryImpl implements MinimalUserRepository {
|
||||
entityManager.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.login.persistence.entities;
|
||||
package auth_service.modules.login.persistence.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
@@ -32,4 +32,4 @@ public class MinimalUserEntity {
|
||||
|
||||
@Column(name = "last_login_date")
|
||||
private LocalDateTime lastLoginDate;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.login.persistence.mapper;
|
||||
package auth_service.modules.login.persistence.mapper;
|
||||
|
||||
import auth_service.domain.login.model.User;
|
||||
import auth_service.domain.login.persistence.entities.MinimalUserEntity;
|
||||
import auth_service.modules.login.model.User;
|
||||
import auth_service.modules.login.persistence.entities.MinimalUserEntity;
|
||||
|
||||
public abstract class EntityMapper {
|
||||
|
||||
@@ -19,4 +19,4 @@ public abstract class EntityMapper {
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
package auth_service.domain.login.service;
|
||||
package auth_service.modules.login.service;
|
||||
|
||||
import auth_service.domain.login.exception.InvalidCredentialsException;
|
||||
import auth_service.domain.login.exception.UserNotFoundException;
|
||||
import auth_service.domain.login.model.User;
|
||||
import auth_service.domain.login.persistence.MinimalUserRepository;
|
||||
import auth_service.modules.login.exception.InvalidCredentialsException;
|
||||
import auth_service.modules.login.exception.UserNotFoundException;
|
||||
import auth_service.modules.login.model.User;
|
||||
import auth_service.modules.login.persistence.MinimalUserRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
@@ -32,4 +32,4 @@ public class LoginService {
|
||||
minimalUserRepository.updateLoginDate(foundUser.getId());
|
||||
return tokenGenerator.generateToken(String.valueOf(foundUser.getId()), foundUser.getEmail());
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.login.service;
|
||||
package auth_service.modules.login.service;
|
||||
|
||||
/**
|
||||
* Port interface for token generation.
|
||||
@@ -14,3 +14,4 @@ public interface TokenGenerator {
|
||||
*/
|
||||
String generateToken(String userId, String email);
|
||||
}
|
||||
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
package auth_service.domain.registration.controller;
|
||||
package auth_service.modules.registration.api;
|
||||
|
||||
import auth_service.domain.registration.controller.dto.mapper.ApiMapper;
|
||||
import auth_service.domain.registration.controller.dto.request.RegistrationRequest;
|
||||
import auth_service.domain.registration.controller.dto.response.RegistrationResponse;
|
||||
import auth_service.domain.registration.service.RegistrationService;
|
||||
import auth_service.modules.registration.api.dto.mapper.ApiMapper;
|
||||
import auth_service.modules.registration.api.dto.request.RegistrationRequest;
|
||||
import auth_service.modules.registration.api.dto.response.RegistrationResponse;
|
||||
import auth_service.modules.registration.service.RegistrationService;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -25,4 +25,4 @@ public class RegistrationController {
|
||||
var userId = registrationService.register(ApiMapper.mapToModel(request));
|
||||
return ResponseEntity.ok(RegistrationResponse.builder().userId(userId).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
package auth_service.domain.registration.controller;
|
||||
package auth_service.modules.registration.api;
|
||||
|
||||
import auth_service.shared.controller.dto.response.ErrorResponse;
|
||||
import auth_service.domain.registration.exception.EmailAlreadyInUseException;
|
||||
import auth_service.domain.registration.exception.InvalidInvitationCodeException;
|
||||
import auth_service.domain.registration.exception.SteamIdAlreadyRegisteredException;
|
||||
import auth_service.shared.api.dto.response.ErrorResponse;
|
||||
import auth_service.modules.registration.exception.EmailAlreadyInUseException;
|
||||
import auth_service.modules.registration.exception.InvalidInvitationCodeException;
|
||||
import auth_service.modules.registration.exception.SteamIdAlreadyRegisteredException;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@@ -42,4 +42,4 @@ public class RegistrationExceptionController {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.registration.controller.dto.mapper;
|
||||
package auth_service.modules.registration.api.dto.mapper;
|
||||
|
||||
import auth_service.domain.registration.controller.dto.request.RegistrationRequest;
|
||||
import auth_service.domain.registration.model.Registration;
|
||||
import auth_service.modules.registration.api.dto.request.RegistrationRequest;
|
||||
import auth_service.modules.registration.model.Registration;
|
||||
|
||||
public abstract class ApiMapper {
|
||||
private ApiMapper() {
|
||||
@@ -16,4 +16,4 @@ public abstract class ApiMapper {
|
||||
build();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.registration.controller.dto.request;
|
||||
package auth_service.modules.registration.api.dto.request;
|
||||
|
||||
import lombok.Builder;
|
||||
|
||||
@Builder
|
||||
public record RegistrationRequest(String email, String password, String inviteCode, long steamId) {
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.registration.controller.dto.response;
|
||||
package auth_service.modules.registration.api.dto.response;
|
||||
|
||||
import lombok.Builder;
|
||||
|
||||
@Builder
|
||||
public record RegistrationResponse(long userId) {
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.registration.exception;
|
||||
package auth_service.modules.registration.exception;
|
||||
|
||||
public class EmailAlreadyInUseException extends RuntimeException {
|
||||
public EmailAlreadyInUseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.registration.exception;
|
||||
package auth_service.modules.registration.exception;
|
||||
|
||||
public class InvalidInvitationCodeException extends RuntimeException {
|
||||
public InvalidInvitationCodeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.registration.exception;
|
||||
package auth_service.modules.registration.exception;
|
||||
|
||||
public class SteamIdAlreadyRegisteredException extends RuntimeException {
|
||||
public SteamIdAlreadyRegisteredException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.registration.model;
|
||||
package auth_service.modules.registration.model;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -11,4 +11,4 @@ public class Registration {
|
||||
private String encryptedPassword;
|
||||
private String inviteCode;
|
||||
private long steamId;
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
package auth_service.domain.registration.persistence;
|
||||
package auth_service.modules.registration.persistence;
|
||||
|
||||
import auth_service.domain.registration.model.Registration;
|
||||
import auth_service.modules.registration.model.Registration;
|
||||
|
||||
public interface RegisteredUserRepository {
|
||||
boolean existsByEmail(String email);
|
||||
@@ -8,4 +8,4 @@ public interface RegisteredUserRepository {
|
||||
boolean existsBySteamId(long steamId);
|
||||
|
||||
long save(Registration registration);
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.registration.persistence;
|
||||
package auth_service.modules.registration.persistence;
|
||||
|
||||
import auth_service.domain.registration.model.Registration;
|
||||
import auth_service.domain.registration.persistence.mapper.EntityMapper;
|
||||
import auth_service.modules.registration.model.Registration;
|
||||
import auth_service.modules.registration.persistence.mapper.EntityMapper;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.transaction.Transactional;
|
||||
@@ -40,4 +40,4 @@ public class RegisteredUserRepositoryImpl implements RegisteredUserRepository {
|
||||
entityManager.persist(userToRegisterEntity);
|
||||
return userToRegisterEntity.getId();
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.registration.persistence.entities;
|
||||
package auth_service.modules.registration.persistence.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
@@ -34,4 +34,4 @@ public class RegisteredUserEntity {
|
||||
|
||||
@Column(name = "last_login_date")
|
||||
private LocalDateTime lastLoginDate;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.registration.persistence.mapper;
|
||||
package auth_service.modules.registration.persistence.mapper;
|
||||
|
||||
import auth_service.domain.registration.model.Registration;
|
||||
import auth_service.domain.registration.persistence.entities.RegisteredUserEntity;
|
||||
import auth_service.modules.registration.model.Registration;
|
||||
import auth_service.modules.registration.persistence.entities.RegisteredUserEntity;
|
||||
|
||||
import java.time.Clock;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -21,4 +21,4 @@ public abstract class EntityMapper {
|
||||
lastLoginDate(null).
|
||||
build();
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.registration.service;
|
||||
package auth_service.modules.registration.service;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -16,4 +16,4 @@ public class CodeValidationService {
|
||||
|
||||
return code.equals(invitationCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,10 +1,10 @@
|
||||
package auth_service.domain.registration.service;
|
||||
package auth_service.modules.registration.service;
|
||||
|
||||
import auth_service.domain.registration.exception.EmailAlreadyInUseException;
|
||||
import auth_service.domain.registration.exception.InvalidInvitationCodeException;
|
||||
import auth_service.domain.registration.exception.SteamIdAlreadyRegisteredException;
|
||||
import auth_service.domain.registration.model.Registration;
|
||||
import auth_service.domain.registration.persistence.RegisteredUserRepository;
|
||||
import auth_service.modules.registration.exception.EmailAlreadyInUseException;
|
||||
import auth_service.modules.registration.exception.InvalidInvitationCodeException;
|
||||
import auth_service.modules.registration.exception.SteamIdAlreadyRegisteredException;
|
||||
import auth_service.modules.registration.model.Registration;
|
||||
import auth_service.modules.registration.persistence.RegisteredUserRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -35,4 +35,4 @@ public class RegistrationService {
|
||||
|
||||
return registeredUserRepository.save(registration);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,10 +1,10 @@
|
||||
package auth_service.domain.user.controller;
|
||||
package auth_service.modules.user.api;
|
||||
|
||||
import auth_service.shared.security.UserPrincipal;
|
||||
import auth_service.domain.user.controller.dto.request.UserSettingsRequest;
|
||||
import auth_service.domain.user.controller.dto.response.UserProfileResponse;
|
||||
import auth_service.domain.user.controller.mapper.ApiMapper;
|
||||
import auth_service.domain.user.service.UserService;
|
||||
import auth_service.modules.user.api.dto.request.UserSettingsRequest;
|
||||
import auth_service.modules.user.api.dto.response.UserProfileResponse;
|
||||
import auth_service.modules.user.api.mapper.ApiMapper;
|
||||
import auth_service.modules.user.service.UserService;
|
||||
import io.micrometer.core.annotation.Timed;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -12,7 +12,7 @@ import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* Controller handling user profile operations for the dashboard.
|
||||
* API handling user profile operations for the dashboard.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/users")
|
||||
@@ -42,4 +42,4 @@ public class UserController {
|
||||
this.userService.updateUserSettings(principal.getIdAsLong(), request.steamId(), ApiMapper.toDomain(request));
|
||||
return ResponseEntity.ok().build();
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.user.controller;
|
||||
package auth_service.modules.user.api;
|
||||
|
||||
import auth_service.shared.controller.dto.response.ErrorResponse;
|
||||
import auth_service.domain.user.exception.UserNotFoundException;
|
||||
import auth_service.shared.api.dto.response.ErrorResponse;
|
||||
import auth_service.modules.user.exception.UserNotFoundException;
|
||||
import lombok.NonNull;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.annotation.Order;
|
||||
@@ -33,4 +33,4 @@ public class UserExceptionController {
|
||||
return response(body, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.user.controller.dto.request;
|
||||
package auth_service.modules.user.api.dto.request;
|
||||
|
||||
public record UserSettingsRequest(boolean useDarkTheme, String language, long steamId) {
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.user.controller.dto.response;
|
||||
package auth_service.modules.user.api.dto.response;
|
||||
|
||||
import lombok.Builder;
|
||||
|
||||
@Builder
|
||||
public record SettingsResponse(long id, boolean useDarkTheme, String language) {
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.user.controller.dto.response;
|
||||
package auth_service.modules.user.api.dto.response;
|
||||
|
||||
import lombok.Builder;
|
||||
|
||||
@@ -6,4 +6,4 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Builder
|
||||
public record UserProfileResponse(long id, String email, String role, LocalDateTime lastLogin, LocalDateTime createdDate, long steamId, SettingsResponse settings) {
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,11 +1,11 @@
|
||||
package auth_service.domain.user.controller.mapper;
|
||||
package auth_service.modules.user.api.mapper;
|
||||
|
||||
|
||||
import auth_service.domain.user.controller.dto.request.UserSettingsRequest;
|
||||
import auth_service.domain.user.controller.dto.response.SettingsResponse;
|
||||
import auth_service.domain.user.controller.dto.response.UserProfileResponse;
|
||||
import auth_service.domain.user.model.User;
|
||||
import auth_service.domain.user.model.UserSettings;
|
||||
import auth_service.modules.user.api.dto.request.UserSettingsRequest;
|
||||
import auth_service.modules.user.api.dto.response.SettingsResponse;
|
||||
import auth_service.modules.user.api.dto.response.UserProfileResponse;
|
||||
import auth_service.modules.user.model.User;
|
||||
import auth_service.modules.user.model.UserSettings;
|
||||
|
||||
public abstract class ApiMapper {
|
||||
private ApiMapper() {
|
||||
@@ -34,4 +34,4 @@ public abstract class ApiMapper {
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package auth_service.domain.user.exception;
|
||||
package auth_service.modules.user.exception;
|
||||
|
||||
public class UserNotFoundException extends RuntimeException {
|
||||
public UserNotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.user.model;
|
||||
package auth_service.modules.user.model;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -16,4 +16,4 @@ public class User {
|
||||
private long steamId;
|
||||
|
||||
private UserSettings settings;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.user.model;
|
||||
package auth_service.modules.user.model;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -8,4 +8,4 @@ import lombok.Data;
|
||||
public class UserSettings {
|
||||
private String language;
|
||||
private String theme;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -1,8 +1,8 @@
|
||||
package auth_service.domain.user.persistence;
|
||||
package auth_service.modules.user.persistence;
|
||||
|
||||
|
||||
import auth_service.domain.user.model.User;
|
||||
import auth_service.domain.user.model.UserSettings;
|
||||
import auth_service.modules.user.model.User;
|
||||
import auth_service.modules.user.model.UserSettings;
|
||||
import jakarta.transaction.Transactional;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@@ -25,4 +25,4 @@ public interface UserRepository {
|
||||
|
||||
@Transactional
|
||||
boolean updateSettings(long userId, long steamId, UserSettings settings);
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -1,10 +1,10 @@
|
||||
package auth_service.domain.user.persistence;
|
||||
package auth_service.modules.user.persistence;
|
||||
|
||||
import auth_service.domain.user.model.User;
|
||||
import auth_service.domain.user.model.UserSettings;
|
||||
import auth_service.domain.user.persistence.entities.UserEntity;
|
||||
import auth_service.domain.user.persistence.entities.UserSettingsEntity;
|
||||
import auth_service.domain.user.persistence.mapper.EntityMapper;
|
||||
import auth_service.modules.user.model.User;
|
||||
import auth_service.modules.user.model.UserSettings;
|
||||
import auth_service.modules.user.persistence.entities.UserEntity;
|
||||
import auth_service.modules.user.persistence.entities.UserSettingsEntity;
|
||||
import auth_service.modules.user.persistence.mapper.EntityMapper;
|
||||
import jakarta.persistence.EntityManager;
|
||||
import jakarta.persistence.PersistenceContext;
|
||||
import jakarta.persistence.TypedQuery;
|
||||
@@ -81,4 +81,4 @@ public class UserRepositoryImpl implements UserRepository {
|
||||
|
||||
return steamIdChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.user.persistence.entities;
|
||||
package auth_service.modules.user.persistence.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.*;
|
||||
@@ -42,4 +42,4 @@ public class UserEntity {
|
||||
@OneToOne(cascade = jakarta.persistence.CascadeType.ALL, fetch = jakarta.persistence.FetchType.LAZY)
|
||||
@jakarta.persistence.PrimaryKeyJoinColumn
|
||||
private UserSettingsEntity settings;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package auth_service.domain.user.persistence.entities;
|
||||
package auth_service.modules.user.persistence.entities;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
@@ -23,4 +23,4 @@ public class UserSettingsEntity {
|
||||
|
||||
@Column(nullable = false)
|
||||
private String theme;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
package auth_service.domain.user.persistence.mapper;
|
||||
package auth_service.modules.user.persistence.mapper;
|
||||
|
||||
import auth_service.domain.user.model.User;
|
||||
import auth_service.domain.user.model.UserSettings;
|
||||
import auth_service.domain.user.persistence.entities.UserEntity;
|
||||
import auth_service.domain.user.persistence.entities.UserSettingsEntity;
|
||||
import auth_service.modules.user.model.User;
|
||||
import auth_service.modules.user.model.UserSettings;
|
||||
import auth_service.modules.user.persistence.entities.UserEntity;
|
||||
import auth_service.modules.user.persistence.entities.UserSettingsEntity;
|
||||
|
||||
public abstract class EntityMapper {
|
||||
|
||||
@@ -49,4 +49,4 @@ public abstract class EntityMapper {
|
||||
entity.setTheme(settings.getTheme());
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,9 +1,9 @@
|
||||
package auth_service.domain.user.service;
|
||||
package auth_service.modules.user.service;
|
||||
|
||||
import auth_service.domain.user.exception.UserNotFoundException;
|
||||
import auth_service.domain.user.model.User;
|
||||
import auth_service.domain.user.model.UserSettings;
|
||||
import auth_service.domain.user.persistence.UserRepository;
|
||||
import auth_service.modules.user.exception.UserNotFoundException;
|
||||
import auth_service.modules.user.model.User;
|
||||
import auth_service.modules.user.model.UserSettings;
|
||||
import auth_service.modules.user.persistence.UserRepository;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -38,4 +38,4 @@ public class UserService {
|
||||
}
|
||||
log.info("User settings has been updated!");
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,12 +1,13 @@
|
||||
package auth_service.shared.controller.dto.response;
|
||||
package auth_service.shared.api.dto.response;
|
||||
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
/**
|
||||
* Shared error response record for all domains.
|
||||
* Shared error response record for all modules.
|
||||
*
|
||||
* @param code A machine-readable error code.
|
||||
* @param message A human-readable error message.
|
||||
*/
|
||||
public record ErrorResponse(@NonNull String code, @NonNull String message) {
|
||||
}
|
||||
|
||||
@@ -15,4 +15,4 @@ public record UserPrincipal(
|
||||
public long getIdAsLong() {
|
||||
return Long.parseLong(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user