Skip to content
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

[Team#04][BE] 3주차 PR입니다 #45

Merged

Conversation

JJONSOO
Copy link

@JJONSOO JJONSOO commented Aug 11, 2023

What is this PR? 👓

3주차 진행상황에 대한 PR입니다.

  • 레이블, 마일스톤 CRUD
  • Github Action, Docker를 통한 CI/CD
  • Validator 추가
  • Client의 이미지를 받아 AWS S3에 이미지 업로드 후 경로 반환
  • AOP를 활용한 History 구현
  • 로그아웃
  • 테스트 코드

JJONSOO and others added 30 commits August 4, 2023 19:13
…factoring

[BE] 요구사항에 따른 코드 래픽토링
…lestone

[BE] 마일스톤 CRUD API 개발
Copy link

@kses1010 kses1010 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다. 이번 PR에서 느낀점은 코드들이 대부분 깔끔하게 작성되었다는걸 느꼈습니다.

다만 validator를 만드셔서 적용하고 있는데 걱정스러운 점은 서비스 코드에 validator코드가 잔뜩 늘어나면 어떡하면 좋을까 생각했습니다. 이땐 어떻게 처리하면 좋을지 고민하시는걸 추천드립니다.

Comment on lines +28 to +41
@Around("execution(* com.issuetrackermax.service.issue.IssueService.post(..)) && args(request,writerId)")
public Object save(ProceedingJoinPoint joinPoint, IssuePostRequest request, Long writerId) throws Throwable {
IssuePostResponse issuePostResponse = (IssuePostResponse)joinPoint.proceed();
Long issueId = issuePostResponse.getId();

historyService.save(HistoryRequest.builder()
.issueId(issueId)
.editor(memberRepository.findById(writerId).get().getNickName())
.issueIsOpen(true)
.build());
return issuePostResponse;
}

@Around("execution(* com.issuetrackermax.service.issue.IssueService.updateStatus(..)) && args(request, memberId)")

Choose a reason for hiding this comment

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

aspect를 직접 사용하셧군요 changeStatus에는 왜 사용하셨나요?

Copy link
Author

Choose a reason for hiding this comment

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

이슈 상태를 바꾸는 것도 History에 저장하기 위해 사용하였습니다.
ex) A에 의해 5분전에 변경되었습니다.

