Skip to content

Commit

Permalink
[FEAT] GroupController + Service FIX + WebSocket Config FIX + (위치 공유 …
Browse files Browse the repository at this point in the history
…on/off 추가)
  • Loading branch information
jinjoo-lab committed Oct 16, 2023
1 parent 78b0a51 commit 3efb263
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -18,12 +20,12 @@ public GroupController(GroupService groupService) {
}

// 자신이 속한 그룹 반환 API
@GetMapping("/get/{id}")
public ResponseEntity<GroupInfoDto> getGroupByGroupId(@PathVariable String id) {
return ResponseEntity.ok(groupService.getGroupByGroupId(id));
@GetMapping("/{id}")
public ResponseEntity<GroupInfoDto> getGroupByGroupId(@PathVariable UUID id) {
return ResponseEntity.ok(groupService.getGroupById(id));
}

@PostMapping("/make")
@PostMapping()
public ResponseEntity<GroupInfoDto> makeGroup(@RequestBody MakeGroupDto makeGroupDto){
return ResponseEntity.ok(groupService.makeGroup(makeGroupDto));
}
Expand All @@ -34,8 +36,8 @@ public ResponseEntity<GroupInfoDto> joinGroup(@RequestBody JoinGroupDto joinGrou
}

@PutMapping("/share/{group}")
public ResponseEntity<Void> changeShare(@PathVariable String group){
groupService.changeShare(group);
public ResponseEntity<Void> changeShare(@PathVariable UUID id){
groupService.changeShare(id);
return ResponseEntity.ok().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Group {

private String name;
private String groupImage;
private UUID leader;
private UUID leaderId;

@OneToMany(
mappedBy = "group",
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit 3efb263

Please sign in to comment.