From b3ed9427eda2eb0393cd88e709d0c5541a303d6b Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:43:38 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix=20:=20endDate->finishDate=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 --- .../java/com/gongjakso/server/domain/apply/dto/ApplyRes.java | 4 ++-- .../gongjakso/server/domain/apply/dto/ParticipationList.java | 4 ++-- .../java/com/gongjakso/server/domain/apply/dto/PeriodReq.java | 2 +- .../gongjakso/server/domain/apply/service/ApplyService.java | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.java b/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.java index b01da976..721f417d 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.java +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/ApplyRes.java @@ -8,12 +8,12 @@ public record ApplyRes( String title, LocalDateTime startDate, - LocalDateTime endDate, + LocalDateTime finishDate, Long max_person, int current_person, Boolean postType ) { public static ApplyRes of(Post post, int current_person){ - return new ApplyRes(post.getTitle(),post.getStartDate(),post.getEndDate(),post.getMaxPerson(),current_person,post.isPostType()); + return new ApplyRes(post.getTitle(),post.getStartDate(),post.getFinishDate(),post.getMaxPerson(),current_person,post.isPostType()); } } diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/ParticipationList.java b/src/main/java/com/gongjakso/server/domain/apply/dto/ParticipationList.java index 4c40aa02..1c3e3b7b 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/ParticipationList.java +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/ParticipationList.java @@ -11,11 +11,11 @@ public record ParticipationList( CategoryType recruit_part, String leaderName, LocalDateTime startDate, - LocalDateTime endDate, + LocalDateTime finishDate, PostStatus postStatus, Boolean postType ) { public static ParticipationList of(Post post,CategoryType recruit_part) { - return new ParticipationList(post.getTitle(), recruit_part,post.getMember().getName(),post.getStartDate(),post.getEndDate(),post.getStatus(), post.isPostType()); + return new ParticipationList(post.getTitle(), recruit_part,post.getMember().getName(),post.getStartDate(),post.getFinishDate(),post.getStatus(), post.isPostType()); } } diff --git a/src/main/java/com/gongjakso/server/domain/apply/dto/PeriodReq.java b/src/main/java/com/gongjakso/server/domain/apply/dto/PeriodReq.java index 7755dc80..75133972 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/dto/PeriodReq.java +++ b/src/main/java/com/gongjakso/server/domain/apply/dto/PeriodReq.java @@ -3,6 +3,6 @@ import java.time.LocalDateTime; public record PeriodReq( - LocalDateTime endDate + LocalDateTime finishDate ) { } \ No newline at end of file diff --git a/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java b/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java index 33daac79..46836fda 100644 --- a/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java +++ b/src/main/java/com/gongjakso/server/domain/apply/service/ApplyService.java @@ -42,7 +42,7 @@ public void save(Member member, Long post_id, ApplyReq req){ //재지원 판단 if(!applyRepository.existsApplyByMemberAndPost(member, post)){ //지원 기간인지 판단 - if(post.getEndDate().isBefore(LocalDateTime.now())){ + if(post.getFinishDate().isBefore(LocalDateTime.now())){ throw new ApplicationException(ErrorCode.NOT_APPLY_EXCEPTION); }else { Apply apply = req.toEntity(member, post); @@ -174,7 +174,7 @@ public void updatePostPeriod(Long post_id, PeriodReq req) { }else { //공고 상태가 모집 중인지 판단 if(post.getStatus()==RECRUITING){ - post.setEndDate(req.endDate()); + post.setFinishDate(req.finishDate()); }else { throw new ApplicationException(ErrorCode.NOT_RECRUITING_EXCEPION); } From 771d62c179a998759e70ef0a83ecb5b2c7a3af4e Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sat, 17 Feb 2024 20:31:57 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix=20:=20=EC=98=A4=ED=83=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20=EB=B0=8F=20endDate->finishDate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ontroller.java => CalendarController.java} | 20 ++++++++----------- .../server/domain/post/dto/CalendarRes.java | 11 ++++++++++ .../server/domain/post/dto/CalenderRes.java | 13 ------------ .../server/domain/post/dto/ScrapPost.java | 4 ++-- ...enderService.java => CalendarService.java} | 10 ++++------ 5 files changed, 25 insertions(+), 33 deletions(-) rename src/main/java/com/gongjakso/server/domain/post/controller/{CalenderController.java => CalendarController.java} (56%) create mode 100644 src/main/java/com/gongjakso/server/domain/post/dto/CalendarRes.java delete mode 100644 src/main/java/com/gongjakso/server/domain/post/dto/CalenderRes.java rename src/main/java/com/gongjakso/server/domain/post/service/{CalenderService.java => CalendarService.java} (86%) diff --git a/src/main/java/com/gongjakso/server/domain/post/controller/CalenderController.java b/src/main/java/com/gongjakso/server/domain/post/controller/CalendarController.java similarity index 56% rename from src/main/java/com/gongjakso/server/domain/post/controller/CalenderController.java rename to src/main/java/com/gongjakso/server/domain/post/controller/CalendarController.java index 7713267e..a48d2309 100644 --- a/src/main/java/com/gongjakso/server/domain/post/controller/CalenderController.java +++ b/src/main/java/com/gongjakso/server/domain/post/controller/CalendarController.java @@ -1,28 +1,24 @@ package com.gongjakso.server.domain.post.controller; -import com.gongjakso.server.domain.apply.dto.ApplyReq; -import com.gongjakso.server.domain.post.dto.CalenderRes; -import com.gongjakso.server.domain.post.dto.ScrapPost; -import com.gongjakso.server.domain.post.repository.PostScrapRepository; -import com.gongjakso.server.domain.post.service.CalenderService; +import com.gongjakso.server.domain.post.dto.CalendarRes; +import com.gongjakso.server.domain.post.service.CalendarService; import com.gongjakso.server.global.common.ApplicationResponse; import com.gongjakso.server.global.security.PrincipalDetails; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.transaction.Transactional; import lombok.RequiredArgsConstructor; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; @RestController -@RequestMapping("/api/v1/calender") +@RequestMapping("/api/v1/calendar") @RequiredArgsConstructor -@Tag(name = "Calender", description = "캘린더 관련 API") -public class CalenderController { - private final CalenderService calenderService; +@Tag(name = "Calendar", description = "캘린더 관련 API") +public class CalendarController { + private final CalendarService calendarService; @Operation(summary = "캘린더 정보 API", description = "자신이 스크랩한 공고 정보 요청") @GetMapping("") - public ApplicationResponse addApply(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestParam(name = "year", defaultValue = "2024") int year, @RequestParam(name = "month", defaultValue = "11") int month){ - return ApplicationResponse.ok(calenderService.findScrapPost(principalDetails.getMember(),year,month)); + public ApplicationResponse addApply(@AuthenticationPrincipal PrincipalDetails principalDetails, @RequestParam(name = "year", defaultValue = "2024") int year, @RequestParam(name = "month", defaultValue = "11") int month){ + return ApplicationResponse.ok(calendarService.findScrapPost(principalDetails.getMember(),year,month)); } } diff --git a/src/main/java/com/gongjakso/server/domain/post/dto/CalendarRes.java b/src/main/java/com/gongjakso/server/domain/post/dto/CalendarRes.java new file mode 100644 index 00000000..80e66a51 --- /dev/null +++ b/src/main/java/com/gongjakso/server/domain/post/dto/CalendarRes.java @@ -0,0 +1,11 @@ +package com.gongjakso.server.domain.post.dto; + +import java.util.List; + +public record CalendarRes( + List scrapPosts +) { + public static CalendarRes of(List scrapPosts){ + return new CalendarRes(scrapPosts); + } +} diff --git a/src/main/java/com/gongjakso/server/domain/post/dto/CalenderRes.java b/src/main/java/com/gongjakso/server/domain/post/dto/CalenderRes.java deleted file mode 100644 index 3b17d4b7..00000000 --- a/src/main/java/com/gongjakso/server/domain/post/dto/CalenderRes.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.gongjakso.server.domain.post.dto; - -import com.gongjakso.server.domain.post.entity.Post; - -import java.util.List; - -public record CalenderRes( - List scrapPosts -) { - public static CalenderRes of(List scrapPosts){ - return new CalenderRes(scrapPosts); - } -} diff --git a/src/main/java/com/gongjakso/server/domain/post/dto/ScrapPost.java b/src/main/java/com/gongjakso/server/domain/post/dto/ScrapPost.java index 716c410d..03501b86 100644 --- a/src/main/java/com/gongjakso/server/domain/post/dto/ScrapPost.java +++ b/src/main/java/com/gongjakso/server/domain/post/dto/ScrapPost.java @@ -7,10 +7,10 @@ public record ScrapPost( long postId, String title, - LocalDateTime endDate, + LocalDateTime finishDate, Boolean postType ) { public static ScrapPost of(Post post){ - return new ScrapPost(post.getPostId(),post.getTitle(),post.getEndDate(),post.isPostType()); + return new ScrapPost(post.getPostId(),post.getTitle(),post.getFinishDate(),post.isPostType()); } } diff --git a/src/main/java/com/gongjakso/server/domain/post/service/CalenderService.java b/src/main/java/com/gongjakso/server/domain/post/service/CalendarService.java similarity index 86% rename from src/main/java/com/gongjakso/server/domain/post/service/CalenderService.java rename to src/main/java/com/gongjakso/server/domain/post/service/CalendarService.java index bd36e5b3..bbb85aaa 100644 --- a/src/main/java/com/gongjakso/server/domain/post/service/CalenderService.java +++ b/src/main/java/com/gongjakso/server/domain/post/service/CalendarService.java @@ -1,8 +1,7 @@ package com.gongjakso.server.domain.post.service; -import com.gongjakso.server.domain.apply.dto.ApplyList; import com.gongjakso.server.domain.member.entity.Member; -import com.gongjakso.server.domain.post.dto.CalenderRes; +import com.gongjakso.server.domain.post.dto.CalendarRes; import com.gongjakso.server.domain.post.dto.ScrapPost; import com.gongjakso.server.domain.post.entity.Post; import com.gongjakso.server.domain.post.entity.PostScrap; @@ -15,23 +14,22 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; -import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @Service @Transactional @RequiredArgsConstructor -public class CalenderService { +public class CalendarService { private final PostScrapRepository postScrapRepository; private final PostRepository postRepository; - public CalenderRes findScrapPost(Member member,int year,int month){ + public CalendarRes findScrapPost(Member member, int year, int month){ List postScraps = postScrapRepository.findByMemberAndScrapStatus(member,true); List postIdList = postScraps.stream().map(postScrap -> postScrap.getPost().getPostId()).toList(); List posts = postRepository.findAllByEndDateBetweenAndPostIdIn(getFirstDayOfMonth(year,month),getLastDayOfMonth(year,month), postIdList); List scrapPosts = posts.stream().map(ScrapPost::of) .collect(Collectors.toList()); - return CalenderRes.of(scrapPosts); + return CalendarRes.of(scrapPosts); } public static LocalDateTime getFirstDayOfMonth(int year, int month) { LocalDate firstDayOfMonth = LocalDate.of(year, month, 1); From f2dfb6fc4081c79e373703c6aad2d01efa0a0a16 Mon Sep 17 00:00:00 2001 From: sycuuui <102959791+sycuuui@users.noreply.github.com> Date: Sat, 17 Feb 2024 20:35:10 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix=20:=20calendar=20endDate=EB=A1=9C=20?= =?UTF-8?q?=EB=8B=A4=EC=8B=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/gongjakso/server/domain/post/dto/ScrapPost.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gongjakso/server/domain/post/dto/ScrapPost.java b/src/main/java/com/gongjakso/server/domain/post/dto/ScrapPost.java index 03501b86..716c410d 100644 --- a/src/main/java/com/gongjakso/server/domain/post/dto/ScrapPost.java +++ b/src/main/java/com/gongjakso/server/domain/post/dto/ScrapPost.java @@ -7,10 +7,10 @@ public record ScrapPost( long postId, String title, - LocalDateTime finishDate, + LocalDateTime endDate, Boolean postType ) { public static ScrapPost of(Post post){ - return new ScrapPost(post.getPostId(),post.getTitle(),post.getFinishDate(),post.isPostType()); + return new ScrapPost(post.getPostId(),post.getTitle(),post.getEndDate(),post.isPostType()); } }