From 442ac449632b00842a0d3641148b1695443e25cc Mon Sep 17 00:00:00 2001 From: iamseojin Date: Wed, 27 Aug 2025 15:38:12 +0900 Subject: [PATCH 1/5] =?UTF-8?q?[feat]=20Member-Community=20=EC=96=91?= =?UTF-8?q?=EB=B0=A9=ED=96=A5=20=EB=A7=A4=ED=95=91=20=EB=B0=8F=20=ED=8E=B8?= =?UTF-8?q?=EC=9D=98=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arom/with_travel/domain/community/Community.java | 12 ++++++++++++ .../com/arom/with_travel/domain/member/Member.java | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/src/main/java/com/arom/with_travel/domain/community/Community.java b/src/main/java/com/arom/with_travel/domain/community/Community.java index 0c2b5c6..0c0f1bb 100644 --- a/src/main/java/com/arom/with_travel/domain/community/Community.java +++ b/src/main/java/com/arom/with_travel/domain/community/Community.java @@ -59,9 +59,21 @@ public static Community create(Member writer, String title, String content, .country(country) .city(city) .build(); + c.changeMember(writer); return c; } + public void changeMember(Member newMember) { + if (this.member != null) { + this.member.getCommunities().remove(this); + } + this.member = newMember; + if (newMember != null && !newMember.getCommunities().contains(this)) { + newMember.getCommunities().add(this); + } + } + + public void update(String title, String content, String continent, String country, String city) { if (title != null) this.title = title; if (content != null) this.content = content; diff --git a/src/main/java/com/arom/with_travel/domain/member/Member.java b/src/main/java/com/arom/with_travel/domain/member/Member.java index 9a894c8..9131a93 100644 --- a/src/main/java/com/arom/with_travel/domain/member/Member.java +++ b/src/main/java/com/arom/with_travel/domain/member/Member.java @@ -179,4 +179,9 @@ public void uploadImage(Image image){ public void setSurvey(Survey survey) { this.survey = survey; } + + public void addCommunity(Community community) { + if (community == null) return; + community.changeMember(this); + } } \ No newline at end of file From ddb31c85558c85584117851a1316919e00661a95 Mon Sep 17 00:00:00 2001 From: iamseojin Date: Wed, 27 Aug 2025 15:41:41 +0900 Subject: [PATCH 2/5] =?UTF-8?q?[refactor]=20=EC=BB=A4=EB=AE=A4=EB=8B=88?= =?UTF-8?q?=ED=8B=B0=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20update=20=EC=8B=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EA=B0=92=EC=9C=BC=EB=A1=9C=20=EC=A0=84?= =?UTF-8?q?=EC=B2=B4=20=ED=95=84=EB=93=9C=20=EB=8D=AE=EC=96=B4=EC=93=B0?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arom/with_travel/domain/community/Community.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/arom/with_travel/domain/community/Community.java b/src/main/java/com/arom/with_travel/domain/community/Community.java index 0c0f1bb..ef5d771 100644 --- a/src/main/java/com/arom/with_travel/domain/community/Community.java +++ b/src/main/java/com/arom/with_travel/domain/community/Community.java @@ -75,10 +75,10 @@ public void changeMember(Member newMember) { public void update(String title, String content, String continent, String country, String city) { - if (title != null) this.title = title; - if (content != null) this.content = content; - if (continent != null) this.continent = continent; - if (country != null) this.country = country; - if (city != null) this.city = city; + this.title = title; + this.content = content; + this.continent = continent; + this.country = country; + this.city = city; } } From ee403dbd5a2b6e1f58df91e5ae978f94cd1aa108 Mon Sep 17 00:00:00 2001 From: iamseojin Date: Wed, 27 Aug 2025 16:01:59 +0900 Subject: [PATCH 3/5] =?UTF-8?q?[feat]=20=EC=BB=A4=EB=AE=A4=EB=8B=88?= =?UTF-8?q?=ED=8B=B0=20=EC=A1=B0=ED=9A=8C=EC=88=98=20=EC=A6=9D=EA=B0=80=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=EC=A0=84=20=EC=A1=B4=EC=9E=AC=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/community/service/CommunityService.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/arom/with_travel/domain/community/service/CommunityService.java b/src/main/java/com/arom/with_travel/domain/community/service/CommunityService.java index d6c1605..3bd4d76 100644 --- a/src/main/java/com/arom/with_travel/domain/community/service/CommunityService.java +++ b/src/main/java/com/arom/with_travel/domain/community/service/CommunityService.java @@ -70,10 +70,17 @@ private static String requireUrl(String url) { @Transactional public CommunityDetailResponse readAndIncreaseView(Long id) { - communityRepository.increaseViewCount(id); + if (!communityRepository.existsById(id)) { + throw BaseException.from(ErrorCode.COMMUNITY_NOT_FOUND); + } + + int updated = communityRepository.increaseViewCount(id); + Community c = communityRepository.findDetailById(id); - if (c == null) throw BaseException.from(ErrorCode.COMMUNITY_NOT_FOUND); - List urls = c.getImages().stream().map(Image::getImageUrl).collect(Collectors.toList()); + if (c == null) { throw BaseException.from(ErrorCode.COMMUNITY_NOT_FOUND);} + + List urls = c.getImages().stream().map(Image::getImageUrl).toList(); + return new CommunityDetailResponse( c.getId(), c.getTitle(), c.getContent(), c.getContinent(), c.getCountry(), c.getCity(), From 38a263334bb3013e6291e7d86ceff23c77c20d44 Mon Sep 17 00:00:00 2001 From: iamseojin Date: Wed, 27 Aug 2025 16:09:20 +0900 Subject: [PATCH 4/5] =?UTF-8?q?[feat]=20=EC=BB=A4=EB=AE=A4=EB=8B=88?= =?UTF-8?q?=ED=8B=B0=20=EB=8C=93=EA=B8=80=20=EB=B0=8F=20=EC=A2=8B=EC=95=84?= =?UTF-8?q?=EC=9A=94=EC=99=80=20Member=20=EA=B0=84=EC=9D=98=20=EC=96=91?= =?UTF-8?q?=EB=B0=A9=ED=96=A5=20=EC=97=B0=EA=B4=80=EA=B4=80=EA=B3=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/community/Community.java | 8 +++++++- .../domain/community_reply/CommunityReply.java | 13 +++++++++++++ .../community_reply/CommunityReplyLike.java | 1 + .../arom/with_travel/domain/member/Member.java | 18 ++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/arom/with_travel/domain/community/Community.java b/src/main/java/com/arom/with_travel/domain/community/Community.java index ef5d771..d1343c0 100644 --- a/src/main/java/com/arom/with_travel/domain/community/Community.java +++ b/src/main/java/com/arom/with_travel/domain/community/Community.java @@ -40,7 +40,7 @@ public class Community extends BaseEntity { @JoinColumn(name = "member_id", nullable = false) private Member member; - @OneToMany(mappedBy = "community") + @OneToMany(mappedBy = "community", orphanRemoval = true) private List communityReplies = new ArrayList<>(); @OneToMany(mappedBy = "community") @@ -73,6 +73,12 @@ public void changeMember(Member newMember) { } } + public void addReply(CommunityReply reply) { + this.communityReplies.add(reply); + if (reply.getCommunity() != this) { + reply.setCommunity(this); + } + } public void update(String title, String content, String continent, String country, String city) { this.title = title; diff --git a/src/main/java/com/arom/with_travel/domain/community_reply/CommunityReply.java b/src/main/java/com/arom/with_travel/domain/community_reply/CommunityReply.java index ea05143..64a5e3a 100644 --- a/src/main/java/com/arom/with_travel/domain/community_reply/CommunityReply.java +++ b/src/main/java/com/arom/with_travel/domain/community_reply/CommunityReply.java @@ -9,7 +9,11 @@ import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLRestriction; +import java.util.ArrayList; +import java.util.List; + @Getter +@Setter @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Builder @@ -33,6 +37,9 @@ public class CommunityReply extends BaseEntity { @JoinColumn(name = "member_id", nullable = false) private Member member; + @OneToMany(mappedBy = "reply", orphanRemoval = true) + private List likes = new ArrayList<>(); + public static CommunityReply create(Community community, Member writer, String content) { return CommunityReply.builder() .community(community) @@ -45,5 +52,11 @@ public void changeContent(String content) { this.content = content; } + public void addLike(CommunityReplyLike like) { + this.likes.add(like); + if (like.getReply() != this) { + like.setReply(this); + } + } } diff --git a/src/main/java/com/arom/with_travel/domain/community_reply/CommunityReplyLike.java b/src/main/java/com/arom/with_travel/domain/community_reply/CommunityReplyLike.java index 5b692a4..32edead 100644 --- a/src/main/java/com/arom/with_travel/domain/community_reply/CommunityReplyLike.java +++ b/src/main/java/com/arom/with_travel/domain/community_reply/CommunityReplyLike.java @@ -5,6 +5,7 @@ import lombok.*; @Getter +@Setter @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) diff --git a/src/main/java/com/arom/with_travel/domain/member/Member.java b/src/main/java/com/arom/with_travel/domain/member/Member.java index 9131a93..ac352ea 100644 --- a/src/main/java/com/arom/with_travel/domain/member/Member.java +++ b/src/main/java/com/arom/with_travel/domain/member/Member.java @@ -6,6 +6,7 @@ import com.arom.with_travel.domain.chat.model.ChatPart; import com.arom.with_travel.domain.community.Community; import com.arom.with_travel.domain.community_reply.CommunityReply; +import com.arom.with_travel.domain.community_reply.CommunityReplyLike; import com.arom.with_travel.domain.image.Image; import com.arom.with_travel.domain.likes.Likes; import com.arom.with_travel.domain.shorts.Shorts; @@ -105,6 +106,9 @@ public static Member create(String memberName, String email, String oauthId) { @OneToMany(mappedBy = "member") private List communities = new ArrayList<>(); + @OneToMany(mappedBy = "member", orphanRemoval = true) + private List replyLikes = new ArrayList<>(); + @OneToMany(mappedBy = "member") private List communityReplies = new ArrayList<>(); @@ -184,4 +188,18 @@ public void addCommunity(Community community) { if (community == null) return; community.changeMember(this); } + + public void addReply(CommunityReply reply) { + this.communityReplies.add(reply); + if (reply.getMember() != this) { + reply.setMember(this); + } + } + + public void addReplyLike(CommunityReplyLike like) { + this.replyLikes.add(like); + if (like.getMember() != this) { + like.setMember(this); + } + } } \ No newline at end of file From af05b8f35c0c0ab26ba85399bdc417651a7fff27 Mon Sep 17 00:00:00 2001 From: iamseojin Date: Wed, 27 Aug 2025 16:35:58 +0900 Subject: [PATCH 5/5] =?UTF-8?q?[feat]=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=9A=94=EC=B2=AD=20dto=20=EB=B0=8F=20=EB=A9=A4?= =?UTF-8?q?=EB=B2=84=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=EC=97=90=20=EC=A0=84=EB=B2=88=20=C2=B7=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=C2=B7=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20=C2=B7=20=EB=B9=84?= =?UTF-8?q?=EB=B2=88=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../with_travel/domain/member/Member.java | 10 ++++---- .../dto/request/MemberSignupRequestDto.java | 23 ++++++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/arom/with_travel/domain/member/Member.java b/src/main/java/com/arom/with_travel/domain/member/Member.java index ac352ea..1542018 100644 --- a/src/main/java/com/arom/with_travel/domain/member/Member.java +++ b/src/main/java/com/arom/with_travel/domain/member/Member.java @@ -39,6 +39,7 @@ public class Member extends BaseEntity { private String oauthId; private String email; + @Column(length = 255) private String password; private LocalDate birth; @Enumerated(EnumType.STRING) private Gender gender; @@ -129,15 +130,16 @@ public static Member create(String memberName, String email, String oauthId) { private Image image; @Builder - public Member(Long id, String oauthId, String email, String name, LocalDate birth, Gender gender, - String phone, LoginType loginType, String nickname, String introduction, - TravelType travelType, Role role) { + public Member(Long id, String oauthId, String email, String password, String name, + LocalDate birth, Gender gender, String phone, LoginType loginType, + String nickname, String introduction, TravelType travelType, Role role) { this.id = id; this.oauthId = oauthId; this.email = email; + this.password = password; + this.name = name; this.birth = birth; this.gender = gender; - this.name = name; this.phone = phone; this.loginType = loginType; this.nickname = nickname; diff --git a/src/main/java/com/arom/with_travel/domain/member/dto/request/MemberSignupRequestDto.java b/src/main/java/com/arom/with_travel/domain/member/dto/request/MemberSignupRequestDto.java index 7bb8271..b7598c0 100644 --- a/src/main/java/com/arom/with_travel/domain/member/dto/request/MemberSignupRequestDto.java +++ b/src/main/java/com/arom/with_travel/domain/member/dto/request/MemberSignupRequestDto.java @@ -3,9 +3,7 @@ import com.arom.with_travel.domain.member.Member.Gender; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.*; import lombok.Getter; import lombok.Setter; @@ -32,4 +30,23 @@ public class MemberSignupRequestDto { @NotEmpty(message = "자기소개란을 작성해주세요") @Schema(description = "짧은 자기소개", example = "안녕하세요") private String introduction; + + @NotBlank(message = "이메일을 입력해주세요.") + @Email(message = "올바른 이메일 형식이 아닙니다.") + @Schema(description = "로그인용 이메일", example = "pikachu@example.com") + private String email; + + @NotBlank(message = "비밀번호를 입력해주세요.") + @Size(min = 8, max = 64, message = "비밀번호는 8~64자여야 합니다.") + @Schema(description = "로그인 비밀번호(서버에서 해시 저장)", example = "pika1234!") + private String password; + + @NotBlank(message = "이름(실명)을 입력해주세요.") + @Schema(description = "이름(실명)", example = "한지우") + private String name; + + @NotBlank(message = "전화번호를 입력해주세요.") + @Pattern(regexp = "^[0-9\\-]{8,15}$", message = "전화번호 형식이 올바르지 않습니다.") + @Schema(description = "전화번호", example = "010-1234-5678") + private String phone; }