Skip to content

Commit

Permalink
Merge pull request #81 from AR-TTUBEOG/feat/80
Browse files Browse the repository at this point in the history
[Feat] 스웨거 빠진 부분 보충
  • Loading branch information
choeun7 authored Feb 18, 2024
2 parents c31e179 + ec697c2 commit 8955655
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ttubeog.domain.image.dto.response;

import com.ttubeog.domain.image.domain.ImageType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
Expand All @@ -13,10 +14,19 @@
@NoArgsConstructor
public class ImageResponseDto {

@Schema(description = "이미지 ID", defaultValue = "1")
public Long id;

@Schema(description = "랜덤 고유 식별자", defaultValue = "100")
public String uuid;

@Schema(description = "이미지", defaultValue = "url")
public String image;

@Schema(description = "이미지 타입", defaultValue = "SPOT")
public ImageType imageType;

@Schema(description = "장소 ID", defaultValue = "1")
public Long placeId;

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
package com.ttubeog.domain.image.presentation;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.ttubeog.domain.benefit.dto.response.SaveBenefitRes;
import com.ttubeog.domain.image.application.ImageService;
import com.ttubeog.domain.image.dto.response.ImageResponseDto;
import com.ttubeog.global.config.security.token.CurrentUser;
import com.ttubeog.global.payload.ErrorResponse;
import com.ttubeog.global.payload.Message;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
Expand All @@ -21,8 +31,13 @@ public class ImageController {

private final ImageService imageService;

@Operation(summary = "산책스팟 이미지 저장", description = "산책스팟의 이미지를 저장합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "이미지 저장 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ImageResponseDto.class) ) } ),
@ApiResponse(responseCode = "400", description = "이미지 저장 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
})
// @ResponseStatus(value = HttpStatus.CREATED)
@PostMapping(value = "/spot", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(value = HttpStatus.CREATED)
public ResponseEntity<?> createSpotImage(
@CurrentUser HttpServletRequest request,
@RequestParam Long spotId,
Expand All @@ -31,8 +46,13 @@ public ResponseEntity<?> createSpotImage(
return imageService.createSpotImage(request, spotId, fileList);
}

@Operation(summary = "매장 이미지 저장", description = "매장의 이미지를 저장합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "이미지 저장 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ImageResponseDto.class) ) } ),
@ApiResponse(responseCode = "400", description = "이미지 저장 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
})
@PostMapping(value = "/store", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(value = HttpStatus.CREATED)
// @ResponseStatus(value = HttpStatus.CREATED)
public ResponseEntity<?> createStoreImage(
@CurrentUser HttpServletRequest request,
@RequestParam Long storeId,
Expand All @@ -41,8 +61,13 @@ public ResponseEntity<?> createStoreImage(
return imageService.createStoreImage(request, storeId, fileList);
}

@Operation(summary = "방명록 이미지 저장", description = "방명록의 이미지를 저장합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "이미지 저장 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ImageResponseDto.class) ) } ),
@ApiResponse(responseCode = "400", description = "이미지 저장 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
})
@PostMapping(value = "/guestbook", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(value = HttpStatus.CREATED)
// @ResponseStatus(value = HttpStatus.CREATED)
public ResponseEntity<?> createGuestBookImage(
@CurrentUser HttpServletRequest request,
@RequestParam Long guestBookId,
Expand All @@ -51,26 +76,41 @@ public ResponseEntity<?> createGuestBookImage(
return imageService.createGuestBookImage(request, guestBookId, fileList);
}

@Operation(summary = "산책스팟 이미지 조회", description = "산책스팟ID로 해당 이미지를 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "이미지 조회 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ImageResponseDto.class) ) } ),
@ApiResponse(responseCode = "400", description = "이미지 조회 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
})
@GetMapping(value = "/{spotId}")
@ResponseStatus(value = HttpStatus.OK)
// @ResponseStatus(value = HttpStatus.OK)
public ResponseEntity<?> findImageBySpotId(
@CurrentUser HttpServletRequest request,
@RequestParam Long spotId
) {
return imageService.findImageBySpotId(request, spotId);
}

@Operation(summary = "매장 이미지 조회", description = "매장ID로 해당 이미지를 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "이미지 조회 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ImageResponseDto.class) ) } ),
@ApiResponse(responseCode = "400", description = "이미지 조회 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
})
@GetMapping(value = "/{storeId}")
@ResponseStatus(value = HttpStatus.OK)
// @ResponseStatus(value = HttpStatus.OK)
public ResponseEntity<?> findImageByStoreId(
@CurrentUser HttpServletRequest request,
@RequestParam Long storeId
) {
return imageService.findImageByStoreId(request, storeId);
}

@Operation(summary = "방명록 이미지 조회", description = "방명록ID로 해당 이미지를 조회합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "이미지 조회 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ImageResponseDto.class) ) } ),
@ApiResponse(responseCode = "400", description = "이미지 조회 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
})
@GetMapping(value = "/{guestBookId}")
@ResponseStatus(value = HttpStatus.OK)
// @ResponseStatus(value = HttpStatus.OK)
public ResponseEntity<?> findImageByGuestBookId(
@CurrentUser HttpServletRequest request,
@RequestParam Long guestBookId
Expand All @@ -79,24 +119,39 @@ public ResponseEntity<?> findImageByGuestBookId(
}


@Operation(summary = "산책스팟 이미지 삭제", description = "산책스팟의 이미지를 삭제합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "이미지 삭제 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = Message.class) ) } ),
@ApiResponse(responseCode = "400", description = "이미지 삭제 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
})
@DeleteMapping(value = "/{spotId}")
@ResponseStatus(value = HttpStatus.OK)
// @ResponseStatus(value = HttpStatus.OK)
public ResponseEntity<?> deleteImageBySpotId(
@RequestParam Long spotId
) {
return imageService.deleteImageBySpotId(spotId);
}

@Operation(summary = "매장 이미지 삭제", description = "매장의 이미지를 삭제합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "이미지 삭제 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = Message.class) ) } ),
@ApiResponse(responseCode = "400", description = "이미지 삭제 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
})
@DeleteMapping(value = "/{storeId}")
@ResponseStatus(value = HttpStatus.OK)
// @ResponseStatus(value = HttpStatus.OK)
public ResponseEntity<?> deleteImageByStoreId(
@RequestParam Long storeId
) {
return imageService.deleteImageByStoreId(storeId);
}

@Operation(summary = "방명록 이미지 삭제", description = "방명록의 이미지를 삭제합니다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "이미지 삭제 성공", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = Message.class) ) } ),
@ApiResponse(responseCode = "400", description = "이미지 삭제 실패", content = { @Content(mediaType = "application/json", schema = @Schema(implementation = ErrorResponse.class) ) } ),
})
@DeleteMapping(value = "/{guestBookId}")
@ResponseStatus(value = HttpStatus.OK)
// @ResponseStatus(value = HttpStatus.OK)
public ResponseEntity<?> deleteImageByGuestBookId(
@RequestParam Long guestBookId
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public ResponseEntity<?> createRoad(HttpServletRequest request, CreateRoadReques
.roadType(RoadType.SPOT)
.spotId(road.getSpot().getId())
.memberId(road.getMember().getId())
.memberName(road.getMember().getNickname())
.name(road.getName())
.roadCoordinateDoubleList(roadCoordinateDoubleListResponse)
.build();
Expand All @@ -135,6 +136,7 @@ public ResponseEntity<?> createRoad(HttpServletRequest request, CreateRoadReques
.roadType(RoadType.STORE)
.storeId(road.getStore().getId())
.memberId(road.getMember().getId())
.memberName(road.getMember().getNickname())
.name(road.getName())
.roadCoordinateDoubleList(roadCoordinateDoubleListResponse)
.build();
Expand All @@ -154,7 +156,7 @@ public ResponseEntity<?> findRoadBySpotId(HttpServletRequest request, Long spotI

Long memberId = jwtTokenProvider.getMemberId(request);

Member member = memberRepository.findById(memberId).orElseThrow(InvalidMemberException::new);
memberRepository.findById(memberId).orElseThrow(InvalidMemberException::new);

Page<Road> roadPage = roadRepository.findAllBySpot_Id(spotId, PageRequest.of(pageNum, 1));

Expand All @@ -174,6 +176,7 @@ public ResponseEntity<?> findRoadBySpotId(HttpServletRequest request, Long spotI
.roadType(road.getRoadType())
.spotId(road.getSpot().getId())
.memberId(road.getMember().getId())
.memberName(road.getMember().getNickname())
.name(road.getName())
.roadCoordinateDoubleList(roadCoordinateDoubleList)
.build();
Expand Down Expand Up @@ -212,6 +215,7 @@ public ResponseEntity<?> findRoadByStoreId(HttpServletRequest request, Long stor
.roadType(road.getRoadType())
.storeId(road.getStore().getId())
.memberId(road.getMember().getId())
.memberName(road.getMember().getNickname())
.name(road.getName())
.roadCoordinateDoubleList(roadCoordinateDoubleList)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ttubeog.domain.road.dto.request;

import com.ttubeog.domain.road.domain.RoadType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.Getter;

Expand All @@ -10,14 +11,27 @@
@Getter
public class CreateRoadRequestDto {

@Schema(description = "길 종류", defaultValue = "SPOT")
private RoadType roadType;

@Schema(description = "산책스팟 ID", defaultValue = "1")
private Long spotId;

@Schema(description = "매장 ID", defaultValue = "1")
private Long storeId;

@Schema(description = "길 이름", defaultValue = "스티브의 길")
private String name;

@Schema(description = "좌표 포인트 배열", defaultValue = "[\n" +
"[37.50286865234375, 126.95667670044992],\n" +
"[37.5029296875, 126.95677684301509],\n" +
"[37.5030517578125, 126.9568895358081],\n" +
"[37.503204345703125, 126.95712283976323],\n" +
"[37.503173828125, 126.95706043328734],\n" +
"[37.503143310546875, 126.95698617501382],\n" +
"[37.503204345703125, 126.95701685426971]\n" +
"]")
private List<List<Double>> roadCoordinateList;

}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.ttubeog.domain.road.dto.response;

import com.ttubeog.domain.member.domain.Member;
import com.ttubeog.domain.road.domain.RoadType;
import com.ttubeog.domain.roadcoordinate.domain.RoadCoordinate;
import com.ttubeog.domain.spot.domain.Spot;
import com.ttubeog.domain.store.domain.Store;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
Expand All @@ -16,18 +13,36 @@
@Builder
public class RoadResponseDto {

@Schema(description = "길 ID", defaultValue = "1")
private Long id;

@Schema(description = "길 종류", defaultValue = "SPOT")
private RoadType roadType;

@Schema(description = "산책스팟 ID", defaultValue = "1")
private Long spotId;

@Schema(description = "매장 ID", defaultValue = "1")
private Long storeId;

@Schema(description = "멤버 ID", defaultValue = "1")
private Long memberId;

@Schema(description = "멤버 이름", defaultValue = "스티브")
private String memberName;

@Schema(description = "길 이름", defaultValue = "1")
private String name;

@Schema(description = "좌표 포인트 배열", defaultValue = "[\n" +
"[37.50286865234375, 126.95667670044992],\n" +
"[37.5029296875, 126.95677684301509],\n" +
"[37.5030517578125, 126.9568895358081],\n" +
"[37.503204345703125, 126.95712283976323],\n" +
"[37.503173828125, 126.95706043328734],\n" +
"[37.503143310546875, 126.95698617501382],\n" +
"[37.503204345703125, 126.95701685426971]\n" +
"]")
private List<List<Double>> roadCoordinateDoubleList;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public ResponseEntity<?> createRoad(
content = {
@Content(
mediaType = "application/json",
array = @ArraySchema(schema = @Schema(implementation = RoadRepository.class))
array = @ArraySchema(schema = @Schema(implementation = RoadResponseDto.class))
)
}
),
Expand Down Expand Up @@ -126,7 +126,7 @@ public ResponseEntity<?> findRoadBySpotId(
content = {
@Content(
mediaType = "application/json",
array = @ArraySchema(schema = @Schema(implementation = RoadRepository.class))
array = @ArraySchema(schema = @Schema(implementation = RoadResponseDto.class))
)
}
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.ttubeog.domain.spot.application.SpotService;
import com.ttubeog.domain.spot.dto.request.CreateSpotRequestDto;
import com.ttubeog.domain.spot.dto.request.UpdateSpotRequestDto;
import com.ttubeog.domain.spot.dto.response.GetSpotDetailRes;
import com.ttubeog.domain.spot.dto.response.SpotResponseDto;
import com.ttubeog.domain.spot.exception.AlreadyExistsSpotException;
import com.ttubeog.domain.spot.exception.InvalidDongAreaException;
Expand Down Expand Up @@ -121,7 +122,7 @@ public ResponseEntity<?> createSpot(
content = {
@Content(
mediaType = "application/json",
array = @ArraySchema(schema = @Schema(implementation = SpotResponseDto.class))
array = @ArraySchema(schema = @Schema(implementation = GetSpotDetailRes.class))
)
}
),
Expand Down

0 comments on commit 8955655

Please sign in to comment.