From 6c86d0429dfa79d6ae82700591bab134d2d8923f Mon Sep 17 00:00:00 2001 From: sejong Date: Mon, 10 Oct 2022 16:06:23 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=91=B8=EC=8B=9C=20=EB=AC=B8=EA=B5=AC?= =?UTF-8?q?=20=EB=9E=9C=EB=8D=A4=20=EB=B0=9C=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixes Moms-Nagging-Org/MomsNaggingAPI#115 --- .../domain/schedule/service/ScheduleService.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/jasik/momsnaggingapi/domain/schedule/service/ScheduleService.java b/src/main/java/com/jasik/momsnaggingapi/domain/schedule/service/ScheduleService.java index e22fd68..edb11f8 100644 --- a/src/main/java/com/jasik/momsnaggingapi/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/jasik/momsnaggingapi/domain/schedule/service/ScheduleService.java @@ -9,6 +9,7 @@ import com.jasik.momsnaggingapi.domain.schedule.Schedule.CategoryListResponse; import com.jasik.momsnaggingapi.domain.schedule.Schedule.ScheduleListResponse; import com.jasik.momsnaggingapi.domain.schedule.Schedule.ScheduleResponse; +import com.jasik.momsnaggingapi.domain.schedule.Schedule.ScheduleType; import com.jasik.momsnaggingapi.domain.schedule.repository.CategoryRepository; import com.jasik.momsnaggingapi.domain.schedule.repository.ScheduleRepository; import com.jasik.momsnaggingapi.domain.user.User; @@ -29,6 +30,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.Random; import java.util.concurrent.RejectedExecutionException; import java.util.stream.Collectors; import javax.json.JsonPatch; @@ -57,14 +59,17 @@ public class ScheduleService extends RejectedExecutionException { private final ObjectMapper objectMapper; private final AsyncService asyncService; private final Utils utils; + // TODO: 상수 저장 + private Long[] defaultPushIds = new Long[]{1L, 30L, 31L, 32L, 33L}; + private Random rand = new Random(); @Transactional public Schedule.ScheduleResponse postSchedule(Long userId, Schedule.ScheduleRequest dto) { // TODO: nagging ID 연동 // TODO: 하루 최대 생성갯수 조건 추가 - // 커스텀 할일/습관일 경우 nagging 지정 + // 커스텀 할일/습관일 경우 nagging 지정 -> 랜덤으로 if (dto.getNaggingId() == null || dto.getNaggingId() == 0) { - dto.setNaggingId(1L); + dto.setNaggingId(defaultPushIds[rand.nextInt(defaultPushIds.length)]); } Schedule newSchedule = modelMapper.map(dto, Schedule.class); Schedule originSchedule = scheduleRepository.save(newSchedule);