-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
195 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package likelion.MZConnent.dto.club; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class LeaderDto { | ||
private String username; | ||
private String profileImageUrl; | ||
private List<SelfIntroductionDto> selfIntroductions; | ||
|
||
@Builder | ||
public LeaderDto(String username, String profileImageUrl, List<SelfIntroductionDto> selfIntroductions) { | ||
this.username = username; | ||
this.profileImageUrl = profileImageUrl; | ||
this.selfIntroductions = selfIntroductions; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/likelion/MZConnent/dto/club/SelfIntroductionDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package likelion.MZConnent.dto.club; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class SelfIntroductionDto { | ||
private Long cultureCategoryId; | ||
private String name; | ||
|
||
@Builder | ||
public SelfIntroductionDto(Long cultureCategoryId, String name) { | ||
this.cultureCategoryId = cultureCategoryId; | ||
this.name = name; | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/main/java/likelion/MZConnent/dto/club/response/ClubDetailResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package likelion.MZConnent.dto.club.response; | ||
|
||
import likelion.MZConnent.domain.club.AgeRestriction; | ||
import likelion.MZConnent.domain.club.GenderRestriction; | ||
import likelion.MZConnent.dto.club.LeaderDto; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
|
||
@Slf4j | ||
@Getter | ||
@NoArgsConstructor | ||
public class ClubDetailResponse { | ||
private Long clubId; | ||
private String title; | ||
private LocalDate meetingDate; | ||
private LocalDateTime createdDate; | ||
private String content; | ||
private GenderRestriction genderRestriction; | ||
private AgeRestriction ageRestriction; | ||
private String cultureImageUrl; | ||
private String cultureName; | ||
private String regionName; | ||
private int currentParticipant; | ||
private int maxParticipant; | ||
private String registrationStatus; | ||
private List<LeaderDto> leader; | ||
|
||
@Builder | ||
public ClubDetailResponse(Long clubId, String title, LocalDate meetingDate, LocalDateTime createdDate, String content, | ||
GenderRestriction genderRestriction, AgeRestriction ageRestriction, String cultureImageUrl, | ||
String cultureName, String regionName, int currentParticipant, int maxParticipant, | ||
String registrationStatus, List<LeaderDto> leader) { | ||
this.clubId = clubId; | ||
this.title = title; | ||
this.meetingDate = meetingDate; | ||
this.createdDate = createdDate; | ||
this.content = content; | ||
this.genderRestriction = genderRestriction; | ||
this.ageRestriction = ageRestriction; | ||
this.cultureImageUrl = cultureImageUrl; | ||
this.cultureName = cultureName; | ||
this.regionName = regionName; | ||
this.currentParticipant = currentParticipant; | ||
this.maxParticipant = maxParticipant; | ||
this.registrationStatus = registrationStatus; | ||
this.leader = leader; | ||
} | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
src/main/java/likelion/MZConnent/service/club/ClubInfoService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package likelion.MZConnent.service.club; | ||
|
||
import likelion.MZConnent.domain.club.ClubRole; | ||
import likelion.MZConnent.domain.member.Member; | ||
import likelion.MZConnent.dto.club.LeaderDto; | ||
import likelion.MZConnent.dto.club.SelfIntroductionDto; | ||
import likelion.MZConnent.dto.club.response.ClubDetailResponse; | ||
import likelion.MZConnent.repository.club.ClubRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
import likelion.MZConnent.domain.club.Club; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class ClubInfoService { | ||
private final ClubRepository clubRepository; | ||
|
||
// 로그인하지 않은 사용자 | ||
public ClubDetailResponse getClubDetail(Long clubId) { | ||
return buildClubDetailResponse(clubId, null); | ||
} | ||
|
||
// 로그인한 사용자 | ||
public ClubDetailResponse getClubDetail(Long clubId, Member member) { | ||
return buildClubDetailResponse(clubId, member); | ||
} | ||
|
||
private ClubDetailResponse buildClubDetailResponse(Long clubId, Member member) { | ||
Club club = clubRepository.findById(clubId) | ||
.orElseThrow(() -> new IllegalArgumentException("존재하지 않는 모임입니다.")); | ||
|
||
List<LeaderDto> leaderResponses = club.getClubMembers().stream() | ||
.filter(cm -> cm.getClubRole() == ClubRole.LEADER) | ||
.map(cm -> LeaderDto.builder() | ||
.username(cm.getMember().getUsername()) | ||
.profileImageUrl(cm.getMember().getProfileImageUrl()) | ||
.selfIntroductions(cm.getMember().getSelfIntroductions().stream() | ||
.map(si -> SelfIntroductionDto.builder() | ||
.cultureCategoryId(si.getCultureCategory().getId()) | ||
.name(si.getCultureCategory().getName()) | ||
.build()) | ||
.collect(Collectors.toList())) | ||
.build()) | ||
.collect(Collectors.toList()); | ||
|
||
String registrationStatus = "신청하기"; | ||
|
||
// 로그인한 사용자가 해당 모임에 가입되어 있는지 확인 | ||
if (member != null) { | ||
boolean isMemberJoined = club.getClubMembers().stream() | ||
.anyMatch(cm -> { | ||
return cm.getMember().getId().equals(member.getId()); | ||
}); | ||
registrationStatus = isMemberJoined ? "신청완료" : "신청하기"; | ||
} | ||
|
||
|
||
return ClubDetailResponse.builder() | ||
.clubId(club.getClubId()) | ||
.title(club.getTitle()) | ||
.meetingDate(club.getMeetingDate()) | ||
.createdDate(club.getCreatedDate()) | ||
.content(club.getContent()) | ||
.genderRestriction(club.getGenderRestriction()) | ||
.ageRestriction(club.getAgeRestriction()) | ||
.cultureImageUrl(club.getCulture().getCultureImageUrl()) | ||
.cultureName(club.getCulture().getName()) | ||
.regionName(club.getRegion().getName()) | ||
.currentParticipant(club.getCurrentParticipant()) | ||
.maxParticipant(club.getMaxParticipant()) | ||
.registrationStatus(registrationStatus) | ||
.leader(leaderResponses) | ||
.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters