-
Notifications
You must be signed in to change notification settings - Fork 24
[조현아] Sprint3 #79
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
azjaehyun
merged 35 commits into
codeit-bootcamp-spring:조현아
from
hyohyo-zz:sprint3-advenced
May 21, 2025
Merged
[조현아] Sprint3 #79
azjaehyun
merged 35 commits into
codeit-bootcamp-spring:조현아
from
hyohyo-zz:sprint3-advenced
May 21, 2025
Conversation
This file contains hidden or 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
Sprint3 basic
Sprint3 advenced
5019046
to
23fd93c
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Spring 프로젝트 초기화
3.4.0
입니다.——→3.4.4사용했음com.sprint.mission
입니다.discodeit
입니다.Jar
입니다application.properties
파일을yaml
형식으로 변경하세요.DiscodeitApplication
의 main 메서드를 실행하고 로그를 확인해보세요.Bean 선언 및 테스트
JavaApplication
에서 테스트했던 코드를DiscodeitApplication
에서 테스트해보세요.JavaApplication
의 main 메소드를 제외한 모든 메소드를DiscodeitApplication
클래스로 복사하세요.JavaApplication
의 main 메소드에서 Service를 초기화하는 코드를 Spring Context를 활용하여 대체하세요.JavaApplication
의 main 메소드의 셋업, 테스트 부분의 코드를DiscodeitApplication
클래스로 복사하세요.Spring 핵심 개념 이해하기
JavaApplication
과DiscodeitApplication
에서 Service를 초기화하는 방식의 차이에 대해 다음의 키워드를 중심으로 정리해보세요.이 내용은 PR에 첨부해주세요.
[비교](https://www.notion.so/1de05961b06480e3af98d5b22b49f18c?pvs=21)
Lombok 적용
@Getter
로 대체해보세요.Basic*Service
의 생성자를@RequiredArgsConstructor
로 대체해보세요.비즈니스 로직 고도화
추가 기능요구사항
추가 기능 요구사항
시간 타입 변경하기
Instant
로 통일합니다.새로운 도메인 추가하기
도메인 모델 간 참조 관계를 참고하세요.
공통: 앞서 정의한 도메인 모델과 동일하게 공통 필드(
id
,createdAt
,updatedAt
)를 포함합니다.ReadStatus
UserStatus
사용자 별 마지막으로 확인된 접속 시간을 표현하는 도메인 모델입니다. 사용자의 온라인 상태를 확인하기 위해 활용합니다.
마지막 접속 시간을 기준으로 현재 로그인한 유저로 판단할 수 있는 메소드를 정의하세요.
public voidisOnlineNow() {
if( lastOnlineTime = null ) return false;
Duration duration = Duration.between(lastOnlineTime, InstantNow());
return duration.toMinutes() ≤5;
BinaryContent
updatedAt
필드는 정의하지 않습니다.→finalUser
,Message
도메인 모델과의 의존 관계 방향성을 잘 고려하여id
참조 필드를 추가하세요.각 도메인 모델 별 레포지토리 인터페이스를 선언하세요.
DTO 활용하기
[DTO란?](https://www.codeit.kr/topics/6789bcf706985c5b264f9ee9/lessons/679c2fe348fe9b1f66b1df32)
[DTO란?](https://www.notion.so/DTO-1de05961b064807a8f44e8703270f6ba?pvs=21)
userDTO는 id, name, profileId, email
UserService 고도화
create
username
과email
은 다른 유저와 같으면 안됩니다.UserStatus
를 같이 생성합니다.find
,findAll
update
delete
BinaryContent
(프로필),UserStatus
같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
AuthService 구현
login
username
,password
과 일치하는 유저가 있는지 확인합니다.같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
ChannelService 고도화
create
User
의 정보를 받아User
별ReadStatus
정보를 생성합니다.name
과description
속성은 생략합니다.find
User
의id
정보를 포함합니다.findAll
User
의id
정보를 포함합니다.User
가 볼 수 있는 Channel 목록을 조회하도록 조회 조건을 추가하고, 메소드 명을 변경합니다.findAllByUserId
User
가 참여한 채널만 조회합니다.update
delete
Message
,ReadStatus
같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
MessageService 고도화
create
findAll
Channel
의 Message 목록을 조회하도록 조회 조건을 추가하고, 메소드 명을 변경합니다.findallByChannelId
update
delete
BinaryContent
)같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
ReadStatusService 구현
create
Channel
이나User
가 존재하지 않으면 예외를 발생시킵니다.Channel
과User
와 관련된 객체가 이미 존재하면 예외를 발생시킵니다.find
id
로 조회합니다.findAllByUserId
userId
를 조건으로 조회합니다.update
id
파라미터, 수정할 값 파라미터delete
id
로 삭제합니다.같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
UserStatusService 고도화
create
User
가 존재하지 않으면 예외를 발생시킵니다.User
와 관련된 객체가 이미 존재하면 예외를 발생시킵니다.find
id
로 조회합니다.findAll
update
id
파라미터, 수정할 값 파라미터updateByUserId
userId
로 특정User
의 객체를 업데이트합니다.delete
id
로 삭제합니다.같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
BinaryContentService 구현
create
find
id
로 조회합니다.findAllByIdIn
id
목록으로 조회합니다.delete
id
로 삭제합니다.같은 레이어 간 의존성 주입은 순환 참조 방지를 위해 지양합니다. 다른 Service 대신 필요한 Repository 의존성을 주입해보세요.
새로운 도메인 Repository 구현체 구현
지금까지 인터페이스로 설계한 각각의 Repository를 JCF, File로 각각 구현하세요.
FileBinaryContentRepo
JCFBinaryContentRepo
FileReadStatusRepo
JCFReadStatusRepo
FIleUserStatusRepo
JCFUserStatusRepo
discodeit 스프링 Appication 수정
심화 요구사항
Bean 다루기
Repository 구현체 중에 어떤 구현체를 Bean으로 등록할지 Java 코드의 변경 없이 application.yaml 설정 값을 통해 제어해보세요.
discodeit.repository.type
설정값에 따라 Repository 구현체가 정해집니다.jcf
이거나 없으면 JCF*Repository 구현체가 Bean으로 등록되어야 합니다.file
이면 File*Repository 구현체가 Bean으로 등록되어야 합니다.File*Repository 구현체의 파일을 저장할 디렉토리 경로를 application.yaml 설정 값을 통해 제어해보세요.
스크린샷
멘토에게