Skip to content

Feature/#94 사용자 제출 관련 api 구현 #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 23, 2025
Merged

Conversation

seokbeom00
Copy link
Member

@seokbeom00 seokbeom00 commented Mar 18, 2025

💡 Issue

📄 Description

  • 전체문제 조회
  • 바로 풀러가기 : 문항 제출 생성(진행중으로)
  • 단계별로 풀러가기 : 새끼문항 제출 생성(시작전으로)
  • 문항 제출 상태 변경
  • 새끼문항 제출 상테 변경
  • 새끼문항 스킵(틀림 처리)
  • 해설 조회
  • 사용자 문항 조회
  • 사용자 새끼문항 조회

💬 To Reviewers

  • 새끼문항에 '시작전' 상태가 추가되었습니다.
  • 프론트엔드 개발자와 논의 한 후, 단계별로 풀러가기를 눌렀을 떄 새끼문항제출 데이터들이 생성되는 것이 자연스럽다고 생각했습니다.
  • 현재 로그인 기능이 없어서, 모든 api의 memberId는 1을 기준으로 구현되었습니다.
  • 추후 로그인 기능 추가 후, 일괄 변경하겠습니다.

@seokbeom00 seokbeom00 added the Type: Feature [이슈 목적] 새로운 기능 추가 label Mar 18, 2025
@seokbeom00 seokbeom00 self-assigned this Mar 18, 2025
Copy link
Contributor

@sejoon00 sejoon00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨어요!
기능에 대한 테스트 코드는 swagger로 수행했다고 생각할게요!
시간이 촉박하니 간단하게 수정할 수 있는 것만 고치고 merge하고 제가 말한 부분은 고민하고 추후에 수정해봐요!

return ResponseEntity.ok(clientGetService.getCommentary(publishId, problemId));
}

@GetMapping("allProblem/{year}/{month}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

problems/all/ 이런 방식이 괜찮을 것 같아요
URL을 디렉토리 구조라고 생각했을때 문제 도메인에서 전체문제를 찾는 위치를 들어가는 느낌이 괜찮지않나 싶네요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은것 같습니다! 도메인을 타고 들어간다면 problem/all 은 어떨까요?

@RestController
@RequestMapping("/api/v1/client")
@RequiredArgsConstructor
public class ClientGetController {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client 이름이 너무 방대한 것 같아요
Client 안에서도 쪼개는게 좋을 것 같아요.
해설, 문제 이런것들도 client안에서 각 controller로 나누는게 좋은 것 같습니다
나중에 멀티모듈로 쪼개면서 각 모듈에서는 이름이 겹쳐도 되니까 쪼개면서 나눠봐요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋은 것 같아요.
일단 문제랑 해설 2개로 분리해놓겠습니다!

return isCorrect ? RETRY_CORRECT : INCORRECT;
} else if (currentStatus == IN_PROGRESS) {
return isCorrect ? CORRECT : INCORRECT;
} else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

간단한 리뷰인데요! Reurn으로 내보낼거라면 else if 안쓰고

if (currentStatus == CORRECT) {
    return isCorrect ? CORRECT : INCORRECT;
} 
if (currentStatus == INCORRECT) {
    return isCorrect ? RETRY_CORRECT : INCORRECT;
} 
if (currentStatus == IN_PROGRESS) {
    return isCorrect ? CORRECT : INCORRECT;
} 
return Comment;

처럼 하고 틀렸는지 맞았는지 로직도 메서드 추출하면 가독서잉 좀더 좋아질것 같아요
아니면 switch문도 괜찮은것 같습니다

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇네요! switch문으로 변경하겠습니다.

problem.getMainProblemImageUrl(),
problem.getPrescriptionImageUrls(),
problemSubmit.getStatus()
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파라미터 개수가 많아져서 도메인을 넘겨서 Dto로 바꿔주는 mapper로직을 DTO안에 구성하면 좋을 것 같아요

cp.getImageUrl(),
cp.getPrescriptionImageUrls(),
childProblemSubmitRepository.findByMemberIdAndPublishIdAndChildProblemIdElseThrow(memberId, publishId,
cp.getId()).getStatus()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 친구도 mapper 로직이 DTO로 들어가면 좋겠네용

problem.getMainHandwritingExplanationImageUrl(),
problem.getReadingTipImageUrl(),
problem.getSeniorTipImageUrl(),
prescription
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이친구도용

public List<AllProblemGetResponse> getAllProblem(int year, int month) {
Long memberId = 1L;

if (month < 1 || month > 12) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

매직넘버는 없애주세용.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

상수로 처리하는 것도 괜찮지만 달 계산하는 로직은 많이 쓴다면 util처럼 감싸두 되구용

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영하겠습니다!

List<ProblemSubmit> submissions = problemSubmitRepository.findByMemberIdAndPublishId(memberId, publishId);
List<ProblemSubmitStatus> problemStatuses = submissions.stream()
.map(ProblemSubmit::getStatus)
.toList();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요새 저의 코드도 그렇고 특정 조건으로 도메인을 조회하는 repository가 여러 service레이어에서 사용되면서 의존성이 점점 퍼지고 얽혀서 나중에 분리하기가 어려워질 것 같다는 생각이 드는데요.
특정 도메인 조회하는 서비스레이어를 거쳐서 가져오는것도 괜찮다는 생각이 드는 요즘입니다.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋습니다. 특히 조회 로직 작성할 때 의존성이 점점 불어나더라고요. 리팩토링 단계에서 같이 이야기해봐요!

@sejoon00 sejoon00 merged commit 955a490 into develop Mar 23, 2025
1 check passed
@sejoon00 sejoon00 deleted the feature/#94 branch March 23, 2025 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature [이슈 목적] 새로운 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

✨ 클라이언트 뷰 api 구현
2 participants