Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public ResponseEntity<?> setUsersSatisfaction(@AuthenticationPrincipal CustomUse

User user = userDetails.getUser();

if(user.getRole() == Role.USER){
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("접근 권한이 없습니다");
}
// if(user.getRole() == Role.USER){
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("접근 권한이 없습니다");
// }
userSatisfactionService.setUserSatisfaction(user, satisfaction, roomId);
return ResponseEntity.ok("sucess");
}
Expand All @@ -49,9 +49,9 @@ public ResponseEntity<?> getUsersSatisfaction(@AuthenticationPrincipal CustomUse

User user = userDetails.getUser();

if(user.getRole() == Role.USER){
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("접근 권한이 없습니다");
}
// if(user.getRole() == Role.USER){
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("접근 권한이 없습니다");
// }
List<UserSatisfactionResponseDto> list = userSatisfactionService.getUserSatisfaction(user, roomId);
return ResponseEntity.ok(list);
}
Expand All @@ -67,9 +67,9 @@ public ResponseEntity<?> updateUserSatisfaction(@AuthenticationPrincipal CustomU

User user = userDetails.getUser();

if (user.getRole() == Role.USER) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("접근 권한이 없습니다");
}
// if (user.getRole() == Role.USER) {
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("접근 권한이 없습니다");
// }

try {
userSatisfactionService.updateUserSatisfaction(user, satisfactionId, newSatisfaction);
Expand All @@ -89,9 +89,9 @@ public ResponseEntity<?> deleteUserSatisfaction(@AuthenticationPrincipal CustomU

User user = userDetails.getUser();

if (user.getRole() == Role.USER) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("접근 권한이 없습니다");
}
// if (user.getRole() == Role.USER) {
// return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body("접근 권한이 없습니다");
// }

try {
userSatisfactionService.deleteUserSatisfaction(user, satisfactionId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public String setAnomalyReport(AnomalyReportDto dto) throws Exception {

LocalDateTime anomalyDate = LocalDateTime.parse(dto.getAnomalyTimestamp(), ANOMALY_TIMESTAMP_FORMATTER);

HourlySensorAirQualitySnapshot hourlySnapshot = hourlyDeviceAirQualitySnapshotRepository
.findBySensorAndSnapshotHour(sensor, anomalyDate)
.orElseThrow(() -> new CustomException(ErrorCode.SNAPSHOT_NOT_FOUND, String.format("해당 센서의 시간별 스냅샷을 찾을 수 없습니다. 시리얼 번호: %s, 날짜: %s", sensor.getSerialNumber(), anomalyDate)));

DailySensorAirQualityReport dailyReport = dailySensorAirQualityReportRepository
.findBySensorAndReportDate(sensor, LocalDate.from(anomalyDate))
.orElseThrow(() -> new CustomException(ErrorCode.NO_DAILY_REPORTS_FOUND, String.format("해당 센서의 일일 보고서를 찾을 수 없습니다. 시리얼 번호: %s, 날짜: %s", sensor.getSerialNumber(), LocalDate.from(anomalyDate))));
// HourlySensorAirQualitySnapshot hourlySnapshot = hourlyDeviceAirQualitySnapshotRepository
// .findBySensorAndSnapshotHour(sensor, anomalyDate)
// .orElseThrow(() -> new CustomException(ErrorCode.SNAPSHOT_NOT_FOUND, String.format("해당 센서의 시간별 스냅샷을 찾을 수 없습니다. 시리얼 번호: %s, 날짜: %s", sensor.getSerialNumber(), anomalyDate)));
//
// DailySensorAirQualityReport dailyReport = dailySensorAirQualityReportRepository
// .findBySensorAndReportDate(sensor, LocalDate.from(anomalyDate))
// .orElseThrow(() -> new CustomException(ErrorCode.NO_DAILY_REPORTS_FOUND, String.format("해당 센서의 일일 보고서를 찾을 수 없습니다. 시리얼 번호: %s, 날짜: %s", sensor.getSerialNumber(), LocalDate.from(anomalyDate))));

String description = generateDescription(
dto.getPollutant(),
Expand All @@ -84,8 +84,10 @@ public String setAnomalyReport(AnomalyReportDto dto) throws Exception {
.pollutant(Pollutant.valueOf(dto.getPollutant()))
.pollutantValue(dto.getPollutantValue())
.description(description)
.relatedHourlySnapshot(hourlySnapshot)
.relatedDailyReport(dailyReport)
.relatedDailyReport(null)
.relatedHourlySnapshot(null)
//.relatedHourlySnapshot(hourlySnapshot)
//.relatedDailyReport(dailyReport)
.build();
anomalyReportRepository.save(anomalyReport);
log.info("Anomaly report saved: {}", anomalyReport.getId());
Expand Down