diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentController.java b/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentController.java index 3d96a560..ece131ec 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentController.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentController.java @@ -5,7 +5,8 @@ import com.bbteam.budgetbuddies.domain.comment.dto.CommentResponseDto; import com.bbteam.budgetbuddies.domain.comment.service.CommentService; import com.bbteam.budgetbuddies.domain.comment.validation.ExistComment; -import com.bbteam.budgetbuddies.domain.user.validation.ExistUser; +import com.bbteam.budgetbuddies.domain.user.dto.UserDto; +import com.bbteam.budgetbuddies.global.security.utils.AuthUser; import jakarta.validation.Valid; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.domain.Page; @@ -36,9 +37,9 @@ public CommentController(CommentService saveDiscountInfoComment( - @RequestParam("userId") @ExistUser Long userId, + @AuthUser UserDto.AuthUserDto userDto, @RequestBody CommentRequestDto.DiscountInfoCommentRequestDto discountInfoCommentRequestDto){ - CommentResponseDto.DiscountInfoCommentResponseDto dto = discountCommentService.saveComment(userId, discountInfoCommentRequestDto); + CommentResponseDto.DiscountInfoCommentResponseDto dto = discountCommentService.saveComment(userDto.getId(), discountInfoCommentRequestDto); return ApiResponse.onSuccess(dto); } @@ -54,9 +55,9 @@ public ApiResponse> find @PostMapping("/supports/comments") public ApiResponse saveSupportInfoComment( - @RequestParam("userId") @ExistUser Long userId, + @AuthUser UserDto.AuthUserDto userDto, @RequestBody CommentRequestDto.SupportInfoCommentRequestDto supportInfoCommentRequestDto){ - CommentResponseDto.SupportInfoCommentResponseDto dto = supportCommentService.saveComment(userId, supportInfoCommentRequestDto); + CommentResponseDto.SupportInfoCommentResponseDto dto = supportCommentService.saveComment(userDto.getId(), supportInfoCommentRequestDto); return ApiResponse.onSuccess(dto); } diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentControllerApi.java b/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentControllerApi.java index b8279e41..69336b43 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentControllerApi.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentControllerApi.java @@ -5,7 +5,8 @@ import com.bbteam.budgetbuddies.domain.comment.dto.CommentRequestDto; import com.bbteam.budgetbuddies.domain.comment.dto.CommentResponseDto; import com.bbteam.budgetbuddies.domain.comment.validation.ExistComment; -import com.bbteam.budgetbuddies.domain.user.validation.ExistUser; +import com.bbteam.budgetbuddies.domain.user.dto.UserDto; +import com.bbteam.budgetbuddies.global.security.utils.AuthUser; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -24,12 +25,11 @@ public interface CommentControllerApi { @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), }) @Parameters({ - @Parameter(name = "userId", description = "현재 댓글을 다는 유저 id입니다. parameter"), @Parameter(name = "discountInfoId", description = "댓글을 다는 할인 정보 게시글 id입니다. requestBody"), @Parameter(name = "content", description = "댓글 내용입니다. requestBody"), }) ApiResponse saveDiscountInfoComment( - @ExistUser Long userId, + @AuthUser UserDto.AuthUserDto userDto, CommentRequestDto.DiscountInfoCommentRequestDto discountInfoCommentRequestDto); @@ -51,12 +51,11 @@ ApiResponse> findAllByDi @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), }) @Parameters({ - @Parameter(name = "userId", description = "현재 댓글을 다는 유저 id입니다. parameter"), @Parameter(name = "supportInfoId", description = "댓글을 다는 지원 정보 게시글 id입니다. requestBody"), @Parameter(name = "content", description = "댓글 내용입니다. requestBody"), }) ApiResponse saveSupportInfoComment( - @ExistUser Long userId, + @AuthUser UserDto.AuthUserDto userDto, CommentRequestDto.SupportInfoCommentRequestDto supportInfoCommentRequestDto); @Operation(summary = "[User] 특정 지원 정보 게시글의 댓글 조회하기", description = "특정 지원 정보 게시글의 댓글을 가져오는 API입니다.") diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/faq/controller/FaqApi.java b/src/main/java/com/bbteam/budgetbuddies/domain/faq/controller/FaqApi.java index 8485960f..1f2d5fb7 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/faq/controller/FaqApi.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/faq/controller/FaqApi.java @@ -4,7 +4,8 @@ import com.bbteam.budgetbuddies.apiPayload.ApiResponse; import com.bbteam.budgetbuddies.domain.faq.dto.FaqRequestDto; import com.bbteam.budgetbuddies.domain.faq.validation.ExistFaq; -import com.bbteam.budgetbuddies.domain.user.validation.ExistUser; +import com.bbteam.budgetbuddies.domain.user.dto.UserDto; +import com.bbteam.budgetbuddies.global.security.utils.AuthUser; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; @@ -44,11 +45,7 @@ public interface FaqApi { @ApiResponses({ @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), }) - @Parameters({ - @Parameter(name = "userId", description = "FAQ를 사용하는 userId입니다.. pathVariable", in = ParameterIn.QUERY), - } - ) - ApiResponse postFaq(@ExistUser @RequestParam Long userId, + ApiResponse postFaq(@AuthUser UserDto.AuthUserDto userDto, @Valid @org.springframework.web.bind.annotation.RequestBody FaqRequestDto.FaqPostRequest dto); @Operation(summary = "[Admin] FAQ 조회 API", description = "FAQ를 조회하는 API입니다." ) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/faq/controller/FaqController.java b/src/main/java/com/bbteam/budgetbuddies/domain/faq/controller/FaqController.java index c15fe5d2..5c0b1a1b 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/faq/controller/FaqController.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/faq/controller/FaqController.java @@ -5,9 +5,9 @@ import com.bbteam.budgetbuddies.domain.faq.dto.FaqResponseDto; import com.bbteam.budgetbuddies.domain.faq.service.FaqService; import com.bbteam.budgetbuddies.domain.faq.validation.ExistFaq; -import com.bbteam.budgetbuddies.domain.user.validation.ExistUser; +import com.bbteam.budgetbuddies.domain.user.dto.UserDto; +import com.bbteam.budgetbuddies.global.security.utils.AuthUser; import jakarta.validation.Valid; -import jakarta.validation.constraints.Null; import lombok.RequiredArgsConstructor; import org.springdoc.core.annotations.ParameterObject; import org.springframework.data.domain.Page; @@ -26,9 +26,9 @@ public class FaqController implements FaqApi{ @Override @PostMapping("") - public ApiResponse postFaq(@ExistUser @RequestParam Long userId, + public ApiResponse postFaq(@AuthUser UserDto.AuthUserDto userDto, @Valid @RequestBody FaqRequestDto.FaqPostRequest dto) { - return ApiResponse.onSuccess(faqService.postFaq(dto, userId)); + return ApiResponse.onSuccess(faqService.postFaq(dto, userDto.getId())); } @Override diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/mainpage/controller/MainPageApi.java b/src/main/java/com/bbteam/budgetbuddies/domain/mainpage/controller/MainPageApi.java index 757722f8..9caf9f26 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/mainpage/controller/MainPageApi.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/mainpage/controller/MainPageApi.java @@ -2,13 +2,10 @@ import com.bbteam.budgetbuddies.apiPayload.ApiResponse; import com.bbteam.budgetbuddies.domain.mainpage.dto.MainPageResponseDto; -import com.bbteam.budgetbuddies.domain.user.validation.ExistUser; +import com.bbteam.budgetbuddies.domain.user.dto.UserDto; +import com.bbteam.budgetbuddies.global.security.utils.AuthUser; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.responses.ApiResponses; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestParam; public interface MainPageApi { @@ -16,8 +13,5 @@ public interface MainPageApi { @ApiResponses({ @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "COMMON200", description = "OK, 성공"), }) - @Parameters({ - @Parameter(name = "userId", description = "현재 데이터를 요청하는 사용자입니다. parameter"), - }) - ApiResponse getMainPage(@RequestParam("userId") @ExistUser Long userId); + ApiResponse getMainPage(@AuthUser UserDto.AuthUserDto userDto); } diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/mainpage/controller/MainPageController.java b/src/main/java/com/bbteam/budgetbuddies/domain/mainpage/controller/MainPageController.java index 534bb66a..1be20827 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/mainpage/controller/MainPageController.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/mainpage/controller/MainPageController.java @@ -3,13 +3,11 @@ import com.bbteam.budgetbuddies.apiPayload.ApiResponse; import com.bbteam.budgetbuddies.domain.mainpage.dto.MainPageResponseDto; import com.bbteam.budgetbuddies.domain.mainpage.service.MainPageService; -import com.bbteam.budgetbuddies.domain.user.validation.ExistUser; +import com.bbteam.budgetbuddies.domain.user.dto.UserDto; +import com.bbteam.budgetbuddies.global.security.utils.AuthUser; import lombok.RequiredArgsConstructor; -import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController @@ -21,8 +19,8 @@ public class MainPageController implements MainPageApi{ @GetMapping("/main") public ApiResponse getMainPage - (@RequestParam("userId") @ExistUser Long userId) { - MainPageResponseDto mainPage = mainPageService.getMainPage(userId); + (@AuthUser UserDto.AuthUserDto userDto) { + MainPageResponseDto mainPage = mainPageService.getMainPage(userDto.getId()); return ApiResponse.onSuccess(mainPage); } }