Skip to content

Commit

Permalink
refactor : Hive 유저 탈퇴시 호스트 는 탈퇴불가 설정 예외처리 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
“adashkdy9960 committed Jan 31, 2024
1 parent 7329051 commit 2c45982
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
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.getId())) {
throw new HostNotResignHiveException();
}

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);}
}

0 comments on commit 2c45982

Please sign in to comment.