Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package com.now.naaga.auth.application;

import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN;

import com.now.naaga.auth.application.dto.AuthCommand;
import com.now.naaga.auth.infrastructure.dto.AuthInfo;
import com.now.naaga.auth.application.dto.RefreshTokenCommand;
import com.now.naaga.auth.domain.AuthToken;
import com.now.naaga.auth.exception.AuthException;
import com.now.naaga.auth.infrastructure.AuthClient;
import com.now.naaga.auth.infrastructure.dto.AuthInfo;
import com.now.naaga.auth.infrastructure.dto.MemberAuth;
import com.now.naaga.auth.infrastructure.jwt.AuthTokenGenerator;
import com.now.naaga.auth.persistence.AuthRepository;
import com.now.naaga.member.application.MemberService;
import com.now.naaga.member.application.dto.CreateMemberCommand;
import com.now.naaga.member.application.dto.DeleteMemberCommand;
import com.now.naaga.member.application.MemberService;
import com.now.naaga.member.domain.Member;
import com.now.naaga.player.application.PlayerService;
import com.now.naaga.player.application.dto.CreatePlayerCommand;
import com.now.naaga.player.application.dto.DeletePlayerCommand;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN;

@Transactional
@Service
public class AuthService {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.now.naaga.auth.domain;

import com.now.naaga.member.domain.Member;
import jakarta.persistence.*;

import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import java.util.Objects;

@Entity
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.now.naaga.auth.infrastructure;

import com.now.naaga.auth.infrastructure.dto.AuthInfo;
import com.now.naaga.auth.exception.AuthException;
import com.now.naaga.auth.exception.AuthExceptionType;
import com.now.naaga.auth.infrastructure.dto.AuthInfo;
import com.now.naaga.auth.infrastructure.dto.LogoutInfo;
import com.now.naaga.auth.infrastructure.dto.UnlinkInfo;
import org.springframework.beans.factory.annotation.Value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package com.now.naaga.auth.infrastructure;

import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_HEADER;
import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN;
import static com.now.naaga.auth.exception.AuthExceptionType.NOT_EXIST_HEADER;

import com.now.naaga.auth.exception.AuthException;
import com.now.naaga.auth.infrastructure.dto.MemberAuth;
import com.now.naaga.auth.infrastructure.jwt.JwtProvider;
import com.now.naaga.auth.exception.AuthException;
import com.now.naaga.common.exception.InternalException;
import org.springframework.stereotype.Component;

import static com.now.naaga.auth.exception.AuthExceptionType.*;

@Component
public class BearerAuthExtractor implements AuthenticationExtractor<MemberAuth> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.now.naaga.auth.infrastructure;

import static com.now.naaga.common.exception.InternalExceptionType.FAIL_JSON_TO_OBJECT;
import static com.now.naaga.common.exception.InternalExceptionType.FAIL_OBJECT_TO_JSON;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.now.naaga.auth.infrastructure.dto.MemberAuth;
import com.now.naaga.common.exception.InternalException;

import static com.now.naaga.common.exception.InternalExceptionType.FAIL_JSON_TO_OBJECT;
import static com.now.naaga.common.exception.InternalExceptionType.FAIL_OBJECT_TO_JSON;

public class MemberAuthMapper {

private static final ObjectMapper objectMapper = new ObjectMapper();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Objects;

public class AuthInfo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.now.naaga.auth.infrastructure.dto;

import com.now.naaga.auth.infrastructure.AuthType;

import java.util.Objects;

public class MemberAuth {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
package com.now.naaga.auth.infrastructure.jwt;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN_ACCESS;

import com.now.naaga.auth.domain.AuthToken;
import com.now.naaga.auth.exception.AuthException;
import com.now.naaga.auth.infrastructure.AuthType;
import com.now.naaga.auth.infrastructure.MemberAuthMapper;
import com.now.naaga.auth.infrastructure.dto.MemberAuth;
import com.now.naaga.common.exception.InternalException;
import com.now.naaga.common.exception.InternalExceptionType;
import com.now.naaga.member.domain.Member;
import org.springframework.stereotype.Component;
import org.springframework.validation.ObjectError;

import java.util.Date;

import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_TOKEN_ACCESS;
import org.springframework.stereotype.Component;

@Component
public class AuthTokenGenerator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

import com.now.naaga.auth.exception.AuthException;
import com.now.naaga.auth.exception.AuthExceptionType;
import io.jsonwebtoken.*;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.io.Decoders;
import io.jsonwebtoken.security.Keys;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.security.Key;
import java.util.Date;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class JwtProvider {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.now.naaga.auth.persistence;

import com.now.naaga.auth.domain.AuthToken;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;

public interface AuthRepository extends JpaRepository<AuthToken, Long> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package com.now.naaga.auth.presentation;

import com.now.naaga.auth.presentation.annotation.Auth;
import com.now.naaga.auth.application.AuthService;
import com.now.naaga.auth.application.dto.AuthCommand;
import com.now.naaga.auth.application.dto.RefreshTokenCommand;
import com.now.naaga.auth.domain.AuthToken;
import com.now.naaga.auth.infrastructure.dto.MemberAuth;
import com.now.naaga.auth.presentation.annotation.Auth;
import com.now.naaga.auth.presentation.dto.AuthRequest;
import com.now.naaga.auth.presentation.dto.AuthResponse;
import com.now.naaga.auth.presentation.dto.RefreshTokenRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/auth")
@RestController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.now.naaga.auth.presentation.argumentresolver;

import com.now.naaga.auth.presentation.annotation.Auth;
import com.now.naaga.auth.infrastructure.AuthenticationExtractor;
import com.now.naaga.auth.infrastructure.dto.MemberAuth;
import com.now.naaga.auth.presentation.dto.MemberRequest;
import com.now.naaga.auth.presentation.annotation.Auth;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.now.naaga.auth.presentation.argumentresolver;

import com.now.naaga.auth.presentation.annotation.Auth;
import com.now.naaga.auth.infrastructure.AuthenticationExtractor;
import com.now.naaga.auth.infrastructure.dto.MemberAuth;
import com.now.naaga.auth.presentation.annotation.Auth;
import com.now.naaga.player.application.PlayerService;
import com.now.naaga.player.domain.Player;
import com.now.naaga.player.presentation.dto.PlayerRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.now.naaga.auth.infrastructure.AuthenticationExtractor;
import com.now.naaga.auth.infrastructure.dto.MemberAuth;
import com.now.naaga.member.domain.Member;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.HttpHeaders;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package com.now.naaga.auth.presentation.interceptor;

import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_HEADER;
import static com.now.naaga.auth.exception.AuthExceptionType.INVALID_MANAGER;
import static com.now.naaga.auth.exception.AuthExceptionType.NOT_EXIST_HEADER;

import com.now.naaga.auth.exception.AuthException;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import java.util.Arrays;
import java.util.Base64;
import java.util.List;
import java.util.Objects;

import static com.now.naaga.auth.exception.AuthExceptionType.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

@Component
public class ManagerAuthInterceptor implements HandlerInterceptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
import com.now.naaga.gameresult.domain.gamescore.ResultScoreCalculator;
import com.now.naaga.gameresult.domain.gamescore.ResultScorePolicy;
import com.now.naaga.gameresult.domain.gamescore.SuccessResultScorePolicy;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@Configuration
public class BeanConfig {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.now.naaga.common.config;

import static org.hibernate.cfg.AvailableSettings.STATEMENT_INSPECTOR;

import com.now.naaga.common.presentation.QueryInspector;
import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import static org.hibernate.cfg.AvailableSettings.STATEMENT_INSPECTOR;

@Configuration
public class HibernateConfig {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package com.now.naaga.common.infrastructure;

import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_BODY;
import static com.now.naaga.common.exception.InternalExceptionType.FAIL_MAKE_DIRECTORY;

import com.now.naaga.common.exception.CommonException;
import com.now.naaga.common.exception.CommonExceptionType;
import com.now.naaga.common.exception.InternalException;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.util.UUID;

import com.now.naaga.common.exception.InternalException;
import com.now.naaga.common.exception.InternalExceptionType;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import static com.now.naaga.common.exception.CommonExceptionType.INVALID_REQUEST_BODY;
import static com.now.naaga.common.exception.InternalExceptionType.FAIL_MAKE_DIRECTORY;

@Component
public class MultipartFileManager implements FileManager<MultipartFile> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package com.now.naaga.common.presentation;

import jakarta.servlet.*;
import static com.now.naaga.common.presentation.MdcToken.REQUEST_ID;

import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import java.io.IOException;
import java.util.UUID;

import static com.now.naaga.common.presentation.MdcToken.*;

public class LogFilter implements Filter {

private static final String LOG_FORMAT = "uri: {}, method: {}, time: {}ms, queryCount: {}";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package com.now.naaga.common.presentation;

import java.util.Objects;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;

import java.util.Objects;

@Component
public class QueryInspector implements StatementInspector {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.HttpMethod;
import org.springframework.web.servlet.HandlerInterceptor;

import java.util.ArrayList;
import java.util.List;
import org.springframework.http.HttpMethod;
import org.springframework.web.servlet.HandlerInterceptor;

public class RequestMatcherInterceptor implements HandlerInterceptor {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
package com.now.naaga.game.application;

import com.now.naaga.game.application.dto.*;
import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS;
import static com.now.naaga.game.exception.GameExceptionType.ALREADY_IN_PROGRESS;
import static com.now.naaga.game.exception.GameExceptionType.CAN_NOT_FIND_PLACE;
import static com.now.naaga.game.exception.GameExceptionType.NOT_EXIST;
import static com.now.naaga.game.exception.GameExceptionType.NOT_EXIST_IN_PROGRESS;
import static com.now.naaga.gameresult.exception.GameResultExceptionType.GAME_RESULT_NOT_EXIST;

import com.now.naaga.game.application.dto.CreateGameCommand;
import com.now.naaga.game.application.dto.CreateGameResultCommand;
import com.now.naaga.game.application.dto.EndGameCommand;
import com.now.naaga.game.application.dto.FindAllGamesCommand;
import com.now.naaga.game.application.dto.FindGameByIdCommand;
import com.now.naaga.game.application.dto.FindGameByStatusCommand;
import com.now.naaga.game.application.dto.FindGameInProgressCommand;
import com.now.naaga.game.domain.EndType;
import com.now.naaga.game.domain.Game;
import com.now.naaga.game.domain.GameRecord;
Expand All @@ -19,15 +32,10 @@
import com.now.naaga.player.application.PlayerService;
import com.now.naaga.player.domain.Player;
import com.now.naaga.player.presentation.dto.PlayerRequest;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

import static com.now.naaga.game.domain.GameStatus.IN_PROGRESS;
import static com.now.naaga.game.exception.GameExceptionType.*;
import static com.now.naaga.gameresult.exception.GameResultExceptionType.GAME_RESULT_NOT_EXIST;

@Transactional
@Service
public class GameService {
Expand Down
Loading