From eb8b1bf48d6ca7b68752713a690b5b38972c3693 Mon Sep 17 00:00:00 2001 From: MyunghyunNero <91003734+MyunghyunNero@users.noreply.github.com> Date: Thu, 23 Nov 2023 09:51:46 +0900 Subject: [PATCH] Hotfix/program (#39) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * hot fix : 이미지 변경사항이 있는지 공고등록 model에 추가 * hot fix : 공고 등록할때 마감일이 현재시간보다 전이면 마감상태로 저장 * hotfix : 진행중인 공고 마감일 오타 수정 --- .../gallae/dto/program/ProgramManagerRes.java | 2 +- .../service/admin/ManagerServiceImpl.java | 27 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/kusitms/gallae/dto/program/ProgramManagerRes.java b/src/main/java/kusitms/gallae/dto/program/ProgramManagerRes.java index 4ba8d0e..3a446b4 100644 --- a/src/main/java/kusitms/gallae/dto/program/ProgramManagerRes.java +++ b/src/main/java/kusitms/gallae/dto/program/ProgramManagerRes.java @@ -17,5 +17,5 @@ public class ProgramManagerRes { private LocalDate recruitStartDate; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "Asia/Seoul") - private LocalDate recuritEndDate; + private LocalDate recruitEndDate; } diff --git a/src/main/java/kusitms/gallae/service/admin/ManagerServiceImpl.java b/src/main/java/kusitms/gallae/service/admin/ManagerServiceImpl.java index 9ac60bf..21aa559 100644 --- a/src/main/java/kusitms/gallae/service/admin/ManagerServiceImpl.java +++ b/src/main/java/kusitms/gallae/service/admin/ManagerServiceImpl.java @@ -21,6 +21,7 @@ import org.springframework.stereotype.Service; import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -97,6 +98,8 @@ public ProgramPostReq getTempProgram(String username) { } @Override public Long postProgram(ProgramPostReq programPostReq ,String username) { + LocalDateTime localDateTime = LocalDateTime.now().plusHours(9); + LocalDate localdate = localDateTime.toLocalDate(); User user = userRepository.findById(Long.valueOf(username)).get(); Program tempProgram = programRespository.findByUserIdAndStatus(user.getId(), //나중에 유저 생기면 수정 필요 Program.ProgramStatus.TEMP); @@ -106,18 +109,25 @@ public Long postProgram(ProgramPostReq programPostReq ,String username) { Program saveProgram = this.getProgramEntity(program,programPostReq); saveProgram.setUser(user); saveProgram.setStatus(Program.ProgramStatus.SAVE); + if(saveProgram.getRecruitEndDate().isBefore(localdate)){ + saveProgram.setStatus(Program.ProgramStatus.FINISH); + } Program programId = programRespository.save(saveProgram); return programId.getId(); }else { //임시 저장이 있으면 Program saveProgram = this.getProgramEntity(tempProgram, programPostReq); saveProgram.setStatus(Program.ProgramStatus.SAVE); + if(saveProgram.getRecruitEndDate().isBefore(localdate)){ + saveProgram.setStatus(Program.ProgramStatus.FINISH); + } return tempProgram.getId(); } } @Override public Long editProgram(ProgramPostReq programPostReq ,String username) { - + LocalDateTime localDateTime = LocalDateTime.now().plusHours(9); + LocalDate localdate = localDateTime.toLocalDate(); User user = userRepository.findById(Long.valueOf(username)).get(); Program tempProgram = programRespository.findById(programPostReq.getProgramId()).orElse(null); if(user.getId() != tempProgram.getUser().getId()) { @@ -125,6 +135,9 @@ public Long editProgram(ProgramPostReq programPostReq ,String username) { } Program saveProgram = this.getProgramEntity(tempProgram,programPostReq); + if(saveProgram.getRecruitEndDate().isBefore(localdate)){ + saveProgram.setStatus(Program.ProgramStatus.FINISH); + } saveProgram.setStatus(Program.ProgramStatus.SAVE); Program programId = programRespository.save(saveProgram); return programId.getId(); @@ -135,17 +148,24 @@ public Long postTempProgram(ProgramPostReq programPostReq , String username) { User user = userRepository.findById(Long.valueOf(username)).get(); Program tempProgram = programRespository.findByUserIdAndStatus(user.getId(), //나중에 유저 생기면 수정 필요 Program.ProgramStatus.TEMP); - + LocalDateTime localDateTime = LocalDateTime.now().plusHours(9); + LocalDate localdate = localDateTime.toLocalDate(); if(tempProgram == null) { //임시 저장이 없으면 Program program = new Program(); Program saveProgram = this.getProgramEntity(program,programPostReq); saveProgram.setUser(user); saveProgram.setStatus(Program.ProgramStatus.TEMP); + if(saveProgram.getRecruitEndDate().isBefore(localdate)){ + saveProgram.setStatus(Program.ProgramStatus.FINISH); + } Program programId = programRespository.save(saveProgram); return programId.getId(); }else { //임시 저장이 있으면 Program saveProgram = this.getProgramEntity(tempProgram, programPostReq); saveProgram.setStatus(Program.ProgramStatus.TEMP); + if(saveProgram.getRecruitEndDate().isBefore(localdate)){ + saveProgram.setStatus(Program.ProgramStatus.FINISH); + } return saveProgram.getId(); } } @@ -192,7 +212,7 @@ private List getProgramManagerRes(List programs){ programManagerRes.setLike(program.getProgramLike()); programManagerRes.setViewCount(program.getViewCount()); programManagerRes.setRecruitStartDate(program.getRecruitStartDate()); - programManagerRes.setRecuritEndDate(program.getRecruitEndDate()); + programManagerRes.setRecruitEndDate(program.getRecruitEndDate()); return programManagerRes; }).collect(Collectors.toList()); } @@ -219,6 +239,7 @@ private Program getProgramEntity(Program program ,ProgramPostReq programPostReq) program.setDescription(programPostReq.getBody()); program.setProgramLike(0L); program.setViewCount(0L); + return program; } }