From f7d75e2c46f80a722edec82e36fcbd439df8dcac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Mon, 4 Dec 2023 02:23:33 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[FEAT]=20=EA=B7=B8=EB=A3=B9=20=EC=B4=88?= =?UTF-8?q?=EB=8C=80=EC=8B=9C=20=EC=A0=84=EC=B2=B4=20=EC=B4=88=EB=8C=80?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/docs/group.adoc | 7 +- .../group/controller/GroupController.java | 12 +++- .../group/dto/request/InviteGroupRequest.java | 6 +- .../backend/domain/group/entity/Group.java | 20 +++++- .../domain/group/entity/GroupMember.java | 19 ++++-- .../domain/group/mapper/GroupMapper.java | 18 ++--- .../domain/group/service/GroupService.java | 35 +++++----- .../backend/domain/member/entity/Member.java | 8 +++ .../twtw/backend/domain/plan/entity/Plan.java | 4 +- .../group/controller/GroupControllerTest.java | 34 ++++++++-- .../group/repository/GroupRepositoryTest.java | 16 ++--- .../group/service/GroupServiceTest.java | 66 ++++++------------- .../plan/repository/PlanRepositoryTest.java | 12 ++-- .../domain/plan/service/PlanServiceTest.java | 10 +-- .../fixture/group/GroupEntityFixture.java | 14 ++-- .../group/GroupMemberEntityFixture.java | 37 ----------- .../fixture/plan/PlanEntityFixture.java | 9 +-- 17 files changed, 159 insertions(+), 168 deletions(-) delete mode 100644 backend/src/test/java/com/twtw/backend/fixture/group/GroupMemberEntityFixture.java diff --git a/backend/src/docs/group.adoc b/backend/src/docs/group.adoc index e79fec32..f12063d8 100644 --- a/backend/src/docs/group.adoc +++ b/backend/src/docs/group.adoc @@ -17,8 +17,11 @@ operation::post join group[snippets='http-request,http-response'] === 그룹 초대 operation::post invite group[snippets='http-request,http-response'] -=== 위치 공유 여부 수정 -operation::post change share[snippets='http-request,http-response'] +=== 위치 공유 ON +operation::post share location[snippets='http-request,http-response'] + +=== 위치 공유 OFF +operation::post unshare location[snippets='http-request,http-response'] === 위치 공유 여부 조회 operation::get share[snippets='http-request,http-response'] diff --git a/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java b/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java index 9896303b..a4ebe617 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/controller/GroupController.java @@ -47,8 +47,14 @@ public ResponseEntity inviteGroup( } @PostMapping("/share/{id}") - public ResponseEntity changeShare(@PathVariable UUID id) { - groupService.changeShare(id); + public ResponseEntity shareLocation(@PathVariable UUID id) { + groupService.shareLocation(id); + return ResponseEntity.noContent().build(); + } + + @PostMapping("/unshare/{id}") + public ResponseEntity unShareLocation(@PathVariable UUID id) { + groupService.unShareLocation(id); return ResponseEntity.noContent().build(); } @@ -57,7 +63,7 @@ public ResponseEntity getShare(@PathVariable UUID id) { return ResponseEntity.ok(groupService.getShare(id)); } - @GetMapping() + @GetMapping public ResponseEntity> getMyGroups() { return ResponseEntity.ok(groupService.getMyGroups()); } diff --git a/backend/src/main/java/com/twtw/backend/domain/group/dto/request/InviteGroupRequest.java b/backend/src/main/java/com/twtw/backend/domain/group/dto/request/InviteGroupRequest.java index 31b89257..11093a2e 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/dto/request/InviteGroupRequest.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/dto/request/InviteGroupRequest.java @@ -1,15 +1,15 @@ package com.twtw.backend.domain.group.dto.request; +import java.util.List; +import java.util.UUID; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.UUID; - @Getter @NoArgsConstructor @AllArgsConstructor public class InviteGroupRequest { - private UUID friendMemberId; + private List friendMemberIds; private UUID groupId; } diff --git a/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java b/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java index 788f1679..b8d9f97b 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java @@ -1,5 +1,6 @@ package com.twtw.backend.domain.group.entity; +import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.domain.plan.entity.Plan; import com.twtw.backend.global.audit.AuditListener; import com.twtw.backend.global.audit.Auditable; @@ -52,13 +53,26 @@ public class Group implements Auditable { @Column(nullable = false) private BaseTime baseTime; - public Group(String name, String groupImage, UUID leaderId) { + @Builder + public Group(final String name, final String groupImage, final Member leader) { this.name = name; this.groupImage = groupImage; - this.leaderId = leaderId; + this.leaderId = leader.getId(); + + final GroupMember groupMember = new GroupMember(this, leader); + this.groupMembers.add(groupMember); + groupMember.changeGroupCode(); } - public void addToGroup(final Plan plan) { + public void addPlan(final Plan plan) { this.groupPlans.add(plan); } + + public void inviteAll(final List friends) { + friends.forEach(friend -> addGroupMember(new GroupMember(this, friend))); + } + + private boolean addGroupMember(final GroupMember groupMember) { + return this.groupMembers.add(groupMember); + } } diff --git a/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java b/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java index 7040a7ea..50809abb 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java @@ -58,16 +58,23 @@ public GroupMember(Group group, Member member) { this.group = group; this.member = member; this.share = true; - group.getGroupMembers().add(this); - member.getGroupMembers().add(this); + member.addGroupMember(this); this.groupInviteCode = GroupInviteCode.REQUESTED; } - public void changeShare() { - this.share = !this.share; + public void share() { + this.share = true; + } + + public void unShare() { + this.share = false; + } + + public void changeGroupCode() { + this.groupInviteCode = GroupInviteCode.ACCEPTED; } - public void changeGroupCode(GroupInviteCode groupInviteCode) { - this.groupInviteCode = groupInviteCode; + public UUID getGroupId() { + return this.group.getId(); } } 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 08b5b827..090b3437 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 @@ -6,24 +6,18 @@ 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 org.mapstruct.*; - import java.util.List; -import java.util.UUID; +import org.mapstruct.IterableMapping; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.MappingConstants; +import org.mapstruct.Named; @Mapper(componentModel = MappingConstants.ComponentModel.SPRING) public interface GroupMapper { - @Mapping(target = "baseTime", ignore = true) - GroupMember connectGroupMember(Group group, Member member); - - @Mapping(target = "baseTime", ignore = true) - @Mapping(target = "groupMembers", ignore = true) - @Mapping(target = "groupPlans", ignore = true) @Mapping(target = "name", source = "groupDto.name") @Mapping(target = "groupImage", source = "groupDto.groupImage") - @Mapping(target = "leaderId", source = "leaderId") - Group toGroupEntity(MakeGroupRequest groupDto, UUID leaderId); + Group toGroupEntity(MakeGroupRequest groupDto, Member leader); @Mapping(target = "groupId", source = "id") GroupInfoResponse toGroupInfo(Group group); diff --git a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java index 47846d07..8619a0a9 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java @@ -7,7 +7,6 @@ import com.twtw.backend.domain.group.dto.response.ShareInfoResponse; import com.twtw.backend.domain.group.dto.response.SimpleGroupInfoResponse; import com.twtw.backend.domain.group.entity.Group; -import com.twtw.backend.domain.group.entity.GroupInviteCode; import com.twtw.backend.domain.group.entity.GroupMember; import com.twtw.backend.domain.group.mapper.GroupMapper; import com.twtw.backend.domain.group.repository.GroupMemberRepository; @@ -16,12 +15,11 @@ import com.twtw.backend.domain.member.service.AuthService; import com.twtw.backend.domain.member.service.MemberService; import com.twtw.backend.global.exception.EntityNotFoundException; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - import java.util.List; import java.util.UUID; +import java.util.function.Consumer; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class GroupService { @@ -63,9 +61,7 @@ public GroupMember getGroupMemberEntity(UUID groupId, UUID memberId) { @Transactional public GroupInfoResponse makeGroup(MakeGroupRequest groupDto) { Member member = authService.getMemberByJwt(); - Group group = groupMapper.toGroupEntity(groupDto, member.getId()); - GroupMember groupMember = groupMapper.connectGroupMember(group, member); - groupMember.changeGroupCode(GroupInviteCode.ACCEPTED); + Group group = groupMapper.toGroupEntity(groupDto, member); return groupMapper.toGroupInfo(groupRepository.save(group)); } @@ -76,18 +72,27 @@ public SimpleGroupInfoResponse joinGroup(JoinGroupRequest joinGroupRequest) { GroupMember groupMember = getGroupMemberEntity(joinGroupRequest.getGroupId(), member.getId()); - groupMember.changeGroupCode(GroupInviteCode.ACCEPTED); + groupMember.changeGroupCode(); - return new SimpleGroupInfoResponse(groupMember.getGroup().getId()); + return new SimpleGroupInfoResponse(groupMember.getGroupId()); } @Transactional - public void changeShare(UUID id) { + public void shareLocation(final UUID id) { + changeShare(GroupMember::share, id); + } + + @Transactional + public void unShareLocation(final UUID id) { + changeShare(GroupMember::unShare, id); + } + + private void changeShare(final Consumer changeShare, final UUID id) { Member member = this.authService.getMemberByJwt(); GroupInfoResponse groupInfo = getGroupById(id); GroupMember groupMember = getGroupMemberEntity(groupInfo.getGroupId(), member.getId()); - groupMember.changeShare(); + changeShare.accept(groupMember); } @Transactional @@ -103,8 +108,8 @@ public ShareInfoResponse getShare(UUID id) { @Transactional public GroupInfoResponse inviteGroup(InviteGroupRequest inviteGroupRequest) { Group group = getGroupEntity(inviteGroupRequest.getGroupId()); - Member friend = memberService.getMemberById(inviteGroupRequest.getFriendMemberId()); - groupMapper.connectGroupMember(group, friend); + List friends = memberService.getMembersByIds(inviteGroupRequest.getFriendMemberIds()); + group.inviteAll(friends); return groupMapper.toGroupInfo(group); } @@ -117,7 +122,7 @@ public GroupInfoResponse getGroupInfoResponse(Group group) { public List getMyGroups() { Member loginMember = authService.getMemberByJwt(); - if (loginMember.getGroupMembers().isEmpty()) { + if (loginMember.hasNoGroupMember()) { return List.of(); } diff --git a/backend/src/main/java/com/twtw/backend/domain/member/entity/Member.java b/backend/src/main/java/com/twtw/backend/domain/member/entity/Member.java index 9a4fd64e..797eb5d7 100644 --- a/backend/src/main/java/com/twtw/backend/domain/member/entity/Member.java +++ b/backend/src/main/java/com/twtw/backend/domain/member/entity/Member.java @@ -62,4 +62,12 @@ public Member(String nickname, String profileImage, OAuth2Info oauthInfo) { this.role = Role.ROLE_USER; this.oauthInfo = oauthInfo; } + + public void addGroupMember(final GroupMember groupMember) { + this.groupMembers.add(groupMember); + } + + public boolean hasNoGroupMember() { + return this.groupMembers.isEmpty(); + } } 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 ac117c2a..be3f1235 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 @@ -84,13 +84,13 @@ private PlanMember findPlanMember(final Member member) { .orElseThrow(InvalidPlanMemberException::new); } - public void addPlace(final Place place) { + private void addPlace(final Place place) { this.place = place; } public void addGroup(final Group group) { this.group = group; - this.group.addToGroup(this); + this.group.addPlan(this); } public UUID getPlanMakerId() { 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 b077bc6b..d9e5edc9 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 @@ -136,7 +136,7 @@ void inviteGroup() throws Exception { .content( toRequestBody( new InviteGroupRequest( - UUID.randomUUID(), UUID.randomUUID()))) + List.of(UUID.randomUUID()), UUID.randomUUID()))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); @@ -153,7 +153,7 @@ void inviteGroup() throws Exception { @Test @DisplayName("위치 공유 수정 API가 수행되는가") - void changeShare() throws Exception { + void shareLocation() throws Exception { // when final ResultActions perform = mockMvc.perform( @@ -162,7 +162,7 @@ void changeShare() throws Exception { .content( toRequestBody( new InviteGroupRequest( - UUID.randomUUID(), UUID.randomUUID()))) + List.of(UUID.randomUUID()), UUID.randomUUID()))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); @@ -172,7 +172,31 @@ void changeShare() throws Exception { // docs perform.andDo(print()) - .andDo(document("post change share", getDocumentRequest(), getDocumentResponse())); + .andDo(document("post share location", getDocumentRequest(), getDocumentResponse())); + } + + @Test + @DisplayName("위치 공유 수정 API가 수행되는가") + void unShareLocation() throws Exception { + // when + final ResultActions perform = + mockMvc.perform( + post("/group/unshare/" + UUID.randomUUID()) + .contentType(MediaType.APPLICATION_JSON) + .content( + toRequestBody( + new InviteGroupRequest( + List.of(UUID.randomUUID()), UUID.randomUUID()))) + .header( + "Authorization", + "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); + + // then + perform.andExpect(status().isNoContent()); + + // docs + perform.andDo(print()) + .andDo(document("post unshare location", getDocumentRequest(), getDocumentResponse())); } @Test @@ -191,7 +215,7 @@ void getShare() throws Exception { .content( toRequestBody( new InviteGroupRequest( - UUID.randomUUID(), UUID.randomUUID()))) + List.of(UUID.randomUUID()), UUID.randomUUID()))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); 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 db6e61d2..39204808 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 @@ -13,6 +13,7 @@ import com.twtw.backend.fixture.place.PlaceEntityFixture; import com.twtw.backend.support.repository.RepositoryTest; +import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -33,10 +34,9 @@ void makeGroup() { Member member1 = memberRepository.save(MemberEntityFixture.FIRST_MEMBER.toEntity()); Member member2 = memberRepository.save(MemberEntityFixture.SECOND_MEMBER.toEntity()); - Group group = GroupEntityFixture.BTS_GROUP.toEntity(); + Group group = GroupEntityFixture.BTS_GROUP.toEntity(member1); - GroupMember groupMember1 = new GroupMember(group, member1); - GroupMember groupMember2 = new GroupMember(group, member2); + group.inviteAll(List.of(member2)); Place place = PlaceEntityFixture.FIRST_PLACE.toEntity(); @@ -47,7 +47,7 @@ void makeGroup() { final Group saveGroup = groupRepository.save(group); // then - assertThat(saveGroup.getGroupMembers().size()).isEqualTo(2); + assertThat(saveGroup.getGroupMembers()).hasSize(2); } @Test @@ -57,9 +57,8 @@ void getGroupById() { Member member1 = memberRepository.save(MemberEntityFixture.FIRST_MEMBER.toEntity()); Member member2 = memberRepository.save(MemberEntityFixture.SECOND_MEMBER.toEntity()); - Group group = GroupEntityFixture.BTS_GROUP.toEntity(); + Group group = GroupEntityFixture.BTS_GROUP.toEntity(member1); - GroupMember groupMember1 = new GroupMember(group, member1); GroupMember groupMember2 = new GroupMember(group, member2); final Group saveGroup = groupRepository.save(group); @@ -80,9 +79,8 @@ void getPlan() { Member member1 = memberRepository.save(MemberEntityFixture.FIRST_MEMBER.toEntity()); Member member2 = memberRepository.save(MemberEntityFixture.SECOND_MEMBER.toEntity()); - Group group = GroupEntityFixture.BTS_GROUP.toEntity(); + Group group = GroupEntityFixture.BTS_GROUP.toEntity(member1); - GroupMember groupMember1 = new GroupMember(group, member1); GroupMember groupMember2 = new GroupMember(group, member2); Place place = PlaceEntityFixture.FIRST_PLACE.toEntity(); @@ -94,6 +92,6 @@ void getPlan() { final Group saveGroup = groupRepository.save(group); // then - assertThat(group.getGroupPlans().size()).isEqualTo(1); + assertThat(saveGroup.getGroupPlans()).hasSize(1); } } diff --git a/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java index e2662175..ee36fb9f 100644 --- a/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java @@ -13,27 +13,19 @@ import com.twtw.backend.domain.group.repository.GroupMemberRepository; import com.twtw.backend.domain.group.repository.GroupRepository; import com.twtw.backend.domain.member.entity.Member; -import com.twtw.backend.domain.member.repository.MemberRepository; -import com.twtw.backend.domain.member.service.AuthService; import com.twtw.backend.fixture.member.MemberEntityFixture; import com.twtw.backend.support.service.LoginTest; - +import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; - @DisplayName("GroupService의") -public class GroupServiceTest extends LoginTest { +class GroupServiceTest extends LoginTest { @Autowired private GroupService groupService; - @Autowired private AuthService authService; - @Autowired private GroupRepository groupRepository; - @Autowired private MemberRepository memberRepository; - @Autowired private GroupMemberRepository groupMemberRepository; @Test @@ -55,17 +47,14 @@ void makeGroup() { @DisplayName("Group에 Join할 수 있는가") void joinGroup() { // given - Member member = memberRepository.save(authService.getMemberByJwt()); - Member leader = memberRepository.save(MemberEntityFixture.FIRST_MEMBER.toEntity()); - Group group = new Group("BABY_MONSTER", "YG_OFFICIAL_IMAGE", leader.getId()); + Group group = new Group("BABY_MONSTER", "YG_OFFICIAL_IMAGE", leader); - GroupMember groupMember1 = new GroupMember(group, leader); + Group saveGroup = groupRepository.save(group); - GroupMember groupMember2 = new GroupMember(group, member); + saveGroup.inviteAll(List.of(loginUser)); - Group saveGroup = groupRepository.save(group); // when JoinGroupRequest request = new JoinGroupRequest(saveGroup.getId()); @@ -79,17 +68,13 @@ void joinGroup() { @DisplayName("Group에 초대할 수 있는가") void inviteGroup() { // given - Member member = memberRepository.save(authService.getMemberByJwt()); - Member leader = memberRepository.save(MemberEntityFixture.FIRST_MEMBER.toEntity()); - Group group = new Group("BABY_MONSTER", "YG_OFFICIAL_IMAGE", leader.getId()); - - GroupMember groupMember1 = new GroupMember(group, leader); + Group group = new Group("BABY_MONSTER", "YG_OFFICIAL_IMAGE", leader); Group saveGroup = groupRepository.save(group); - InviteGroupRequest request = new InviteGroupRequest(member.getId(), saveGroup.getId()); + InviteGroupRequest request = new InviteGroupRequest(List.of(loginUser.getId()), saveGroup.getId()); // when GroupInfoResponse response = groupService.inviteGroup(request); @@ -101,17 +86,15 @@ void inviteGroup() { @DisplayName("위치 공유 정보가 반환되는가") void getShare() { // given - Member member = memberRepository.save(authService.getMemberByJwt()); - Member leader = memberRepository.save(MemberEntityFixture.FIRST_MEMBER.toEntity()); - Group group = new Group("BABY_MONSTER", "YG_OFFICIAL_IMAGE", leader.getId()); - - GroupMember groupMember1 = new GroupMember(group, leader); - GroupMember groupMember2 = new GroupMember(group, member); + Group group = new Group("BABY_MONSTER", "YG_OFFICIAL_IMAGE", leader); Group saveGroup = groupRepository.save(group); + group.inviteAll(List.of(loginUser)); + + // when ShareInfoResponse response = groupService.getShare(saveGroup.getId()); @@ -123,22 +106,19 @@ void getShare() { @DisplayName("위치 공유를 공개 -> 비공개 변경이 가능한가") void changeShare() { // given - Member member = memberRepository.save(authService.getMemberByJwt()); - Member leader = memberRepository.save(MemberEntityFixture.FIRST_MEMBER.toEntity()); - Group group = new Group("BABY_MONSTER", "YG_OFFICIAL_IMAGE", leader.getId()); - - GroupMember groupMember1 = new GroupMember(group, leader); - GroupMember groupMember2 = new GroupMember(group, member); + Group group = new Group("BABY_MONSTER", "YG_OFFICIAL_IMAGE", leader); Group saveGroup = groupRepository.save(group); + group.inviteAll(List.of(loginUser)); + // when - groupService.changeShare(saveGroup.getId()); + groupService.unShareLocation(saveGroup.getId()); GroupMember result = groupMemberRepository - .findByGroupIdAndMemberId(saveGroup.getId(), member.getId()) + .findByGroupIdAndMemberId(saveGroup.getId(), loginUser.getId()) .orElseThrow(); // then @@ -149,18 +129,14 @@ void changeShare() { @DisplayName("자신이 소속된 Group정보들이 반환되는가") void getMyGroups() { // given - Member member = memberRepository.save(authService.getMemberByJwt()); - Member leader = memberRepository.save(MemberEntityFixture.FIRST_MEMBER.toEntity()); - Group group1 = new Group("BABY_MONSTER", "YG_OFFICIAL_IMAGE", leader.getId()); - Group group2 = new Group("BLACK_PINK", "YG_OFFICIAL_IMAGE", leader.getId()); + Group group1 = new Group("BABY_MONSTER", "YG_OFFICIAL_IMAGE", leader); + Group group2 = new Group("BLACK_PINK", "YG_OFFICIAL_IMAGE", leader); - GroupMember groupMember1 = new GroupMember(group1, leader); - GroupMember groupMember2 = new GroupMember(group1, member); + GroupMember groupMember1 = new GroupMember(group1, loginUser); - GroupMember groupMember3 = new GroupMember(group2, leader); - GroupMember groupMember4 = new GroupMember(group2, member); + GroupMember groupMember2 = new GroupMember(group2, loginUser); Group saveGroup1 = groupRepository.save(group1); Group saveGroup2 = groupRepository.save(group2); @@ -169,6 +145,6 @@ void getMyGroups() { List responses = groupService.getMyGroups(); // then - assertThat(responses.size()).isEqualTo(2); + assertThat(responses).hasSize(2); } } 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 6b931f8e..b0b64468 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 @@ -7,6 +7,7 @@ import com.twtw.backend.domain.member.repository.MemberRepository; import com.twtw.backend.domain.place.entity.Place; import com.twtw.backend.domain.plan.entity.Plan; +import com.twtw.backend.fixture.group.GroupEntityFixture; import com.twtw.backend.fixture.member.MemberEntityFixture; import com.twtw.backend.fixture.plan.PlanEntityFixture; import com.twtw.backend.support.repository.RepositoryTest; @@ -34,7 +35,7 @@ class PlanRepositoryTest extends RepositoryTest { void saveAndFindById() { // given final Member member = memberRepository.save(MemberEntityFixture.LOGIN_MEMBER.toEntity()); - final Plan plan = PlanEntityFixture.FIRST_PLACE.toEntity(member); + final Plan plan = PlanEntityFixture.FIRST_PLACE.toEntity(member, GroupEntityFixture.BTS_GROUP.toEntity(member)); // when final UUID expected = planRepository.save(plan).getId(); @@ -48,13 +49,12 @@ void saveAndFindById() { @DisplayName("soft delete가 수행되는가") void softDelete() { // given - final Member member = MemberEntityFixture.LOGIN_MEMBER.toEntity(); final Place place = Place.builder().longitude(1.1).latitude(2.2).placeName("스타벅스").build(); - final UUID memberId = memberRepository.save(member).getId(); + final Member member = memberRepository.save(MemberEntityFixture.LOGIN_MEMBER.toEntity()); em.persist(place); - final Group group = new Group("그룹", "http://abcdefg", memberId); + final Group group = new Group("그룹", "http://abcdefg", member); final UUID planId = planRepository.save(new Plan(member, place, group)).getId(); @@ -84,10 +84,10 @@ void findAllPlanByMember() { final Member secondMember = memberRepository.save(MemberEntityFixture.SECOND_MEMBER.toEntity()); - final Group group = new Group("그룹", "http://abcdefg", member.getId()); + final Group group = new Group("그룹", "http://abcdefg", member); final Plan plan = planRepository.save(new Plan(member, firstPlace, group)); - planRepository.save(new Plan(member, secondPlace, new Group("1", "2", member.getId()))); + planRepository.save(new Plan(member, secondPlace, new Group("1", "2", member))); plan.addMember(firstMember); plan.addMember(secondMember); 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 22c662ff..8398b140 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 @@ -51,7 +51,7 @@ void searchPlanDestination() { @DisplayName("계획 저장이 수행되는가") void savePlan() { // given - final UUID groupId = groupRepository.save(GroupEntityFixture.HDJ_GROUP.toEntity()).getId(); + final UUID groupId = groupRepository.save(GroupEntityFixture.HDJ_GROUP.toEntity(loginUser)).getId(); // when final PlanResponse planResponse = @@ -74,7 +74,7 @@ void joinPlan() { new Plan( member, PlaceEntityFixture.FIRST_PLACE.toEntity(), - GroupEntityFixture.BTS_GROUP.toEntity())); + GroupEntityFixture.BTS_GROUP.toEntity(loginUser))); final UUID planId = plan.getId(); // when @@ -89,7 +89,7 @@ void joinPlan() { @DisplayName("계획 나가기가 수행되는가") // TODO: 계획에 1명 있는데 나가는 경우 생각해보기 void outPlan() { // given - final Plan plan = PlanEntityFixture.SECOND_PLACE.toEntity(loginUser); + final Plan plan = PlanEntityFixture.SECOND_PLACE.toEntity(loginUser, GroupEntityFixture.HDJ_GROUP.toEntity(loginUser)); final UUID planId = planRepository.save(plan).getId(); // when @@ -110,7 +110,7 @@ void getPlanById() { new Plan( loginUser, PlaceEntityFixture.SECOND_PLACE.toEntity(), - GroupEntityFixture.HDJ_GROUP.toEntity())) + GroupEntityFixture.HDJ_GROUP.toEntity(loginUser))) .getId(); // when @@ -130,7 +130,7 @@ void deletePlan() { new Plan( loginUser, PlaceEntityFixture.SECOND_PLACE.toEntity(), - GroupEntityFixture.HDJ_GROUP.toEntity())) + GroupEntityFixture.HDJ_GROUP.toEntity(loginUser))) .getId(); // when diff --git a/backend/src/test/java/com/twtw/backend/fixture/group/GroupEntityFixture.java b/backend/src/test/java/com/twtw/backend/fixture/group/GroupEntityFixture.java index e7c96a05..6c117612 100644 --- a/backend/src/test/java/com/twtw/backend/fixture/group/GroupEntityFixture.java +++ b/backend/src/test/java/com/twtw/backend/fixture/group/GroupEntityFixture.java @@ -1,23 +1,19 @@ package com.twtw.backend.fixture.group; import com.twtw.backend.domain.group.entity.Group; - +import com.twtw.backend.domain.member.entity.Member; import lombok.RequiredArgsConstructor; -import java.util.UUID; - @RequiredArgsConstructor public enum GroupEntityFixture { - HDJ_GROUP("HDG", "http://hdgToS3", UUID.randomUUID()), - BTS_GROUP("BTS", "https://btsToS3", UUID.randomUUID()); + HDJ_GROUP("HDG", "http://hdgToS3"), + BTS_GROUP("BTS", "https://btsToS3"); private final String name; private final String groupImage; - private final UUID leaderId; - - public Group toEntity() { - return new Group(this.name, this.groupImage, this.leaderId); + public Group toEntity(final Member member) { + return new Group(this.name, this.groupImage, member); } } diff --git a/backend/src/test/java/com/twtw/backend/fixture/group/GroupMemberEntityFixture.java b/backend/src/test/java/com/twtw/backend/fixture/group/GroupMemberEntityFixture.java deleted file mode 100644 index 8c35ae97..00000000 --- a/backend/src/test/java/com/twtw/backend/fixture/group/GroupMemberEntityFixture.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.twtw.backend.fixture.group; - -import com.twtw.backend.domain.group.entity.Group; -import com.twtw.backend.domain.group.entity.GroupInviteCode; -import com.twtw.backend.domain.group.entity.GroupMember; -import com.twtw.backend.domain.member.entity.Member; -import com.twtw.backend.fixture.member.MemberEntityFixture; - -import lombok.RequiredArgsConstructor; - -@RequiredArgsConstructor -public enum GroupMemberEntityFixture { - FIRST_GROUP_MEMBER( - GroupEntityFixture.HDJ_GROUP.toEntity(), - MemberEntityFixture.FIRST_MEMBER.toEntity(), - true, - GroupInviteCode.REQUESTED), - SECOND_GROUP_MEMBER( - GroupEntityFixture.HDJ_GROUP.toEntity(), - MemberEntityFixture.SECOND_MEMBER.toEntity(), - true, - GroupInviteCode.ACCEPTED), - THIRD_GROUP_MEMBER( - GroupEntityFixture.BTS_GROUP.toEntity(), - MemberEntityFixture.LOGIN_MEMBER.toEntity(), - true, - GroupInviteCode.ACCEPTED); - - private final Group group; - private final Member member; - private final Boolean share; - private final GroupInviteCode groupInviteCode; - - public GroupMember toEntity() { - return new GroupMember(this.group, this.member); - } -} 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 79a385b7..b7a7183e 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 @@ -4,21 +4,18 @@ import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.domain.place.entity.Place; import com.twtw.backend.domain.plan.entity.Plan; -import com.twtw.backend.fixture.group.GroupEntityFixture; import com.twtw.backend.fixture.place.PlaceEntityFixture; - import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public enum PlanEntityFixture { - FIRST_PLACE(PlaceEntityFixture.FIRST_PLACE.toEntity(), GroupEntityFixture.HDJ_GROUP.toEntity()), + FIRST_PLACE(PlaceEntityFixture.FIRST_PLACE.toEntity()), SECOND_PLACE( - PlaceEntityFixture.SECOND_PLACE.toEntity(), GroupEntityFixture.HDJ_GROUP.toEntity()); + PlaceEntityFixture.SECOND_PLACE.toEntity()); private final Place place; - private final Group group; - public Plan toEntity(final Member member) { + public Plan toEntity(final Member member, final Group group) { return new Plan(member, place, group); } } From ca15bc597a4c689c27c6682896302a5af44a8d87 Mon Sep 17 00:00:00 2001 From: github-actions <> Date: Sun, 3 Dec 2023 17:23:56 +0000 Subject: [PATCH 2/4] Google Java Format --- .../group/dto/request/InviteGroupRequest.java | 5 ++-- .../domain/group/mapper/GroupMapper.java | 4 +++- .../domain/group/service/GroupService.java | 9 ++++--- .../group/controller/GroupControllerTest.java | 24 ++++++++++++++----- .../group/repository/GroupRepositoryTest.java | 3 ++- .../group/service/GroupServiceTest.java | 8 ++++--- .../plan/repository/PlanRepositoryTest.java | 4 +++- .../domain/plan/service/PlanServiceTest.java | 7 ++++-- .../fixture/group/GroupEntityFixture.java | 1 + .../fixture/plan/PlanEntityFixture.java | 4 ++-- 10 files changed, 48 insertions(+), 21 deletions(-) diff --git a/backend/src/main/java/com/twtw/backend/domain/group/dto/request/InviteGroupRequest.java b/backend/src/main/java/com/twtw/backend/domain/group/dto/request/InviteGroupRequest.java index 11093a2e..f3b0ae79 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/dto/request/InviteGroupRequest.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/dto/request/InviteGroupRequest.java @@ -1,11 +1,12 @@ package com.twtw.backend.domain.group.dto.request; -import java.util.List; -import java.util.UUID; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; +import java.util.UUID; + @Getter @NoArgsConstructor @AllArgsConstructor 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 090b3437..d5d7b528 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 @@ -6,13 +6,15 @@ 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 java.util.List; + import org.mapstruct.IterableMapping; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.MappingConstants; import org.mapstruct.Named; +import java.util.List; + @Mapper(componentModel = MappingConstants.ComponentModel.SPRING) public interface GroupMapper { @Mapping(target = "name", source = "groupDto.name") diff --git a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java index 8619a0a9..3c615aa4 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java @@ -15,11 +15,13 @@ import com.twtw.backend.domain.member.service.AuthService; import com.twtw.backend.domain.member.service.MemberService; import com.twtw.backend.global.exception.EntityNotFoundException; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + import java.util.List; import java.util.UUID; import java.util.function.Consumer; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; @Service public class GroupService { @@ -108,7 +110,8 @@ public ShareInfoResponse getShare(UUID id) { @Transactional public GroupInfoResponse inviteGroup(InviteGroupRequest inviteGroupRequest) { Group group = getGroupEntity(inviteGroupRequest.getGroupId()); - List friends = memberService.getMembersByIds(inviteGroupRequest.getFriendMemberIds()); + List friends = + memberService.getMembersByIds(inviteGroupRequest.getFriendMemberIds()); group.inviteAll(friends); return groupMapper.toGroupInfo(group); 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 d9e5edc9..4a538c73 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 @@ -136,7 +136,8 @@ void inviteGroup() throws Exception { .content( toRequestBody( new InviteGroupRequest( - List.of(UUID.randomUUID()), UUID.randomUUID()))) + List.of(UUID.randomUUID()), + UUID.randomUUID()))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); @@ -162,7 +163,8 @@ void shareLocation() throws Exception { .content( toRequestBody( new InviteGroupRequest( - List.of(UUID.randomUUID()), UUID.randomUUID()))) + List.of(UUID.randomUUID()), + UUID.randomUUID()))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); @@ -172,7 +174,11 @@ void shareLocation() throws Exception { // docs perform.andDo(print()) - .andDo(document("post share location", getDocumentRequest(), getDocumentResponse())); + .andDo( + document( + "post share location", + getDocumentRequest(), + getDocumentResponse())); } @Test @@ -186,7 +192,8 @@ void unShareLocation() throws Exception { .content( toRequestBody( new InviteGroupRequest( - List.of(UUID.randomUUID()), UUID.randomUUID()))) + List.of(UUID.randomUUID()), + UUID.randomUUID()))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); @@ -196,7 +203,11 @@ void unShareLocation() throws Exception { // docs perform.andDo(print()) - .andDo(document("post unshare location", getDocumentRequest(), getDocumentResponse())); + .andDo( + document( + "post unshare location", + getDocumentRequest(), + getDocumentResponse())); } @Test @@ -215,7 +226,8 @@ void getShare() throws Exception { .content( toRequestBody( new InviteGroupRequest( - List.of(UUID.randomUUID()), UUID.randomUUID()))) + List.of(UUID.randomUUID()), + UUID.randomUUID()))) .header( "Authorization", "Bearer wefa3fsdczf32.gaoiuergf92.gb5hsa2jgh")); 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 39204808..de6dc4ae 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 @@ -13,11 +13,12 @@ import com.twtw.backend.fixture.place.PlaceEntityFixture; import com.twtw.backend.support.repository.RepositoryTest; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.util.List; + @DisplayName("GroupRepository의") class GroupRepositoryTest extends RepositoryTest { diff --git a/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java b/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java index ee36fb9f..fd8f131c 100644 --- a/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java +++ b/backend/src/test/java/com/twtw/backend/domain/group/service/GroupServiceTest.java @@ -15,11 +15,13 @@ import com.twtw.backend.domain.member.entity.Member; import com.twtw.backend.fixture.member.MemberEntityFixture; import com.twtw.backend.support.service.LoginTest; -import java.util.List; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import java.util.List; + @DisplayName("GroupService의") class GroupServiceTest extends LoginTest { @Autowired private GroupService groupService; @@ -74,7 +76,8 @@ void inviteGroup() { Group saveGroup = groupRepository.save(group); - InviteGroupRequest request = new InviteGroupRequest(List.of(loginUser.getId()), saveGroup.getId()); + InviteGroupRequest request = + new InviteGroupRequest(List.of(loginUser.getId()), saveGroup.getId()); // when GroupInfoResponse response = groupService.inviteGroup(request); @@ -94,7 +97,6 @@ void getShare() { group.inviteAll(List.of(loginUser)); - // when ShareInfoResponse response = groupService.getShare(saveGroup.getId()); 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 b0b64468..126df216 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 @@ -35,7 +35,9 @@ class PlanRepositoryTest extends RepositoryTest { void saveAndFindById() { // given final Member member = memberRepository.save(MemberEntityFixture.LOGIN_MEMBER.toEntity()); - final Plan plan = PlanEntityFixture.FIRST_PLACE.toEntity(member, GroupEntityFixture.BTS_GROUP.toEntity(member)); + final Plan plan = + PlanEntityFixture.FIRST_PLACE.toEntity( + member, GroupEntityFixture.BTS_GROUP.toEntity(member)); // when final UUID expected = planRepository.save(plan).getId(); 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 8398b140..f257eb81 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 @@ -51,7 +51,8 @@ void searchPlanDestination() { @DisplayName("계획 저장이 수행되는가") void savePlan() { // given - final UUID groupId = groupRepository.save(GroupEntityFixture.HDJ_GROUP.toEntity(loginUser)).getId(); + final UUID groupId = + groupRepository.save(GroupEntityFixture.HDJ_GROUP.toEntity(loginUser)).getId(); // when final PlanResponse planResponse = @@ -89,7 +90,9 @@ void joinPlan() { @DisplayName("계획 나가기가 수행되는가") // TODO: 계획에 1명 있는데 나가는 경우 생각해보기 void outPlan() { // given - final Plan plan = PlanEntityFixture.SECOND_PLACE.toEntity(loginUser, GroupEntityFixture.HDJ_GROUP.toEntity(loginUser)); + final Plan plan = + PlanEntityFixture.SECOND_PLACE.toEntity( + loginUser, GroupEntityFixture.HDJ_GROUP.toEntity(loginUser)); final UUID planId = planRepository.save(plan).getId(); // when diff --git a/backend/src/test/java/com/twtw/backend/fixture/group/GroupEntityFixture.java b/backend/src/test/java/com/twtw/backend/fixture/group/GroupEntityFixture.java index 6c117612..66d67cf1 100644 --- a/backend/src/test/java/com/twtw/backend/fixture/group/GroupEntityFixture.java +++ b/backend/src/test/java/com/twtw/backend/fixture/group/GroupEntityFixture.java @@ -2,6 +2,7 @@ import com.twtw.backend.domain.group.entity.Group; import com.twtw.backend.domain.member.entity.Member; + import lombok.RequiredArgsConstructor; @RequiredArgsConstructor 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 b7a7183e..eb44aaf2 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 @@ -5,13 +5,13 @@ import com.twtw.backend.domain.place.entity.Place; import com.twtw.backend.domain.plan.entity.Plan; import com.twtw.backend.fixture.place.PlaceEntityFixture; + import lombok.RequiredArgsConstructor; @RequiredArgsConstructor public enum PlanEntityFixture { FIRST_PLACE(PlaceEntityFixture.FIRST_PLACE.toEntity()), - SECOND_PLACE( - PlaceEntityFixture.SECOND_PLACE.toEntity()); + SECOND_PLACE(PlaceEntityFixture.SECOND_PLACE.toEntity()); private final Place place; From 82eae12a2d7e2135e6d6e20dbfc1a3a55c8915f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Mon, 4 Dec 2023 02:25:22 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[FEAT]=20=EB=A9=A4=EB=B2=84=20pk=EB=A5=BC?= =?UTF-8?q?=20=ED=86=B5=ED=95=9C=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/twtw/backend/domain/member/service/MemberService.java | 4 ++++ 1 file changed, 4 insertions(+) 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 857b990e..aa9ade92 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 @@ -61,4 +61,8 @@ public MemberResponse getResponseByMember(Member member) { public List getMemberResponses(final Plan plan) { return memberMapper.toMemberResponses(plan.getPlanMembers()); } + + public List getMembersByIds(final List friendMemberIds) { + return memberRepository.findAllById(friendMemberIds); + } } From 30ec4b43fd791d361a0aafac9e0b7d219f79f174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=8A=B9=EC=A7=84?= Date: Mon, 4 Dec 2023 02:36:17 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[FEAT]=20=EC=9E=98=EB=AA=BB=EB=90=9C=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/twtw/backend/domain/group/entity/Group.java | 2 +- .../java/com/twtw/backend/domain/group/entity/GroupMember.java | 2 +- .../com/twtw/backend/domain/group/service/GroupService.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java b/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java index b8d9f97b..926ed08f 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/entity/Group.java @@ -61,7 +61,7 @@ public Group(final String name, final String groupImage, final Member leader) { final GroupMember groupMember = new GroupMember(this, leader); this.groupMembers.add(groupMember); - groupMember.changeGroupCode(); + groupMember.acceptInvite(); } public void addPlan(final Plan plan) { diff --git a/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java b/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java index 50809abb..291301cf 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/entity/GroupMember.java @@ -70,7 +70,7 @@ public void unShare() { this.share = false; } - public void changeGroupCode() { + public void acceptInvite() { this.groupInviteCode = GroupInviteCode.ACCEPTED; } diff --git a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java index 3c615aa4..0177c852 100644 --- a/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java +++ b/backend/src/main/java/com/twtw/backend/domain/group/service/GroupService.java @@ -74,7 +74,7 @@ public SimpleGroupInfoResponse joinGroup(JoinGroupRequest joinGroupRequest) { GroupMember groupMember = getGroupMemberEntity(joinGroupRequest.getGroupId(), member.getId()); - groupMember.changeGroupCode(); + groupMember.acceptInvite(); return new SimpleGroupInfoResponse(groupMember.getGroupId()); }