diff --git a/backend/.gitignore b/backend/.gitignore index 8afde34e..4d0bcb47 100644 --- a/backend/.gitignore +++ b/backend/.gitignore @@ -41,3 +41,5 @@ out/ /src/main/generated/ /src/main/resources/*.json + +*.html diff --git a/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java b/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java index 62d0d44f..db01555a 100644 --- a/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java +++ b/backend/src/main/java/com/twtw/backend/config/socket/StompConfig.java @@ -5,12 +5,14 @@ import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.util.AntPathMatcher; import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker; import org.springframework.web.socket.config.annotation.StompEndpointRegistry; import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; +@Profile("!test") @Configuration @RequiredArgsConstructor @EnableWebSocketMessageBroker diff --git a/backend/src/main/java/com/twtw/backend/domain/friend/dto/response/FriendResponse.java b/backend/src/main/java/com/twtw/backend/domain/friend/dto/response/FriendResponse.java index 583c2e86..765ed09b 100644 --- a/backend/src/main/java/com/twtw/backend/domain/friend/dto/response/FriendResponse.java +++ b/backend/src/main/java/com/twtw/backend/domain/friend/dto/response/FriendResponse.java @@ -12,4 +12,5 @@ public class FriendResponse { private UUID memberId; private String nickname; + private String profileImage; } diff --git a/backend/src/main/java/com/twtw/backend/domain/friend/mapper/FriendMapper.java b/backend/src/main/java/com/twtw/backend/domain/friend/mapper/FriendMapper.java index 0193221d..efbde02a 100644 --- a/backend/src/main/java/com/twtw/backend/domain/friend/mapper/FriendMapper.java +++ b/backend/src/main/java/com/twtw/backend/domain/friend/mapper/FriendMapper.java @@ -20,5 +20,6 @@ public interface FriendMapper { @Mapping(target = "memberId", source = "fromMember.id") @Mapping(target = "nickname", source = "fromMember.nickname") + @Mapping(target = "profileImage", source = "fromMember.profileImage") FriendResponse toResponse(Friend friend); } diff --git a/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java b/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java index 8ef36ba3..7b72d055 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/mapper/GroupMapper.java @@ -23,8 +23,9 @@ public interface GroupMapper { Group toGroupEntity(MakeGroupRequest groupDto, Member leader); @Named("groupMemberToMemberResponse") - @Mapping(target = "id", source = "groupMember.member.id") + @Mapping(target = "memberId", source = "groupMember.member.id") @Mapping(target = "nickname", source = "groupMember.member.nickname") + @Mapping(target = "profileImage", source = "groupMember.member.profileImage") MemberResponse toGroupMemberResponse(GroupMember groupMember); @Named("groupMemberToMemberResponseList") diff --git a/backend/src/main/java/com/twtw/backend/domain/member/dto/response/MemberResponse.java b/backend/src/main/java/com/twtw/backend/domain/member/dto/response/MemberResponse.java index cdba3846..5895fa24 100644 --- a/backend/src/main/java/com/twtw/backend/domain/member/dto/response/MemberResponse.java +++ b/backend/src/main/java/com/twtw/backend/domain/member/dto/response/MemberResponse.java @@ -10,6 +10,7 @@ @Builder @AllArgsConstructor public class MemberResponse { - private UUID id; + private UUID memberId; private String nickname; + private String profileImage; } diff --git a/backend/src/main/java/com/twtw/backend/domain/member/mapper/MemberMapper.java b/backend/src/main/java/com/twtw/backend/domain/member/mapper/MemberMapper.java index 23e54e77..51ceda6d 100644 --- a/backend/src/main/java/com/twtw/backend/domain/member/mapper/MemberMapper.java +++ b/backend/src/main/java/com/twtw/backend/domain/member/mapper/MemberMapper.java @@ -22,8 +22,15 @@ public interface MemberMapper { @Mapping(target = "oauthInfo", source = "oauthRequest", qualifiedByName = "convertOauth") Member toMemberEntity(MemberSaveRequest request); + @Mapping(target = "memberId", source = "member.id") + @Mapping(target = "nickname", source = "member.nickname") + @Mapping(target = "profileImage", source = "member.profileImage") MemberResponse toMemberResponse(Member member); + default List toMemberResponses(List members) { + return members.stream().map(this::toMemberResponse).toList(); + } + @Named("convertOauth") default OAuth2Info convertOauth(OAuthRequest request) { return new OAuth2Info(request.getToken(), request.getAuthType()); @@ -32,7 +39,8 @@ default OAuth2Info convertOauth(OAuthRequest request) { @IterableMapping(elementTargetType = MemberResponse.class) List toMemberResponses(Set planMembers); - @Mapping(target = "id", source = "planMember.member.id") + @Mapping(target = "memberId", source = "planMember.member.id") @Mapping(target = "nickname", source = "planMember.member.nickname") + @Mapping(target = "profileImage", source = "planMember.member.profileImage") MemberResponse toMemberResponse(PlanMember planMember); } diff --git a/backend/src/main/java/com/twtw/backend/domain/member/service/MemberService.java b/backend/src/main/java/com/twtw/backend/domain/member/service/MemberService.java index aa9ade92..aa01771a 100644 --- a/backend/src/main/java/com/twtw/backend/domain/member/service/MemberService.java +++ b/backend/src/main/java/com/twtw/backend/domain/member/service/MemberService.java @@ -58,6 +58,10 @@ public MemberResponse getResponseByMember(Member member) { return memberMapper.toMemberResponse(member); } + public List getResponsesByMembers(final List members) { + return memberMapper.toMemberResponses(members); + } + public List getMemberResponses(final Plan plan) { return memberMapper.toMemberResponses(plan.getPlanMembers()); } diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/dto/request/SavePlanRequest.java b/backend/src/main/java/com/twtw/backend/domain/plan/dto/request/SavePlanRequest.java index fad17772..e7cd46d4 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/dto/request/SavePlanRequest.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/dto/request/SavePlanRequest.java @@ -8,12 +8,14 @@ import lombok.NoArgsConstructor; import java.time.LocalDateTime; +import java.util.List; import java.util.UUID; @Getter @NoArgsConstructor @AllArgsConstructor public class SavePlanRequest { + private String name; private UUID groupId; @JsonFormat( @@ -23,4 +25,6 @@ public class SavePlanRequest { private LocalDateTime planDay; private PlaceDetails placeDetails; + + private List memberIds; } diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/dto/request/UpdatePlanRequest.java b/backend/src/main/java/com/twtw/backend/domain/plan/dto/request/UpdatePlanRequest.java index cdea767d..63407210 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/dto/request/UpdatePlanRequest.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/dto/request/UpdatePlanRequest.java @@ -1,11 +1,14 @@ package com.twtw.backend.domain.plan.dto.request; +import com.fasterxml.jackson.annotation.JsonFormat; import com.twtw.backend.domain.place.entity.CategoryGroupCode; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import java.time.LocalDateTime; +import java.util.List; import java.util.UUID; @Getter @@ -13,10 +16,19 @@ @AllArgsConstructor public class UpdatePlanRequest { private UUID planId; + + @JsonFormat( + shape = JsonFormat.Shape.STRING, + pattern = "yyyy-MM-dd HH:mm", + timezone = "Asia/Seoul") + private LocalDateTime planDay; + + private String name; private String placeName; private String placeUrl; private CategoryGroupCode categoryGroupCode; private String roadAddressName; private Double longitude; private Double latitude; + private List memberIds; } diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/dto/response/PlanInfoResponse.java b/backend/src/main/java/com/twtw/backend/domain/plan/dto/response/PlanInfoResponse.java index 42137613..f4aa14c8 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/dto/response/PlanInfoResponse.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/dto/response/PlanInfoResponse.java @@ -17,8 +17,10 @@ public class PlanInfoResponse { private UUID planId; private UUID placeId; private UUID planMakerId; + private String name; private String planDay; private PlaceDetails placeDetails; private GroupInfoResponse groupInfo; private List members; + private List notJoinedMembers; } diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/entity/Plan.java b/backend/src/main/java/com/twtw/backend/domain/plan/entity/Plan.java index 8a39db9a..f118ef20 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/entity/Plan.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/entity/Plan.java @@ -1,6 +1,7 @@ package com.twtw.backend.domain.plan.entity; import com.twtw.backend.domain.group.entity.Group; +import com.twtw.backend.domain.group.entity.GroupMember; import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.domain.place.entity.CategoryGroupCode; import com.twtw.backend.domain.place.entity.Place; @@ -11,15 +12,13 @@ import jakarta.persistence.*; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; +import lombok.*; import org.hibernate.annotations.Where; import java.time.LocalDateTime; import java.util.HashSet; +import java.util.List; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; @@ -35,6 +34,9 @@ public class Plan implements Auditable { @Column(columnDefinition = "BINARY(16)") private UUID id; + @Column(nullable = false) + private String name; + @JoinColumn(columnDefinition = "BINARY(16)") @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.PERSIST, orphanRemoval = true) private Place place; @@ -56,9 +58,11 @@ public class Plan implements Auditable { private LocalDateTime planDay; - public Plan(Member member, Place place, Group group, LocalDateTime planDay) { + @Builder + public Plan(String name, Member member, Place place, Group group, LocalDateTime planDay) { + this.name = name; this.planMembers.add(new PlanMember(this, member, true)); - organizePlace(place); + this.place = place; organizeGroup(group); this.planDay = planDay; } @@ -90,22 +94,22 @@ private boolean hasNoPlanMaker() { return this.planMembers.stream().noneMatch(PlanMember::getIsPlanMaker); } - private void organizePlace(final Place place) { - this.place = place; - } - - public void organizeGroup(final Group group) { + private void organizeGroup(final Group group) { this.group = group; this.group.addPlan(this); } public void updatePlace( + final String name, + final LocalDateTime planDay, final String placeName, final String placeUrl, final CategoryGroupCode categoryGroupCode, final String roadAddressName, final Double longitude, final Double latitude) { + this.name = name; + this.planDay = planDay; this.place.update( placeName, placeUrl, categoryGroupCode, roadAddressName, longitude, latitude); } @@ -138,4 +142,15 @@ public void acceptInvite(final Member member) { public void deleteInvite(final Member member) { this.planMembers.removeIf(planMember -> planMember.isSameMember(member)); } + + public List getNotJoinedMembers() { + return this.group.getGroupMembers().stream() + .map(GroupMember::getMember) + .filter(member -> !hasSameMember(member)) + .toList(); + } + + public void addMembers(final List membersByIds) { + membersByIds.forEach(this::addMember); + } } diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/mapper/PlanMapper.java b/backend/src/main/java/com/twtw/backend/domain/plan/mapper/PlanMapper.java index f5beda0f..74ab26a5 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/mapper/PlanMapper.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/mapper/PlanMapper.java @@ -1,7 +1,10 @@ package com.twtw.backend.domain.plan.mapper; import com.twtw.backend.domain.group.dto.response.GroupInfoResponse; +import com.twtw.backend.domain.group.entity.Group; import com.twtw.backend.domain.member.dto.response.MemberResponse; +import com.twtw.backend.domain.member.entity.Member; +import com.twtw.backend.domain.place.entity.Place; import com.twtw.backend.domain.plan.dto.client.PlaceClientDetails; import com.twtw.backend.domain.plan.dto.client.SearchDestinationResponse; import com.twtw.backend.domain.plan.dto.response.PlaceDetails; @@ -16,6 +19,7 @@ import org.mapstruct.MappingConstants; import org.mapstruct.Named; +import java.time.LocalDateTime; import java.util.List; @Mapper(componentModel = MappingConstants.ComponentModel.SPRING) @@ -29,6 +33,23 @@ public interface PlanMapper { PlanDestinationResponse toPlanDestinationResponse(SearchDestinationResponse response); @Mapping(target = "planId", source = "plan.id") + @Mapping(target = "name", source = "plan.name") + @Mapping(target = "placeId", source = "plan.place.id") + @Mapping(target = "planMakerId", source = "plan.planMakerId") + @Mapping(target = "groupInfo", source = "groupInfoResponse") + @Mapping(target = "members", source = "memberResponses") + @Mapping(target = "notJoinedMembers", source = "notJoinedMembers") + @Mapping(target = "planDay", source = "planDay") + PlanInfoResponse toPlanInfoResponse( + Plan plan, + PlaceClientDetails placeDetails, + String planDay, + GroupInfoResponse groupInfoResponse, + List memberResponses, + List notJoinedMembers); + + @Mapping(target = "planId", source = "plan.id") + @Mapping(target = "name", source = "plan.name") @Mapping(target = "placeId", source = "plan.place.id") @Mapping(target = "planMakerId", source = "plan.planMakerId") @Mapping(target = "groupInfo", source = "groupInfoResponse") @@ -48,4 +69,8 @@ PlanInfoResponse toPlanInfoResponse( @Mapping(target = "longitude", source = "x") @Mapping(target = "latitude", source = "y") PlaceDetails toPlaceDetail(PlaceClientDetails placeClientDetails); + + @Mapping(target = "name", source = "name") + @Mapping(target = "group", source = "group") + Plan toEntity(String name, Member member, Place place, Group group, LocalDateTime planDay); } diff --git a/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java b/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java index 1177410c..f35855a9 100644 --- a/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java +++ b/backend/src/main/java/com/twtw/backend/domain/plan/service/PlanService.java @@ -39,6 +39,8 @@ @Transactional @RequiredArgsConstructor public class PlanService { + private static final DateTimeFormatter DATE_TIME_FORMATTER = + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); private final PlanRepository planRepository; private final GroupService groupService; @@ -75,13 +77,19 @@ private boolean hasNoSearchData(final List documents) { return documents == null || documents.isEmpty(); } + @Transactional public PlanResponse savePlan(final SavePlanRequest request) { Member member = authService.getMemberByJwt(); Group group = groupService.getGroupEntity(request.getGroupId()); Place place = placeService.getEntityByDetail(request.getPlaceDetails()); - Plan plan = new Plan(member, place, group, request.getPlanDay()); - return planMapper.toPlanResponse(planRepository.save(plan)); + final Plan plan = + planRepository.save( + planMapper.toEntity( + request.getName(), member, place, group, request.getPlanDay())); + plan.addMembers(memberService.getMembersByIds(request.getMemberIds())); + + return planMapper.toPlanResponse(plan); } @Transactional @@ -102,17 +110,29 @@ public void outPlan(PlanMemberRequest request) { public PlanInfoResponse getPlanById(UUID id) { Plan plan = getPlanEntity(id); - return getPlanInfoResponse(plan); + return getPlanInfoResponseWithNotJoinedMembers(plan); + } + + private PlanInfoResponse getPlanInfoResponseWithNotJoinedMembers(final Plan plan) { + GroupInfoResponse groupInfo = groupService.getGroupInfoResponse(plan.getGroup()); + PlaceClientDetails placeDetails = placeService.getPlaceDetails(plan.getPlace()); + List notJoinedMembers = + memberService.getResponsesByMembers(plan.getNotJoinedMembers()); + String planDay = plan.getPlanDay().format(DATE_TIME_FORMATTER); + List memberResponses = toMemberResponse(plan); + + return planMapper.toPlanInfoResponse( + plan, placeDetails, planDay, groupInfo, memberResponses, notJoinedMembers); } private PlanInfoResponse getPlanInfoResponse(final Plan plan) { GroupInfoResponse groupInfo = groupService.getGroupInfoResponse(plan.getGroup()); PlaceClientDetails placeDetails = placeService.getPlaceDetails(plan.getPlace()); - String planDay = plan.getPlanDay().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")); - List memberResponse = toMemberResponse(plan); + String planDay = plan.getPlanDay().format(DATE_TIME_FORMATTER); + List memberResponses = toMemberResponse(plan); return planMapper.toPlanInfoResponse( - plan, placeDetails, planDay, groupInfo, memberResponse); + plan, placeDetails, planDay, groupInfo, memberResponses); } public void deletePlan(UUID id) { @@ -133,16 +153,21 @@ public List getPlans() { return plans.stream().map(this::getPlanInfoResponse).toList(); } + @Transactional public void updatePlan(final UpdatePlanRequest updatePlanRequest) { final Plan plan = getPlanEntity(updatePlanRequest.getPlanId()); plan.updatePlace( + updatePlanRequest.getName(), + updatePlanRequest.getPlanDay(), updatePlanRequest.getPlaceName(), updatePlanRequest.getPlaceUrl(), updatePlanRequest.getCategoryGroupCode(), updatePlanRequest.getRoadAddressName(), updatePlanRequest.getLongitude(), updatePlanRequest.getLatitude()); + + plan.addMembers(memberService.getMembersByIds(updatePlanRequest.getMemberIds())); } @Transactional diff --git a/backend/src/main/resources/application-dev.yml b/backend/src/main/resources/application-dev.yml index 2bc9f0b0..18685b7c 100644 --- a/backend/src/main/resources/application-dev.yml +++ b/backend/src/main/resources/application-dev.yml @@ -32,3 +32,5 @@ spring: redis: host: localhost port: 6379 + jackson: + default-property-inclusion: non_null \ No newline at end of file diff --git a/backend/src/main/resources/application-prod.yml b/backend/src/main/resources/application-prod.yml index f0b63446..998173ad 100644 --- a/backend/src/main/resources/application-prod.yml +++ b/backend/src/main/resources/application-prod.yml @@ -31,6 +31,8 @@ spring: redis: host: redis port: 6379 + jackson: + default-property-inclusion: non_null management: endpoints: web: diff --git a/backend/src/main/resources/application-test.yml b/backend/src/main/resources/application-test.yml index 28ec5e3c..28a9cc74 100644 --- a/backend/src/main/resources/application-test.yml +++ b/backend/src/main/resources/application-test.yml @@ -13,6 +13,8 @@ spring: main: allow-bean-definition-overriding: true + jackson: + default-property-inclusion: non_null datasource: driver-class-name: org.h2.Driver diff --git a/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java index d2091039..5a0fdf82 100644 --- a/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/friend/controller/FriendControllerTest.java @@ -41,8 +41,8 @@ void getFriends() throws Exception { // given final List expected = List.of( - new FriendResponse(UUID.randomUUID(), "정해진"), - new FriendResponse(UUID.randomUUID(), "주어진")); + new FriendResponse(UUID.randomUUID(), "정해진", "http://hojiniSelfie"), + new FriendResponse(UUID.randomUUID(), "주어진", "http://hojiniSelfCamera")); given(friendService.getFriends()).willReturn(expected); // when @@ -68,8 +68,8 @@ void getFriendsByStatus() throws Exception { // given final List expected = List.of( - new FriendResponse(UUID.randomUUID(), "호전"), - new FriendResponse(UUID.randomUUID(), "후진")); + new FriendResponse(UUID.randomUUID(), "호전", "http://HJ39Selfie"), + new FriendResponse(UUID.randomUUID(), "후진", "http://HJ39SelfCamera")); given(friendService.getFriendsByStatus(any())).willReturn(expected); // when @@ -158,8 +158,8 @@ void getFriendByName() throws Exception { // given final List expected = List.of( - new FriendResponse(UUID.randomUUID(), "호진정"), - new FriendResponse(UUID.randomUUID(), "진정해")); + new FriendResponse(UUID.randomUUID(), "호진정", "http://hojiniSelfie"), + new FriendResponse(UUID.randomUUID(), "진정해", "http://hojiniSelfCamera")); given(friendService.getFriendByNickname(any())).willReturn(expected); // when diff --git a/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java index b54f0da0..957b99c9 100644 --- a/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/group/controller/GroupControllerTest.java @@ -47,8 +47,10 @@ void getGroupById() throws Exception { "HDJ", "GROUP-IMAGE", List.of( - new MemberResponse(UUID.randomUUID(), "DEAN"), - new MemberResponse(UUID.randomUUID(), "ZION-T"))); + new MemberResponse( + UUID.randomUUID(), "DEAN", "http://hojiniSelfie"), + new MemberResponse( + UUID.randomUUID(), "ZION-T", "http://hojiniSelfie"))); given(groupService.getGroupById(UUID.fromString("550e8400-e29b-41d4-a716-446655440000"))) .willReturn(expected); @@ -76,8 +78,10 @@ void makeGroup() throws Exception { "HDJ", "GROUP-IMAGE", List.of( - new MemberResponse(UUID.randomUUID(), "DEAN"), - new MemberResponse(UUID.randomUUID(), "ZION-T"))); + new MemberResponse( + UUID.randomUUID(), "DEAN", "http://hojiniSelfie"), + new MemberResponse( + UUID.randomUUID(), "ZION-T", "http://hojiniSelfie"))); given(groupService.makeGroup(any())).willReturn(expected); final ResultActions perform = @@ -135,8 +139,10 @@ void inviteGroup() throws Exception { "홍담진", "http://someUrlToS3", List.of( - new MemberResponse(UUID.randomUUID(), "DEAN"), - new MemberResponse(UUID.randomUUID(), "ZION-T"))); + new MemberResponse( + UUID.randomUUID(), "DEAN", "http://hojiniSelfie"), + new MemberResponse( + UUID.randomUUID(), "ZION-T", "http://hojiniSelfie"))); given(groupService.inviteGroup(any())).willReturn(expected); // when @@ -296,8 +302,10 @@ void getMyGroups() throws Exception { "BLACK_PINK", "I_LOVE_YOU_LOSE", List.of( - new MemberResponse(UUID.randomUUID(), "LISA"), - new MemberResponse(UUID.randomUUID(), "제니"))); + new MemberResponse( + UUID.randomUUID(), "LISA", "http://hojiniSelfieWow"), + new MemberResponse( + UUID.randomUUID(), "제니", "http://hojiniSelfieAwesome"))); GroupInfoResponse response2 = new GroupInfoResponse( UUID.randomUUID(), @@ -305,8 +313,10 @@ void getMyGroups() throws Exception { "LE_SSERAFIM", "I_LOVE_YOU_채원", List.of( - new MemberResponse(UUID.randomUUID(), "카즈하"), - new MemberResponse(UUID.randomUUID(), "사쿠라"))); + new MemberResponse( + UUID.randomUUID(), "카즈하", "http://hojiniSelfieGreat"), + new MemberResponse( + UUID.randomUUID(), "사쿠라", "http://hojiniSelfieGoat"))); responseList.add(response1); responseList.add(response2); diff --git a/backend/src/test/java/com/twtw/backend/domain/group/repository/GroupRepositoryTest.java b/backend/src/test/java/com/twtw/backend/domain/group/repository/GroupRepositoryTest.java index 19e1efdc..49e33ecc 100644 --- a/backend/src/test/java/com/twtw/backend/domain/group/repository/GroupRepositoryTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/group/repository/GroupRepositoryTest.java @@ -42,7 +42,7 @@ void makeGroup() { Place place = PlaceEntityFixture.FIRST_PLACE.toEntity(); - Plan plan = new Plan(member1, place, group, LocalDateTime.of(2023, 12, 25, 13, 30)); + Plan plan = new Plan("모임명", member1, place, group, LocalDateTime.of(2023, 12, 25, 13, 30)); plan.addMember(member2); // when @@ -83,11 +83,11 @@ void getPlan() { Group group = GroupEntityFixture.BTS_GROUP.toEntity(member1); - GroupMember groupMember2 = new GroupMember(group, member2); + new GroupMember(group, member2); Place place = PlaceEntityFixture.FIRST_PLACE.toEntity(); - Plan plan = new Plan(member1, place, group, LocalDateTime.of(2023, 12, 25, 13, 30)); + Plan plan = new Plan("모임명", member1, place, group, LocalDateTime.of(2023, 12, 25, 13, 30)); plan.addMember(member2); // when diff --git a/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java index 11a84786..8f1b7def 100644 --- a/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/member/controller/MemberControllerTest.java @@ -61,7 +61,7 @@ void searchMemberByNickname() throws Exception { String expectedNickname = "JIN_JOO_ONE"; final MemberResponse memberResponse = - new MemberResponse(UUID.randomUUID(), expectedNickname); + new MemberResponse(UUID.randomUUID(), expectedNickname, "http://HJ39"); final SearchMemberResponse response = new SearchMemberResponse(true, memberResponse); given(memberService.getMemberByNickname(expectedNickname)).willReturn(response); diff --git a/backend/src/test/java/com/twtw/backend/domain/member/service/MemberServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/member/service/MemberServiceTest.java index f1396fc5..8a01bfaf 100644 --- a/backend/src/test/java/com/twtw/backend/domain/member/service/MemberServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/member/service/MemberServiceTest.java @@ -54,7 +54,7 @@ void getResponseByMember() { MemberResponse memberResponse = memberService.getResponseByMember(member); // then - assertThat(memberResponse.getId()).isEqualTo(member.getId()); + assertThat(memberResponse.getMemberId()).isEqualTo(member.getId()); } @Test @@ -68,6 +68,6 @@ void searchMemberByNickname() { memberService.getMemberByNickname(member.getNickname()); // then - assertThat(response.getMemberResponse().getId()).isEqualTo(member.getId()); + assertThat(response.getMemberResponse().getMemberId()).isEqualTo(member.getId()); } } diff --git a/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java b/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java index 0f2ef619..818716ec 100644 --- a/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/plan/controller/PlanControllerTest.java @@ -34,6 +34,7 @@ import org.springframework.test.web.servlet.ResultActions; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.UUID; @@ -107,6 +108,7 @@ void savePlan() throws Exception { .content( toRequestBody( new SavePlanRequest( + "약속이름", UUID.randomUUID(), LocalDateTime.of(2023, 12, 25, 15, 30), new PlaceDetails( @@ -114,7 +116,10 @@ void savePlan() throws Exception { "https://place.map.kakao.com/1625295668", "경기 안성시 죽산면 죽산초교길 36-4", 127.420430538256, - 37.0766874564297)))) + 37.0766874564297), + List.of( + UUID.randomUUID(), + UUID.randomUUID())))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); @@ -137,6 +142,7 @@ void getPlanById() throws Exception { UUID.randomUUID(), UUID.randomUUID(), UUID.randomUUID(), + "약속이름", "2023-12-25 15:30", new PlaceDetails( "카페 온마이마인드", @@ -150,9 +156,14 @@ void getPlanById() throws Exception { "홍담진", "http://someUrlToS3", List.of( - new MemberResponse(UUID.randomUUID(), "카즈하"), - new MemberResponse(UUID.randomUUID(), "사쿠라"))), - List.of(new MemberResponse(UUID.randomUUID(), "진호정"))); + new MemberResponse( + UUID.randomUUID(), "카즈하", "http://HJ39FaceCamera"), + new MemberResponse( + UUID.randomUUID(), "사쿠라", "http://HJ39FaceCam"))), + List.of(new MemberResponse(UUID.randomUUID(), "진호정", "http://HJ39Face")), + List.of( + new MemberResponse( + UUID.randomUUID(), "진정Ho", "http://HJ39Camera"))); given(planService.getPlanById(any())).willReturn(expected); // when @@ -294,46 +305,76 @@ void getPlans() throws Exception { // given final List expected = List.of( - new PlanInfoResponse( - UUID.randomUUID(), - UUID.randomUUID(), - UUID.randomUUID(), - "2023-12-25 15:30", - new PlaceDetails( - "카페 온마이마인드", - "https://place.map.kakao.com/1625295668", - "경기 안성시 죽산면 죽산초교길 36-4", - 127.420430538256, - 37.0766874564297), - new GroupInfoResponse( - UUID.randomUUID(), - UUID.randomUUID(), - "홍담진", - "http://someUrlToS3", + PlanInfoResponse.builder() + .planId(UUID.randomUUID()) + .planMakerId(UUID.randomUUID()) + .placeId(UUID.randomUUID()) + .name("약속1") + .planDay("2023-12-25 15:30") + .placeDetails( + new PlaceDetails( + "카페 온마이마인드", + "https://place.map.kakao.com/1625295668", + "경기 안성시 죽산면 죽산초교길 36-4", + 127.420430538256, + 37.0766874564297)) + .groupInfo( + new GroupInfoResponse( + UUID.randomUUID(), + UUID.randomUUID(), + "홍담진", + "http://someUrlToS3", + List.of( + new MemberResponse( + UUID.randomUUID(), + "카즈하", + "http://HJ39GOAT"), + new MemberResponse( + UUID.randomUUID(), + "사쿠라", + "http://HJ39")))) + .members( List.of( - new MemberResponse(UUID.randomUUID(), "카즈하"), - new MemberResponse(UUID.randomUUID(), "사쿠라"))), - List.of(new MemberResponse(UUID.randomUUID(), "진호정"))), - new PlanInfoResponse( - UUID.randomUUID(), - UUID.randomUUID(), - UUID.randomUUID(), - "2023-12-26 15:30", - new PlaceDetails( - "카페 온유어마인드", - "https://place.map.kakao.com/1625295669", - "경기 안성시 죽산면 죽산초교길 36-5", - 127.420430538257, - 37.0766874564298), - new GroupInfoResponse( - UUID.randomUUID(), - UUID.randomUUID(), - "HongDamJin", - "http://someUrlToS3", + new MemberResponse( + UUID.randomUUID(), + "진호정", + "http://HoJin39"))) + .build(), + PlanInfoResponse.builder() + .planId(UUID.randomUUID()) + .planMakerId(UUID.randomUUID()) + .placeId(UUID.randomUUID()) + .name("약속2") + .planDay("2023-12-25 15:30") + .placeDetails( + new PlaceDetails( + "카페 온마이마인드", + "https://place.map.kakao.com/1625295668", + "경기 안성시 죽산면 죽산초교길 36-4", + 127.420430538256, + 37.0766874564297)) + .groupInfo( + new GroupInfoResponse( + UUID.randomUUID(), + UUID.randomUUID(), + "HongDamJin", + "http://someUrlToS3", + List.of( + new MemberResponse( + UUID.randomUUID(), + "카즈하", + "http://HJ39"), + new MemberResponse( + UUID.randomUUID(), + "사쿠라", + "http://HJ39")))) + .members( List.of( - new MemberResponse(UUID.randomUUID(), "카즈하"), - new MemberResponse(UUID.randomUUID(), "사쿠라"))), - List.of(new MemberResponse(UUID.randomUUID(), "JinHoJeong")))); + new MemberResponse( + UUID.randomUUID(), + "JinHoJeong", + "http://HJ39"))) + .build()); given(planService.getPlans()).willReturn(expected); @@ -389,6 +430,7 @@ void updatePlanDay() throws Exception { void updatePlan() throws Exception { // given willDoNothing().given(planService).updatePlan(any()); + final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); // when final ResultActions perform = @@ -399,12 +441,20 @@ void updatePlan() throws Exception { toRequestBody( new UpdatePlanRequest( UUID.randomUUID(), + LocalDateTime.parse( + LocalDateTime.now() + .format(formatter), + formatter), + "약속명", "별다방", "http://place.map.kakao.com/1562566188", CategoryGroupCode.CE7, "경기 안성시 죽산면 죽주로 287-1", 127.426865189637, - 37.0764635355795))) + 37.0764635355795, + List.of( + UUID.randomUUID(), + UUID.randomUUID())))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); diff --git a/backend/src/test/java/com/twtw/backend/domain/plan/repository/PlanRepositoryTest.java b/backend/src/test/java/com/twtw/backend/domain/plan/repository/PlanRepositoryTest.java index 90f7207a..2401b60f 100644 --- a/backend/src/test/java/com/twtw/backend/domain/plan/repository/PlanRepositoryTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/plan/repository/PlanRepositoryTest.java @@ -65,6 +65,7 @@ void softDelete() { planRepository .save( new Plan( + "모임명", member, place, group, @@ -102,9 +103,14 @@ void findAllPlanByMember() { final Plan plan = planRepository.save( new Plan( - member, firstPlace, group, LocalDateTime.of(2023, 12, 25, 13, 30))); + "모임명", + member, + firstPlace, + group, + LocalDateTime.of(2023, 12, 25, 13, 30))); planRepository.save( new Plan( + "모임명", member, secondPlace, new Group("1", "2", member), diff --git a/backend/src/test/java/com/twtw/backend/domain/plan/service/PlanServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/plan/service/PlanServiceTest.java index daf668fe..3d97359f 100644 --- a/backend/src/test/java/com/twtw/backend/domain/plan/service/PlanServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/plan/service/PlanServiceTest.java @@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import java.time.LocalDateTime; +import java.util.List; import java.util.Optional; import java.util.UUID; @@ -59,9 +60,11 @@ void savePlan() { final PlanResponse planResponse = planService.savePlan( new SavePlanRequest( + "모임명", groupId, LocalDateTime.of(2023, 12, 25, 15, 30), - PlaceDetailsFixture.FIRST_PLACE.toPlaceDetails())); + PlaceDetailsFixture.FIRST_PLACE.toPlaceDetails(), + List.of(UUID.randomUUID()))); // then final Optional result = planRepository.findById(planResponse.getPlanId()); @@ -76,6 +79,7 @@ void joinPlan() { final Plan plan = planRepository.save( new Plan( + "모임명", member, PlaceEntityFixture.FIRST_PLACE.toEntity(), GroupEntityFixture.BTS_GROUP.toEntity(loginUser), @@ -119,6 +123,7 @@ void getPlanById() { planRepository .save( new Plan( + "모임명", loginUser, PlaceEntityFixture.SECOND_PLACE.toEntity(), GroupEntityFixture.HDJ_GROUP.toEntity(loginUser), @@ -140,6 +145,7 @@ void deletePlan() { planRepository .save( new Plan( + "모임명", loginUser, PlaceEntityFixture.SECOND_PLACE.toEntity(), GroupEntityFixture.HDJ_GROUP.toEntity(loginUser), diff --git a/backend/src/test/java/com/twtw/backend/fixture/plan/PlanEntityFixture.java b/backend/src/test/java/com/twtw/backend/fixture/plan/PlanEntityFixture.java index db3f1f4f..3fcca04f 100644 --- a/backend/src/test/java/com/twtw/backend/fixture/plan/PlanEntityFixture.java +++ b/backend/src/test/java/com/twtw/backend/fixture/plan/PlanEntityFixture.java @@ -12,12 +12,13 @@ @RequiredArgsConstructor public enum PlanEntityFixture { - FIRST_PLACE(PlaceEntityFixture.FIRST_PLACE.toEntity()), - SECOND_PLACE(PlaceEntityFixture.SECOND_PLACE.toEntity()); + FIRST_PLACE("호캉스 모임", PlaceEntityFixture.FIRST_PLACE.toEntity()), + SECOND_PLACE("친구 모임", PlaceEntityFixture.SECOND_PLACE.toEntity()); + private final String name; private final Place place; public Plan toEntity(final Member member, final Group group, final LocalDateTime planDay) { - return new Plan(member, place, group, planDay); + return new Plan(name, member, place, group, planDay); } }