From 45f573517aa38c06cbf8686f7132561dbf7c4922 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Sat, 20 Jan 2024 03:44:13 +0900 Subject: [PATCH 01/27] =?UTF-8?q?feat:=20Schedule=20API=20=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=20=EC=84=A4=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleController.java | 27 +++++++++++++++++ .../dto/response/ScheduleResponse.java | 30 +++++++++++++++++++ .../repository/ScheduleRepository.java | 7 +++++ .../schedule/service/ScheduleService.java | 4 +++ .../schedule/service/ScheduleServiceImpl.java | 11 +++++++ 5 files changed, 79 insertions(+) create mode 100644 src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java create mode 100644 src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java create mode 100644 src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java create mode 100644 src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java create mode 100644 src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java new file mode 100644 index 00000000..bb332a07 --- /dev/null +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -0,0 +1,27 @@ +package com.umc.networkingService.domain.schedule.controller; + +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse; +import com.umc.networkingService.domain.schedule.service.ScheduleService; +import com.umc.networkingService.global.common.base.BaseResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "달력 API", description = "달력 관련 API") +@RestController +@RequiredArgsConstructor +@RequestMapping("/schedules") +public class ScheduleController { + + private final ScheduleService scheduleService; + + @Operation(summary = "캘린더 조회 API", description = "홈 화면의 달력을 조회하는 API입니다.") + @PostMapping + public BaseResponse getSchedule() { + return null; + } + +} diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java new file mode 100644 index 00000000..cab43921 --- /dev/null +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -0,0 +1,30 @@ +package com.umc.networkingService.domain.schedule.dto.response; + +import com.umc.networkingService.domain.schedule.entity.Schedule; +import java.time.LocalDateTime; +import java.util.List; +import java.util.UUID; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +public class ScheduleResponse { + + @Getter + @AllArgsConstructor + @NoArgsConstructor + private static class CalendarInfoForDay { + private UUID id; + private String title; + private LocalDateTime startDateTime; + private LocalDateTime endDateTime; + private String hostType; + } + + @Getter + @AllArgsConstructor + @NoArgsConstructor + private static class CalendarInfoForMonth { + private List calendarInfos; + } +} diff --git a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java new file mode 100644 index 00000000..649d2557 --- /dev/null +++ b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java @@ -0,0 +1,7 @@ +package com.umc.networkingService.domain.schedule.repository; + +import com.umc.networkingService.domain.schedule.entity.Schedule; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ScheduleRepository extends JpaRepository { +} diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java new file mode 100644 index 00000000..eb6cb5b0 --- /dev/null +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -0,0 +1,4 @@ +package com.umc.networkingService.domain.schedule.service; + +public interface ScheduleService { +} diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java new file mode 100644 index 00000000..3d986e4c --- /dev/null +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -0,0 +1,11 @@ +package com.umc.networkingService.domain.schedule.service; + +import com.umc.networkingService.domain.schedule.repository.ScheduleRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@RequiredArgsConstructor +public class ScheduleServiceImpl implements ScheduleService { + private final ScheduleRepository scheduleRepository; +} From 55635c498ce22eaee1c80f4b4920fe45f077b5da Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Mon, 22 Jan 2024 01:38:47 +0900 Subject: [PATCH 02/27] =?UTF-8?q?feat:=20Schedule=20=EC=A1=B0=ED=9A=8C=20A?= =?UTF-8?q?PI=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleController.java | 8 ++++++-- .../dto/response/ScheduleResponse.java | 13 +++---------- .../domain/schedule/mapper/ScheduleMapper.java | 18 ++++++++++++++++++ .../repository/ScheduleRepository.java | 8 ++++++++ .../schedule/service/ScheduleService.java | 4 ++++ .../schedule/service/ScheduleServiceImpl.java | 13 +++++++++++++ 6 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index bb332a07..fae97e30 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -1,13 +1,16 @@ package com.umc.networkingService.domain.schedule.controller; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; import com.umc.networkingService.domain.schedule.service.ScheduleService; import com.umc.networkingService.global.common.base.BaseResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @Tag(name = "달력 API", description = "달력 관련 API") @@ -20,8 +23,9 @@ public class ScheduleController { @Operation(summary = "캘린더 조회 API", description = "홈 화면의 달력을 조회하는 API입니다.") @PostMapping - public BaseResponse getSchedule() { - return null; + public BaseResponse> getSchedule(@RequestParam Long month) { + + return BaseResponse.onSuccess(scheduleService.getSchedulesByMonth(month)); } } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java index cab43921..d08ba76a 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -1,10 +1,10 @@ package com.umc.networkingService.domain.schedule.dto.response; -import com.umc.networkingService.domain.schedule.entity.Schedule; import java.time.LocalDateTime; import java.util.List; import java.util.UUID; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -13,18 +13,11 @@ public class ScheduleResponse { @Getter @AllArgsConstructor @NoArgsConstructor - private static class CalendarInfoForDay { + @Builder + public static class ScheduleInfo { private UUID id; - private String title; private LocalDateTime startDateTime; private LocalDateTime endDateTime; private String hostType; } - - @Getter - @AllArgsConstructor - @NoArgsConstructor - private static class CalendarInfoForMonth { - private List calendarInfos; - } } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java new file mode 100644 index 00000000..7fbf1b62 --- /dev/null +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -0,0 +1,18 @@ +package com.umc.networkingService.domain.schedule.mapper; + +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; +import com.umc.networkingService.domain.schedule.entity.Schedule; +import org.springframework.stereotype.Component; + +@Component +public class ScheduleMapper { + + public ScheduleInfo toScheduleInfo(Schedule schedule) { + return ScheduleInfo.builder() + .id(schedule.getId()) + .startDateTime(schedule.getStartDateTime()) + .endDateTime(schedule.getEndDateTime()) + .hostType(schedule.getHostType().toString()) + .build(); + } +} diff --git a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java index 649d2557..06feaf10 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java @@ -1,7 +1,15 @@ package com.umc.networkingService.domain.schedule.repository; import com.umc.networkingService.domain.schedule.entity.Schedule; +import io.lettuce.core.dynamic.annotation.Param; +import java.time.LocalDateTime; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; public interface ScheduleRepository extends JpaRepository { + + @Query(value = "SELECT s FROM Schedule s WHERE (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime)) AND s.deletedAt IS NULL") + List findSchedulesByMonth( + @Param("month") Long month); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index eb6cb5b0..558c55b4 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -1,4 +1,8 @@ package com.umc.networkingService.domain.schedule.service; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; +import java.util.List; + public interface ScheduleService { + public List getSchedulesByMonth(Long month); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index 3d986e4c..de75723c 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -1,6 +1,9 @@ package com.umc.networkingService.domain.schedule.service; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; +import com.umc.networkingService.domain.schedule.mapper.ScheduleMapper; import com.umc.networkingService.domain.schedule.repository.ScheduleRepository; +import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -8,4 +11,14 @@ @RequiredArgsConstructor public class ScheduleServiceImpl implements ScheduleService { private final ScheduleRepository scheduleRepository; + private final ScheduleMapper scheduleMapper; + + @Override + public List getSchedulesByMonth(Long month) { + + + return scheduleRepository.findSchedulesByMonth(month).stream() + .map(schedule -> scheduleMapper.toScheduleInfo(schedule)) + .toList(); + } } From e518b1f7b4dff230ba00f996515c5d633525a1ec Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Mon, 22 Jan 2024 01:53:13 +0900 Subject: [PATCH 03/27] =?UTF-8?q?feat:=20Schedule=20=EC=A1=B0=ED=9A=8C=20A?= =?UTF-8?q?PI=20result=20=ED=98=95=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/controller/ScheduleController.java | 3 ++- .../domain/schedule/dto/response/ScheduleResponse.java | 8 ++++++++ .../domain/schedule/mapper/ScheduleMapper.java | 10 ++++++++++ .../domain/schedule/service/ScheduleService.java | 4 ++-- .../domain/schedule/service/ScheduleServiceImpl.java | 8 +++++--- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index fae97e30..c478c2ba 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -2,6 +2,7 @@ import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import com.umc.networkingService.domain.schedule.service.ScheduleService; import com.umc.networkingService.global.common.base.BaseResponse; import io.swagger.v3.oas.annotations.Operation; @@ -23,7 +24,7 @@ public class ScheduleController { @Operation(summary = "캘린더 조회 API", description = "홈 화면의 달력을 조회하는 API입니다.") @PostMapping - public BaseResponse> getSchedule(@RequestParam Long month) { + public BaseResponse getSchedule(@RequestParam Long month) { return BaseResponse.onSuccess(scheduleService.getSchedulesByMonth(month)); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java index d08ba76a..4122f533 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -20,4 +20,12 @@ public static class ScheduleInfo { private LocalDateTime endDateTime; private String hostType; } + + @Getter + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class ScheduleInfoList { + private List schedules; + } } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index 7fbf1b62..503ca8fc 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -1,7 +1,9 @@ package com.umc.networkingService.domain.schedule.mapper; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import com.umc.networkingService.domain.schedule.entity.Schedule; +import java.util.List; import org.springframework.stereotype.Component; @Component @@ -15,4 +17,12 @@ public ScheduleInfo toScheduleInfo(Schedule schedule) { .hostType(schedule.getHostType().toString()) .build(); } + + public ScheduleInfoList toScheduleInfoList(List schedules) { + return ScheduleInfoList.builder() + .schedules(schedules) + .build(); + } + + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index 558c55b4..5d12d992 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -1,8 +1,8 @@ package com.umc.networkingService.domain.schedule.service; -import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import java.util.List; public interface ScheduleService { - public List getSchedulesByMonth(Long month); + public ScheduleInfoList getSchedulesByMonth(Long month); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index de75723c..2ccc8aff 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -1,6 +1,7 @@ package com.umc.networkingService.domain.schedule.service; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import com.umc.networkingService.domain.schedule.mapper.ScheduleMapper; import com.umc.networkingService.domain.schedule.repository.ScheduleRepository; import java.util.List; @@ -14,11 +15,12 @@ public class ScheduleServiceImpl implements ScheduleService { private final ScheduleMapper scheduleMapper; @Override - public List getSchedulesByMonth(Long month) { + public ScheduleInfoList getSchedulesByMonth(Long month) { - return scheduleRepository.findSchedulesByMonth(month).stream() + return scheduleMapper.toScheduleInfoList( + scheduleRepository.findSchedulesByMonth(month).stream() .map(schedule -> scheduleMapper.toScheduleInfo(schedule)) - .toList(); + .toList()); } } From 0e9c786f95f3c2fe9ae5d2f8d318089bc412a2a8 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Mon, 22 Jan 2024 02:22:21 +0900 Subject: [PATCH 04/27] =?UTF-8?q?fix:=20=EC=BA=98=EB=A6=B0=EB=8D=94=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20API=20=EC=97=94=EB=93=9C=ED=8F=AC=EC=9D=B8?= =?UTF-8?q?=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/controller/ScheduleController.java | 7 ++----- .../domain/schedule/service/ScheduleService.java | 3 +-- .../domain/schedule/service/ScheduleServiceImpl.java | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index c478c2ba..53a7932d 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -1,13 +1,10 @@ package com.umc.networkingService.domain.schedule.controller; -import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse; -import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import com.umc.networkingService.domain.schedule.service.ScheduleService; import com.umc.networkingService.global.common.base.BaseResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -23,10 +20,10 @@ public class ScheduleController { private final ScheduleService scheduleService; @Operation(summary = "캘린더 조회 API", description = "홈 화면의 달력을 조회하는 API입니다.") - @PostMapping + @PostMapping("/calendar") public BaseResponse getSchedule(@RequestParam Long month) { - return BaseResponse.onSuccess(scheduleService.getSchedulesByMonth(month)); + return BaseResponse.onSuccess(scheduleService.getCalendarByMonth(month)); } } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index 5d12d992..08e29d1b 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -1,8 +1,7 @@ package com.umc.networkingService.domain.schedule.service; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; -import java.util.List; public interface ScheduleService { - public ScheduleInfoList getSchedulesByMonth(Long month); + public ScheduleInfoList getCalendarByMonth(Long month); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index 2ccc8aff..5199351f 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -15,7 +15,7 @@ public class ScheduleServiceImpl implements ScheduleService { private final ScheduleMapper scheduleMapper; @Override - public ScheduleInfoList getSchedulesByMonth(Long month) { + public ScheduleInfoList getCalendarByMonth(Long month) { return scheduleMapper.toScheduleInfoList( From e36baeff38619d5ab2541c5d7d89513ee92fcc52 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Mon, 22 Jan 2024 03:17:51 +0900 Subject: [PATCH 05/27] =?UTF-8?q?feat:=20Schedule=20=EC=B6=94=EA=B0=80=20A?= =?UTF-8?q?PI=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleController.java | 11 ++++++++ .../schedule/dto/request/ScheduleRequest.java | 26 +++++++++++++++++++ .../dto/response/ScheduleResponse.java | 4 +++ .../domain/schedule/entity/Schedule.java | 4 +++ .../schedule/mapper/ScheduleMapper.java | 16 ++++++++++++ .../schedule/service/ScheduleService.java | 3 +++ .../schedule/service/ScheduleServiceImpl.java | 12 +++++++++ 7 files changed, 76 insertions(+) create mode 100644 src/main/java/com/umc/networkingService/domain/schedule/dto/request/ScheduleRequest.java diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index 53a7932d..7ed4679e 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -1,12 +1,16 @@ package com.umc.networkingService.domain.schedule.controller; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import com.umc.networkingService.domain.schedule.service.ScheduleService; import com.umc.networkingService.global.common.base.BaseResponse; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.headers.Header; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -26,4 +30,11 @@ public BaseResponse getSchedule(@RequestParam Long month) { return BaseResponse.onSuccess(scheduleService.getCalendarByMonth(month)); } + @Operation(summary = "스케줄 추가 API", description = "운영진 관리 페이지의 스케줄을 추가하는 API입니다.") + @PostMapping + public BaseResponse createSchedule(@RequestBody CreateSchedule request) { + + return BaseResponse.onSuccess(scheduleService.createSchedule(request)); + } + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/request/ScheduleRequest.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/request/ScheduleRequest.java new file mode 100644 index 00000000..b43e93e6 --- /dev/null +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/request/ScheduleRequest.java @@ -0,0 +1,26 @@ +package com.umc.networkingService.domain.schedule.dto.request; + +import com.umc.networkingService.domain.board.entity.HostType; +import com.umc.networkingService.global.common.enums.Semester; +import java.time.LocalDateTime; +import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +public class ScheduleRequest { + @Getter + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class CreateSchedule { + private String title; + private String content; + private LocalDateTime startDateTime; + private LocalDateTime endDateTime; + private List semesterPermission; + private HostType hostType; + private String placeSetting; + } +} diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java index 4122f533..0f4ad697 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -1,5 +1,7 @@ package com.umc.networkingService.domain.schedule.dto.response; +import com.umc.networkingService.domain.board.entity.HostType; +import com.umc.networkingService.global.common.enums.Semester; import java.time.LocalDateTime; import java.util.List; import java.util.UUID; @@ -28,4 +30,6 @@ public static class ScheduleInfo { public static class ScheduleInfoList { private List schedules; } + + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java b/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java index 0cf8f4f9..2271022b 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java @@ -6,6 +6,8 @@ import com.umc.networkingService.global.common.enums.Semester; import jakarta.persistence.*; import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import org.hibernate.annotations.SQLRestriction; @@ -18,6 +20,8 @@ @Getter @Entity +@Builder +@AllArgsConstructor @NoArgsConstructor(access= AccessLevel.PROTECTED) @SQLRestriction("deleted_at is null") public class Schedule extends BaseEntity { diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index 503ca8fc..8c2d9241 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -1,5 +1,7 @@ package com.umc.networkingService.domain.schedule.mapper; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import com.umc.networkingService.domain.schedule.entity.Schedule; @@ -24,5 +26,19 @@ public ScheduleInfoList toScheduleInfoList(List schedules) { .build(); } + public Schedule toSchedule(CreateSchedule request) { + return Schedule.builder() + .title(request.getTitle()) + .content(request.getContent()) + .startDateTime(request.getStartDateTime()) + .endDateTime(request.getEndDateTime()) + .semesterPermission(request.getSemesterPermission()) + .hostType(request.getHostType()) + .placeSetting(request.getPlaceSetting()) + .build(); + } + + + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index 08e29d1b..e7bd8e74 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -1,7 +1,10 @@ package com.umc.networkingService.domain.schedule.service; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; +import java.util.UUID; public interface ScheduleService { public ScheduleInfoList getCalendarByMonth(Long month); + public UUID createSchedule(CreateSchedule request); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index 5199351f..cbd5a72a 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -1,10 +1,13 @@ package com.umc.networkingService.domain.schedule.service; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; +import com.umc.networkingService.domain.schedule.entity.Schedule; import com.umc.networkingService.domain.schedule.mapper.ScheduleMapper; import com.umc.networkingService.domain.schedule.repository.ScheduleRepository; import java.util.List; +import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -23,4 +26,13 @@ public ScheduleInfoList getCalendarByMonth(Long month) { .map(schedule -> scheduleMapper.toScheduleInfo(schedule)) .toList()); } + + @Override + public UUID createSchedule(CreateSchedule request) { + Schedule schedule = scheduleMapper.toSchedule(request); + + scheduleRepository.save(schedule); + + return schedule.getId(); + } } From 9ca7346f9170180931e4266185edf452907ee73a Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Mon, 22 Jan 2024 03:59:56 +0900 Subject: [PATCH 06/27] =?UTF-8?q?feat:=20Schedule=20=EC=88=98=EC=A0=95=20A?= =?UTF-8?q?PI=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleController.java | 12 ++++++++++ .../schedule/dto/request/ScheduleRequest.java | 14 +++++++++++ .../dto/response/ScheduleResponse.java | 8 +++++++ .../domain/schedule/entity/Schedule.java | 2 ++ .../schedule/mapper/ScheduleMapper.java | 24 +++++++++++++++++-- .../repository/ScheduleRepository.java | 8 +++++-- .../schedule/service/ScheduleService.java | 4 ++++ .../schedule/service/ScheduleServiceImpl.java | 18 +++++++++++--- .../global/common/exception/ErrorCode.java | 5 +++- 9 files changed, 87 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index 7ed4679e..0ab15eff 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -1,6 +1,8 @@ package com.umc.networkingService.domain.schedule.controller; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import com.umc.networkingService.domain.schedule.service.ScheduleService; import com.umc.networkingService.global.common.base.BaseResponse; @@ -9,6 +11,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import java.util.UUID; import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -37,4 +40,13 @@ public BaseResponse createSchedule(@RequestBody CreateSchedule request) { return BaseResponse.onSuccess(scheduleService.createSchedule(request)); } + @Operation(summary = "스케줄 수정 API", description = "운영진 관리 페이지의 스케줄을 수정하는 API입니다.") + @PostMapping("/update/{scheduleId}") + public BaseResponse updateSchedule(@PathVariable("scheduleId") UUID scheduleId, @RequestBody UpdateSchedule request) { + + return BaseResponse.onSuccess(scheduleService.updateSchedule(scheduleId, request)); + } + + + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/request/ScheduleRequest.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/request/ScheduleRequest.java index b43e93e6..de35796e 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/request/ScheduleRequest.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/request/ScheduleRequest.java @@ -23,4 +23,18 @@ public static class CreateSchedule { private HostType hostType; private String placeSetting; } + + @Getter + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class UpdateSchedule { + private String title; + private String content; + private LocalDateTime startDateTime; + private LocalDateTime endDateTime; + private List semesterPermission; + private HostType hostType; + private String placeSetting; + } } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java index 0f4ad697..f1313895 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -31,5 +31,13 @@ public static class ScheduleInfoList { private List schedules; } + @Getter + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class ScheduleId { + private UUID scheduleId; + } + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java b/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java index 2271022b..b1109b74 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java @@ -10,6 +10,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import org.hibernate.annotations.SQLRestriction; import org.hibernate.annotations.UuidGenerator; @@ -18,6 +19,7 @@ import java.util.List; import java.util.UUID; +@Setter @Getter @Entity @Builder diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index 8c2d9241..2e4389f0 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -1,11 +1,14 @@ package com.umc.networkingService.domain.schedule.mapper; -import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import com.umc.networkingService.domain.schedule.entity.Schedule; import java.util.List; +import java.util.UUID; +import lombok.Setter; import org.springframework.stereotype.Component; @Component @@ -26,7 +29,7 @@ public ScheduleInfoList toScheduleInfoList(List schedules) { .build(); } - public Schedule toSchedule(CreateSchedule request) { + public Schedule createScheduleToSchedule(CreateSchedule request) { return Schedule.builder() .title(request.getTitle()) .content(request.getContent()) @@ -38,6 +41,23 @@ public Schedule toSchedule(CreateSchedule request) { .build(); } + public Schedule updateScheduleToSchedule(UpdateSchedule request, Schedule schedule) { + schedule.setTitle(request.getTitle()); + schedule.setContent(request.getContent()); + schedule.setStartDateTime(request.getStartDateTime()); + schedule.setEndDateTime(request.getEndDateTime()); + schedule.setSemesterPermission(request.getSemesterPermission()); + schedule.setHostType(request.getHostType()); + schedule.setPlaceSetting(request.getPlaceSetting()); + return schedule; + } + + public ScheduleId UUIDtoScheduleId(UUID scheduleId) { + return ScheduleId.builder() + .scheduleId(scheduleId) + .build(); + } + diff --git a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java index 06feaf10..faf26650 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java @@ -4,12 +4,16 @@ import io.lettuce.core.dynamic.annotation.Param; import java.time.LocalDateTime; import java.util.List; +import java.util.UUID; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -public interface ScheduleRepository extends JpaRepository { +public interface ScheduleRepository extends JpaRepository { @Query(value = "SELECT s FROM Schedule s WHERE (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime)) AND s.deletedAt IS NULL") List findSchedulesByMonth( - @Param("month") Long month); + @Param("month") Long month + ); + + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index e7bd8e74..6d8ecb16 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -1,10 +1,14 @@ package com.umc.networkingService.domain.schedule.service; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import java.util.UUID; public interface ScheduleService { public ScheduleInfoList getCalendarByMonth(Long month); public UUID createSchedule(CreateSchedule request); + public ScheduleId updateSchedule(UUID scheduleId, UpdateSchedule request); + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index cbd5a72a..d88fe69e 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -1,12 +1,14 @@ package com.umc.networkingService.domain.schedule.service; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; -import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; import com.umc.networkingService.domain.schedule.entity.Schedule; import com.umc.networkingService.domain.schedule.mapper.ScheduleMapper; import com.umc.networkingService.domain.schedule.repository.ScheduleRepository; -import java.util.List; +import com.umc.networkingService.global.common.exception.ErrorCode; +import com.umc.networkingService.global.common.exception.RestApiException; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -29,10 +31,20 @@ public ScheduleInfoList getCalendarByMonth(Long month) { @Override public UUID createSchedule(CreateSchedule request) { - Schedule schedule = scheduleMapper.toSchedule(request); + Schedule schedule = scheduleMapper.createScheduleToSchedule(request); scheduleRepository.save(schedule); return schedule.getId(); } + + @Override + public ScheduleId updateSchedule(UUID scheduleId, UpdateSchedule request) { + Schedule schedule = scheduleRepository.findById(scheduleId).orElseThrow(() -> new RestApiException(ErrorCode.EMPTY_SCHEDULE)); + schedule = scheduleMapper.updateScheduleToSchedule(request, schedule); + + scheduleRepository.save(schedule); + + return scheduleMapper.UUIDtoScheduleId(schedule.getId()); + } } diff --git a/src/main/java/com/umc/networkingService/global/common/exception/ErrorCode.java b/src/main/java/com/umc/networkingService/global/common/exception/ErrorCode.java index 1db297d3..f9e35495 100644 --- a/src/main/java/com/umc/networkingService/global/common/exception/ErrorCode.java +++ b/src/main/java/com/umc/networkingService/global/common/exception/ErrorCode.java @@ -54,7 +54,10 @@ public enum ErrorCode { EMPTY_BRANCH(HttpStatus.BAD_REQUEST, "BRANCH001", "존재하지 않는 지부입니다."), // Image - FAILED_UPLOAD_S3_IMAGE(HttpStatus.INTERNAL_SERVER_ERROR, "IMAGE001", "이미지 저장에 실패하였습니다."); + FAILED_UPLOAD_S3_IMAGE(HttpStatus.INTERNAL_SERVER_ERROR, "IMAGE001", "이미지 저장에 실패하였습니다."), + + // Schedule + EMPTY_SCHEDULE(HttpStatus.BAD_REQUEST, "SCHEDULE001", "존재하지 않는 스케줄입니다."); private final HttpStatus httpStatus; private final String code; From 86f7780a6c102074c1f62384e10360e3bd4c18bb Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Mon, 22 Jan 2024 04:02:09 +0900 Subject: [PATCH 07/27] =?UTF-8?q?feat:=20Schedule=20=EC=B6=94=EA=B0=80=20A?= =?UTF-8?q?PI=20Response=20=EC=88=98=EC=A0=95(rebase=20=EC=A0=81=EC=9A=A9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/controller/ScheduleController.java | 2 +- .../domain/schedule/service/ScheduleService.java | 2 +- .../domain/schedule/service/ScheduleServiceImpl.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index 0ab15eff..0a2563a6 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -35,7 +35,7 @@ public BaseResponse getSchedule(@RequestParam Long month) { @Operation(summary = "스케줄 추가 API", description = "운영진 관리 페이지의 스케줄을 추가하는 API입니다.") @PostMapping - public BaseResponse createSchedule(@RequestBody CreateSchedule request) { + public BaseResponse createSchedule(@RequestBody CreateSchedule request) { return BaseResponse.onSuccess(scheduleService.createSchedule(request)); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index 6d8ecb16..f4079ad5 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -8,7 +8,7 @@ public interface ScheduleService { public ScheduleInfoList getCalendarByMonth(Long month); - public UUID createSchedule(CreateSchedule request); + public ScheduleId createSchedule(CreateSchedule request); public ScheduleId updateSchedule(UUID scheduleId, UpdateSchedule request); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index d88fe69e..1b1901ba 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -30,12 +30,12 @@ public ScheduleInfoList getCalendarByMonth(Long month) { } @Override - public UUID createSchedule(CreateSchedule request) { + public ScheduleId createSchedule(CreateSchedule request) { Schedule schedule = scheduleMapper.createScheduleToSchedule(request); scheduleRepository.save(schedule); - return schedule.getId(); + return scheduleMapper.UUIDtoScheduleId(schedule.getId()); } @Override From 3016afe86cb54b57bf4a6d9c54a178f25502061d Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Mon, 22 Jan 2024 22:53:58 +0900 Subject: [PATCH 08/27] =?UTF-8?q?feat:=20Schedule=20=EC=82=AD=EC=A0=9C=20A?= =?UTF-8?q?PI=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/controller/ScheduleController.java | 8 ++++++++ .../schedule/dto/response/ScheduleResponse.java | 2 +- .../domain/schedule/mapper/ScheduleMapper.java | 2 +- .../domain/schedule/service/ScheduleService.java | 2 ++ .../domain/schedule/service/ScheduleServiceImpl.java | 12 ++++++++++++ 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index 0a2563a6..5b03c15b 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -11,6 +11,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import java.util.UUID; import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -48,5 +49,12 @@ public BaseResponse updateSchedule(@PathVariable("scheduleId") UUID } + @Operation(summary = "스케줄 삭제 API", description = "운영진 관리 페이지의 스케줄을 삭제하는 API입니다.") + @DeleteMapping("/{scheduleId}") + public BaseResponse deleteSchedule(@PathVariable("scheduleId") UUID scheduleId) { + + return BaseResponse.onSuccess(scheduleService.deleteSchedule(scheduleId)); + } + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java index f1313895..5fd2f7b5 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -17,7 +17,7 @@ public class ScheduleResponse { @NoArgsConstructor @Builder public static class ScheduleInfo { - private UUID id; + private UUID scheduleId; private LocalDateTime startDateTime; private LocalDateTime endDateTime; private String hostType; diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index 2e4389f0..465efd79 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -16,7 +16,7 @@ public class ScheduleMapper { public ScheduleInfo toScheduleInfo(Schedule schedule) { return ScheduleInfo.builder() - .id(schedule.getId()) + .scheduleId(schedule.getId()) .startDateTime(schedule.getStartDateTime()) .endDateTime(schedule.getEndDateTime()) .hostType(schedule.getHostType().toString()) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index f4079ad5..ad83257f 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -11,4 +11,6 @@ public interface ScheduleService { public ScheduleId createSchedule(CreateSchedule request); public ScheduleId updateSchedule(UUID scheduleId, UpdateSchedule request); + public ScheduleId deleteSchedule(UUID scheduleId); + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index 1b1901ba..40b6faba 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -47,4 +47,16 @@ public ScheduleId updateSchedule(UUID scheduleId, UpdateSchedule request) { return scheduleMapper.UUIDtoScheduleId(schedule.getId()); } + + @Override + public ScheduleId deleteSchedule(UUID scheduleId) { + Schedule schedule = scheduleRepository.findById(scheduleId).orElseThrow(() -> new RestApiException(ErrorCode.EMPTY_SCHEDULE)); + + schedule.delete(); + scheduleRepository.save(schedule); + + return scheduleMapper.UUIDtoScheduleId(schedule.getId()); + } + + } From ed2c9e9f39f8811735db124e286c15d09c9c2c9f Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Tue, 23 Jan 2024 03:18:34 +0900 Subject: [PATCH 09/27] =?UTF-8?q?feat:=20=EC=9D=BC=EC=A0=95=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C(Web)=20-=20=EC=A4=91=EC=95=99/=EC=A7=80=EB=B6=80/?= =?UTF-8?q?=ED=95=99=EA=B5=90=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleController.java | 14 ++++++-- .../dto/response/ScheduleResponse.java | 29 ++++++++++++--- .../schedule/mapper/ScheduleMapper.java | 35 +++++++++++++++---- .../repository/ScheduleRepository.java | 9 +++++ .../schedule/service/ScheduleService.java | 7 ++-- .../schedule/service/ScheduleServiceImpl.java | 35 ++++++++++++++++--- 6 files changed, 109 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index 5b03c15b..4e93380b 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -3,15 +3,16 @@ import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; -import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummaryLists; import com.umc.networkingService.domain.schedule.service.ScheduleService; import com.umc.networkingService.global.common.base.BaseResponse; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.headers.Header; import io.swagger.v3.oas.annotations.tags.Tag; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -27,9 +28,16 @@ public class ScheduleController { private final ScheduleService scheduleService; + @Operation(summary = "스케줄 조회(Web) - 중앙, 지부, 학교", description = "홈화면의 일정을 조회하는 API입니다.") + @GetMapping + public BaseResponse getScheduleLists(@RequestParam Long month) { + + return BaseResponse.onSuccess((scheduleService.getScheduleLists(month))); + } + @Operation(summary = "캘린더 조회 API", description = "홈 화면의 달력을 조회하는 API입니다.") @PostMapping("/calendar") - public BaseResponse getSchedule(@RequestParam Long month) { + public BaseResponse getSchedule(@RequestParam Long month) { return BaseResponse.onSuccess(scheduleService.getCalendarByMonth(month)); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java index 5fd2f7b5..44e84acd 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -1,7 +1,6 @@ package com.umc.networkingService.domain.schedule.dto.response; import com.umc.networkingService.domain.board.entity.HostType; -import com.umc.networkingService.global.common.enums.Semester; import java.time.LocalDateTime; import java.util.List; import java.util.UUID; @@ -16,7 +15,7 @@ public class ScheduleResponse { @AllArgsConstructor @NoArgsConstructor @Builder - public static class ScheduleInfo { + public static class ScheduleInfoSummaryInCalendar { private UUID scheduleId; private LocalDateTime startDateTime; private LocalDateTime endDateTime; @@ -27,8 +26,30 @@ public static class ScheduleInfo { @AllArgsConstructor @NoArgsConstructor @Builder - public static class ScheduleInfoList { - private List schedules; + public static class ScheduleInfoSummariesInCalendar { + private List schedules; + } + + @Getter + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class ScheduleInfoSummary { + private UUID scheduleId; + private LocalDateTime startDateTime; + private LocalDateTime endDatetime; + private String title; + private HostType hostType; + } + + @Getter + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class ScheduleInfoSummaryLists { + private List campusSchedules; + private List branchSchedules; + private List centerSchedules; } @Getter diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index 465efd79..12c00a50 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -3,19 +3,21 @@ import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; -import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfo; -import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummary; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummaryInCalendar; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummaryLists; import com.umc.networkingService.domain.schedule.entity.Schedule; +import java.time.LocalDateTime; import java.util.List; import java.util.UUID; -import lombok.Setter; import org.springframework.stereotype.Component; @Component public class ScheduleMapper { - public ScheduleInfo toScheduleInfo(Schedule schedule) { - return ScheduleInfo.builder() + public ScheduleInfoSummaryInCalendar toScheduleInfoSummaryInCalendar(Schedule schedule) { + return ScheduleInfoSummaryInCalendar.builder() .scheduleId(schedule.getId()) .startDateTime(schedule.getStartDateTime()) .endDateTime(schedule.getEndDateTime()) @@ -23,12 +25,31 @@ public ScheduleInfo toScheduleInfo(Schedule schedule) { .build(); } - public ScheduleInfoList toScheduleInfoList(List schedules) { - return ScheduleInfoList.builder() + public ScheduleInfoSummariesInCalendar toScheduleInfoSummariesInCalendar(List schedules) { + return ScheduleInfoSummariesInCalendar.builder() .schedules(schedules) .build(); } + public ScheduleInfoSummary toScheduleInfoSummary(Schedule schedule) { + return ScheduleInfoSummary.builder() + .scheduleId(schedule.getId()) + .startDateTime(schedule.getStartDateTime()) + .endDatetime(schedule.getEndDateTime()) + .title(schedule.getTitle()) + .hostType(schedule.getHostType()) + .build(); + } + + public ScheduleInfoSummaryLists toScheduleInfoSummaries(List campusSchedules, List branchSchedules, List centerSchedules) { + return ScheduleInfoSummaryLists.builder() + .campusSchedules(campusSchedules) + .branchSchedules(branchSchedules) + .centerSchedules(centerSchedules) + .build(); + } + + public Schedule createScheduleToSchedule(CreateSchedule request) { return Schedule.builder() .title(request.getTitle()) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java index faf26650..81c53415 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java @@ -1,5 +1,6 @@ package com.umc.networkingService.domain.schedule.repository; +import com.umc.networkingService.domain.board.entity.HostType; import com.umc.networkingService.domain.schedule.entity.Schedule; import io.lettuce.core.dynamic.annotation.Param; import java.time.LocalDateTime; @@ -15,5 +16,13 @@ List findSchedulesByMonth( @Param("month") Long month ); + @Query(value = "SELECT s FROM Schedule s WHERE s.hostType = 1 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL) " + + "UNION " + + "SELECT s FROM Schedule s WHERE s.hostType = 2 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL) " + + "UNION " + + "SELECT s FROM Schedule s WHERE s.hostType = 3 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL)") + List> findByHostTypes ( + @Param("month") Long month + ); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index ad83257f..ef664513 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -3,14 +3,17 @@ import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; -import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummaryLists; import java.util.UUID; public interface ScheduleService { - public ScheduleInfoList getCalendarByMonth(Long month); + public ScheduleInfoSummariesInCalendar getCalendarByMonth(Long month); public ScheduleId createSchedule(CreateSchedule request); public ScheduleId updateSchedule(UUID scheduleId, UpdateSchedule request); public ScheduleId deleteSchedule(UUID scheduleId); + public ScheduleInfoSummaryLists getScheduleLists(Long month); + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index 40b6faba..0e169a2d 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -1,14 +1,18 @@ package com.umc.networkingService.domain.schedule.service; +import com.umc.networkingService.domain.board.entity.HostType; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; -import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoList; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummary; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummaryLists; import com.umc.networkingService.domain.schedule.entity.Schedule; import com.umc.networkingService.domain.schedule.mapper.ScheduleMapper; import com.umc.networkingService.domain.schedule.repository.ScheduleRepository; import com.umc.networkingService.global.common.exception.ErrorCode; import com.umc.networkingService.global.common.exception.RestApiException; +import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -20,15 +24,36 @@ public class ScheduleServiceImpl implements ScheduleService { private final ScheduleMapper scheduleMapper; @Override - public ScheduleInfoList getCalendarByMonth(Long month) { + public ScheduleInfoSummariesInCalendar getCalendarByMonth(Long month) { - return scheduleMapper.toScheduleInfoList( + return scheduleMapper.toScheduleInfoSummariesInCalendar( scheduleRepository.findSchedulesByMonth(month).stream() - .map(schedule -> scheduleMapper.toScheduleInfo(schedule)) + .map(schedule -> scheduleMapper.toScheduleInfoSummaryInCalendar(schedule)) .toList()); } + @Override + public ScheduleInfoSummaryLists getScheduleLists(Long month) { + List schedulesLists = scheduleRepository.findSchedulesByMonth(month); + List campusSchedules = schedulesLists.stream() + .filter(schedule -> schedule.getHostType().equals(HostType.CAMPUS)) + .map(schedule -> scheduleMapper.toScheduleInfoSummary(schedule)) + .toList(); + + List branchSchedules = schedulesLists.stream() + .filter(schedule -> schedule.getHostType().equals(HostType.BRANCH)) + .map(schedule -> scheduleMapper.toScheduleInfoSummary(schedule)) + .toList(); + + List centerSchedules = schedulesLists.stream() + .map(schedule -> scheduleMapper.toScheduleInfoSummary(schedule)) + .filter(schedule -> schedule.getHostType().equals(HostType.CENTER)) + .toList(); + + return scheduleMapper.toScheduleInfoSummaries(campusSchedules, branchSchedules, centerSchedules); + } + @Override public ScheduleId createSchedule(CreateSchedule request) { Schedule schedule = scheduleMapper.createScheduleToSchedule(request); @@ -59,4 +84,6 @@ public ScheduleId deleteSchedule(UUID scheduleId) { } + + } From 1c2c7e11fcb49264d63d3cd6a34020ff0eb5c17d Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Tue, 23 Jan 2024 04:22:45 +0900 Subject: [PATCH 10/27] =?UTF-8?q?feat:=20=EC=9D=BC=EC=A0=95=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C(=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C)=20API=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleController.java | 20 +++++++++++++++---- .../dto/response/ScheduleResponse.java | 18 +++++++++++++++++ .../schedule/mapper/ScheduleMapper.java | 14 +++++++++++++ .../schedule/service/ScheduleService.java | 3 +++ .../schedule/service/ScheduleServiceImpl.java | 8 ++++++++ 5 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index 4e93380b..a05f7e68 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -2,6 +2,7 @@ import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleDetail; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummaryLists; @@ -28,13 +29,23 @@ public class ScheduleController { private final ScheduleService scheduleService; - @Operation(summary = "스케줄 조회(Web) - 중앙, 지부, 학교", description = "홈화면의 일정을 조회하는 API입니다.") + // GET + @Operation(summary = "일정 조회(Web) - 중앙, 지부, 학교", description = "홈화면의 일정을 조회하는 API입니다.") @GetMapping public BaseResponse getScheduleLists(@RequestParam Long month) { return BaseResponse.onSuccess((scheduleService.getScheduleLists(month))); } + @Operation(summary = "일정 조회(상세조회)", description = "홈화면의 달력에서 일정을 상세조회하는 API입니다.") + @GetMapping("/detail/{scheduleId}") + public BaseResponse getScheduleDetail(@PathVariable("scheduleId") UUID scheduleId) { + + return BaseResponse.onSuccess(scheduleService.getScheduleDetail(scheduleId)); + } + + // POST + @Operation(summary = "캘린더 조회 API", description = "홈 화면의 달력을 조회하는 API입니다.") @PostMapping("/calendar") public BaseResponse getSchedule(@RequestParam Long month) { @@ -42,22 +53,23 @@ public BaseResponse getSchedule(@RequestParam L return BaseResponse.onSuccess(scheduleService.getCalendarByMonth(month)); } - @Operation(summary = "스케줄 추가 API", description = "운영진 관리 페이지의 스케줄을 추가하는 API입니다.") + @Operation(summary = "일정 추가 API", description = "운영진 관리 페이지의 일정을 추가하는 API입니다.") @PostMapping public BaseResponse createSchedule(@RequestBody CreateSchedule request) { return BaseResponse.onSuccess(scheduleService.createSchedule(request)); } - @Operation(summary = "스케줄 수정 API", description = "운영진 관리 페이지의 스케줄을 수정하는 API입니다.") + @Operation(summary = "일정 수정 API", description = "운영진 관리 페이지의 일정을 수정하는 API입니다.") @PostMapping("/update/{scheduleId}") public BaseResponse updateSchedule(@PathVariable("scheduleId") UUID scheduleId, @RequestBody UpdateSchedule request) { return BaseResponse.onSuccess(scheduleService.updateSchedule(scheduleId, request)); } + // DELETE - @Operation(summary = "스케줄 삭제 API", description = "운영진 관리 페이지의 스케줄을 삭제하는 API입니다.") + @Operation(summary = "일정 삭제 API", description = "운영진 관리 페이지의 일정을 삭제하는 API입니다.") @DeleteMapping("/{scheduleId}") public BaseResponse deleteSchedule(@PathVariable("scheduleId") UUID scheduleId) { diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java index 44e84acd..35e8a05e 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -1,6 +1,8 @@ package com.umc.networkingService.domain.schedule.dto.response; import com.umc.networkingService.domain.board.entity.HostType; +import com.umc.networkingService.domain.member.entity.Member; +import com.umc.networkingService.global.common.enums.Semester; import java.time.LocalDateTime; import java.util.List; import java.util.UUID; @@ -60,5 +62,21 @@ public static class ScheduleId { private UUID scheduleId; } + @Getter + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class ScheduleDetail { + private UUID scheduleId; + private UUID writerId; + private String title; + private String content; + private LocalDateTime startDateTime; + private LocalDateTime endDateTime; + private String placeSetting; + private HostType hostType; + + } + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index 12c00a50..7740be04 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -2,6 +2,7 @@ import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleDetail; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummary; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummaryInCalendar; @@ -16,6 +17,19 @@ @Component public class ScheduleMapper { + public ScheduleDetail toScheduleDetail(Schedule schedule) { + return ScheduleDetail.builder() + .scheduleId(schedule.getId()) + .writerId(schedule.getWriter().getId()) + .title(schedule.getTitle()) + .content(schedule.getContent()) + .startDateTime(schedule.getStartDateTime()) + .endDateTime(schedule.getEndDateTime()) + .placeSetting(schedule.getPlaceSetting()) + .hostType(schedule.getHostType()) + .build(); + } + public ScheduleInfoSummaryInCalendar toScheduleInfoSummaryInCalendar(Schedule schedule) { return ScheduleInfoSummaryInCalendar.builder() .scheduleId(schedule.getId()) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index ef664513..e5911e59 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -2,6 +2,7 @@ import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleDetail; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummaryLists; @@ -16,4 +17,6 @@ public interface ScheduleService { public ScheduleInfoSummaryLists getScheduleLists(Long month); + public ScheduleDetail getScheduleDetail(UUID scheduleId); + } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index 0e169a2d..5fd1da2d 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -3,6 +3,7 @@ import com.umc.networkingService.domain.board.entity.HostType; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleDetail; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummary; @@ -54,6 +55,13 @@ public ScheduleInfoSummaryLists getScheduleLists(Long month) { return scheduleMapper.toScheduleInfoSummaries(campusSchedules, branchSchedules, centerSchedules); } + @Override + public ScheduleDetail getScheduleDetail(UUID scheduleId) { + Schedule schedule = scheduleRepository.findById(scheduleId).orElseThrow(() -> new RestApiException(ErrorCode.EMPTY_SCHEDULE)); + + return scheduleMapper.toScheduleDetail(schedule); + } + @Override public ScheduleId createSchedule(CreateSchedule request) { Schedule schedule = scheduleMapper.createScheduleToSchedule(request); From ab169d4bd507f98c51883d7c7988b0258335e946 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Fri, 26 Jan 2024 16:16:18 +0900 Subject: [PATCH 11/27] =?UTF-8?q?fix:=20git=20=EC=B6=A9=EB=8F=8C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleController.java | 58 +++++++++++-------- .../controller/StaffScheduleController.java | 55 ++++++++++++++++++ .../schedule/mapper/ScheduleMapper.java | 4 +- .../schedule/service/ScheduleService.java | 7 ++- .../schedule/service/ScheduleServiceImpl.java | 17 +++--- .../global/common/exception/ErrorCode.java | 4 +- 6 files changed, 107 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index a05f7e68..aa917b95 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -1,5 +1,7 @@ package com.umc.networkingService.domain.schedule.controller; +import com.umc.networkingService.config.security.auth.CurrentMember; +import com.umc.networkingService.domain.member.entity.Member; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleDetail; @@ -10,6 +12,7 @@ import com.umc.networkingService.global.common.base.BaseResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.DeleteMapping; @@ -19,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @Tag(name = "달력 API", description = "달력 관련 API") @@ -39,9 +43,10 @@ public BaseResponse getScheduleLists(@RequestParam Lon @Operation(summary = "일정 조회(상세조회)", description = "홈화면의 달력에서 일정을 상세조회하는 API입니다.") @GetMapping("/detail/{scheduleId}") - public BaseResponse getScheduleDetail(@PathVariable("scheduleId") UUID scheduleId) { + public BaseResponse getScheduleDetail(@CurrentMember Member member, + @PathVariable("scheduleId") UUID scheduleId) { - return BaseResponse.onSuccess(scheduleService.getScheduleDetail(scheduleId)); + return BaseResponse.onSuccess(scheduleService.getScheduleDetail(member, scheduleId)); } // POST @@ -52,29 +57,32 @@ public BaseResponse getSchedule(@RequestParam L return BaseResponse.onSuccess(scheduleService.getCalendarByMonth(month)); } - - @Operation(summary = "일정 추가 API", description = "운영진 관리 페이지의 일정을 추가하는 API입니다.") - @PostMapping - public BaseResponse createSchedule(@RequestBody CreateSchedule request) { - - return BaseResponse.onSuccess(scheduleService.createSchedule(request)); - } - - @Operation(summary = "일정 수정 API", description = "운영진 관리 페이지의 일정을 수정하는 API입니다.") - @PostMapping("/update/{scheduleId}") - public BaseResponse updateSchedule(@PathVariable("scheduleId") UUID scheduleId, @RequestBody UpdateSchedule request) { - - return BaseResponse.onSuccess(scheduleService.updateSchedule(scheduleId, request)); - } - - // DELETE - - @Operation(summary = "일정 삭제 API", description = "운영진 관리 페이지의 일정을 삭제하는 API입니다.") - @DeleteMapping("/{scheduleId}") - public BaseResponse deleteSchedule(@PathVariable("scheduleId") UUID scheduleId) { - - return BaseResponse.onSuccess(scheduleService.deleteSchedule(scheduleId)); - } +// +// @Operation(summary = "일정 추가 API", description = "운영진 관리 페이지의 일정을 추가하는 API입니다.") +// @PostMapping +// public BaseResponse createSchedule(@CurrentMember Member member, +// @RequestBody CreateSchedule request) { +// +// return BaseResponse.onSuccess(scheduleService.createSchedule(member, request)); +// } +// +// @Operation(summary = "일정 수정 API", description = "운영진 관리 페이지의 일정을 수정하는 API입니다.") +// @PostMapping("/update/{scheduleId}") +// public BaseResponse updateSchedule(@CurrentMember Member member, +// @PathVariable("scheduleId") UUID scheduleId, +// @RequestBody UpdateSchedule request) { +// +// return BaseResponse.onSuccess(scheduleService.updateSchedule(member, scheduleId, request)); +// } +// +// // DELETE +// +// @Operation(summary = "일정 삭제 API", description = "운영진 관리 페이지의 일정을 삭제하는 API입니다.") +// @DeleteMapping("/{scheduleId}") +// public BaseResponse deleteSchedule(@PathVariable("scheduleId") UUID scheduleId) { +// +// return BaseResponse.onSuccess(scheduleService.deleteSchedule(scheduleId)); +// } } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java new file mode 100644 index 00000000..75f440fc --- /dev/null +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java @@ -0,0 +1,55 @@ +package com.umc.networkingService.domain.schedule.controller; + +import com.umc.networkingService.config.security.auth.CurrentMember; +import com.umc.networkingService.domain.member.entity.Member; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; +import com.umc.networkingService.domain.schedule.service.ScheduleService; +import com.umc.networkingService.global.common.base.BaseResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.UUID; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "운영진 달력 API", description = "운영진 달력 관련 API") +@RestController +@RequiredArgsConstructor +@RequestMapping("/staff/schedules") +public class StaffScheduleController { + + private final ScheduleService scheduleService; + + @Operation(summary = "일정 추가 API", description = "운영진 관리 페이지의 일정을 추가하는 API입니다.") + @PostMapping + public BaseResponse createSchedule(@CurrentMember Member member, + @RequestBody CreateSchedule request) { + + return BaseResponse.onSuccess(scheduleService.createSchedule(member, request)); + } + + @Operation(summary = "일정 수정 API", description = "운영진 관리 페이지의 일정을 수정하는 API입니다.") + @PostMapping("/update/{scheduleId}") + public BaseResponse updateSchedule(@CurrentMember Member member, + @PathVariable("scheduleId") UUID scheduleId, + @RequestBody UpdateSchedule request) { + + return BaseResponse.onSuccess(scheduleService.updateSchedule(member, scheduleId, request)); + } + + // DELETE + + @Operation(summary = "일정 삭제 API", description = "운영진 관리 페이지의 일정을 삭제하는 API입니다.") + @DeleteMapping("/{scheduleId}") + public BaseResponse deleteSchedule(@PathVariable("scheduleId") UUID scheduleId) { + + return BaseResponse.onSuccess(scheduleService.deleteSchedule(scheduleId)); + } + +} diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index 7740be04..9b1d38eb 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -1,5 +1,6 @@ package com.umc.networkingService.domain.schedule.mapper; +import com.umc.networkingService.domain.member.entity.Member; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.CreateSchedule; import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleDetail; @@ -64,9 +65,10 @@ public ScheduleInfoSummaryLists toScheduleInfoSummaries(List new RestApiException(ErrorCode.EMPTY_SCHEDULE)); return scheduleMapper.toScheduleDetail(schedule); } @Override - public ScheduleId createSchedule(CreateSchedule request) { - Schedule schedule = scheduleMapper.createScheduleToSchedule(request); + public ScheduleId createSchedule(Member member, CreateSchedule request) { + Schedule schedule = scheduleMapper.createScheduleToSchedule(member, request); scheduleRepository.save(schedule); @@ -72,8 +73,12 @@ public ScheduleId createSchedule(CreateSchedule request) { } @Override - public ScheduleId updateSchedule(UUID scheduleId, UpdateSchedule request) { + public ScheduleId updateSchedule(Member member, UUID scheduleId, UpdateSchedule request) { Schedule schedule = scheduleRepository.findById(scheduleId).orElseThrow(() -> new RestApiException(ErrorCode.EMPTY_SCHEDULE)); + // 만약 수정하려는 멤버와 일정 작성자가 일치하지 않을 경우 에러 반환 + if (!schedule.getWriter().getId().equals(member.getId())) { + throw new RestApiException(ErrorCode.NO_PERMISSION_MEMBER); + } schedule = scheduleMapper.updateScheduleToSchedule(request, schedule); scheduleRepository.save(schedule); @@ -90,8 +95,4 @@ public ScheduleId deleteSchedule(UUID scheduleId) { return scheduleMapper.UUIDtoScheduleId(schedule.getId()); } - - - - } diff --git a/src/main/java/com/umc/networkingService/global/common/exception/ErrorCode.java b/src/main/java/com/umc/networkingService/global/common/exception/ErrorCode.java index f9e35495..9c9eaf1f 100644 --- a/src/main/java/com/umc/networkingService/global/common/exception/ErrorCode.java +++ b/src/main/java/com/umc/networkingService/global/common/exception/ErrorCode.java @@ -29,6 +29,7 @@ public enum ErrorCode { EMPTY_MEMBER_UNIVERSITY(HttpStatus.CONFLICT, "MEMBER004", "소속 대학교가 존재하지 않는 사용자입니다."), UNAUTHENTICATED_GITHUB(HttpStatus.BAD_REQUEST, "MEMBER005", "깃허브 연동이 완료되지 않은 사용자입니다."), INVALID_MEMBER_KEYWORD(HttpStatus.BAD_REQUEST, "MEMBER006", "검색어 양식[닉네임/이름]에 맞추어 작성해주세요. ex) 벡스/김준석"), + NO_PERMISSION_MEMBER(HttpStatus.BAD_REQUEST, "MEMBER006", "권한이 없는 사용자입니다."), // SemesterPart EMPTY_SEMESTER_PART(HttpStatus.BAD_REQUEST, "PART006", "존재하지 않는 기수의 파트입니다."), @@ -57,7 +58,8 @@ public enum ErrorCode { FAILED_UPLOAD_S3_IMAGE(HttpStatus.INTERNAL_SERVER_ERROR, "IMAGE001", "이미지 저장에 실패하였습니다."), // Schedule - EMPTY_SCHEDULE(HttpStatus.BAD_REQUEST, "SCHEDULE001", "존재하지 않는 스케줄입니다."); + EMPTY_SCHEDULE(HttpStatus.BAD_REQUEST, "SCHEDULE001", "존재하지 않는 스케줄입니다."), + ; private final HttpStatus httpStatus; private final String code; From 944d296447af31bc4fe3a2ba2c2fdec38bef2c5f Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Wed, 24 Jan 2024 03:04:57 +0900 Subject: [PATCH 12/27] =?UTF-8?q?feat:=20=EC=9D=BC=EC=A0=95=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=20API=20=EC=9E=91=EC=84=B1=EC=9E=90=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EC=BD=94=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/controller/StaffScheduleController.java | 5 +++-- .../domain/schedule/service/ScheduleService.java | 2 +- .../domain/schedule/service/ScheduleServiceImpl.java | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java index 75f440fc..50a263b2 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java @@ -47,9 +47,10 @@ public BaseResponse updateSchedule(@CurrentMember Member member, @Operation(summary = "일정 삭제 API", description = "운영진 관리 페이지의 일정을 삭제하는 API입니다.") @DeleteMapping("/{scheduleId}") - public BaseResponse deleteSchedule(@PathVariable("scheduleId") UUID scheduleId) { + public BaseResponse deleteSchedule(@CurrentMember Member member, + @PathVariable("scheduleId") UUID scheduleId) { - return BaseResponse.onSuccess(scheduleService.deleteSchedule(scheduleId)); + return BaseResponse.onSuccess(scheduleService.deleteSchedule(member, scheduleId)); } } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index caa7762f..1f8e1e39 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -14,7 +14,7 @@ public interface ScheduleService { public ScheduleId createSchedule(Member member, CreateSchedule request); public ScheduleId updateSchedule(Member member, UUID scheduleId, UpdateSchedule request); - public ScheduleId deleteSchedule(UUID scheduleId); + public ScheduleId deleteSchedule(Member member, UUID scheduleId); public ScheduleInfoSummaryLists getScheduleLists(Long month); diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index 03122ff4..e2354c3d 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -87,9 +87,12 @@ public ScheduleId updateSchedule(Member member, UUID scheduleId, UpdateSchedule } @Override - public ScheduleId deleteSchedule(UUID scheduleId) { + public ScheduleId deleteSchedule(Member member, UUID scheduleId) { Schedule schedule = scheduleRepository.findById(scheduleId).orElseThrow(() -> new RestApiException(ErrorCode.EMPTY_SCHEDULE)); - + // 만약 삭제하려는 멤버와 일정 작성자가 일치하지 않을 경우 에러 반환 + if (!schedule.getWriter().getId().equals(member.getId())) { + throw new RestApiException(ErrorCode.NO_PERMISSION_MEMBER); + } schedule.delete(); scheduleRepository.save(schedule); From b717932b70e27148b716ad64bb6326bbc261a73b Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Wed, 24 Jan 2024 03:08:27 +0900 Subject: [PATCH 13/27] =?UTF-8?q?feat:=20=EC=A3=BC=EC=84=9D=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleController.java | 26 ------------------- 1 file changed, 26 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index aa917b95..9a86c60a 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -57,32 +57,6 @@ public BaseResponse getSchedule(@RequestParam L return BaseResponse.onSuccess(scheduleService.getCalendarByMonth(month)); } -// -// @Operation(summary = "일정 추가 API", description = "운영진 관리 페이지의 일정을 추가하는 API입니다.") -// @PostMapping -// public BaseResponse createSchedule(@CurrentMember Member member, -// @RequestBody CreateSchedule request) { -// -// return BaseResponse.onSuccess(scheduleService.createSchedule(member, request)); -// } -// -// @Operation(summary = "일정 수정 API", description = "운영진 관리 페이지의 일정을 수정하는 API입니다.") -// @PostMapping("/update/{scheduleId}") -// public BaseResponse updateSchedule(@CurrentMember Member member, -// @PathVariable("scheduleId") UUID scheduleId, -// @RequestBody UpdateSchedule request) { -// -// return BaseResponse.onSuccess(scheduleService.updateSchedule(member, scheduleId, request)); -// } -// -// // DELETE -// -// @Operation(summary = "일정 삭제 API", description = "운영진 관리 페이지의 일정을 삭제하는 API입니다.") -// @DeleteMapping("/{scheduleId}") -// public BaseResponse deleteSchedule(@PathVariable("scheduleId") UUID scheduleId) { -// -// return BaseResponse.onSuccess(scheduleService.deleteSchedule(scheduleId)); -// } } From 73f1a62b17733d24e6000678328e96fccb55facb Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Wed, 24 Jan 2024 03:20:09 +0900 Subject: [PATCH 14/27] =?UTF-8?q?feat:=20ScheduleControllerTestConfig=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScheduleControllerTestConfig.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTestConfig.java diff --git a/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTestConfig.java b/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTestConfig.java new file mode 100644 index 00000000..b13a11f9 --- /dev/null +++ b/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTestConfig.java @@ -0,0 +1,50 @@ +package com.umc.networkingService.domain.schedule.controller; + + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.umc.networkingService.config.security.jwt.JwtTokenProvider; +import com.umc.networkingService.domain.member.entity.Member; +import com.umc.networkingService.domain.member.entity.SocialType; +import com.umc.networkingService.domain.schedule.entity.Schedule; +import com.umc.networkingService.domain.schedule.repository.ScheduleRepository; +import com.umc.networkingService.global.common.enums.Role; +import java.util.UUID; +import org.junit.jupiter.api.BeforeEach; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.test.web.servlet.MockMvc; + +@SpringBootTest +@AutoConfigureMockMvc +public abstract class ScheduleControllerTestConfig { + @Autowired protected MockMvc mockMvc; + @Autowired protected ObjectMapper objectMapper; + @Autowired protected JwtTokenProvider jwtTokenProvider; + @MockBean protected ScheduleRepository scheduleRepository; + + protected Member member; + protected String accessToken; + protected String refreshToken; + + @BeforeEach + public void setup() { + member = createMember(); + setToken(member); + } + + private Member createMember() { + return Member.builder() + .id(UUID.randomUUID()) + .clientId("123456") + .socialType(SocialType.KAKAO) + .role(Role.MEMBER) + .build(); + } + + private void setToken(Member member) { + accessToken = jwtTokenProvider.generateAccessToken(member.getId()); + refreshToken = jwtTokenProvider.generateRefreshToken(member.getId()); + } +} From f2180488dda798cc6803012affbe19d8695f78d2 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Wed, 24 Jan 2024 03:40:14 +0900 Subject: [PATCH 15/27] =?UTF-8?q?=EC=9E=84=EC=8B=9C=20=EC=BB=A4=EB=B0=8B?= =?UTF-8?q?=20-=20reset=EC=98=88=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dump.rdb | Bin 0 -> 730 bytes .../controller/ScheduleControllerTest.java | 26 ++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 dump.rdb create mode 100644 src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTest.java diff --git a/dump.rdb b/dump.rdb new file mode 100644 index 0000000000000000000000000000000000000000..440b81fbd0b08576fd19037ae3603146417cf646 GIT binary patch literal 730 zcmb7>zi-n(9K|mpMQO!^!otJ=7^lS zO?59^efQ4tFgo@~(gpO)&iUBwXI guJ*Bv@r!L;-RU~J$fef(KbP&N$IpIz`}y?fFGHH@7XSbN literal 0 HcmV?d00001 diff --git a/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTest.java b/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTest.java new file mode 100644 index 00000000..eedd5d1b --- /dev/null +++ b/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTest.java @@ -0,0 +1,26 @@ +package com.umc.networkingService.domain.schedule.controller; + +import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar; +import com.umc.networkingService.domain.schedule.mapper.ScheduleMapper; +import com.umc.networkingService.domain.schedule.service.ScheduleService; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; + +@DisplayName("Schedule 컨트롤러의") +public class ScheduleControllerTest extends ScheduleControllerTestConfig { + + @Autowired private ScheduleMapper scheduleMapper; + + @MockBean private ScheduleService scheduleService; + + @DisplayName("캘린더 조회 API 테스트") + @Test + public void getScheduleTEst() throws Exception { + // given + Long month = 2L; + + + } +} From 4285f7344234fffd0abdaf57b1d8ebb910b079e4 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Fri, 26 Jan 2024 20:54:41 +0900 Subject: [PATCH 16/27] =?UTF-8?q?fix:=20Schedule=20=EC=8A=A4=EC=9B=A8?= =?UTF-8?q?=EA=B1=B0=20=ED=83=9C=EA=B7=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/controller/ScheduleController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index 9a86c60a..0c5fdf34 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -25,7 +25,7 @@ import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; -@Tag(name = "달력 API", description = "달력 관련 API") +@Tag(name = "일정 API", description = "일정 관련 API") @RestController @RequiredArgsConstructor @RequestMapping("/schedules") From 1864f5a314cacd2beb2d3649c3e166fc80e72138 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Fri, 26 Jan 2024 23:52:50 +0900 Subject: [PATCH 17/27] =?UTF-8?q?fix:=20Schedule=20Repository=20findSchedu?= =?UTF-8?q?lesByYearAndMonth=20=EC=BF=BC=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dump.rdb | Bin 730 -> 0 bytes .../schedule/controller/ScheduleController.java | 9 +++++---- .../schedule/repository/ScheduleRepository.java | 8 +++++--- .../domain/schedule/service/ScheduleService.java | 5 +++-- .../schedule/service/ScheduleServiceImpl.java | 12 +++++++----- 5 files changed, 20 insertions(+), 14 deletions(-) delete mode 100644 dump.rdb diff --git a/dump.rdb b/dump.rdb deleted file mode 100644 index 440b81fbd0b08576fd19037ae3603146417cf646..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 730 zcmb7>zi-n(9K|mpMQO!^!otJ=7^lS zO?59^efQ4tFgo@~(gpO)&iUBwXI guJ*Bv@r!L;-RU~J$fef(KbP&N$IpIz`}y?fFGHH@7XSbN diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index 0c5fdf34..7389846b 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -13,6 +13,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import java.time.LocalDate; import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.DeleteMapping; @@ -36,9 +37,9 @@ public class ScheduleController { // GET @Operation(summary = "일정 조회(Web) - 중앙, 지부, 학교", description = "홈화면의 일정을 조회하는 API입니다.") @GetMapping - public BaseResponse getScheduleLists(@RequestParam Long month) { + public BaseResponse getScheduleLists(@RequestParam LocalDate date) { - return BaseResponse.onSuccess((scheduleService.getScheduleLists(month))); + return BaseResponse.onSuccess((scheduleService.getScheduleLists(date))); } @Operation(summary = "일정 조회(상세조회)", description = "홈화면의 달력에서 일정을 상세조회하는 API입니다.") @@ -53,9 +54,9 @@ public BaseResponse getScheduleDetail(@CurrentMember Member memb @Operation(summary = "캘린더 조회 API", description = "홈 화면의 달력을 조회하는 API입니다.") @PostMapping("/calendar") - public BaseResponse getSchedule(@RequestParam Long month) { + public BaseResponse getSchedule(@RequestParam LocalDate date) { - return BaseResponse.onSuccess(scheduleService.getCalendarByMonth(month)); + return BaseResponse.onSuccess(scheduleService.getCalendarByMonth(date)); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java index 81c53415..59221d07 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java @@ -3,7 +3,9 @@ import com.umc.networkingService.domain.board.entity.HostType; import com.umc.networkingService.domain.schedule.entity.Schedule; import io.lettuce.core.dynamic.annotation.Param; +import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Month; import java.util.List; import java.util.UUID; import org.springframework.data.jpa.repository.JpaRepository; @@ -11,9 +13,9 @@ public interface ScheduleRepository extends JpaRepository { - @Query(value = "SELECT s FROM Schedule s WHERE (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime)) AND s.deletedAt IS NULL") - List findSchedulesByMonth( - @Param("month") Long month + @Query(value = "SELECT s FROM Schedule s WHERE (DATE_FORMAT(s.startDateTime, '%Y-%m') <= DATE_FORMAT(:date, '%Y-%m') AND DATE_FORMAT(:date, '%Y-%m') <= DATE_FORMAT(s.endDateTime, '%Y-%m')) AND s.deletedAt IS NULL") + List findSchedulesByYearAndMonth ( + @Param("yearMonth") LocalDate date ); @Query(value = "SELECT s FROM Schedule s WHERE s.hostType = 1 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL) " + diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index 1f8e1e39..fb9ee597 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -7,16 +7,17 @@ import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleId; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar; import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummaryLists; +import java.time.LocalDate; import java.util.UUID; public interface ScheduleService { - public ScheduleInfoSummariesInCalendar getCalendarByMonth(Long month); + public ScheduleInfoSummariesInCalendar getCalendarByMonth(LocalDate date); public ScheduleId createSchedule(Member member, CreateSchedule request); public ScheduleId updateSchedule(Member member, UUID scheduleId, UpdateSchedule request); public ScheduleId deleteSchedule(Member member, UUID scheduleId); - public ScheduleInfoSummaryLists getScheduleLists(Long month); + public ScheduleInfoSummaryLists getScheduleLists(LocalDate date); public ScheduleDetail getScheduleDetail(Member member, UUID scheduleId); diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index e2354c3d..b5a605e5 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -14,6 +14,8 @@ import com.umc.networkingService.domain.schedule.repository.ScheduleRepository; import com.umc.networkingService.global.common.exception.ErrorCode; import com.umc.networkingService.global.common.exception.RestApiException; +import java.time.LocalDate; +import java.time.YearMonth; import java.util.List; import java.util.UUID; import lombok.RequiredArgsConstructor; @@ -26,18 +28,18 @@ public class ScheduleServiceImpl implements ScheduleService { private final ScheduleMapper scheduleMapper; @Override - public ScheduleInfoSummariesInCalendar getCalendarByMonth(Long month) { - + public ScheduleInfoSummariesInCalendar getCalendarByMonth(LocalDate date) { return scheduleMapper.toScheduleInfoSummariesInCalendar( - scheduleRepository.findSchedulesByMonth(month).stream() + scheduleRepository.findSchedulesByYearAndMonth(date).stream() .map(schedule -> scheduleMapper.toScheduleInfoSummaryInCalendar(schedule)) .toList()); } @Override - public ScheduleInfoSummaryLists getScheduleLists(Long month) { - List schedulesLists = scheduleRepository.findSchedulesByMonth(month); + public ScheduleInfoSummaryLists getScheduleLists(LocalDate date) { + + List schedulesLists = scheduleRepository.findSchedulesByYearAndMonth(date); List campusSchedules = schedulesLists.stream() .filter(schedule -> schedule.getHostType().equals(HostType.CAMPUS)) .map(schedule -> scheduleMapper.toScheduleInfoSummary(schedule)) From c5bd64d5fe051944675305f6cd1fe55d9984b911 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Fri, 26 Jan 2024 23:55:19 +0900 Subject: [PATCH 18/27] =?UTF-8?q?fix:=20ScheduleDetail=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/dto/response/ScheduleResponse.java | 2 +- .../domain/schedule/mapper/ScheduleMapper.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java index 35e8a05e..d8db2c30 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -68,7 +68,7 @@ public static class ScheduleId { @Builder public static class ScheduleDetail { private UUID scheduleId; - private UUID writerId; + private Member writer; private String title; private String content; private LocalDateTime startDateTime; diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index 9b1d38eb..0612d351 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -21,7 +21,7 @@ public class ScheduleMapper { public ScheduleDetail toScheduleDetail(Schedule schedule) { return ScheduleDetail.builder() .scheduleId(schedule.getId()) - .writerId(schedule.getWriter().getId()) + .writer(schedule.getWriter()) .title(schedule.getTitle()) .content(schedule.getContent()) .startDateTime(schedule.getStartDateTime()) From 5a32cf72bc26d4152ad37481ab47600dd3d78b53 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Sat, 27 Jan 2024 00:04:20 +0900 Subject: [PATCH 19/27] =?UTF-8?q?fix:=20Schedule=20setter=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20=EB=B0=8F=20updateSchedule=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/entity/Schedule.java | 12 +++++++++++- .../domain/schedule/mapper/ScheduleMapper.java | 8 +------- .../repository/ScheduleRepository.java | 18 +++++++++--------- .../schedule/service/ScheduleService.java | 12 ++++++------ 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java b/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java index b1109b74..c9f025d9 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/entity/Schedule.java @@ -2,6 +2,7 @@ import com.umc.networkingService.domain.board.entity.HostType; import com.umc.networkingService.domain.member.entity.Member; +import com.umc.networkingService.domain.schedule.dto.request.ScheduleRequest.UpdateSchedule; import com.umc.networkingService.global.common.base.BaseEntity; import com.umc.networkingService.global.common.enums.Semester; import jakarta.persistence.*; @@ -19,7 +20,6 @@ import java.util.List; import java.util.UUID; -@Setter @Getter @Entity @Builder @@ -58,4 +58,14 @@ public class Schedule extends BaseEntity { @Column(nullable = false) private HostType hostType; + + public void updateSchedule(UpdateSchedule request) { + this.title = request.getTitle(); + this.content = request.getContent(); + this.startDateTime = request.getStartDateTime(); + this.endDateTime = request.getEndDateTime(); + this.semesterPermission = request.getSemesterPermission(); + this.hostType = request.getHostType(); + this.placeSetting = request.getPlaceSetting(); + } } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index 0612d351..a81f0aea 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -79,13 +79,7 @@ public Schedule createScheduleToSchedule(Member member, CreateSchedule request) } public Schedule updateScheduleToSchedule(UpdateSchedule request, Schedule schedule) { - schedule.setTitle(request.getTitle()); - schedule.setContent(request.getContent()); - schedule.setStartDateTime(request.getStartDateTime()); - schedule.setEndDateTime(request.getEndDateTime()); - schedule.setSemesterPermission(request.getSemesterPermission()); - schedule.setHostType(request.getHostType()); - schedule.setPlaceSetting(request.getPlaceSetting()); + schedule.updateSchedule(request); return schedule; } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java index 59221d07..09bf1303 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java @@ -13,18 +13,18 @@ public interface ScheduleRepository extends JpaRepository { - @Query(value = "SELECT s FROM Schedule s WHERE (DATE_FORMAT(s.startDateTime, '%Y-%m') <= DATE_FORMAT(:date, '%Y-%m') AND DATE_FORMAT(:date, '%Y-%m') <= DATE_FORMAT(s.endDateTime, '%Y-%m')) AND s.deletedAt IS NULL") + @Query(value = "SELECT s FROM Schedule s WHERE DATE_FORMAT(s.startDateTime, '%Y-%m') <= DATE_FORMAT(:date, '%Y-%m') AND DATE_FORMAT(:date, '%Y-%m') <= DATE_FORMAT(s.endDateTime, '%Y-%m')") List findSchedulesByYearAndMonth ( @Param("yearMonth") LocalDate date ); - @Query(value = "SELECT s FROM Schedule s WHERE s.hostType = 1 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL) " + - "UNION " + - "SELECT s FROM Schedule s WHERE s.hostType = 2 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL) " + - "UNION " + - "SELECT s FROM Schedule s WHERE s.hostType = 3 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL)") - List> findByHostTypes ( - @Param("month") Long month - ); +// @Query(value = "SELECT s FROM Schedule s WHERE s.hostType = 1 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL) " + +// "UNION " + +// "SELECT s FROM Schedule s WHERE s.hostType = 2 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL) " + +// "UNION " + +// "SELECT s FROM Schedule s WHERE s.hostType = 3 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL)") +// List> findByHostTypes ( +// @Param("month") Long month +// ); } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java index fb9ee597..3bc0ea70 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleService.java @@ -11,14 +11,14 @@ import java.util.UUID; public interface ScheduleService { - public ScheduleInfoSummariesInCalendar getCalendarByMonth(LocalDate date); - public ScheduleId createSchedule(Member member, CreateSchedule request); - public ScheduleId updateSchedule(Member member, UUID scheduleId, UpdateSchedule request); + ScheduleInfoSummariesInCalendar getCalendarByMonth(LocalDate date); + ScheduleId createSchedule(Member member, CreateSchedule request); + ScheduleId updateSchedule(Member member, UUID scheduleId, UpdateSchedule request); - public ScheduleId deleteSchedule(Member member, UUID scheduleId); + ScheduleId deleteSchedule(Member member, UUID scheduleId); - public ScheduleInfoSummaryLists getScheduleLists(LocalDate date); + ScheduleInfoSummaryLists getScheduleLists(LocalDate date); - public ScheduleDetail getScheduleDetail(Member member, UUID scheduleId); + ScheduleDetail getScheduleDetail(Member member, UUID scheduleId); } From 22192a9ae47c38bdadcddbdff7ea601dc860b9aa Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Sat, 27 Jan 2024 00:18:36 +0900 Subject: [PATCH 20/27] =?UTF-8?q?refactor:=20getScheduleLists()=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=20=EC=BD=94=EB=93=9C=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81=20&=20@Transactional=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B8=ED=95=9C=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20sav?= =?UTF-8?q?e()=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/service/ScheduleServiceImpl.java | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index b5a605e5..0c104892 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -40,24 +40,23 @@ public ScheduleInfoSummariesInCalendar getCalendarByMonth(LocalDate date) { public ScheduleInfoSummaryLists getScheduleLists(LocalDate date) { List schedulesLists = scheduleRepository.findSchedulesByYearAndMonth(date); - List campusSchedules = schedulesLists.stream() - .filter(schedule -> schedule.getHostType().equals(HostType.CAMPUS)) - .map(schedule -> scheduleMapper.toScheduleInfoSummary(schedule)) - .toList(); - List branchSchedules = schedulesLists.stream() - .filter(schedule -> schedule.getHostType().equals(HostType.BRANCH)) - .map(schedule -> scheduleMapper.toScheduleInfoSummary(schedule)) - .toList(); + List campusSchedules = filterSchedulesByHostType(schedulesLists, HostType.CAMPUS); - List centerSchedules = schedulesLists.stream() - .map(schedule -> scheduleMapper.toScheduleInfoSummary(schedule)) - .filter(schedule -> schedule.getHostType().equals(HostType.CENTER)) - .toList(); + List branchSchedules = filterSchedulesByHostType(schedulesLists, HostType.BRANCH); + + List centerSchedules = filterSchedulesByHostType(schedulesLists, HostType.CENTER); return scheduleMapper.toScheduleInfoSummaries(campusSchedules, branchSchedules, centerSchedules); } + private List filterSchedulesByHostType(List schedules, HostType hostType) { + return schedules.stream() + .filter(schedule -> schedule.getHostType().equals(hostType)) + .map(schedule -> scheduleMapper.toScheduleInfoSummary(schedule)) + .toList(); + } + @Override public ScheduleDetail getScheduleDetail(Member member, UUID scheduleId) { Schedule schedule = scheduleRepository.findById(scheduleId).orElseThrow(() -> new RestApiException(ErrorCode.EMPTY_SCHEDULE)); @@ -83,8 +82,6 @@ public ScheduleId updateSchedule(Member member, UUID scheduleId, UpdateSchedule } schedule = scheduleMapper.updateScheduleToSchedule(request, schedule); - scheduleRepository.save(schedule); - return scheduleMapper.UUIDtoScheduleId(schedule.getId()); } @@ -96,7 +93,6 @@ public ScheduleId deleteSchedule(Member member, UUID scheduleId) { throw new RestApiException(ErrorCode.NO_PERMISSION_MEMBER); } schedule.delete(); - scheduleRepository.save(schedule); return scheduleMapper.UUIDtoScheduleId(schedule.getId()); } From a4f698609c11dc36b452b64e64cd13ce07358518 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Sat, 27 Jan 2024 00:34:17 +0900 Subject: [PATCH 21/27] =?UTF-8?q?fix:=20Schedule=20=EC=BB=A8=ED=8A=B8?= =?UTF-8?q?=EB=A1=A4=EB=9F=AC=20ApiResponse=20=EC=B6=94=EA=B0=80=20&=20Sch?= =?UTF-8?q?eduleDetail=20DTO=20=ED=95=84=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/controller/ScheduleController.java | 12 ++++++++++++ .../schedule/controller/StaffScheduleController.java | 12 +++++++++++- .../schedule/dto/response/ScheduleResponse.java | 2 +- .../domain/schedule/mapper/ScheduleMapper.java | 2 +- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index 7389846b..2c225eec 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -11,6 +11,8 @@ import com.umc.networkingService.domain.schedule.service.ScheduleService; import com.umc.networkingService.global.common.base.BaseResponse; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import java.time.LocalDate; @@ -37,6 +39,9 @@ public class ScheduleController { // GET @Operation(summary = "일정 조회(Web) - 중앙, 지부, 학교", description = "홈화면의 일정을 조회하는 API입니다.") @GetMapping + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공") + }) public BaseResponse getScheduleLists(@RequestParam LocalDate date) { return BaseResponse.onSuccess((scheduleService.getScheduleLists(date))); @@ -44,6 +49,10 @@ public BaseResponse getScheduleLists(@RequestParam Loc @Operation(summary = "일정 조회(상세조회)", description = "홈화면의 달력에서 일정을 상세조회하는 API입니다.") @GetMapping("/detail/{scheduleId}") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공"), + @ApiResponse(responseCode = "400", description = "존재하지 않은 스케줄입니다.") + }) public BaseResponse getScheduleDetail(@CurrentMember Member member, @PathVariable("scheduleId") UUID scheduleId) { @@ -54,6 +63,9 @@ public BaseResponse getScheduleDetail(@CurrentMember Member memb @Operation(summary = "캘린더 조회 API", description = "홈 화면의 달력을 조회하는 API입니다.") @PostMapping("/calendar") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공") + }) public BaseResponse getSchedule(@RequestParam LocalDate date) { return BaseResponse.onSuccess(scheduleService.getCalendarByMonth(date)); diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java index 50a263b2..ac4fa92a 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java @@ -8,6 +8,8 @@ import com.umc.networkingService.domain.schedule.service.ScheduleService; import com.umc.networkingService.global.common.base.BaseResponse; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import java.util.UUID; import lombok.RequiredArgsConstructor; @@ -18,7 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -@Tag(name = "운영진 달력 API", description = "운영진 달력 관련 API") +@Tag(name = "운영진 스케줄 API", description = "운영진 스케줄 관련 API") @RestController @RequiredArgsConstructor @RequestMapping("/staff/schedules") @@ -36,6 +38,10 @@ public BaseResponse createSchedule(@CurrentMember Member member, @Operation(summary = "일정 수정 API", description = "운영진 관리 페이지의 일정을 수정하는 API입니다.") @PostMapping("/update/{scheduleId}") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공"), + @ApiResponse(responseCode = "400", description = "존재하지 않은 스케줄입니다.") + }) public BaseResponse updateSchedule(@CurrentMember Member member, @PathVariable("scheduleId") UUID scheduleId, @RequestBody UpdateSchedule request) { @@ -47,6 +53,10 @@ public BaseResponse updateSchedule(@CurrentMember Member member, @Operation(summary = "일정 삭제 API", description = "운영진 관리 페이지의 일정을 삭제하는 API입니다.") @DeleteMapping("/{scheduleId}") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공"), + @ApiResponse(responseCode = "400", description = "존재하지 않은 스케줄입니다.") + }) public BaseResponse deleteSchedule(@CurrentMember Member member, @PathVariable("scheduleId") UUID scheduleId) { diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java index d8db2c30..35e8a05e 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -68,7 +68,7 @@ public static class ScheduleId { @Builder public static class ScheduleDetail { private UUID scheduleId; - private Member writer; + private UUID writerId; private String title; private String content; private LocalDateTime startDateTime; diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index a81f0aea..b8346014 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -21,7 +21,7 @@ public class ScheduleMapper { public ScheduleDetail toScheduleDetail(Schedule schedule) { return ScheduleDetail.builder() .scheduleId(schedule.getId()) - .writer(schedule.getWriter()) + .writerId(schedule.getWriter().getId()) .title(schedule.getTitle()) .content(schedule.getContent()) .startDateTime(schedule.getStartDateTime()) From 474fb4dacbcd91f33231545a67c693dad8b293ce Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Sat, 27 Jan 2024 15:40:14 +0900 Subject: [PATCH 22/27] =?UTF-8?q?fix:=20update,=20delete=20@Transactional?= =?UTF-8?q?=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/service/ScheduleServiceImpl.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index 0c104892..f5ceb8c6 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -20,6 +20,7 @@ import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor @@ -74,6 +75,7 @@ public ScheduleId createSchedule(Member member, CreateSchedule request) { } @Override + @Transactional public ScheduleId updateSchedule(Member member, UUID scheduleId, UpdateSchedule request) { Schedule schedule = scheduleRepository.findById(scheduleId).orElseThrow(() -> new RestApiException(ErrorCode.EMPTY_SCHEDULE)); // 만약 수정하려는 멤버와 일정 작성자가 일치하지 않을 경우 에러 반환 @@ -86,6 +88,7 @@ public ScheduleId updateSchedule(Member member, UUID scheduleId, UpdateSchedule } @Override + @Transactional public ScheduleId deleteSchedule(Member member, UUID scheduleId) { Schedule schedule = scheduleRepository.findById(scheduleId).orElseThrow(() -> new RestApiException(ErrorCode.EMPTY_SCHEDULE)); // 만약 삭제하려는 멤버와 일정 작성자가 일치하지 않을 경우 에러 반환 From df352a6b8985522ca422b38d13fe080b2a4d53b2 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Sat, 27 Jan 2024 15:41:44 +0900 Subject: [PATCH 23/27] =?UTF-8?q?fix:=20=EC=9D=BC=EC=A0=95=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20API=EC=97=90=20@ApiResponses=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/controller/StaffScheduleController.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java index ac4fa92a..b90aa30f 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java @@ -30,6 +30,9 @@ public class StaffScheduleController { @Operation(summary = "일정 추가 API", description = "운영진 관리 페이지의 일정을 추가하는 API입니다.") @PostMapping + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "성공") + }) public BaseResponse createSchedule(@CurrentMember Member member, @RequestBody CreateSchedule request) { From ede32cdc17a72be811827e64a6424fd6d941bb04 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Sat, 27 Jan 2024 15:54:59 +0900 Subject: [PATCH 24/27] =?UTF-8?q?fix:=20ScheduleMapper=20&=20ScheduleRespo?= =?UTF-8?q?nse=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/dto/response/ScheduleResponse.java | 5 ++++- .../domain/schedule/mapper/ScheduleMapper.java | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java index 35e8a05e..c79eede8 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/dto/response/ScheduleResponse.java @@ -2,6 +2,8 @@ import com.umc.networkingService.domain.board.entity.HostType; import com.umc.networkingService.domain.member.entity.Member; +import com.umc.networkingService.domain.member.entity.PositionType; +import com.umc.networkingService.global.common.enums.Role; import com.umc.networkingService.global.common.enums.Semester; import java.time.LocalDateTime; import java.util.List; @@ -68,7 +70,8 @@ public static class ScheduleId { @Builder public static class ScheduleDetail { private UUID scheduleId; - private UUID writerId; + private String writerName; + private String writerNickname; private String title; private String content; private LocalDateTime startDateTime; diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index b8346014..3b361cb7 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -21,7 +21,8 @@ public class ScheduleMapper { public ScheduleDetail toScheduleDetail(Schedule schedule) { return ScheduleDetail.builder() .scheduleId(schedule.getId()) - .writerId(schedule.getWriter().getId()) + .writerName(schedule.getWriter().getName()) + .writerNickname(schedule.getWriter().getNickname()) .title(schedule.getTitle()) .content(schedule.getContent()) .startDateTime(schedule.getStartDateTime()) From deeadd9ad3f6c382cf3d6d1c910c68d1eaff6154 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Sat, 27 Jan 2024 15:55:59 +0900 Subject: [PATCH 25/27] =?UTF-8?q?fix:=20ScheduleTest=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ScheduleControllerTest.java | 26 ---------- .../ScheduleControllerTestConfig.java | 50 ------------------- 2 files changed, 76 deletions(-) delete mode 100644 src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTest.java delete mode 100644 src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTestConfig.java diff --git a/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTest.java b/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTest.java deleted file mode 100644 index eedd5d1b..00000000 --- a/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.umc.networkingService.domain.schedule.controller; - -import com.umc.networkingService.domain.schedule.dto.response.ScheduleResponse.ScheduleInfoSummariesInCalendar; -import com.umc.networkingService.domain.schedule.mapper.ScheduleMapper; -import com.umc.networkingService.domain.schedule.service.ScheduleService; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; - -@DisplayName("Schedule 컨트롤러의") -public class ScheduleControllerTest extends ScheduleControllerTestConfig { - - @Autowired private ScheduleMapper scheduleMapper; - - @MockBean private ScheduleService scheduleService; - - @DisplayName("캘린더 조회 API 테스트") - @Test - public void getScheduleTEst() throws Exception { - // given - Long month = 2L; - - - } -} diff --git a/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTestConfig.java b/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTestConfig.java deleted file mode 100644 index b13a11f9..00000000 --- a/src/test/java/com/umc/networkingService/domain/schedule/controller/ScheduleControllerTestConfig.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.umc.networkingService.domain.schedule.controller; - - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.umc.networkingService.config.security.jwt.JwtTokenProvider; -import com.umc.networkingService.domain.member.entity.Member; -import com.umc.networkingService.domain.member.entity.SocialType; -import com.umc.networkingService.domain.schedule.entity.Schedule; -import com.umc.networkingService.domain.schedule.repository.ScheduleRepository; -import com.umc.networkingService.global.common.enums.Role; -import java.util.UUID; -import org.junit.jupiter.api.BeforeEach; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.test.web.servlet.MockMvc; - -@SpringBootTest -@AutoConfigureMockMvc -public abstract class ScheduleControllerTestConfig { - @Autowired protected MockMvc mockMvc; - @Autowired protected ObjectMapper objectMapper; - @Autowired protected JwtTokenProvider jwtTokenProvider; - @MockBean protected ScheduleRepository scheduleRepository; - - protected Member member; - protected String accessToken; - protected String refreshToken; - - @BeforeEach - public void setup() { - member = createMember(); - setToken(member); - } - - private Member createMember() { - return Member.builder() - .id(UUID.randomUUID()) - .clientId("123456") - .socialType(SocialType.KAKAO) - .role(Role.MEMBER) - .build(); - } - - private void setToken(Member member) { - accessToken = jwtTokenProvider.generateAccessToken(member.getId()); - refreshToken = jwtTokenProvider.generateRefreshToken(member.getId()); - } -} From f0352f0390a2cc156f2033c3039a99d0ac72efee Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Sat, 27 Jan 2024 16:06:44 +0900 Subject: [PATCH 26/27] =?UTF-8?q?fix:=20ScheduleMapper=20updateSchedule=20?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/mapper/ScheduleMapper.java | 4 ---- .../domain/schedule/repository/ScheduleRepository.java | 9 --------- .../domain/schedule/service/ScheduleServiceImpl.java | 3 ++- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java index 3b361cb7..2aaeddff 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/mapper/ScheduleMapper.java @@ -79,10 +79,6 @@ public Schedule createScheduleToSchedule(Member member, CreateSchedule request) .build(); } - public Schedule updateScheduleToSchedule(UpdateSchedule request, Schedule schedule) { - schedule.updateSchedule(request); - return schedule; - } public ScheduleId UUIDtoScheduleId(UUID scheduleId) { return ScheduleId.builder() diff --git a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java index 09bf1303..08342332 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/repository/ScheduleRepository.java @@ -18,13 +18,4 @@ List findSchedulesByYearAndMonth ( @Param("yearMonth") LocalDate date ); -// @Query(value = "SELECT s FROM Schedule s WHERE s.hostType = 1 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL) " + -// "UNION " + -// "SELECT s FROM Schedule s WHERE s.hostType = 2 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL) " + -// "UNION " + -// "SELECT s FROM Schedule s WHERE s.hostType = 3 AND (MONTH(s.startDateTime) <= :month AND :month <= MONTH(s.endDateTime) AND s.deletedAt IS NULL)") -// List> findByHostTypes ( -// @Param("month") Long month -// ); - } diff --git a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java index f5ceb8c6..02403b8e 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/service/ScheduleServiceImpl.java @@ -82,7 +82,8 @@ public ScheduleId updateSchedule(Member member, UUID scheduleId, UpdateSchedule if (!schedule.getWriter().getId().equals(member.getId())) { throw new RestApiException(ErrorCode.NO_PERMISSION_MEMBER); } - schedule = scheduleMapper.updateScheduleToSchedule(request, schedule); + + schedule.updateSchedule(request); return scheduleMapper.UUIDtoScheduleId(schedule.getId()); } From bb77288fac782c290217a5ff040a00b820bc03c5 Mon Sep 17 00:00:00 2001 From: KyungsooLee Date: Sat, 27 Jan 2024 16:08:51 +0900 Subject: [PATCH 27/27] =?UTF-8?q?fix:=20ApiResponse=20responseCode=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/schedule/controller/ScheduleController.java | 2 +- .../domain/schedule/controller/StaffScheduleController.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java index 2c225eec..d7c62a81 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/ScheduleController.java @@ -51,7 +51,7 @@ public BaseResponse getScheduleLists(@RequestParam Loc @GetMapping("/detail/{scheduleId}") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "400", description = "존재하지 않은 스케줄입니다.") + @ApiResponse(responseCode = "SCHEDULE001", description = "존재하지 않은 스케줄입니다.") }) public BaseResponse getScheduleDetail(@CurrentMember Member member, @PathVariable("scheduleId") UUID scheduleId) { diff --git a/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java b/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java index b90aa30f..e667b7c6 100644 --- a/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java +++ b/src/main/java/com/umc/networkingService/domain/schedule/controller/StaffScheduleController.java @@ -43,7 +43,7 @@ public BaseResponse createSchedule(@CurrentMember Member member, @PostMapping("/update/{scheduleId}") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "400", description = "존재하지 않은 스케줄입니다.") + @ApiResponse(responseCode = "SCHEDULE001", description = "존재하지 않은 스케줄입니다.") }) public BaseResponse updateSchedule(@CurrentMember Member member, @PathVariable("scheduleId") UUID scheduleId, @@ -58,7 +58,7 @@ public BaseResponse updateSchedule(@CurrentMember Member member, @DeleteMapping("/{scheduleId}") @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "400", description = "존재하지 않은 스케줄입니다.") + @ApiResponse(responseCode = "SCHEDULE001", description = "존재하지 않은 스케줄입니다.") }) public BaseResponse deleteSchedule(@CurrentMember Member member, @PathVariable("scheduleId") UUID scheduleId) {