Skip to content

Commit

Permalink
[#6] refactor: 모임유저 컨트롤러 uri 수정 및 responseEntity 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
sss4920 committed Oct 7, 2024
1 parent 949efa7 commit 94738d3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,52 @@
import dev.office.networkoffice.gatheringUser.controller.response.ApplicantUserDto;
import dev.office.networkoffice.gatheringUser.service.GatheringUserService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;


@RestController
@RequiredArgsConstructor
@RequestMapping("/api/v1/gathering-user")
@RequestMapping("api/v1/gathering-user")
public class GatheringUserController implements GatheringUserApiDocs {

private final GatheringUserService gatheringUserService;

@PostMapping("/{gatheringId}")
public ResponseEntity<Void> applyGathering(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId) {
@PostMapping("{gatheringId}")
public void applyGathering(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId) {
Long userId = findUserIdInSession(principal);
gatheringUserService.applyGathering(userId, gatheringId);
return ResponseEntity.status(HttpStatus.OK).build();
}

@GetMapping("/{gatheringId}")
public ResponseEntity<ApplicantUserDto> getApplicantsInGatheringByHost(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId) {
@GetMapping("{gatheringId}")
public ApplicantUserDto getApplicantsInGatheringByHost(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId) {
Long userId = findUserIdInSession(principal);
return ResponseEntity.ok(gatheringUserService.readApplicantsByGathering(userId, gatheringId));
return gatheringUserService.readApplicantsByGathering(userId, gatheringId);
}

@PatchMapping("/deny")
public ResponseEntity<Void> denyApplicants(Principal principal, @RequestBody DenyUserDto denyUserDto) {
@PatchMapping("deny")
public void denyApplicants(Principal principal, @RequestBody DenyUserDto denyUserDto) {
Long userId = findUserIdInSession(principal);
gatheringUserService.denyApplicants(userId, denyUserDto);
return ResponseEntity.status(HttpStatus.OK).build();
}

@PatchMapping("/deports")
public ResponseEntity<Void> deportsUser(Principal principal, @RequestBody DenyUserDto denyUserDto) {
@PatchMapping("deports")
public void deportsUser(Principal principal, @RequestBody DenyUserDto denyUserDto) {
Long userId = findUserIdInSession(principal);
gatheringUserService.deportsUser(userId, denyUserDto);
return ResponseEntity.status(HttpStatus.OK).build();
}

@PatchMapping("/accept")
public ResponseEntity<Void> approvedApplicants(Principal principal, @PathVariable(name = "applicantId") Long applicantId) {
@PatchMapping("accept")
public void approvedApplicants(Principal principal, @PathVariable(name = "applicantId") Long applicantId) {
Long userId = findUserIdInSession(principal);
gatheringUserService.approvedApplicants(userId, applicantId);
return ResponseEntity.status(HttpStatus.OK).build();
}

@PatchMapping("/block")
public ResponseEntity<Void> blockUserInGathering(Principal principal, @RequestBody DenyUserDto denyUserDto) {
@PatchMapping("block")
public void blockUserInGathering(Principal principal, @RequestBody DenyUserDto denyUserDto) {
Long userId = findUserIdInSession(principal);
gatheringUserService.blockedUserInGathering(userId, denyUserDto);
return ResponseEntity.status(HttpStatus.OK).build();
}

private Long findUserIdInSession(Principal principal){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public interface GatheringUserApiDocs {
description = "유효하지 않은 코드가 전달되었을 때"
)
})
ResponseEntity<Void> applyGathering(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId);
void applyGathering(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId);

@Operation(summary = "모임 신청 목록 조회")
@ApiResponses(value = {
Expand All @@ -38,7 +38,7 @@ public interface GatheringUserApiDocs {
description = "유효하지 않은 코드가 전달되었을 때"
)
})
ResponseEntity<ApplicantUserDto> getApplicantsInGatheringByHost(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId);
ApplicantUserDto getApplicantsInGatheringByHost(Principal principal, @PathVariable(name = "gatheringId") Long gatheringId);

@Operation(summary = "모임 거절")
@ApiResponses(value = {
Expand All @@ -51,7 +51,7 @@ public interface GatheringUserApiDocs {
description = "유효하지 않은 코드가 전달되었을 때"
)
})
ResponseEntity<Void> denyApplicants(Principal principal, @RequestBody DenyUserDto denyUserDto);
void denyApplicants(Principal principal, @RequestBody DenyUserDto denyUserDto);

@Operation(summary = "모임 추방")
@ApiResponses(value = {
Expand All @@ -64,7 +64,7 @@ public interface GatheringUserApiDocs {
description = "유효하지 않은 코드가 전달되었을 때"
)
})
ResponseEntity<Void> deportsUser(Principal principal, @RequestBody DenyUserDto denyUserDto);
void deportsUser(Principal principal, @RequestBody DenyUserDto denyUserDto);

@Operation(summary = "모임 신청 수락")
@ApiResponses(value = {
Expand All @@ -77,7 +77,7 @@ public interface GatheringUserApiDocs {
description = "유효하지 않은 코드가 전달되었을 때"
)
})
ResponseEntity<Void> approvedApplicants(Principal principal, @PathVariable(name = "applicantId") Long applicantId);
void approvedApplicants(Principal principal, @PathVariable(name = "applicantId") Long applicantId);

@Operation(summary = "모임에 해당 유저 차단")
@ApiResponses(value = {
Expand All @@ -90,6 +90,6 @@ public interface GatheringUserApiDocs {
description = "유효하지 않은 코드가 전달되었을 때"
)
})
ResponseEntity<Void> blockUserInGathering(Principal principal, @RequestBody DenyUserDto denyUserDto);
void blockUserInGathering(Principal principal, @RequestBody DenyUserDto denyUserDto);

}

0 comments on commit 94738d3

Please sign in to comment.