From 3efb263450b38ac7fd074e16ef31df4525271397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A7=84=EC=A3=BC=EC=9B=90?= <84346055+jinjoo-lab@users.noreply.github.com> Date: Mon, 16 Oct 2023 18:59:14 +0900 Subject: [PATCH] =?UTF-8?q?[FEAT]=20GroupController=20+=20Service=20FIX=20?= =?UTF-8?q?+=20WebSocket=20Config=20FIX=20+=20(=EC=9C=84=EC=B9=98=20?= =?UTF-8?q?=EA=B3=B5=EC=9C=A0=20on/off=20=EC=B6=94=EA=B0=80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/group/controller/GroupController.java | 14 ++++++++------ .../twtw/backend/domain/group/entity/Group.java | 4 ++-- .../backend/domain/group/service/GroupService.java | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) 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 7daf63b6..ca46c316 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 @@ -8,6 +8,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.util.UUID; + @RestController @RequestMapping("/group") public class GroupController { @@ -18,12 +20,12 @@ public GroupController(GroupService groupService) { } // 자신이 속한 그룹 반환 API - @GetMapping("/get/{id}") - public ResponseEntity getGroupByGroupId(@PathVariable String id) { - return ResponseEntity.ok(groupService.getGroupByGroupId(id)); + @GetMapping("/{id}") + public ResponseEntity getGroupByGroupId(@PathVariable UUID id) { + return ResponseEntity.ok(groupService.getGroupById(id)); } - @PostMapping("/make") + @PostMapping() public ResponseEntity makeGroup(@RequestBody MakeGroupDto makeGroupDto){ return ResponseEntity.ok(groupService.makeGroup(makeGroupDto)); } @@ -34,8 +36,8 @@ public ResponseEntity joinGroup(@RequestBody JoinGroupDto joinGrou } @PutMapping("/share/{group}") - public ResponseEntity changeShare(@PathVariable String group){ - groupService.changeShare(group); + public ResponseEntity changeShare(@PathVariable UUID id){ + groupService.changeShare(id); return ResponseEntity.ok().build(); } } 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 6fa9334d..1f420443 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 @@ -21,7 +21,7 @@ public class Group { private String name; private String groupImage; - private UUID leader; + private UUID leaderId; @OneToMany( mappedBy = "group", @@ -31,6 +31,6 @@ public class Group { public Group(String name, String groupImage, UUID leader) { this.name = name; this.groupImage = groupImage; - this.leader = leader; + this.leaderId = leader; } } 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 633fba9b..755a4d4c 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 @@ -32,8 +32,8 @@ public GroupService( this.groupMapper = groupMapper; } - public GroupInfoDto getGroupByGroupId(String groupId){ - return groupMapper.toGroupInfo(groupRepository.findById(UUID.fromString(groupId)).orElseThrow(EntityNotFoundException::new)); + public GroupInfoDto getGroupById(UUID groupId){ + return groupMapper.toGroupInfo(groupRepository.findById(groupId).orElseThrow(EntityNotFoundException::new)); } @Transactional @@ -56,9 +56,9 @@ public GroupInfoDto joinGroup(JoinGroupDto joinGroupDto) { } @Transactional - public void changeShare(String id){ + public void changeShare(UUID id){ Member member = this.authService.getMemberByJwt(); - GroupInfoDto groupInfo = getGroupByGroupId(id); + GroupInfoDto groupInfo = getGroupById(id); GroupMember groupMember = groupMemberRepository.findByGroupIdAndMemberId(groupInfo.getGroupId(),member.getId()).orElseThrow(EntityNotFoundException::new); groupMember.changeShare();