Skip to content

Commit

Permalink
Infra/#182 : 클라이언트 수정사항 반영 (#187)
Browse files Browse the repository at this point in the history
* Test : 1분으로 텀 조정

* Feat : HttpStatus 수정

* Fix : TransactionManager 명시

* Fix : 삭제된 일기 조회되는 케이스 수정

* Fix : 클라이언트 수정사항 반영
  • Loading branch information
hyunw9 authored Sep 3, 2024
1 parent be58775 commit 8e1ce8a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class AlarmControllerImpl implements AlarmSwagger{
public ResponseEntity<ApiResponse<AlarmResponse>> getUserAlarmInfo() {
AlarmResponse response = retrieveAlarmInfoUsecase.retrieveAlarmInfo();
return ResponseEntity.status(HttpStatus.OK).body(
ApiResponse.success(SuccessType.OK_SUCCESS, retrieveAlarmInfoUsecase.retrieveAlarmInfo())
ApiResponse.success(SuccessType.OK_SUCCESS, response)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@

import com.clody.domain.alarm.dto.AlarmTotalInfo;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public record AlarmFullResponse(
boolean isDiaryAlarm,
boolean isReplyAlarm,
LocalTime time,
String time,
String fcmToken
) {
public static AlarmFullResponse of(boolean isDiaryAlarm, boolean isReplyAlarm, LocalTime time, String fcmToken) {
return new AlarmFullResponse(isDiaryAlarm, isReplyAlarm, time, fcmToken);
}

public static AlarmFullResponse parseFromAlarmInfo(AlarmTotalInfo alarmTotalInfo){
return AlarmFullResponse.of(alarmTotalInfo.isDiaryAlarm(), alarmTotalInfo.isReplyAlarm(), alarmTotalInfo.alarmTime(), alarmTotalInfo.fcmToken());
}
public static AlarmFullResponse of(boolean isDiaryAlarm, boolean isReplyAlarm, String time,
String fcmToken) {
return new AlarmFullResponse(isDiaryAlarm, isReplyAlarm, time, fcmToken);
}

public static AlarmTotalInfo toAlarmTotalInfo(AlarmFullResponse alarmFullResponse){
return AlarmTotalInfo.of(alarmFullResponse.fcmToken(), alarmFullResponse.time(), alarmFullResponse.isDiaryAlarm(), alarmFullResponse.isReplyAlarm());
}
public static AlarmFullResponse parseFromAlarmInfo(AlarmTotalInfo alarmTotalInfo) {
String timeWithoutSeconds = parseLocalTimeToString(alarmTotalInfo.alarmTime());
return AlarmFullResponse.of(alarmTotalInfo.isDiaryAlarm(), alarmTotalInfo.isReplyAlarm(),
timeWithoutSeconds, alarmTotalInfo.fcmToken());
}

private static String parseLocalTimeToString(LocalTime time) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
return time.format(formatter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@

import com.clody.domain.alarm.dto.AlarmTotalInfo;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public record AlarmResponse(
boolean isDiaryAlarm,
boolean isReplyAlarm,
LocalTime time
String time
) {
public static AlarmResponse of(boolean isDiaryAlarm, boolean isReplyAlarm, LocalTime time) {
public static AlarmResponse of(boolean isDiaryAlarm, boolean isReplyAlarm, String time) {
return new AlarmResponse(isDiaryAlarm, isReplyAlarm, time);
}

public static AlarmResponse of(AlarmTotalInfo alarmTotalInfo){
return new AlarmResponse(alarmTotalInfo.isDiaryAlarm(), alarmTotalInfo.isReplyAlarm(), alarmTotalInfo.alarmTime());
String timeWithoutSecond = parseLocalTimeToString(alarmTotalInfo.alarmTime());
return new AlarmResponse(alarmTotalInfo.isDiaryAlarm(), alarmTotalInfo.isReplyAlarm(), timeWithoutSecond);
}

private static String parseLocalTimeToString(LocalTime time) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
return time.format(formatter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ public record UserSignUpRequest(
String platform,
String email,
String name,

String fcmToken
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
public record UserInfoGetResponse(
String email,
String name,
Platform platform
String platform
) {
public static UserInfoGetResponse of(String email, String name, Platform platform){
return new UserInfoGetResponse(email, name, platform);
return new UserInfoGetResponse(email, name, platform.getName());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.clody.domain.diary.repository.DiaryRepository;
import com.clody.domain.user.User;
import com.clody.support.dto.type.ErrorType;
import com.clody.support.exception.NotFoundException;
import com.clody.support.exception.BusinessException;
import com.clody.support.security.util.JwtUtil;
import java.time.LocalDateTime;
import java.util.List;
Expand All @@ -29,7 +29,7 @@ public List<Diary> saveAll(List<Diary> diaries) {
public List<Diary> findDiariesByUserIdAndCreatedAtBetween(Long userId, LocalDateTime start,
LocalDateTime end) {
return diaryRepository.findDiariesByUserIdAndCreatedAtBetween(userId, start, end)
.orElseThrow(() -> new NotFoundException(ErrorType.DIARY_MESSAGE_NOT_FOUND));
.orElseThrow(() -> new BusinessException(ErrorType.DIARY_MESSAGE_NOT_FOUND));
}

@Override
Expand Down

0 comments on commit 8e1ce8a

Please sign in to comment.