Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REFACTOR]/#86 - ApiResponse 클래스명을 CommonResponse로 변경 #102

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.example.tree.domain.branch.dto.BranchResponseDTO;
import org.example.tree.domain.branch.service.BranchService;
import org.example.tree.domain.member.entity.Member;
import org.example.tree.global.common.ApiResponse;
import org.example.tree.global.common.CommonResponse;
import org.example.tree.global.security.handler.annotation.AuthMember;
import org.springframework.web.bind.annotation.*;

Expand All @@ -16,18 +16,18 @@ public class BranchController {
private final BranchService branchService;

@GetMapping("/trees/{treeId}/branchView")
public ApiResponse<BranchResponseDTO.branchView> getBranchView(
public CommonResponse<BranchResponseDTO.branchView> getBranchView(
@PathVariable Long treeId,
@RequestParam("memberId") Long profileId,
@AuthMember @Parameter(hidden = true) Member member
) {
return ApiResponse.onSuccess(branchService.getBranchView(treeId, member, profileId));
return CommonResponse.onSuccess(branchService.getBranchView(treeId, member, profileId));
}

@GetMapping("/trees/{treeId}/branchView/all")
public ApiResponse<BranchResponseDTO.branchView> getCompleteBranchView(
public CommonResponse<BranchResponseDTO.branchView> getCompleteBranchView(
@PathVariable Long treeId
) {
return ApiResponse.onSuccess(branchService.getCompleteBranchView(treeId));
return CommonResponse.onSuccess(branchService.getCompleteBranchView(treeId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.example.tree.domain.comment.dto.CommentResponseDTO;
import org.example.tree.domain.comment.service.CommentService;
import org.example.tree.domain.member.entity.Member;
import org.example.tree.global.common.ApiResponse;
import org.example.tree.global.common.CommonResponse;
import org.example.tree.global.security.handler.annotation.AuthMember;
import org.springframework.web.bind.annotation.*;

Expand All @@ -20,49 +20,49 @@ public class CommentController {

@PostMapping("/trees/{treeId}/feed/posts/{postId}/comments")
@Operation(summary = "댓글 작성", description = "특정 게시글에 댓글 작성합니다.")
public ApiResponse createComment(
public CommonResponse createComment(
@PathVariable final Long treeId,
@PathVariable final Long postId,
@RequestBody final CommentRequestDTO.createComment request,
@AuthMember @Parameter(hidden = true) Member member

) {
commentService.createComment(treeId, postId, request, member);
return ApiResponse.onSuccess("");
return CommonResponse.onSuccess("");
}

@GetMapping("/trees/{treeId}/feed/posts/{postId}/comments")
@Operation(summary = "댓글 조회", description = "Reaction과 댓글에 달린 답글도 같이 출력됩니다.")
public ApiResponse<List<CommentResponseDTO.getComment>> getComments(
public CommonResponse<List<CommentResponseDTO.getComment>> getComments(
@PathVariable final Long treeId,
@PathVariable final Long postId,
@AuthMember @Parameter(hidden = true) Member member
) {
return ApiResponse.onSuccess(commentService.getComments(treeId, postId, member));
return CommonResponse.onSuccess(commentService.getComments(treeId, postId, member));
}

@PatchMapping("/trees/{treeId}/feed/posts/{postId}/comments/{commentId}")
@Operation(summary = "댓글 수정", description = "댓글을 수정합니다.")
public ApiResponse updateComment(
public CommonResponse updateComment(
@PathVariable final Long treeId,
@PathVariable final Long postId,
@PathVariable final Long commentId,
@RequestBody final CommentRequestDTO.updateComment request,
@AuthMember @Parameter(hidden = true) Member member
) {
commentService.updateComment(treeId, postId, commentId, request, member);
return ApiResponse.onSuccess("");
return CommonResponse.onSuccess("");
}

@DeleteMapping("/trees/{treeId}/feed/posts/{postId}/comments/{commentId}")
@Operation(summary = "댓글 삭제", description = "댓글을 삭제합니다.")
public ApiResponse deleteComment(
public CommonResponse deleteComment(
@PathVariable final Long treeId,
@PathVariable final Long postId,
@PathVariable final Long commentId,
@AuthMember @Parameter(hidden = true) Member member
) {
commentService.deleteComment(treeId, postId, commentId, member);
return ApiResponse.onSuccess("");
return CommonResponse.onSuccess("");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.example.tree.domain.comment.dto.ReplyRequestDTO;
import org.example.tree.domain.comment.service.ReplyService;
import org.example.tree.domain.member.entity.Member;
import org.example.tree.global.common.ApiResponse;
import org.example.tree.global.common.CommonResponse;
import org.example.tree.global.security.handler.annotation.AuthMember;
import org.springframework.web.bind.annotation.*;

Expand All @@ -17,39 +17,39 @@ public class ReplyController {

@PostMapping("/trees/{treeId}/feed/comments/{commentId}/reply")
@Operation(summary = "답글 작성", description = "특정 댓글에 답글을 작성합니다.")
public ApiResponse createReply(
public CommonResponse createReply(
@PathVariable final Long treeId,
@PathVariable final Long commentId,
@RequestBody final ReplyRequestDTO.createReply request,
@AuthMember @Parameter(hidden = true) Member member
) {
replyService.createReply(treeId, commentId, request, member);
return ApiResponse.onSuccess("");
return CommonResponse.onSuccess("");
}

@PatchMapping("/trees/{treeId}/feed/comments/{commentId}/reply/{replyId}")
@Operation(summary = "답글 수정", description = "답글을 수정합니다.")
public ApiResponse updateReply(
public CommonResponse updateReply(
@PathVariable final Long treeId,
@PathVariable final Long commentId,
@PathVariable final Long replyId,
@RequestBody final ReplyRequestDTO.updateReply request,
@AuthMember @Parameter(hidden = true) Member member
) {
replyService.updateReply(treeId, commentId, replyId, request, member);
return ApiResponse.onSuccess("");
return CommonResponse.onSuccess("");
}

@DeleteMapping("/trees/{treeId}/feed/comments/{commentId}/reply/{replyId}")
@Operation(summary = "답글 삭제", description = "답글을 삭제합니다.")
public ApiResponse deleteReply(
public CommonResponse deleteReply(
@PathVariable final Long treeId,
@PathVariable final Long commentId,
@PathVariable final Long replyId,
@AuthMember @Parameter(hidden = true) Member member
) {
replyService.deleteReply(treeId, commentId, replyId, member);
return ApiResponse.onSuccess("");
return CommonResponse.onSuccess("");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,63 +7,61 @@
import org.example.tree.domain.invitation.dto.InvitationResponseDTO;
import org.example.tree.domain.invitation.service.InvitationService;
import org.example.tree.domain.member.entity.Member;
import org.example.tree.global.common.ApiResponse;
import org.example.tree.global.common.CommonResponse;
import org.example.tree.global.security.handler.annotation.AuthMember;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
public class InvitationController {
private final InvitationService invitationService;

@PostMapping("/users/invitation")
@Operation(summary = "신규회원 초대", description = "서비스에 미가입된 사용자를 초대합니다.")
public ApiResponse<InvitationResponseDTO.sendInvitation> sendInvitation(
public CommonResponse<InvitationResponseDTO.sendInvitation> sendInvitation(
@RequestBody final InvitationRequestDTO.sendInvitation request
) {
return ApiResponse.onSuccess(invitationService.inviteUser(request));
return CommonResponse.onSuccess(invitationService.inviteUser(request));
}

@PostMapping("/trees/members/invitation")
@Operation(summary = "회원 초대", description = "서비스에 가입되어 있는 멤버를 다른 트리하우스에 초대합니다.")
public ApiResponse inviteMember(
public CommonResponse inviteMember(
@RequestBody final InvitationRequestDTO.inviteMember request
) {
invitationService.inviteMember(request);
return ApiResponse.onSuccess("");
return CommonResponse.onSuccess("");
}

@PostMapping("/treehouses/members/invitation/accept")
@Operation(summary = "초대 수락", description = "받은 초대를 수락합니다.")
public ApiResponse<InvitationResponseDTO.acceptInvitation> acceptInvitation(
public CommonResponse<InvitationResponseDTO.acceptInvitation> acceptInvitation(
@RequestBody final InvitationRequestDTO.acceptInvitation request
) {
return ApiResponse.onSuccess(invitationService.acceptInvitation(request));
return CommonResponse.onSuccess(invitationService.acceptInvitation(request));
}

@PostMapping("/treehouses/members/invitation/reject")
@Operation(summary = "초대 거절", description = "받은 초대를 거절합니다.")
public ApiResponse<InvitationResponseDTO.rejectInvitation> rejectInvitation(
public CommonResponse<InvitationResponseDTO.rejectInvitation> rejectInvitation(
@RequestBody final InvitationRequestDTO.rejectInvitation request
) {
return ApiResponse.onSuccess(invitationService.rejectInvitation(request));
return CommonResponse.onSuccess(invitationService.rejectInvitation(request));
}

@GetMapping("/users/invitation")
@Operation(summary = "초대장 조회", description = "내가 받은 초대장을 조회합니다.")
public ApiResponse<InvitationResponseDTO.getInvitations> getInvitations(
public CommonResponse<InvitationResponseDTO.getInvitations> getInvitations(
@AuthMember @Parameter(hidden = true) Member member
) {
return ApiResponse.onSuccess(invitationService.getInvitations(member));
return CommonResponse.onSuccess(invitationService.getInvitations(member));
}

@GetMapping("/users/availableInvitation")
@Operation(summary = "가용 초대장 조회", description = "내가 보낼 수 있는 초대장 개수를 조회합니다.")
public ApiResponse<InvitationResponseDTO.getAvailableInvitation> getAvailableInvitation(
public CommonResponse<InvitationResponseDTO.getAvailableInvitation> getAvailableInvitation(
@AuthMember @Parameter(hidden = true) Member member
) {
return ApiResponse.onSuccess(invitationService.getAvailableInvitation(member));
return CommonResponse.onSuccess(invitationService.getAvailableInvitation(member));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import lombok.RequiredArgsConstructor;
import org.example.tree.domain.member.dto.MemberRequestDTO;
import org.example.tree.domain.member.dto.MemberResponseDTO;
import org.example.tree.domain.member.service.MemberService;
import org.example.tree.global.common.ApiResponse;
import org.example.tree.global.common.CommonResponse;
import org.example.tree.global.feign.service.NcpService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestClientException;
Expand All @@ -27,59 +28,59 @@ public class MemberController {

@PostMapping("/checkName")
@Operation(summary = "아이디 중복 체크", description = "서비스에서 사용할 유저이름을 중복 체크합니다.")
public ApiResponse<MemberResponseDTO.checkName> checkName(
public CommonResponse<MemberResponseDTO.checkName> checkName(
@RequestBody final MemberRequestDTO.checkName request
) {
return ApiResponse.onSuccess(memberService.checkName(request));
return CommonResponse.onSuccess(memberService.checkName(request));
}
@PostMapping("/register")
@Operation(summary = "회원가입", description = "회원가입을 진행합니다.")
public ApiResponse<MemberResponseDTO.registerMember> registerMember(
public CommonResponse<MemberResponseDTO.registerMember> registerMember(
@RequestBody final MemberRequestDTO.registerMember request
) {
return ApiResponse.onSuccess((memberService.register(request)));
return CommonResponse.onSuccess((memberService.register(request)));
}

@PostMapping("/reissue")
@Operation(summary = "토큰 재발급", description = "토큰을 재발급합니다.")
public ApiResponse<MemberResponseDTO.reissue> reissue(
public CommonResponse<MemberResponseDTO.reissue> reissue(
@RequestBody final MemberRequestDTO.reissue request
) {
return ApiResponse.onSuccess(memberService.reissue(request));
return CommonResponse.onSuccess(memberService.reissue(request));
}
@PostMapping("/login-tmp")
@Operation(summary = "로그인 임시", description = "로그인 임시.")
public ApiResponse<MemberResponseDTO.registerMember> loginTemp(
public CommonResponse<MemberResponseDTO.registerMember> loginTemp(
@RequestBody final MemberRequestDTO.loginMember request
){
return ApiResponse.onSuccess((memberService.login(request)));
return CommonResponse.onSuccess((memberService.login(request)));
}


@Operation(summary = "인증번호 요청 API ✔️️", description = "인증번호 요청 API입니다. 대시(-) 제외 전화번호 입력하시면 됩니다. ex) 01012345678 ")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "OK 성공 , 인증번호 전송 완료"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "NCP200_1", description = "OK 성공 , 이미 회원가입된 전화번호입니다."),
@ApiResponse(responseCode = "200", description = "OK 성공 , 인증번호 전송 완료"),
@ApiResponse(responseCode = "NCP200_1", description = "OK 성공 , 이미 회원가입된 전화번호입니다."),

})
@PostMapping("/phone/sms")
public ApiResponse<MemberResponseDTO.checkSentSms> sendSms(@RequestBody MemberRequestDTO.SmsRequestDto request) throws JsonProcessingException, RestClientException, URISyntaxException, InvalidKeyException, NoSuchAlgorithmException, UnsupportedEncodingException {
public CommonResponse<MemberResponseDTO.checkSentSms> sendSms(@RequestBody MemberRequestDTO.SmsRequestDto request) throws JsonProcessingException, RestClientException, URISyntaxException, InvalidKeyException, NoSuchAlgorithmException, UnsupportedEncodingException {
memberService.existsByPhoneNum(request.getTargetPhoneNum());
MemberResponseDTO.checkSentSms authNumResultDto = ncpService.sendSms(request.getTargetPhoneNum());
return ApiResponse.onSuccess(authNumResultDto);
return CommonResponse.onSuccess(authNumResultDto);
}

//인증번호 검증
@Operation(summary = "인증번호 검증 API ✔️️", description = "인증번호 검증 API입니다. 대시(-) 제외 전화번호와 인증번호 입력하시면 됩니다.")
@ApiResponses({
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "200", description = "OK 성공 , 인증 성공"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "NCP400_1", description = "BAD_REQUEST, 전화번호를 잘못 전달했거나, 인증요청을 하지않은 상태로 확인버튼을 누른 경우"),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "NCP400_2", description = "BAD_REQUEST, 인증 번호가 옳지 않습니다."),
@io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "NCP400_3", description = "BAD_REQUEST, 인증 시간(5분)이 지났습니다."),
@ApiResponse(responseCode = "200", description = "OK 성공 , 인증 성공"),
@ApiResponse(responseCode = "NCP400_1", description = "BAD_REQUEST, 전화번호를 잘못 전달했거나, 인증요청을 하지않은 상태로 확인버튼을 누른 경우"),
@ApiResponse(responseCode = "NCP400_2", description = "BAD_REQUEST, 인증 번호가 옳지 않습니다."),
@ApiResponse(responseCode = "NCP400_3", description = "BAD_REQUEST, 인증 시간(5분)이 지났습니다."),
})
@PostMapping("/phone/auth")
public ApiResponse<MemberResponseDTO.checkPhoneAuth> authPhoneNum(@RequestBody MemberRequestDTO.PhoneNumAuthDto request) {
public CommonResponse<MemberResponseDTO.checkPhoneAuth> authPhoneNum(@RequestBody MemberRequestDTO.PhoneNumAuthDto request) {
MemberResponseDTO.checkPhoneAuth authNumResultDto = ncpService.authNumber(request.getAuthNum(), request.getPhoneNum());
return ApiResponse.onSuccess(authNumResultDto);
return CommonResponse.onSuccess(authNumResultDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.example.tree.domain.notification.dto.NotificationRequestDTO;
import org.example.tree.domain.notification.dto.NotificationResponseDTO;
import org.example.tree.domain.notification.service.NotificationService;
import org.example.tree.global.common.ApiResponse;
import org.example.tree.global.common.CommonResponse;
import org.example.tree.global.security.handler.annotation.AuthMember;
import org.springframework.web.bind.annotation.*;

Expand All @@ -22,27 +22,27 @@ public class NotificationController {

@Operation(summary = "알림 생성 테스트")
@PostMapping("/test")
public ApiResponse sendNotification(
public CommonResponse sendNotification(
@RequestBody final NotificationRequestDTO.sendNotification request)
{
notificationService.sendNotification(request.getTitle(), request.getMessage(), request.getType(), request.getReceiverId());
return ApiResponse.onSuccess("success");
return CommonResponse.onSuccess("success");
}

@Operation(summary = "전체 알림 조회", description = "유저가 받은 알림들을 조회합니다.")
@GetMapping
public ApiResponse<List<NotificationResponseDTO.getNotification>> getNotifications(
public CommonResponse<List<NotificationResponseDTO.getNotification>> getNotifications(
@AuthMember @Parameter(hidden = true) Member member
) {
return ApiResponse.onSuccess(notificationService.getUserNotifications(member));
return CommonResponse.onSuccess(notificationService.getUserNotifications(member));
}

@Operation(summary = "특정 알림 조회", description = "유저가 받은 알림 중 하나를 조회합니다.")
@GetMapping("/{notificationId}")
public ApiResponse<NotificationResponseDTO.getNotification> getNotification(
public CommonResponse<NotificationResponseDTO.getNotification> getNotification(
@PathVariable final Long notificationId)
{
return ApiResponse.onSuccess(notificationService.getNotification(notificationId));
return CommonResponse.onSuccess(notificationService.getNotification(notificationId));
}

}
Loading
Loading