Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public class AirQualityReportController implements AirQualityReportControllerDoc
@Override
@GetMapping("/daily/{serialNumber}/{date}")
public ResponseEntity<DailyReportResponseDto> getDailyReport(
@Parameter(description = "리포트를 조회할 센서의 일련번호", required = true, example = "1") @PathVariable String serialNumber,
@Parameter(description = "조회할 날짜", required = true, example = "2023-10-28")
@PathVariable String serialNumber,
@PathVariable @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
DailySensorAirQualityReport report = dailyReportService.getDailyReport(serialNumber, date);
return ResponseEntity.ok(DailyReportResponseDto.from(report));
Expand All @@ -49,10 +48,8 @@ public ResponseEntity<DailyReportResponseDto> getDailyReport(
@Override
@GetMapping("/daily/{serialNumber}")
public ResponseEntity<List<DailyReportResponseDto>> getDailyReportsForPeriod(
@Parameter(description = "리포트를 조회할 센서의 일련번호", required = true, example = "1") @PathVariable String serialNumber,
@Parameter(description = "조회 시작 날짜 (YYYY-MM-DD 형식)", required = true, example = "2023-10-01")
@PathVariable String serialNumber,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
@Parameter(description = "조회 종료 날짜 (YYYY-MM-DD 형식)", required = true, example = "2023-10-31")
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) {
List<DailySensorAirQualityReport> reports = dailyReportService.getDailyReportsForPeriod(serialNumber, startDate, endDate);
return ResponseEntity.ok(
Expand All @@ -62,26 +59,44 @@ public ResponseEntity<List<DailyReportResponseDto>> getDailyReportsForPeriod(
);
}

@Override
@PostMapping("/daily/{serialNumber}/create")
public ResponseEntity<DailyReportResponseDto> generateDailyReportManually(
@PathVariable String serialNumber,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
DailySensorAirQualityReport report = dailyReportService.generateDailyReportManually(serialNumber, date);
return ResponseEntity.ok(DailyReportResponseDto.from(report));
}

@Override
@DeleteMapping("/daily/sensor/{serialNumber}/delete")
public ResponseEntity<Void> deleteDailyReportBySerialNumber(
@PathVariable String serialNumber,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date) {
dailyReportService.deleteDailyReportBySerialNumber(serialNumber, date);
return ResponseEntity.noContent().build();
}

@Override
@DeleteMapping("/daily/{reportId}/delete")
public ResponseEntity<Void> deleteDailyReport(
@Parameter(description = "삭제할 일별 리포트의 ID", required = true, example = "100") @PathVariable Long reportId) {
@PathVariable Long reportId) {
dailyReportService.deleteDailyReport(reportId);
return ResponseEntity.noContent().build();
}

@Override
@DeleteMapping("/daily/{serialNumber}/deleteAll")
public ResponseEntity<Integer> deleteDailyReportsByDeviceId(
@Parameter(description = "모든 일별 리포트를 삭제할 센서의 일련번호", required = true, example = "1") @PathVariable String serialNumber) {
@PathVariable String serialNumber) {
int deletedCount = dailyReportService.deleteDailyReportsByDeviceId(serialNumber);
return ResponseEntity.ok(deletedCount);
}

@Override
@DeleteMapping("/old/daily/{reportId}/delete")
@DeleteMapping("/old/daily/delete")
public ResponseEntity<Integer> deleteOldDailyReports(
@Parameter(description = "삭제할 일별 리포트의 ID", required = true, example = "100") @RequestParam Integer days) {
@RequestParam Integer days) {
int deletedCount = dailyReportService.deleteOldDailyReports(days);
return ResponseEntity.ok(deletedCount);
}
Expand All @@ -90,20 +105,18 @@ public ResponseEntity<Integer> deleteOldDailyReports(
@Override
@GetMapping("/weekly/{serialNumber}/{year}/{weekOfYear}")
public ResponseEntity<WeeklyReportResponseDto> getWeeklyReport(
@Parameter(description = "리포트를 조회할 센서의 일련번호", required = true, example = "1") @PathVariable String serialNumber,
@Parameter(description = "조회할 연도 (YYYY 형식)", required = true, example = "2023") @PathVariable Integer year,
@Parameter(description = "조회할 주차 (1-53 사이의 숫자, ISO 8601 기준)", required = true, example = "43") @PathVariable Integer weekOfYear) {
@PathVariable String serialNumber,
@PathVariable Integer year,
@PathVariable Integer weekOfYear) {
WeeklySensorAirQualityReport report = weeklyReportService.getWeeklyReport(serialNumber, year, weekOfYear);
return ResponseEntity.ok(WeeklyReportResponseDto.from(report));
}

@Override
@GetMapping("/weekly/{serialNumber}")
public ResponseEntity<List<WeeklyReportResponseDto>> getWeeklyReportsForPeriod(
@Parameter(description = "리포트를 조회할 센서의 일련번호", required = true, example = "1") @PathVariable String serialNumber,
@Parameter(description = "조회 시작 날짜 (YYYY-MM-DD 형식)", required = true, example = "2023-10-01")
@PathVariable String serialNumber,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate startDate,
@Parameter(description = "조회 종료 날짜 (YYYY-MM-DD 형식)", required = true, example = "2023-10-31")
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate) {
List<WeeklySensorAirQualityReport> reports = weeklyReportService.getWeeklyReportsForPeriod(serialNumber, startDate, endDate);
return ResponseEntity.ok(
Expand All @@ -113,26 +126,35 @@ public ResponseEntity<List<WeeklyReportResponseDto>> getWeeklyReportsForPeriod(
);
}

@Override
@PostMapping("/weekly/{serialNumber}/create")
public ResponseEntity<WeeklyReportResponseDto> generateWeeklyReportManually(
@PathVariable String serialNumber,
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate weekStartDate) {
WeeklySensorAirQualityReport report = weeklyReportService.generateWeeklyReportManually(serialNumber, weekStartDate);
return ResponseEntity.ok(WeeklyReportResponseDto.from(report));
}

@Override
@DeleteMapping("/weekly/{reportId}/delete")
public ResponseEntity<Void> deleteWeeklyReport(
@Parameter(description = "삭제할 주간 리포트의 ID", required = true, example = "100") @PathVariable Long reportId) {
@PathVariable Long reportId) {
weeklyReportService.deleteWeeklyReport(reportId);
return ResponseEntity.noContent().build();
}

@Override
@DeleteMapping("/old/weekly/delete")
public ResponseEntity<Integer> deleteOldWeeklyReports(
@Parameter(description = "삭제할 주간 리포트의 ID", required = true, example = "100") @RequestParam Integer weeksOld) {
@RequestParam Integer weeksOld) {
int deletedCount = weeklyReportService.deleteOldWeeklyReports(weeksOld);
return ResponseEntity.ok(deletedCount);
}

@Override
@DeleteMapping("/weekly/{serialNumber}/deleteAll")
public ResponseEntity<Integer> deleteWeeklyReportsByDeviceId(
@Parameter(description = "모든 주간 리포트를 삭제할 센서의 일련번호", required = true, example = "1") @PathVariable String serialNumber) {
@PathVariable String serialNumber) {
int deletedCount = weeklyReportService.deleteWeeklyReportsByDeviceId(serialNumber);
return ResponseEntity.ok(deletedCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

Expand Down Expand Up @@ -55,6 +56,32 @@ ResponseEntity<List<DailyReportResponseDto>> getDailyReportsForPeriod(
@Parameter(description = "조회 종료 날짜 (YYYY-MM-DD 형식)", required = true, example = "2023-10-31")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate);

@Operation(summary = "일별 공기질 리포트 수동 생성",
description = "특정 센서의 지정된 날짜에 대한 일별 공기질 리포트를 생성합니다. " +
"지정 날짜의 시간별 스냅샷 데이터가 최소 한 개 이상 존재해야 합니다." ,
responses = {
@ApiResponse(responseCode = "201", description = "일별 리포트 생성 성공",
content = @Content(schema = @Schema(implementation = DailyReportResponseDto.class))),
@ApiResponse(responseCode = "404", description = "센서를 찾을 수 없음",
content = @Content(schema = @Schema(hidden = true)))
})
ResponseEntity<DailyReportResponseDto> generateDailyReportManually(
@Parameter(description = "센서 일련번호", required = true, example = "1") String serialNumber,
@Parameter(description = "생성할 리포트의 날짜 (YYYY-MM-DD 형식)", required = true, example = "2023-10-28")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date);

@Operation(summary = "특정 센서의 지정된 일별 공기질 리포트 삭제",
description = "지정된 센서의 특정 날짜에 대한 일별 공기질 리포트를 삭제합니다.",
responses = {
@ApiResponse(responseCode = "204", description = "삭제 성공 (No Content)"),
@ApiResponse(responseCode = "404", description = "삭제할 리포트를 찾을 수 없음",
content = @Content(schema = @Schema(hidden = true)))
})
ResponseEntity<Void> deleteDailyReportBySerialNumber(
@Parameter(description = "삭제할 일별 리포트의 센서 일련번호", required = true, example = "1") String serialNumber,
@Parameter(description = "삭제할 리포트의 날짜 (YYYY-MM-DD 형식)", required = true, example = "2023-10-28")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date);

@Operation(summary = "특정 연도 및 주차의 주간 공기질 리포트 조회",
description = "특정 센서의 지정된 연도와 주차(ISO 8601 기준)에 대한 주간 공기질 리포트를 조회합니다.",
responses = {
Expand Down Expand Up @@ -85,6 +112,20 @@ ResponseEntity<List<WeeklyReportResponseDto>> getWeeklyReportsForPeriod(
@Parameter(description = "조회 종료 날짜 (YYYY-MM-DD 형식)", required = true, example = "2023-10-31")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate endDate);

@Operation(summary = "주간 공기질 리포트 수동 생성",
description = "특정 센서의 지정된 주(날짜)에 대한 주간 공기질 리포트를 수동으로 생성합니다. " +
"시작일은 자동으로 월요일로 조정됩니다." ,
responses = {
@ApiResponse(responseCode = "201", description = "주간 리포트 생성 성공",
content = @Content(schema = @Schema(implementation = WeeklyReportResponseDto.class))),
@ApiResponse(responseCode = "404", description = "센서를 찾을 수 없음",
content = @Content(schema = @Schema(hidden = true)))
})
ResponseEntity<WeeklyReportResponseDto> generateWeeklyReportManually(
@Parameter(description = "센서 일련번호", required = true, example = "1") String serialNumber,
@Parameter(description = "생성할 리포트의 시작일(YYYY-MM-DD 형식)", required = true, example = "2023-10-23")
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate weekStartDate);

@Operation(summary = "특정 ID의 일별 리포트 삭제",
description = "지정된 리포트 ID에 해당하는 일별 공기질 리포트를 삭제합니다.",
responses = {
Expand All @@ -98,7 +139,7 @@ ResponseEntity<Void> deleteDailyReport(
@Operation(summary = "특정 센서의 모든 일별 리포트 삭제",
description = "지정된 센서 일련번호와 관련된 모든 일별 공기질 리포트를 삭제하고, 삭제된 리포트의 수를 반환합니다. " ,
responses = {
@ApiResponse(responseCode = "200", description = "삭제 성공 및 삭제된 리포트 수 반환",
@ApiResponse(responseCode = "204", description = "삭제 성공 및 삭제된 리포트 수 반환",
content = @Content(schema = @Schema(type = "integer", format = "int32", example = "5"))),
@ApiResponse(responseCode = "404", description = "센서를 찾을 수 없음 (삭제할 리포트가 없는 경우도 0을 반환)",
content = @Content(schema = @Schema(hidden = true)))
Expand All @@ -114,7 +155,7 @@ ResponseEntity<Integer> deleteDailyReportsByDeviceId(
content = @Content(schema = @Schema(hidden = true)))
})
ResponseEntity<Integer> deleteOldDailyReports(
@Parameter(description = "삭제할 일별 리포트의 ID", required = true, example = "100") Integer days);
@Parameter(description = "N일", required = true, example = "100") Integer days);

@Operation(summary = "특정 ID의 주간 리포트 삭제",
description = "지정된 리포트 ID에 해당하는 주간 공기질 리포트를 삭제합니다.",
Expand All @@ -139,7 +180,7 @@ ResponseEntity<Integer> deleteOldWeeklyReports(
@Operation(summary = "특정 센서의 모든 주간 리포트 삭제",
description = "지정된 센서 일련번호와 관련된 모든 주간 공기질 리포트를 삭제하고, 삭제된 리포트의 수를 반환합니다.",
responses = {
@ApiResponse(responseCode = "200", description = "삭제 성공 및 삭제된 리포트 수 반환",
@ApiResponse(responseCode = "204", description = "삭제 성공 및 삭제된 리포트 수 반환",
content = @Content(schema = @Schema(type = "integer", format = "int32", example = "5"))),
@ApiResponse(responseCode = "404", description = "센서를 찾을 수 없음 (삭제할 리포트가 없는 경우도 0을 반환)",
content = @Content(schema = @Schema(hidden = true)))
Expand Down
Loading