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

refactor : Hive 유저 탈퇴시 호스트 는 탈퇴불가 설정 예외처리 추가 #112

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/main/java/com/HHive/hhive/domain/hive/entity/Hive.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ public class Hive extends BaseTimeEntity {
@JoinColumn(name = "user_id")
private User user;

// @ManyToOne
// @JoinColumn(name = "category_id")
// private Category category;


public void updateHiveTitle(UpdateHiveTitleRequestDTO updateHiveTitleRequestDTO) {
if (updateHiveTitleRequestDTO.getTitle() != null) {
this.title = updateHiveTitleRequestDTO.getTitle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.HHive.hhive.domain.user.repository.UserRepository;
import com.HHive.hhive.domain.user.service.UserService;
import com.HHive.hhive.global.exception.hive.AlreadyExistHiveException;
import com.HHive.hhive.global.exception.hive.HostNotResignHiveException;
import com.HHive.hhive.global.exception.hive.NotFoundHiveException;
import com.HHive.hhive.global.exception.user.AlreadyExistEmailException;
import com.HHive.hhive.global.exception.user.NotFoundUserException;
Expand Down Expand Up @@ -129,6 +130,10 @@ public void deleteHiveUser(User user, Long hiveId, String username) {
Hive hive = getHiveAndCheckAuth(user, hiveId);
User hiveUser = userService.findUserByUsername(username);

if (user.getId().equals(hive.getCreatorId())) {
throw new HostNotResignHiveException();
}

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
Collaborator Author

Choose a reason for hiding this comment

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

네 맞네요
이러면 아이디 순서대로 작성했던거랑 하이브 순서대로 만든거에대한 비교가 되버려서 잘못된거더군요
creatorId와 비교해서삭제가 안되겠끔 다시 수정했습니다.

Copy link
Contributor

Choose a reason for hiding this comment

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

빠른 피드백 감사합니다!

if (!hiveUserService.isExistedUser(hiveUser, hive)) {
throw new NotFoundUserException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum ErrorCode {
ALREADY_EXIST_HIVE_EXCEPTION(401, "중복된 타이틀입니다."),
FORBIDDEN_ABOUT_HIVE_EXCEPTION(403, "해당 하이브에 대한 권한이 없습니다."),
NOT_FOUND_HIVE_EXCEPTION(404, "해당 하이브를 찾을 수 없습니다."),
HIVE_HOST_NOT_RESIGN_EXCEPTION(403,"호스트는 하이브 탈퇴가 불가능합니다."),

//Party
PARTY_NOT_FOUND_EXCEPTION(404, "해당 파티를 찾을 수 없습니다."),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.HHive.hhive.global.exception.hive;

import com.HHive.hhive.global.exception.common.CustomException;
import com.HHive.hhive.global.exception.common.ErrorCode;

public class HostNotResignHiveException extends CustomException {

public HostNotResignHiveException() { super(ErrorCode.HIVE_HOST_NOT_RESIGN_EXCEPTION);}
}
Loading