Skip to content

Commit

Permalink
[FIX] #30 - memberId 받는거 수정
Browse files Browse the repository at this point in the history
- converter에 memberId 수정
  • Loading branch information
aelimited committed May 30, 2024
1 parent f58d837 commit 360776f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/main/java/com/core/linkup/club/converter/ClubConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.core.linkup.common.exception.BaseException;
import com.core.linkup.common.response.BaseResponseStatus;
import com.core.linkup.member.entity.Member;
import com.core.linkup.security.MemberDetails;

@Converter
public class ClubConverter {
Expand All @@ -24,7 +25,7 @@ public ClubSearchResponse toClubResponse(Club club) {
}


public Club toClubEntity(ClubCreateRequest request, Long memberId) {
public Club toClubEntity(ClubCreateRequest request, MemberDetails member) {
ClubType category;
try {
category = ClubType.fromKor(String.valueOf(request.clubType()));
Expand All @@ -40,8 +41,7 @@ public Club toClubEntity(ClubCreateRequest request, Long memberId) {
.detailedIntroduction(request.detailedIntroduction())
.applicationIntroduction(request.applicationIntroduction())
.clubThumbnail(request.clubThumbnail())
.member(
Member.builder().id(memberId).build())
.member(member.getMember())
.build();

//TODO : list로 question 받는거 해야 함, clubid르 null로 받아옴
Expand All @@ -57,7 +57,7 @@ public Club toClubEntity(ClubCreateRequest request, Long memberId) {
return club;
}

public Club updateClubEntity(Club updateClub, ClubUpdateRequest updateRequest,Long memberId) {
public Club updateClubEntity(Club updateClub, ClubUpdateRequest updateRequest,MemberDetails member) {
ClubType category = ClubType.fromKor(String.valueOf(updateRequest.clubType()));
return Club.builder()
.id(updateClub.getId())
Expand All @@ -68,8 +68,7 @@ public Club updateClubEntity(Club updateClub, ClubUpdateRequest updateRequest,Lo
.detailedIntroduction(updateRequest.detailedIntroduction())
.applicationIntroduction(updateRequest.applicationIntroduction())
.clubThumbnail(updateRequest.clubThumbnail())
.member(
Member.builder().id(memberId).build())
.member(member.getMember())
.build();
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/core/linkup/club/service/ClubService.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Page<ClubSearchResponse> findClubs(Pageable pageable, ClubSearchRequest r

public ClubSearchResponse createClub(MemberDetails member, ClubCreateRequest request) {
Long memberId = getMemberId(member);
Club club = clubConverter.toClubEntity(request, memberId);
Club club = clubConverter.toClubEntity(request, member);
Club savedClub = clubRepository.save(club);

return clubConverter.toClubResponse(savedClub);
Expand All @@ -52,7 +52,7 @@ public ClubSearchResponse updateClub(MemberDetails member, Long clubId, ClubUpda
throw new BaseException(BaseResponseStatus.INVALID_MEMBER);
}

Club updatedClub = clubConverter.updateClubEntity(existingClub, updateRequest, memberId);
Club updatedClub = clubConverter.updateClubEntity(existingClub, updateRequest, member);
Club savedClub = clubRepository.save(updatedClub);
return clubConverter.toClubResponse(savedClub);
}
Expand Down

0 comments on commit 360776f

Please sign in to comment.