diff --git a/src/main/java/com/sparta/tdd/domain/address/controller/AddressController.java b/src/main/java/com/sparta/tdd/domain/address/controller/AddressController.java index 1e4108ee..a7d1db38 100644 --- a/src/main/java/com/sparta/tdd/domain/address/controller/AddressController.java +++ b/src/main/java/com/sparta/tdd/domain/address/controller/AddressController.java @@ -4,6 +4,7 @@ import com.sparta.tdd.domain.address.service.AddressService; import com.sparta.tdd.domain.address.service.NaverMapService; import com.sparta.tdd.domain.auth.UserDetailsImpl; +import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; @@ -24,7 +25,11 @@ public class AddressController { private final AddressService addressService; private final NaverMapService naverMapService; - // 주소 조회 + @Operation( + summary = "주소 조회", + description = """ + 외부 api를 사용하여 입력한 주소의 지번주소, 도로명주소, 위도, 경도를 조회합니다. + """) @GetMapping("/{address}") public ResponseEntity> getAddress(@PathVariable("address") String address, Pageable pageable) { @@ -32,7 +37,13 @@ public ResponseEntity> getAddress(@PathVariable("addres return ResponseEntity.status(HttpStatus.OK).body(addressPage); } - // 가게 주소 등록 + @Operation( + summary = "가게 주소 등록", + description = """ + 지번주소, 도로명주소, 위도, 경도를 입력하여 가게의 주소를 등록합니다. + 가게의 주인만 주소를 등록할 수 있습니다. + """ + ) @PreAuthorize("hasAnyRole('OWNER')") @PostMapping("/store/{storeId}") public ResponseEntity createStoreAddress(@PathVariable("storeId") UUID storeId, @@ -40,50 +51,93 @@ public ResponseEntity createStoreAddress(@PathVariable( StoreAddressResponseDto responseDto = addressService.createStoreAddress(storeId, requestDto); return ResponseEntity.status(HttpStatus.CREATED).body(responseDto); } - // 회원 주소 등록 + + @Operation( + summary = "유저 주소 등록", + description = """ + 지번주소, 도로명주소, 별칭, 위도, 경도를 입력하여 본인의 주소를 등록할 수 있습니다. + 자신의 주소만 등록할 수 있습니다. + """ + ) @PostMapping("/user") public ResponseEntity createUserAddress(@RequestBody UserAddressRequestDto requestDto, @AuthenticationPrincipal UserDetailsImpl userDetails) { UserAddressResponseDto responseDto = addressService.createUserAddress(userDetails.getUserId(), requestDto); return ResponseEntity.status(HttpStatus.CREATED).body(responseDto); } - // 회원 주소 목록 조회 - @PreAuthorize("hasAnyRole('CUSTOMER')") + + @Operation( + summary = "주소 목록 조회", + description = """ + 자신의 주소 목록을 조회합니다. + """ + ) @GetMapping("/user") public ResponseEntity> getUserAddresses(@AuthenticationPrincipal UserDetailsImpl userDetails) { List responseDtoList = addressService.getUserAddressByUserId(userDetails.getUserId()); return ResponseEntity.status(HttpStatus.OK).body(responseDtoList); } - // 모든 가게 주소 페이징 조회 + @Operation( + summary = "가게 주소 목록 조회", + description = """ + 모든 가게의 주소만을 조회합니다. + MASTER 권한을 가진 유저만 조회할 수 있습니다. + """ + ) @PreAuthorize("hasAnyRole('MASTER')") @GetMapping("/store") public ResponseEntity> getAllStoreAddress(Pageable pageable) { Page allStoreAddress = addressService.getAllStoreAddress(pageable); return ResponseEntity.status(HttpStatus.OK).body(allStoreAddress); } - // 모든 회원 주소 페이징 조회 + + @Operation( + summary = "회원 주소 목록 조회", + description = """ + 모든 회원의 주소를 조회합니다. + MASTER 권한을 가진 유저만 조회할 수 있습니다. + """ + ) @PreAuthorize("hasAnyRole('MASTER')") @GetMapping("/user/all") public ResponseEntity> getAllUserAddress(Pageable pageable) { Page allUserAddress = addressService.getAllUserAddress(pageable); return ResponseEntity.status(HttpStatus.OK).body(allUserAddress); } - // 가게 주소 수정 + + @Operation( + summary = "가게 주소 업데이트", + description = """ + 지번주소, 도로명주소, 위도, 경도를 입력하여 가게의 주소를 변경합니다. + 해당 가게의 주인만이 주소를 변경할 수 있습니다. + """ + ) @PreAuthorize("hasAnyRole('OWNER')") @PatchMapping("/store/{addressId}") public ResponseEntity updateStoreAddress(@PathVariable("addressId") UUID addressId, StoreAddressRequestDto requestDto) { StoreAddressResponseDto responseDto = addressService.updateStoreAddress(addressId, requestDto); return ResponseEntity.status(HttpStatus.OK).body(responseDto); } - // 회원 주소 수정 - @PreAuthorize("hasAnyRole('CUSTOMER')") + + @Operation( + summary = "회원 주소 업데이트", + description = """ + 지번주소, 도로명주소, 별칭, 위도, 경도를 입력하여 회원의 주소를 변경합니다. + """ + ) @PatchMapping("/user/{addressId}") public ResponseEntity updateUserAddress(@PathVariable("addressId") UUID addressId, UserAddressRequestDto requestDto) { UserAddressResponseDto responseDto = addressService.updateUserAddress(addressId, requestDto); return ResponseEntity.status(HttpStatus.OK).body(responseDto); } - // 가게 주소 삭제 + + @Operation( + summary = "가게 주소 삭제", + description = """ + 가게의 주소를 삭제합니다. + """ + ) @PreAuthorize("hasAnyRole('OWNER')") @DeleteMapping("/store/{addressId}") public ResponseEntity deleteStoreAddress(@PathVariable("addressId") UUID addressId, @@ -91,15 +145,26 @@ public ResponseEntity deleteStoreAddress(@PathVariable("addressId") UUID a addressService.deleteStoreAddress(addressId, userDetails.getUserId()); return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); } - // 회원 주소 단건 삭제 - @PreAuthorize("hasAnyRole('CUSTOMER')") + + @Operation( + summary = "회원 주소 삭제", + description = """ + 회원 주소를 삭제합니다. 자신의 주소만 삭제할 수 있습니다. + """ + ) @DeleteMapping("/user/{addressId}") public ResponseEntity deleteUserAddress(@PathVariable("addressId") UUID addressId, @AuthenticationPrincipal UserDetailsImpl userDetails) { addressService.deleteUserAddress(addressId, userDetails.getUserId()); return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); } - // 회원 대표 주소 변경 + + @Operation( + summary = "회원 대표 주소 갱신", + description = """ + 회원의 대표 주소를 갱신합니다. 자신의 주소만 갱신할 수 있습니다. + """ + ) @PatchMapping("/user/{addressId}/primary") public ResponseEntity updatePrimaryUserAddress(@PathVariable("addressId") UUID addressId, @AuthenticationPrincipal UserDetailsImpl userDetails) {