@@ -21,7 +22,7 @@ public AssigneeResponse(Long id, String name) {

public static List<AssigneeResponse> convertToAssigneeResponseList(String assigneeIds, String assigneeNames) {
if (assigneeIds == null) {
return null;
return new ArrayList<>();

Choose a reason for hiding this comment

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

null에서 빈리스트를 돌려주기로 했군요

Copy link
Author

Choose a reason for hiding this comment

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

넵 null로 반환하는게 어색하다고 생각하여 빈 리스트를 반환하도록 코드를 수정하였습니다.

Comment on lines +24 to +30
public static LabelResponse from(Label label) {
return LabelResponse.builder()
.id(label.getId())
.title(label.getTitle())
.textColor(label.getTextColor())
.backgroundColor(label.getBackgroundColor())
.build();

Choose a reason for hiding this comment

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

전체적으로 dto쪽이 깔끔해지고 있네요

Comment on lines +44 to 47
public ApiResponse<Void> updateStatus(@RequestBody IssuesStatusRequest request, HttpServletRequest servletRequest) {
Integer memberId = (Integer)servletRequest.getAttribute(MEMBER_ID);
issueService.updateStatus(request, memberId.longValue());
return ApiResponse.success();

Choose a reason for hiding this comment

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

질문있습니다. memberId가 Long으로 캐시팅되는것 같은데 나중에 Long으로 바꾸거나 할 생각이 있으신가요?

Choose a reason for hiding this comment

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

추가적으로 IssueStatusRequest도 나중에 validation이 들어가나요?

Copy link
Author

Choose a reason for hiding this comment

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

JwtService에서 28line
Jwt jwt = jwtProvider.createJwt(generateMemberClaims(member.getId()));
Member Long id를 저장하지만 Filter를 통과할 때 claim.get(MEMBER_ID)를 할 떄, Interger로 변환되는 것 같습니다.
HttpServletRequest.setAttribute 할 때, Long 타입으로 변환하여 저장하도록 코드를 수정하겠습니다.

Copy link

@Ojeegu Ojeegu Aug 12, 2023

Choose a reason for hiding this comment

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

IssueStatusRequestList<Long> ids@NotNull을 붙였어야 했는데 누락됐습니다. 다음번에 수정하겠습니다. String issueStatus는 서비스단에서 if문으로 처리하여 따로 validation은 추가하지 않으려고 합니다.

Comment on lines +37 to +40
Long labelSize = (long)labelService.getLabelList().size();
List<MilestoneDetailResponse> milestones = milestoneService.getOpenMilestone();
Long closedMilestoneCount = (long)milestoneService.getClosedMilestone().size();

Choose a reason for hiding this comment

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

이렇게 라벨 사이즈, 닫은 마일스톤 사이즈를 체크해서 가져오는 코드인데 문제는 만약 라벨이 많아지고 닫은 마일스톤도 많아지면 계속해서 size()를 통해서 가져오나요?
따로 count를 해서 바로 알수 있는 방법은 없을까요?

Choose a reason for hiding this comment

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

객체를 객체 내부에서 생성하도록 하면 컨트롤러단에서 호출만 하면 되겠죠?

Copy link
Author

Choose a reason for hiding this comment

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

넵 Count만 가져오도록 수정하겠습니다.

Comment on lines +107 to +108
if (request.getIds() == null) {
return;

Choose a reason for hiding this comment

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

요건 request 내부에서 validation해야하는데 서비스까지 내려온 것 같네요

Copy link
Author

Choose a reason for hiding this comment

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

request내부에서 validation하도록 수정하겠습니다.

Comment on lines +120 to +121
if (request.getIds() == null) {
return;

Choose a reason for hiding this comment

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

여기도 마찬가지

Copy link
Author

Choose a reason for hiding this comment

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

request내부에서 validation하도록 수정하겠습니다.


@MockBean
protected MilestoneService milestoneService;

Choose a reason for hiding this comment

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

계속해서 abstract class에 새로은 서비스가 추가되는 군요
차라리 도메인별로 만드는건 어떤가요? 이름이 ControllerTestSupport 이다 보니 나중에 새로운 컨트롤러, 새로운 도메인이 생길때마다 계속해서 MockBean을 추가해야하는 번거로움이 보입니당

Copy link
Author

Choose a reason for hiding this comment

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

도메인 별로 만들면 Spring Boot가 실행되는 횟수가 많아져서
Spring Boot가 뜨는 횟수를 줄이기 위해 하나의 abstract class에서 처리하도록 코드를 작성하였습니다.
또한 현재 하나의 도메인에 하나의 Controller만 있는 상태라 도메인 별로 Controller를 만들면 abstract class가 의미가 떨어지는 거 같아서, 하나의 ControllerTestSupport를 만들어서 사용하고 있는데,
추후에 하나의 도메인에 여러 Controller가 생긴다면 도메인으로 묶어 abstract class를 만들어보겠습니다.

Comment on lines +49 to +54
Boolean isOpen = true;
String title = "새로운 이슈";
Long milestoneId = 1L;
Long writerId = 1L;
issue = makeIssue(isOpen, title, milestoneId, writerId);
issueId = issueRepository.save(issue);

Choose a reason for hiding this comment

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

새로운 객체 만들다가 필드를 새로 지정한 이유가 무엇인가요? 이렇게 설정하면 어떤 이점이 있던가요?

Copy link

Choose a reason for hiding this comment

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

setup() 메서드 생성 전에 사용했던 필드를 그대로 남긴 건데 사용할 필요가 없어 보입니다. 필드는 지우고 setup() 메서드 안에서 객체를 만들도록 변경하겠습니다.

Comment on lines +98 to +100
@Test
void getClosedMilestone() {
}

Choose a reason for hiding this comment

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

지난번에도 말씀드렸지만 안에 아무것도 없는 테스트는 삭제해주세요 필요할 때마다 추가하시는걸 추천합니다.

Copy link
Author

Choose a reason for hiding this comment

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

넵 삭제하겠습니다.

kses1010 pushed a commit that referenced this pull request Aug 13, 2023
Copy link

@kses1010 kses1010 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다. PR Merge하겠습니다.

@kses1010 kses1010 merged commit 43c63a5 into codesquad-members-2023:team-04 Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants