From 744f6bbf1c3b88ff76c3d1949df99b8afa509adf Mon Sep 17 00:00:00 2001 From: nohy6630 Date: Fri, 3 Nov 2023 17:04:48 +0900 Subject: [PATCH] =?UTF-8?q?Feat(#43):=20Swagger=20=EC=84=A4=EB=AA=85=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../disaster/controller/DisasterController.java | 14 +++++++++++++- .../dto/response/LatestDisasterResponse.java | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/numberone/backend/domain/disaster/controller/DisasterController.java b/src/main/java/com/numberone/backend/domain/disaster/controller/DisasterController.java index 399f4ce5..973cc2ed 100644 --- a/src/main/java/com/numberone/backend/domain/disaster/controller/DisasterController.java +++ b/src/main/java/com/numberone/backend/domain/disaster/controller/DisasterController.java @@ -3,16 +3,28 @@ import com.numberone.backend.domain.disaster.dto.request.LatestDisasterRequest; import com.numberone.backend.domain.disaster.dto.response.LatestDisasterResponse; import com.numberone.backend.domain.disaster.service.DisasterService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; +@Tag(name = "disasters", description = "재난문자 관련 API") @RestController @RequiredArgsConstructor @RequestMapping("/api/disaster") public class DisasterController { private final DisasterService disasterService; + + @Operation(summary = "유저와 관련된 가장 최근 재난 문자 가져오기", description = + """ + 현재 유저의 GPS 정보와 유저가 등록한 지역을 기준으로 가장 최근 재난 문자에 대한 정보를 가져옵니다. + + 유저의 GPS 정보는 api 요청시에 위도(latitude), 경도(longitude)를 body에 담아 전달해주세요. + + 유저가 등록한 지역은 유저가 인증을 위해 같이 보내야하는 jwt 토큰으로부터 알아서 추출해서 처리할 것입니다. + """) @PostMapping("/latest") - public LatestDisasterResponse getLatestDisaster(@RequestBody LatestDisasterRequest latestDisasterRequest){ + public LatestDisasterResponse getLatestDisaster(@RequestBody LatestDisasterRequest latestDisasterRequest) { return disasterService.getLatestDisaster(latestDisasterRequest); } } diff --git a/src/main/java/com/numberone/backend/domain/disaster/dto/response/LatestDisasterResponse.java b/src/main/java/com/numberone/backend/domain/disaster/dto/response/LatestDisasterResponse.java index 2fff2d5f..0cd2cffb 100644 --- a/src/main/java/com/numberone/backend/domain/disaster/dto/response/LatestDisasterResponse.java +++ b/src/main/java/com/numberone/backend/domain/disaster/dto/response/LatestDisasterResponse.java @@ -2,6 +2,7 @@ import com.numberone.backend.domain.disaster.entity.Disaster; import com.numberone.backend.domain.disaster.util.DisasterType; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @Getter @@ -9,10 +10,15 @@ @AllArgsConstructor @Builder public class LatestDisasterResponse { + @Schema(defaultValue = "화재") private String disasterType; + @Schema(defaultValue = "2") private Integer severity; + @Schema(defaultValue = "서울특별시 강남구 동작동 화재 발생") private String title; + @Schema(defaultValue = "금일 10.23. 19:39경 소촌동 855 화재 발생, 인근주민은 안전유의 및 차량우회바랍니다. 960-8222") private String msg; + @Schema(defaultValue = "서울특별시 강남구 ・ 오후 2시 46분") private String info; public static LatestDisasterResponse of(Disaster disaster) {