-
Notifications
You must be signed in to change notification settings - Fork 0
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
8 changed files
with
179 additions
and
22 deletions.
There are no files selected for viewing
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
43 changes: 43 additions & 0 deletions
43
src/main/java/com/spaceclub/club/controller/dto/ClubGetResponse.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,43 @@ | ||
package com.spaceclub.club.controller.dto; | ||
|
||
import com.spaceclub.club.domain.Club; | ||
import com.spaceclub.club.domain.ClubNotice; | ||
import lombok.Builder; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public record ClubGetResponse( | ||
String name, | ||
String info, | ||
Long memberCount, | ||
String image, | ||
List<String> notices | ||
) { | ||
|
||
@Builder | ||
public ClubGetResponse(String name, String info, Long memberCount, String image, List<String> notices) { | ||
this.name = name; | ||
this.info = info; | ||
this.memberCount = memberCount; | ||
this.image = image; | ||
this.notices = new ArrayList<>(notices); | ||
} | ||
|
||
public static ClubGetResponse from(Club club) { | ||
long memberCount = club.getClubUser().stream() | ||
.filter((user) -> user.getClub().getId().equals(club.getId())) | ||
.count(); | ||
|
||
return ClubGetResponse.builder() | ||
.name(club.getName()) | ||
.info(club.getInfo()) | ||
.memberCount(memberCount) | ||
.image(club.getImage()) | ||
.notices(club.getNotices().stream() | ||
.map(ClubNotice::getNotice) | ||
.toList()) | ||
.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
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,31 @@ | ||
package com.spaceclub.club.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class ClubNotice { | ||
|
||
@Id | ||
@Column(name = "club_notice_id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "club_id") | ||
private Club club; | ||
|
||
@Getter | ||
private String notice; | ||
|
||
public ClubNotice(String notice) { | ||
this.notice = notice; | ||
} | ||
|
||
} |
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,33 @@ | ||
package com.spaceclub.club.domain; | ||
|
||
import com.spaceclub.global.BaseTimeEntity; | ||
import com.spaceclub.user.domain.User; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import lombok.Getter; | ||
|
||
@Table(name = "club_user") | ||
@Entity | ||
public class ClubUser extends BaseTimeEntity { | ||
|
||
@Id | ||
@Column(name = "club_user_id") | ||
private Long id; | ||
|
||
@Getter | ||
@ManyToOne | ||
@JoinColumn(name = "club_id") | ||
private Club club; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
@Column(length = 16, nullable = false) | ||
private String role; | ||
|
||
} |
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