-
Notifications
You must be signed in to change notification settings - Fork 24
임정현 sprint3 #87
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
임정현 sprint3 #87
The head ref may contain hidden characters: "\uC784\uC815\uD604-sprint3"
Conversation
codingjigi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이전보다 훨씬 성장하셨네요.. 노력한만큼 결과가 나오고 있는 것 같아서 저도 기분이 좋습니다~
고생 많으셨어요!
| //} | ||
|
|
||
| @Configuration | ||
| public class AppConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config 패키지를 따로 만들어 책임을 분리하는 방법은 어떠세요?
| // return user; | ||
| // } | ||
|
|
||
| static Channel setupChannel(ChannelService channelService) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
모의 객체 생성을 위한 클래스를 만들어서 책임을 분리하는게 좋을 것 같아요. 메인 메서드는 실행만 두는게 좋습니다!
| Channel channel = setupChannel(channelService); | ||
| setupMessage(messageService, channel, user); | ||
| // 테스트 | ||
| messageCreateTest(messageService, channel, user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트도 이제 테스트 패키지에서 직접 실습해봐도 좋을 것 같아요. 잘하셨네요!
| this.readStatus = null; // 채널을 읽은 유저들의 상태 | ||
| } | ||
|
|
||
| // public UUID getId() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사용하지 않는 코드는 제거해주세요~
| package com.sprint.mission.discodeit.entity; | ||
|
|
||
| public enum ChannelType { | ||
| PUBLIC, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굳
| } | ||
|
|
||
| public boolean isCurrenlyLoggedIn() { | ||
| return lastLoginAt.plusSeconds(300).isAfter(Instant.now()); // true: 로그인 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
300 이라는 숫자가 의미를 가지고 있는 매직넘버라면 상수로 처리하는게 좋아보여요.
|
|
||
| @Bean | ||
| public UserStatusRepository userStatusRepository() { | ||
| if ("file".equalsIgnoreCase(repositoryType)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
잘하셨네요. 혹시 이렇게 구현하신 이유를 알 수 있을까요?
|
|
||
| public class JCFBinaryContentRepository implements BinaryContentRepository { | ||
|
|
||
| Map<UUID, BinaryContent> binaryContentMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map 은 동시성 이슈가 발생할 수 있어서, 동시성 이슈가 발생하지 않는 자료구조를 한번 찾아보세요~
| Map<UUID, List<ReadStatus>> readStatusMapWithUserId; | ||
|
|
||
| public JCFReadStatusRepository() { | ||
| this.readStatusMap = new HashMap<>(); // 이게 얼마나 비효율적일까 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오.. 목적에 맞게 잘 설계하셨네요! 비효율적인건 없어요~ 사람마다 구현방법은 다르니까요
| .stream() | ||
| .toList(); | ||
|
|
||
| for (User user : userList) { // O(n) 시간 복잡도 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굳
기본 요구사항
Spring 프로젝트 초기화
3.4.0입니다.com.sprint.mission입니다.discodeit입니다.Jar입니다application.properties파일을yaml형식으로 변경하세요.DiscodeitApplication의 main 메서드를 실행하고 로그를 확인해보세요.Bean 선언 및 테스트
JavaApplication에서 테스트했던 코드를DiscodeitApplication에서 테스트해보세요.JavaApplication의 main 메소드를 제외한 모든 메소드를DiscodeitApplication클래스로 복사하세요.JavaApplication의 main 메소드에서 Service를 초기화하는 코드를 Spring Context를 활용하여 대체하세요.JavaApplication의 main 메소드의 셋업, 테스트 부분의 코드를DiscodeitApplication클래스로 복사하세요.Lombok 적용
@Getter로 대체해보세요.Basic*Service의 생성자를@RequiredArgsConstructor로 대체해보세요.추가 기능 요구사항
비즈니스 로직 고도화
다음의 기능 요구 사항을 구현하세요.
[추가 기능 요구 사항](https://www.codeit.kr/topics/6789bcf706985c5b264f9ee9/lessons/679c2cb69d24771229c93510)
시간 타입 변경하기
Instant로 통일합니다.새로운 도메인 추가하기
도메인 모델 간 참조 관계를 참고하세요.
공통: 앞서 정의한 도메인 모델과 동일하게 공통 필드(
id,createdAt,updatedAt)를 포함합니다.ReadStatusUserStatusBinaryContentupdatedAt필드는 정의하지 않습니다.User,Message도메인 모델과의 의존 관계 방향성을 잘 고려하여id참조 필드를 추가하세요.각 도메인 모델 별 레포지토리 인터페이스를 선언하세요.
DTO 활용하기
[DTO란?](https://www.codeit.kr/topics/6789bcf706985c5b264f9ee9/lessons/679c2fe348fe9b1f66b1df32)
UserService 고도화
createusername과email은 다른 유저와 같으면 안됩니다.UserStatus를 같이 생성합니다.find,findAllupdatedeleteBinaryContent(프로필),UserStatus같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
AuthService 구현
loginusername,password과 일치하는 유저가 있는지 확인합니다.같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
ChannelService 고도화
createUser의 정보를 받아User별ReadStatus정보를 생성합니다.name과description속성은 생략합니다.findUser의id정보를 포함합니다.findAllUser의id정보를 포함합니다.User가 볼 수 있는 Channel 목록을 조회하도록 조회 조건을 추가하고, 메소드 명을 변경합니다.findAllByUserIdUser가 참여한 채널만 조회합니다.updatedeleteMessage,ReadStatus같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
MessageService 고도화
createfindAllChannel의 Message 목록을 조회하도록 조회 조건을 추가하고, 메소드 명을 변경합니다.findallByChannelIdupdatedeleteBinaryContent)같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
ReadStatusService 구현
createChannel이나User가 존재하지 않으면 예외를 발생시킵니다.Channel과User와 관련된 객체가 이미 존재하면 예외를 발생시킵니다.findid로 조회합니다.findAllByUserIduserId를 조건으로 조회합니다.updateid파라미터, 수정할 값 파라미터deleteid로 삭제합니다.같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
UserStatusService 고도화
createUser가 존재하지 않으면 예외를 발생시킵니다.User와 관련된 객체가 이미 존재하면 예외를 발생시킵니다.findid로 조회합니다.findAllupdateid파라미터, 수정할 값 파라미터updateByUserIduserId로 특정User의 객체를 업데이트합니다.deleteid로 삭제합니다.같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
BinaryContentService 구현
createfindid로 조회합니다.findAllByIdInid목록으로 조회합니다.deleteid로 삭제합니다.같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
새로운 도메인 Repository 구현체 구현
[ 세모 ] 지금까지 인터페이스로 설계한 각각의 Repository를 JCF, File로 각각 구현하세요.
심화 요구사항
Bean 다루기
[ 세모 ] Repository 구현체 중에 어떤 구현체를 Bean으로 등록할지 Java 코드의 변경 없이 application.yaml 설정 값을 통해 제어해보세요.
discodeit.repository.type설정값에 따라 Repository 구현체가 정해집니다.jcf이거나 없으면 JCF*Repository 구현체가 Bean으로 등록되어야 합니다.file이면 File*Repository 구현체가 Bean으로 등록되어야 합니다.File*Repository 구현체의 파일을 저장할 디렉토리 경로를 application.yaml 설정 값을 통해 제어해보세요.
Spring 핵심 개념 이해하기
JavaApplication과DiscodeitApplication에서 Service를 초기화하는 방식의 차이에 대해 다음의 키워드를 중심으로 정리해보세요.이 내용은 PR에 첨부해주세요.
스크린샷
멘토에게
멘토님도 제 글을 보고 어리둥절 하실 것 같은데, 제 말은 요구사항을 정리하여 어떻게 작업을 할 지 구상할 때, 어느 정도까지 지침을 두고 시작해야 하는지, 예를 들어서 클래스와 메서드, 메서드의 파라미터, 메서드의 리턴 값을 구상하고, 각 연결관계를 위임으로 연결하는 것까지 해야 하는지 그 이상 혹은 그 이하인지 잘 모르겠습니다. 멘토님이 처음 요구사항을 받고 구상하시는 방법을 살짝 알려주시면 정말 감사하겠습니다.