Skip to content

Commit

Permalink
fix: club 엔티티가 Category 객체를 가지도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
gorapang committed Dec 21, 2024
1 parent 0f40b8d commit 039e83b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public class MeetingTimeService {
private final MeetingTimeRepository meetingTimeRepository;
private final PostRepository postRepository;
private final SessionVerifier sessionVerifier;


//면접시간 리스트 생성
public void createMeetingTimes(Long recruitingId, List<MeetingTimeRequestDTO.MeetingTimeDto> meetingTimeDtos, HttpSession session) {

Recruiting recruiting = recruitingRepository.findById(recruitingId)
Expand Down Expand Up @@ -70,7 +71,7 @@ Club checkClub(HttpSession session) {
return club;
}


//면접시간 정보 조회
public CommonResponse<MeetingTimeListResponseDTO> getMeetingTimesByRecruitingId(Long recruitingId) {
// recruiting 찾기
Recruiting recruiting = recruitingRepository.findById(recruitingId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
@Data
public class ClubSignUpRequestDto {
private String name; // 동아리 이름
private String loginId; // 로그인 ID
private String loginId; // 로그인 ID
private String password; // 비밀번호
private String email; // 이메일
private String school; // 학교
private Long category;
private Long categoryId; // 카테고리 ID
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class ClubResponseDto {
private String name;
private String school;
private Long categoryId;
private String categoryName;
private String email;
private String imageUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public class Club extends DataEntity implements User {
@Column(name = "login_id", unique = true, nullable = false)
private String loginId;

// @Column(name = "cate_list")
private Long category;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "category_id")
private ClubCategory category;

@OneToMany(mappedBy = "club", orphanRemoval = true, cascade = CascadeType.ALL)
private List<Post> postList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class ClubCategory extends DataEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "category_id")
private Long id;

@Column(name = "category_name")
private String categoryName;
}
19 changes: 13 additions & 6 deletions src/main/java/com/likelion/innerjoin/user/service/ClubService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class ClubService {
private final ClubRepository clubRepository;
private final ClubCategoryRepository clubCategoryRepository;
private final SessionVerifier sessionVerifier;
//private final BlobService blobService;


/**
* 이메일 중복 확인
Expand Down Expand Up @@ -66,6 +68,7 @@ public List<ClubCategoryResponseDto> getClubCategories() {
.collect(Collectors.toList());
}


/**
* 동아리 회원 정보 조회
*
Expand Down Expand Up @@ -95,6 +98,8 @@ Club checkClub(HttpSession session) {
}
return club;
}


/**
* Club 엔티티 -> ClubResponseDto 변환
*/
Expand All @@ -105,13 +110,12 @@ private ClubResponseDto toClubResponseDto(Club club) {
.name(club.getName())
.school(club.getSchool())
.email(club.getEmail())
.imageUrl(club.getImageUrl())
.categoryId(club.getCategory())
.imageUrl(club.getImageUrl()) //이미지 임시
.categoryId(club.getCategory().getId())
.categoryName(club.getCategory().getCategoryName())
.build();
}

private final BlobService blobService;

public void signupClub(ClubSignUpRequestDto requestDto) {
// 아이디 중복 체크
if (clubRepository.findByLoginId(requestDto.getLoginId()).isPresent()) {
Expand All @@ -132,15 +136,18 @@ public void signupClub(ClubSignUpRequestDto requestDto) {
// }
// }

ClubCategory category = clubCategoryRepository.findById(requestDto.getCategoryId())
.orElseThrow(() -> new IllegalArgumentException("Invalid category ID: " + requestDto.getCategoryId()));

// Club 엔티티 생성 및 저장
Club club = Club.builder()
.name(requestDto.getName())
.loginId(requestDto.getLoginId())
.password(requestDto.getPassword())
.email(requestDto.getEmail())
.school(requestDto.getSchool())
.category(requestDto.getCategory())
//.imageUrl(imageUrl)
.category(category)
//.imageUrl(imageUrl) //회원가입 시에는 이미지 필요 없음
.build();

clubRepository.save(club);
Expand Down

0 comments on commit 039e83b

Please sign in to comment.