Skip to content

Commit

Permalink
ãrefactor : change req parameter userId to token for group private ch…
Browse files Browse the repository at this point in the history
…ange
  • Loading branch information
silkair committed Jan 18, 2025
1 parent 535ed45 commit e2b9e2c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.bookmile.backend.domain.group.service.GroupService;
import com.bookmile.backend.domain.group.service.Impl.GroupMemberServiceImpl;
import com.bookmile.backend.global.common.CommonResponse;
import com.bookmile.backend.domain.user.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -120,9 +119,11 @@ public ResponseEntity<GroupDetailResponseDto> getGroupDetail(@PathVariable Long
@Operation(summary = "그룹 공개/비공개 전환", description = "그룹장은 그룹 공개여부를 변경할 수 있습니다.")
public ResponseEntity<CommonResponse<Object>> updateGroupVisibility(
@PathVariable Long groupId,
@RequestBody @Valid GroupPrivateRequestDto requestDto
@RequestBody @Valid GroupPrivateRequestDto requestDto,
@AuthenticationPrincipal UserDetails userDetails
) {
groupService.updateGroupPrivate(groupId, requestDto.getIsOpen(), requestDto.getUserId());
String userEmail = userDetails.getUsername();
groupService.updateGroupPrivate(groupId, requestDto.getIsOpen(), userEmail);
return ResponseEntity.ok(CommonResponse.from(GROUP_PRIVATE_UPDATE.getMessage()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
@Getter
@NoArgsConstructor
public class GroupPrivateRequestDto {
private Long userId;
private Boolean isOpen;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ public interface GroupService {

GroupDetailResponseDto getGroupDetail(Long groupId);

void updateGroupPrivate(Long groupId, Boolean isOpen, Long userId);
void updateGroupPrivate(Long groupId, Boolean isOpen, String userEmail);
}
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,11 @@ public GroupDetailResponseDto getGroupDetail(Long groupId) {

@Override
@Transactional
public void updateGroupPrivate(Long groupId, Boolean isOpen, Long userId) {
public void updateGroupPrivate(Long groupId, Boolean isOpen, String userEmail) {
User user = validateUserByEmail(userEmail);
Group group = findGroupById(groupId);

UserGroup userGroup = findUserGroupById(userId, groupId);
UserGroup userGroup = findUserGroupById(user.getId(), groupId);
validateGroupMaster(userGroup);

group.setIsOpen(isOpen);
Expand Down

0 comments on commit e2b9e2c

Please sign in to comment.