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

중복 모임 채팅방 생성 버그 픽스 #759

Merged
merged 2 commits into from
Oct 24, 2024
Merged

Conversation

ksk0605
Copy link
Contributor

@ksk0605 ksk0605 commented Oct 24, 2024

PR의 목적이 무엇인가요?

새로운 채팅방을 생성할 때 targetId 와 ChatRoomType 을 기준으로 이미 존재하는 채팅방인지 검증하는 로직 누락으로 이미 존재하는 채팅방이 있음에도 중복 생성이 되는 문제 해결

이슈 ID는 무엇인가요?

설명

기존 ChatRoomWriter.append

public long append(long targetId, long darakbangId, ChatRoomType chatRoomType) {
ChatRoomEntity chatRoomEntity = ChatRoomEntity.builder()
	.targetId(targetId)
	.darakbangId(darakbangId)
	.type(chatRoomType)
	.build();
return chatRoomRepository.save(chatRoomEntity).getId();
}

변경된 ChatRoomWriter

private final ChatRoomValidator chatRoomValidator;

public long append(long targetId, long darakbangId, ChatRoomType chatRoomType) {
chatRoomValidator.validateAlreadyExists(targetId, chatRoomType);

ChatRoomEntity chatRoomEntity = ChatRoomEntity.builder()
	.targetId(targetId)
	.darakbangId(darakbangId)
	.type(chatRoomType)
	.build();
return chatRoomRepository.save(chatRoomEntity).getId();
}

검증 코드의 위치를 서비스가 아닌 구현레이어에 둔 이유

채팅방이 이미 존재하는지 검증하는 로직은 항상 생성하는 로직 이전에 이루어져야 한다고 판단하였습니다.

질문 혹은 공유 사항 (Optional)

@ksk0605 ksk0605 added BE 백엔드 관련 이슈입니다. 🚑 버그 fix (develop에서 파생된 문제) labels Oct 24, 2024
Copy link
Contributor

@ay-eonii ay-eonii left a comment

Choose a reason for hiding this comment

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

어푸루브 드릴게요

Copy link
Contributor

@hoyeonyy hoyeonyy left a comment

Choose a reason for hiding this comment

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

어푸푸르브 드릴꼐요

@ay-eonii ay-eonii merged commit fda6b1c into develop-backend Oct 24, 2024
1 check passed
@ay-eonii ay-eonii deleted the fix/#751 branch October 24, 2024 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE 백엔드 관련 이슈입니다. 🚑 버그 fix (develop에서 파생된 문제)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants