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

[Feature] 리마인드 관련 API 개발 #26

Merged
merged 12 commits into from
Jan 9, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
public record CreateTimerRequestDto(
Long categoryId,
String remindTime,
ArrayList<String> remindDates){
ArrayList<Integer> remindDates){
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

import java.util.ArrayList;

public record UpdateTimerDateTimeDto(String remindTime, ArrayList<String> remindDate) {
public record UpdateTimerDateTimeDto(String remindTime, ArrayList<Integer> remindDate) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.app.toaster.controller.response.timer;

import com.app.toaster.controller.response.search.CategoryResult;
import com.app.toaster.controller.response.search.SearchCategoryResult;
import com.app.toaster.domain.Reminder;

import java.util.List;

public record CompletedTimerDto(Long timerId, Long categoryId, String remindTime, String remindDate, String comment) {
public static CompletedTimerDto of(Reminder timer,String remindTime, String remindDate){
return new CompletedTimerDto(timer.getId(), timer.getCategory().getCategoryId(), remindTime, remindDate, timer.getComment() );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.app.toaster.domain;

import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Converter;
import java.util.ArrayList;

@Converter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

converter라는 어노테이션을 써본적없었는데 이렇게 활용할 수 있군용..! ☺️ 덕분에 저도 많이 배웁니다 ㅎㅎ.

public class IntegerListConverter implements AttributeConverter<ArrayList<Integer>, String> {

@Override
public String convertToDatabaseColumn(ArrayList<Integer> attribute) {
if (attribute == null || attribute.isEmpty()) {
return null;
}
return String.join(",", attribute.stream().map(String::valueOf).toArray(String[]::new));
}

@Override
public ArrayList<Integer> convertToEntityAttribute(String dbData) {
if (dbData == null || dbData.isEmpty()) {
return new ArrayList<>();
}
String[] values = dbData.split(",");
ArrayList<Integer> result = new ArrayList<>();
for (String value : values) {
result.add(Integer.valueOf(value));
}
return result;
}
}
8 changes: 4 additions & 4 deletions linkmind/src/main/java/com/app/toaster/domain/Reminder.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public class Reminder {

private LocalTime remindTime;

@Convert(converter = StringListConverter.class)
private ArrayList<String> remindDates;
@Convert(converter = IntegerListConverter.class)
private ArrayList<Integer> remindDates;

private String comment;

private Boolean isAlarm;

@Builder
public Reminder(User user, Category category, String comment, LocalTime remindTime, ArrayList<String> remindDates, Boolean isAlarm) {
public Reminder(User user, Category category, String comment, LocalTime remindTime, ArrayList<Integer> remindDates, Boolean isAlarm) {
this.user = user;
this.category = category;
this.comment = comment;
Expand All @@ -49,7 +49,7 @@ public void updateRemindTime(String remindTime){
this.remindTime = LocalTime.parse(remindTime);
}

public void updateRemindDates(ArrayList<String> remindDates){
public void updateRemindDates(ArrayList<Integer> remindDates){
this.remindDates = remindDates;
}

Expand Down

This file was deleted.