Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infra/#182 : 클라이언트 수정사항 반영 #187

Merged
merged 5 commits into from
Sep 3, 2024
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 @@ -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 @@ -81,7 +81,7 @@ public ResponseEntity<ApiResponse<DiaryCreatedTimeResponse>> getDiaryCreatedTime
@DeleteMapping("/diary")
public ResponseEntity<ApiResponse<?>> deleteDiary(
int year, int month, int date) {
return ResponseEntity.status(HttpStatus.NO_CONTENT)
return ResponseEntity.status(HttpStatus.OK)
.body(ApiResponse.success(SuccessType.DELETED_SUCCESS,
diaryDeletionUsecase.deleteDiary(year, month, date)));
}
Expand Down
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 @@ -7,7 +7,7 @@ public class FirstAlarmDelayStrategy implements ScheduleTimeStrategy{

@Override
public Optional<RelativeTime> calculateAlarmDelayTime() {
return Optional.of(new RelativeTime(10, TimeUnit.MINUTES));
return Optional.of(new RelativeTime(1, TimeUnit.MINUTES));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
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;
import java.util.stream.Collectors;
import org.springframework.stereotype.Component;

@Component
Expand All @@ -28,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 All @@ -46,7 +47,10 @@ public List<Diary> findTodayDiary(LocalDateTime start) {
Long userId = JwtUtil.getLoginMemberId();

LocalDateTime end = start.plusDays(1);
return findDiariesByUserIdAndCreatedAtBetween(userId, start, end);

return findDiariesByUserIdAndCreatedAtBetween(userId, start, end).stream()
.filter(diary -> !diary.checkDiaryDeleted())
.collect(Collectors.toUnmodifiableList());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import com.clody.domain.reply.Reply;
import com.clody.domain.reply.repository.ReplyRepository;
import com.clody.infra.config.TransactionManagerConfig;
import com.clody.support.dto.type.ErrorType;
import com.clody.support.exception.NotFoundException;
import jakarta.transaction.Transactional;
import java.time.LocalDate;
import java.util.List;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

@Component
public class ReplyRepositoryAdapter implements ReplyRepository {
Expand Down Expand Up @@ -47,6 +48,7 @@ public boolean existsByUserIdAndDiaryCreatedDate(Long userId, LocalDate localDat
}

@Override
@Transactional(TransactionManagerConfig.DOMAIN_TRANSACTION_MANAGER)
public Reply save(Reply reply) {
return jpaReplyRepository.save(reply);
}
Expand Down
Loading