Skip to content

Commit

Permalink
#13 refactor: 모임 응답시 멤버리시트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
wjdwlghks committed May 5, 2024
1 parent 2b80bd6 commit 35a1463
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 15 deletions.
1 change: 1 addition & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
/src/main/resources/data.sql
.idea
*.iws
*.iml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
@AllArgsConstructor
@Getter
@Builder
@Table(name = "book")
public class Book {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@
import com.project.capstone.book.domain.Book;
import com.project.capstone.club.domain.Club;
import com.project.capstone.club.domain.PublicStatus;
import com.project.capstone.member.controller.dto.SimpleMemberResponse;
import com.project.capstone.memberclub.domain.MemberClub;
import com.project.capstone.post.controller.dto.PostResponse;
import com.project.capstone.post.domain.Post;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public record ClubResponse (
Long id,
BookResponse book,
UUID managerId,
String topic,
String name,
LocalDateTime createdAt,
int maximum,
int memberCnt,
PublicStatus publicstatus,
List<PostResponse> posts
List<PostResponse> posts,
List<SimpleMemberResponse> memberList

) {
public ClubResponse(Club club) {
this(club.getId(), club.getBook() == null ? null : createBookResponse(club.getBook()), club.getTopic(), club.getName(), club.getCreatedAt(), club.getMaximum(),
club.getPublicStatus(), createPostResponseList(club.getPosts()));
this(club.getId(), club.getBook() == null ? null : createBookResponse(club.getBook()), club.getManagerId(), club.getTopic(), club.getName(), club.getCreatedAt(), club.getMaximum(),
club.getMembers().size(), club.getPublicStatus(), createPostResponseList(club.getPosts()), createSimpleMemberResponse(club.getMembers()));
}

private static List<PostResponse> createPostResponseList(List<Post> postList) {
Expand All @@ -36,6 +42,14 @@ private static List<PostResponse> createPostResponseList(List<Post> postList) {
return postResponseList;
}

private static List<SimpleMemberResponse> createSimpleMemberResponse(List<MemberClub> memberClubList) {
List<SimpleMemberResponse> simpleMemberResponseList = new ArrayList<>();
for (MemberClub memberClub : memberClubList) {
simpleMemberResponseList.add(new SimpleMemberResponse(memberClub));
}
return simpleMemberResponseList;
}

private static BookResponse createBookResponse(Book book) {
return new BookResponse(book);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@Setter
@Builder
@ToString
@Table(name = "club")
public class Club {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(name = "comment")
public class Comment {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "content")
public class Content {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.project.capstone.member.controller.dto;

import com.project.capstone.member.domain.Gender;
import com.project.capstone.memberclub.domain.MemberClub;

import java.util.UUID;

public record SimpleMemberResponse(
UUID id,
String name,
Gender gender
) {
public SimpleMemberResponse(MemberClub memberClub) {
this(memberClub.getMember().getId(), memberClub.getMember().getName(), memberClub.getMember().getGender());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "member")
public class Member {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Table(name = "member_club")
public class MemberClub {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Table(name = "my_book")
public class MyBook {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "post")
public class Post {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Table(name = "quiz")
public class Quiz {

@Id
Expand Down
107 changes: 95 additions & 12 deletions backend/src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("3f06af63-a93c-11e4-9797-00505690773f", "-","")), '[email protected]', '홍길동1', 17, 'MALE', '2023-05-16 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec61-e527-15ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동2', 17, 'MALE', '2023-05-26 15:48:57.450179');
(UNHEX(REPLACE("8fbcec61-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동2', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec62-e527-14ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동3', 17, 'MALE', '2023-05-26 15:48:57.450179');
(UNHEX(REPLACE("8fbcec62-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동3', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec63-e527-10ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동4', 17, 'MALE', '2023-05-26 15:48:57.450179');
(UNHEX(REPLACE("8fbcec63-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동4', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec64-e527-11ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동5', 17, 'MALE', '2023-05-26 15:48:57.450179');
(UNHEX(REPLACE("8fbcec64-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동5', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec65-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동6', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec66-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동7', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec67-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동8', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec68-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동9', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec69-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동10', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec70-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동11', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec71-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동12', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec72-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동13', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec73-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동14', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec74-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동15', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec75-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동16', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec76-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동17', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec77-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동18', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec78-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동19', 17, 'MALE', '2023-05-26 15:48:57.450179');
insert into member (id, email, name, age, gender, created_at) values
(UNHEX(REPLACE("8fbcec79-e527-12ee-bd3d-0242ac120002", "-","")), '[email protected]', '홍길동20', 17, 'MALE', '2023-05-26 15:48:57.450179');


insert into book (id, title, category_1d, category_2d, category_3d, author, publisher, publish_date) values
(1, '제목1', '카테고리1', '카테고리2', '카테고리3', '저자1', '출판사1', '2022-04-10');
Expand All @@ -24,25 +53,79 @@ insert into book (id, title, category_1d, category_2d, category_3d, author, publ


insert into club (id, manager_id, topic, name, created_at, maximum, public_status, password, book_id) values
(1, UNHEX(REPLACE("3f06af63-a93c-11e4-9797-00505690773f", "-","")), '역사', '길동1의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, 1);
(1, UNHEX(REPLACE("3f06af63-a93c-11e4-9797-00505690773f", "-","")), '역사', '길동1의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, null);
insert into club (id, manager_id, topic, name, created_at, maximum, public_status, password, book_id) values
(2, UNHEX(REPLACE("8fbcec61-e527-15ee-bd3d-0242ac120002", "-","")), '경제', '길동2의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, null);
(2, UNHEX(REPLACE("8fbcec61-e527-12ee-bd3d-0242ac120002", "-","")), '경제', '길동2의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, null);
insert into club (id, manager_id, topic, name, created_at, maximum, public_status, password, book_id) values
(3, UNHEX(REPLACE("8fbcec62-e527-14ee-bd3d-0242ac120002", "-","")), '종교', '길동3의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, 2);
(3, UNHEX(REPLACE("8fbcec62-e527-12ee-bd3d-0242ac120002", "-","")), '종교', '길동3의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, null);
insert into club (id, manager_id, topic, name, created_at, maximum, public_status, password, book_id) values
(4, UNHEX(REPLACE("8fbcec63-e527-10ee-bd3d-0242ac120002", "-","")), '사회', '길동4의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, 3);
(4, UNHEX(REPLACE("8fbcec63-e527-12ee-bd3d-0242ac120002", "-","")), '사회', '길동4의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, null);

insert into club (id, manager_id, topic, name, created_at, maximum, public_status, password, book_id) values
(5, UNHEX(REPLACE("3f06af63-a93c-11e4-9797-00505690773f", "-","")), '역사', '길동1의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, 1);
(5, UNHEX(REPLACE("3f06af63-a93c-11e4-9797-00505690773f", "-","")), '역사', '길동1의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, null);
insert into club (id, manager_id, topic, name, created_at, maximum, public_status, password, book_id) values
(6, UNHEX(REPLACE("8fbcec61-e527-15ee-bd3d-0242ac120002", "-","")), '경제', '길동2의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, null);
(6, UNHEX(REPLACE("8fbcec61-e527-12ee-bd3d-0242ac120002", "-","")), '경제', '길동2의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, null);
insert into club (id, manager_id, topic, name, created_at, maximum, public_status, password, book_id) values
(7, UNHEX(REPLACE("8fbcec62-e527-14ee-bd3d-0242ac120002", "-","")), '종교', '길동3의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, 2);
(7, UNHEX(REPLACE("8fbcec62-e527-12ee-bd3d-0242ac120002", "-","")), '종교', '길동3의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, null);
insert into club (id, manager_id, topic, name, created_at, maximum, public_status, password, book_id) values
(8, UNHEX(REPLACE("8fbcec63-e527-10ee-bd3d-0242ac120002", "-","")), '사회', '길동4의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, 3);
(8, UNHEX(REPLACE("8fbcec63-e527-12ee-bd3d-0242ac120002", "-","")), '사회', '길동4의 모임', '2023-05-26 15:48:57.450179', 10, 'PUBLIC', null, null);

insert into member_club (id, member_id, club_id) values
(1, UNHEX(REPLACE("3f06af63-a93c-11e4-9797-00505690773f", "-","")), 1);
insert into member_club (id, member_id, club_id) values
(2, UNHEX(REPLACE("8fbcec61-e527-12ee-bd3d-0242ac120002", "-","")), 2);
insert into member_club (id, member_id, club_id) values
(3, UNHEX(REPLACE("8fbcec62-e527-12ee-bd3d-0242ac120002", "-","")), 3);
insert into member_club (id, member_id, club_id) values
(4, UNHEX(REPLACE("8fbcec63-e527-12ee-bd3d-0242ac120002", "-","")), 4);

insert into member_club (id, member_id, club_id) values
(5, UNHEX(REPLACE("3f06af63-a93c-11e4-9797-00505690773f", "-","")), 5);
insert into member_club (id, member_id, club_id) values
(6, UNHEX(REPLACE("8fbcec61-e527-12ee-bd3d-0242ac120002", "-","")), 6);
insert into member_club (id, member_id, club_id) values
(7, UNHEX(REPLACE("8fbcec62-e527-12ee-bd3d-0242ac120002", "-","")), 7);
insert into member_club (id, member_id, club_id) values
(8, UNHEX(REPLACE("8fbcec63-e527-12ee-bd3d-0242ac120002", "-","")), 8);


insert into member_club (id, member_id, club_id) values
(9, UNHEX(REPLACE("8fbcec64-e527-12ee-bd3d-0242ac120002", "-","")), 1);
insert into member_club (id, member_id, club_id) values
(10, UNHEX(REPLACE("8fbcec65-e527-12ee-bd3d-0242ac120002", "-","")), 1);
insert into member_club (id, member_id, club_id) values
(11, UNHEX(REPLACE("8fbcec66-e527-12ee-bd3d-0242ac120002", "-","")), 1);
insert into member_club (id, member_id, club_id) values
(12, UNHEX(REPLACE("8fbcec67-e527-12ee-bd3d-0242ac120002", "-","")), 1);

insert into member_club (id, member_id, club_id) values
(13, UNHEX(REPLACE("8fbcec68-e527-12ee-bd3d-0242ac120002", "-","")), 2);
insert into member_club (id, member_id, club_id) values
(14, UNHEX(REPLACE("8fbcec69-e527-12ee-bd3d-0242ac120002", "-","")), 2);
insert into member_club (id, member_id, club_id) values
(15, UNHEX(REPLACE("8fbcec70-e527-12ee-bd3d-0242ac120002", "-","")), 2);
insert into member_club (id, member_id, club_id) values
(16, UNHEX(REPLACE("8fbcec71-e527-12ee-bd3d-0242ac120002", "-","")), 2);

insert into member_club (id, member_id, club_id) values
(17, UNHEX(REPLACE("8fbcec72-e527-12ee-bd3d-0242ac120002", "-","")), 3);
insert into member_club (id, member_id, club_id) values
(18, UNHEX(REPLACE("8fbcec73-e527-12ee-bd3d-0242ac120002", "-","")), 3);
insert into member_club (id, member_id, club_id) values
(19, UNHEX(REPLACE("8fbcec74-e527-12ee-bd3d-0242ac120002", "-","")), 3);
insert into member_club (id, member_id, club_id) values
(20, UNHEX(REPLACE("8fbcec75-e527-12ee-bd3d-0242ac120002", "-","")), 3);


insert into member_club (id, member_id, club_id) values
(21, UNHEX(REPLACE("8fbcec76-e527-12ee-bd3d-0242ac120002", "-","")), 4);
insert into member_club (id, member_id, club_id) values
(22, UNHEX(REPLACE("8fbcec77-e527-12ee-bd3d-0242ac120002", "-","")), 4);
insert into member_club (id, member_id, club_id) values
(23, UNHEX(REPLACE("8fbcec78-e527-12ee-bd3d-0242ac120002", "-","")), 4);
insert into member_club (id, member_id, club_id) values
(24, UNHEX(REPLACE("8fbcec79-e527-12ee-bd3d-0242ac120002", "-","")), 4);


insert into post (id, club_id, member_id, title, body, created_at, is_sticky) values
(1, 1, UNHEX(REPLACE("3f06af63-a93c-11e4-9797-00505690773f", "-","")), '게시글 제목 1', '게시글 내용 1', '2023-05-26 15:48:57.450179', true);
Expand Down

0 comments on commit 35a1463

Please sign in to comment.