-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DailyDefense 컨트롤러 작성 및 시험 타이머 기능 개발 (#36)
* feat: solved problemnumber set 반환 * feat: 사용자 로그인 여부에 따라 오늘의 문제 정보를 반환하는 service 및 테스트 개발 * feat: 오늘의 문제 시험 정보, 랭킹 정보 페이지로 반환하는 서비스 * fix: RankUseCaseImpl 패키지 이동 및 AtomicLong long 캐스팅 * test: DailyDefenseInfoResponse Test 추가 * refactor: DTO 생성 로직 Mapper로 분리 * feat: 오늘의 문제 정보 반환, 오늘의 문제 랭킹 Controller 및 테스트 작성 * 🎨 Mapper 기본 생성자 private 변경 * 🎨 필요없는 중괄호 삭제 * 🔥 Remove unused import 'StartDailyDefenseResponse' * 🎨 Dailydefense mapper 생성 * fix: @JsonInclude 어노테이션 필드로 이동 * fix: dailydefense 조회 시 problem fecth join * ✨ DailyDefense 시작 시 문제 content 포함 dto 변경 * ✨ 시험 시작 시 문제 본문 가져오게 구현, 테스트코드 작성 * fix: 응용서비스에서 Port 이용하게 변경 * 🐛 WebClient 정상적으로 mocking되도록 변경 * 🔥 Remove unused import * 🔥 사용하지 않는 throws 제거 * ✨ Webclient retryWhen을 통해 재처리 로직 추가 * ♻️ Problem Content 책임에 따라 problem_information하위로 이동 * ⚡ TempCode hashmap enummap으로 변경 * 🔥 Remove unused import * 🎨 기본생성자 private으로 변경 * Google OAuth 적용 및 커스텀 예외 코드 추가 (#37) * ✨ Google OAuth 적용 및 커스텀 예외 추가 * ✏️ 패키지 구조 일부 변경 * ✏️ 출력 관련 코드 제거 * ✏️ MemberAdapter 코드 수정 * ✏️ OAuth Login과 관련한 Cookie 발급과 관련한 작업을 Service 단에서 처리하도록 수정 * ✏️ OAuth AccessToken 발급과 관련한 메서드 분리 * ✏️ GoogleUserDto에 @Setter, @AllArgsConstructor 제거 * ✏️ SetDomain 관련 url, path를 yml에 저장하여 관리 * ✏️ ErrorCode 관련 코드 수정 및 RestControllerAdvice 코드 수정 * ✏️ OAuth domain 관련 패키지 구조 변경 * ✏️ LoginUseCase를 목적에 맞게 AuthenticationUseCase로 변경 (인증과 관련한 작업) * ✏️ JwtToken 및 publicKey와 PrivateKey를 발급하는 코드 수정 * ✏️ LoginMember에서 Repository를 호출하는 형태 변경 및 패키지 구조 일부 변경 * ✏️ Filter를 통과하는 url 리스트를 정규 표현식으로 검사하도록 수정 * ✏️ Spring Security Filter와 관련한 코드 수정 * ✏️ CORS 설정을 시큐리티 기본값에서 직접 정의한 내용으로 수정 * ✨ RefreshToken 관리를 위한 Redis 환경 구성 * ✨ RefreshToken을 검증하여 accessToken을 재발급하도록 코드 추가 * ✏️ Redis에 저장하는 refreshToken에 대한 key 값을 명확하게 하기 위해 코드 수정 * ✏️ RefreshToken을 Redis에 저장하는 로직 수정 * ✏️ OAuth 정보와 관련된 DTO를 OAuthUserInfo, GoogleOAuthUserInfo 형태로 변경 * ✏️ RefreshToken을 구하는 로직 수정 * ✏️ JwtAuthenticationFilter 구조 변경 (jwtProvider, authenticationProvider, isIgnoredURIManager로 분리) * ✏️ JwtAuthenticationFilter에서 else if를 if로 수정 * ✏️ AccessToken, RefreshToken을 검사하는 필터에서 주석 추가 * ✏️ Cookie 발급 로직을 CookieUtils에서 처리하도록 수정 * ✏️ Security, OAuth 부분 패키지 구조 변경 * ✏️ ErrorCode 및 일부 패키지 구조 수정 * ✏️ 사용하지 않는 ErrorCode 삭제 * ✏️ RestControllerAdvice에서 쿠키를 받는 로직을 cookieUtils 를 사용하도록 수정 * ✏️ OAuth 관련 패키지 구조 일부 수정 * ✏️ Jwt 검증과 관련한 메서드를 JwtValidator로 분리 * ✏️ Securty, Jwt, OAuth 관련 패키지 분리 * ✏️ Domain security 관련 패키지를 Application로 이동 * ✏️ 패키지 구조 일부 변경 * 🎨 RefreshToken 오류 수정 및 임시 coverage 하향 * 🎨 Google oauth 예외처리 * 🐛 Google oauth 예외처리 --------- Co-authored-by: miiiinju1 <[email protected]> * ✨ 시험 시작 시 문제 본문 가져오게 구현, 테스트코드 작성 * ✅ Spring Security & WebMvcTest 충돌 해결 * 🔥 충돌 해결 * 🔥 Remove unused import * ✨ HandlerMethodArgumentResolver 추가 및 controller 반영 * ✨ SetAuthentication 로직 변경 * 🎨 GetDailydefenseInfo 로직 변경 * 🎨 로그인 여부 관계없는 API로직 filter 반영 * ✨ 제한 시간 후 시험 자동 종료 로직 추가 * 🎨 도메인 서비스 구조 변경 * 🎨 ConcurrentHashMap 대신 구조적으로 타이머 등록 1회 보장 * 🎨 롤백시 타이머 정상 제거를 위해 Timer Event 발행 방식 선택 * ✅ 롤백 테스트 추가 * ✨ RestDocs 추가 및 docstest 작성 * 📝 오늘의 문제 랭킹 restdocs 추가 * 🔥 Remove unused import * 🔥 Remove unused import * ✅ 테스트 환경 통합 * 🎨 DailyDefenseProblemStrategy로 이름 변경 --------- Co-authored-by: Jeong Yong Choi <[email protected]>
- Loading branch information
Showing
117 changed files
with
3,700 additions
and
411 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[[Daily-Defense]] | ||
== 오늘의 문제 정보 조회 | ||
|
||
=== Request | ||
include::{snippets}/daily-defense-info/http-request.adoc[] | ||
|
||
=== Response | ||
include::{snippets}/daily-defense-info/http-response.adoc[] | ||
include::{snippets}/daily-defense-info/response-fields.adoc[] | ||
|
||
== 오늘의 문제 기록 조회 | ||
|
||
=== Request | ||
include::{snippets}/daily-defense-ranking/http-request.adoc[] | ||
|
||
=== Response | ||
include::{snippets}/daily-defense-ranking/http-response.adoc[] | ||
include::{snippets}/daily-defense-ranking/response-fields.adoc[] | ||
|
||
|
||
== 오늘의 문제 시작 | ||
|
||
=== Request | ||
include::{snippets}/daily-defense-start/http-request.adoc[] | ||
|
||
=== Response | ||
include::{snippets}/daily-defense-start/http-response.adoc[] | ||
include::{snippets}/daily-defense-start/response-fields.adoc[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
ifndef::snippets[] | ||
:snippets: ../../build/generated-snippets | ||
endif::[] | ||
= 모두의 랜덤 디펜스 REST API | ||
:doctype: book | ||
:icons: font | ||
:source-highlighter: highlightjs | ||
:toc: left | ||
:toclevels: 1 | ||
:sectlinks: | ||
|
||
include::api/dailydefense/dailydefense.adoc[] | ||
|
||
|
||
|
||
[[Daily-Defense-List]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/kr/co/morandi/backend/common/config/WebMvcConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package kr.co.morandi.backend.common.config; | ||
|
||
import kr.co.morandi.backend.common.web.resolver.MemberHandlerMethodArgumentResolver; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
import java.util.List; | ||
|
||
@Configuration | ||
public class WebMvcConfig implements WebMvcConfigurer { | ||
|
||
@Bean | ||
MemberHandlerMethodArgumentResolver memberHandlerMethodArgumentResolver() { | ||
return new MemberHandlerMethodArgumentResolver(); | ||
} | ||
|
||
@Override | ||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) { | ||
resolvers.add(memberHandlerMethodArgumentResolver()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/kr/co/morandi/backend/common/web/MemberId.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package kr.co.morandi.backend.common.web; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface MemberId { | ||
} |
22 changes: 22 additions & 0 deletions
22
...n/java/kr/co/morandi/backend/common/web/resolver/MemberHandlerMethodArgumentResolver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package kr.co.morandi.backend.common.web.resolver; | ||
|
||
import kr.co.morandi.backend.common.web.MemberId; | ||
import kr.co.morandi.backend.member_management.infrastructure.config.security.utils.SecurityUtils; | ||
import org.springframework.core.MethodParameter; | ||
import org.springframework.web.bind.support.WebDataBinderFactory; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
|
||
public class MemberHandlerMethodArgumentResolver implements HandlerMethodArgumentResolver { | ||
@Override | ||
public boolean supportsParameter(MethodParameter parameter) { | ||
return parameter.getParameterAnnotation(MemberId.class) != null | ||
&& parameter.getParameterType().equals(Long.class); | ||
} | ||
|
||
@Override | ||
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception { | ||
return SecurityUtils.getCurrentMemberId(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...orandi/backend/defense_information/application/dto/response/DailyDefenseInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package kr.co.morandi.backend.defense_information.application.dto.response; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class DailyDefenseInfoResponse { | ||
|
||
private String defenseName; | ||
private Integer problemCount; | ||
private Long attemptCount; | ||
private List<DailyDefenseProblemInfoResponse> problems; | ||
|
||
|
||
@Builder | ||
private DailyDefenseInfoResponse(String defenseName, Integer problemCount, Long attemptCount, List<DailyDefenseProblemInfoResponse> problems) { | ||
this.defenseName = defenseName; | ||
this.problemCount = problemCount; | ||
this.attemptCount = attemptCount; | ||
this.problems = problems; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...backend/defense_information/application/dto/response/DailyDefenseProblemInfoResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package kr.co.morandi.backend.defense_information.application.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import kr.co.morandi.backend.defense_information.domain.model.defense.ProblemTier; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class DailyDefenseProblemInfoResponse { | ||
|
||
private Long problemNumber; | ||
private Long problemId; | ||
private Long baekjoonProblemId; | ||
private ProblemTier difficulty; | ||
private Long solvedCount; | ||
private Long submitCount; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
private Boolean isSolved; | ||
|
||
@Builder | ||
private DailyDefenseProblemInfoResponse(Long problemNumber, Long problemId, Long baekjoonProblemId, ProblemTier difficulty, Long solvedCount, Long submitCount, Boolean isSolved) { | ||
this.problemNumber = problemNumber; | ||
this.problemId = problemId; | ||
this.baekjoonProblemId = baekjoonProblemId; | ||
this.difficulty = difficulty; | ||
this.solvedCount = solvedCount; | ||
this.submitCount = submitCount; | ||
this.isSolved = isSolved; | ||
} | ||
} | ||
|
||
|
32 changes: 32 additions & 0 deletions
32
...i/backend/defense_information/application/mapper/dailydefense/DailyDefenseInfoMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package kr.co.morandi.backend.defense_information.application.mapper.dailydefense; | ||
|
||
import kr.co.morandi.backend.defense_information.application.dto.response.DailyDefenseInfoResponse; | ||
import kr.co.morandi.backend.defense_information.domain.model.dailydefense.DailyDefense; | ||
import kr.co.morandi.backend.defense_record.domain.model.dailydefense_record.DailyRecord; | ||
import lombok.AccessLevel; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class DailyDefenseInfoMapper { | ||
|
||
public static DailyDefenseInfoResponse fromNonAttempted(DailyDefense dailyDefense) { | ||
return DailyDefenseInfoResponse.builder() | ||
.defenseName(dailyDefense.getContentName()) | ||
.problemCount(dailyDefense.getProblemCount()) | ||
.attemptCount(dailyDefense.getAttemptCount()) | ||
.problems(DailyDefenseProblemInfoMapper.ofNonAttempted(dailyDefense.getDailyDefenseProblems())) | ||
.build(); | ||
} | ||
|
||
public static DailyDefenseInfoResponse ofAttempted(DailyDefense dailyDefense, DailyRecord dailyRecord) { | ||
return DailyDefenseInfoResponse.builder() | ||
.defenseName(dailyDefense.getContentName()) | ||
.problemCount(dailyDefense.getProblemCount()) | ||
.attemptCount(dailyDefense.getAttemptCount()) | ||
.problems(DailyDefenseProblemInfoMapper.ofAttempted( | ||
dailyDefense.getDailyDefenseProblems(), | ||
dailyRecord.getSolvedProblemNumbers()) | ||
) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.