diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/controller/DoController.java b/src/main/java/com/trendithon/timetris/domain/mainpage/controller/DoController.java index 2bf368b..9397e2a 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/controller/DoController.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/controller/DoController.java @@ -51,7 +51,7 @@ public ApiResponse createDo(HttpServletRequest request, @PutMapping("/{doId}") public ApiResponse updateDo(HttpServletRequest request, @PathVariable long doId, - @RequestBody DoViewDTO doViewDTO) + @RequestBody DoRequestDTO doRequestDTO) { String accessToken = tokenProvider.extractAccessToken(request).orElse(null); @@ -67,7 +67,7 @@ public ApiResponse updateDo(HttpServletRequest request, throw new CustomException(ErrorStatus.USER_NOT_FOUND_ERROR); } - doService.updateDo(userId, doId, doViewDTO); + doService.updateDo(userId, doId, doRequestDTO); return ApiResponse.success(SuccessStatus.OK); } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/controller/PlanController.java b/src/main/java/com/trendithon/timetris/domain/mainpage/controller/PlanController.java index ddd0761..1525602 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/controller/PlanController.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/controller/PlanController.java @@ -53,7 +53,7 @@ public ApiResponse createPlan(HttpServletRequest request, @PutMapping("/{planId}") public ApiResponse updatePlan(HttpServletRequest request, @PathVariable long planId, - @RequestBody PlanViewDTO planViewDTO) + @RequestBody PlanRequestDTO planRequestDTO) { String accessToken = tokenProvider.extractAccessToken(request).orElse(null); @@ -69,7 +69,7 @@ public ApiResponse updatePlan(HttpServletRequest request, throw new CustomException(ErrorStatus.USER_NOT_FOUND_ERROR); } - planService.updatePlan(userId, planId, planViewDTO); + planService.updatePlan(userId, planId, planRequestDTO); return ApiResponse.success(SuccessStatus.OK); } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/controller/SeeController.java b/src/main/java/com/trendithon/timetris/domain/mainpage/controller/SeeController.java index 95d9a4f..f7a43f5 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/controller/SeeController.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/controller/SeeController.java @@ -51,7 +51,7 @@ public ApiResponse createSee(HttpServletRequest request, @PutMapping("/{seeId}") public ApiResponse updateSee(HttpServletRequest request, @PathVariable long seeId, - @RequestBody SeeViewDTO seeViewDTO) + @RequestBody SeeRequestDTO seeRequestDTO) { String accessToken = tokenProvider.extractAccessToken(request).orElse(null); @@ -67,7 +67,7 @@ public ApiResponse updateSee(HttpServletRequest request, throw new CustomException(ErrorStatus.USER_NOT_FOUND_ERROR); } - seeService.updateSee(userId, seeId, seeViewDTO); + seeService.updateSee(userId, seeId, seeRequestDTO); return ApiResponse.success(SuccessStatus.OK); } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Do.java b/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Do.java index fbdcb30..85c6e7f 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Do.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Do.java @@ -35,10 +35,11 @@ public Do(DoCreateDTO doCreateDTO, UserDate userDate){ this.userDate = userDate; } - public void updateDo(String title, LocalTime startTime, LocalTime endTime){ + public void updateDo(String title, LocalTime startTime, LocalTime endTime, Category category){ this.title = title; this.startTime = startTime; this.endTime = endTime; + this.category = category; } } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Plan.java b/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Plan.java index fc4ec8f..c4549d7 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Plan.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/domain/Plan.java @@ -36,10 +36,11 @@ public Plan(PlanCreateDTO planCreateDTO, UserDate userDate){ this.userDate = userDate; } - public void updatePlan(String title, LocalTime startTime, LocalTime endTime){ + public void updatePlan(String title, LocalTime startTime, LocalTime endTime, Category category){ this.title = title; this.startTime = startTime; this.endTime = endTime; + this.category = category; } public void donePlan(){ diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryCreateDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryCreateDTO.java index 893a450..61b29e9 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryCreateDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryCreateDTO.java @@ -11,6 +11,5 @@ public class CategoryCreateDTO { private String name; private String colorCode; - private User user; } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryViewDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryViewDTO.java index 68adc46..b5a7715 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryViewDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/CategoryViewDTO.java @@ -14,11 +14,13 @@ @AllArgsConstructor @NoArgsConstructor public class CategoryViewDTO { + private long id; private String name; private String colorCode; public static CategoryViewDTO of(Category category){ return CategoryViewDTO.builder() + .id(category.getId()) .name(category.getName()) .colorCode(category.getColorCode()) .build(); diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoCreateDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoCreateDTO.java index d43aa75..027297d 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoCreateDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoCreateDTO.java @@ -16,6 +16,5 @@ public class DoCreateDTO { private LocalTime startTime; private LocalTime endTime; private Category category; - private UserDate userDate; } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoRequestDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoRequestDTO.java index b35f106..387518d 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoRequestDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoRequestDTO.java @@ -14,6 +14,5 @@ public class DoRequestDTO { private LocalTime startTime; private LocalTime endTime; private long categoryId; - private long userDateId; } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoViewDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoViewDTO.java index a91a453..b7a27cb 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoViewDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/DoViewDTO.java @@ -16,6 +16,7 @@ @AllArgsConstructor @NoArgsConstructor public class DoViewDTO { + private long id; private String title; private LocalTime startTime; private LocalTime endTime; @@ -23,6 +24,7 @@ public class DoViewDTO { public static DoViewDTO of(Do does){ return DoViewDTO.builder() + .id(does.getId()) .title(does.getTitle()) .startTime(does.getStartTime()) .endTime(does.getEndTime()) diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanCreateDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanCreateDTO.java index cc3d331..74ab893 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanCreateDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanCreateDTO.java @@ -17,6 +17,5 @@ public class PlanCreateDTO { private LocalTime endTime; private boolean status; private Category category; - private UserDate userDate; } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanRequestDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanRequestDTO.java index af50a73..39bde55 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanRequestDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanRequestDTO.java @@ -15,6 +15,5 @@ public class PlanRequestDTO { private LocalTime endTime; private boolean status; private long categoryId; - private long userDateId; } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanViewDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanViewDTO.java index f6b96f6..18f5a11 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanViewDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/PlanViewDTO.java @@ -15,6 +15,7 @@ @AllArgsConstructor @NoArgsConstructor public class PlanViewDTO { + private long id; private String title; private LocalTime startTime; private LocalTime endTime; @@ -23,6 +24,7 @@ public class PlanViewDTO { public static PlanViewDTO of(Plan plan){ return PlanViewDTO.builder() + .id(plan.getId()) .title(plan.getTitle()) .startTime(plan.getStartTime()) .endTime(plan.getEndTime()) diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeCreateDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeCreateDTO.java index a7a5ce8..1196623 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeCreateDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeCreateDTO.java @@ -10,6 +10,5 @@ public class SeeCreateDTO { private String content; - private UserDate userDate; } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeRequestDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeRequestDTO.java index 3a202c8..7ec185b 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeRequestDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeRequestDTO.java @@ -9,6 +9,5 @@ public class SeeRequestDTO { private String content; - private long userDateId; } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeViewDTO.java b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeViewDTO.java index e0c6f08..61a6ff3 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeViewDTO.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/dto/SeeViewDTO.java @@ -14,10 +14,12 @@ @AllArgsConstructor @NoArgsConstructor public class SeeViewDTO { + private long id; private String content; public static SeeViewDTO of(See see){ return SeeViewDTO.builder() + .id(see.getId()) .content(see.getContent()) .build(); } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/service/CategoryServiceImpl.java b/src/main/java/com/trendithon/timetris/domain/mainpage/service/CategoryServiceImpl.java index 9584be5..74d6710 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/service/CategoryServiceImpl.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/service/CategoryServiceImpl.java @@ -35,7 +35,7 @@ public List readCategoryAll(long userId) { public Category createCategory(long userId, CategoryRequestDTO categoryRequestDTO) { User user = userRepository.findById(userId) .orElseThrow(() -> new CustomException(ErrorStatus.USER_NOT_FOUND_ERROR)); - CategoryCreateDTO categoryCreateDTO = new CategoryCreateDTO(categoryRequestDTO.getName(), categoryRequestDTO.getColorCode(), user); + CategoryCreateDTO categoryCreateDTO = new CategoryCreateDTO(categoryRequestDTO.getName(), categoryRequestDTO.getColorCode()); Category category = new Category(categoryCreateDTO, user); return categoryRepository.save(category); } @@ -48,6 +48,7 @@ public void updateCategory(long userId, long categoryId, CategoryViewDTO categor throw new CustomException(ErrorStatus.NO_PERMISSION_ERROR); } category.updateCategory(categoryViewDTO.getName(), categoryViewDTO.getColorCode()); + categoryRepository.save(category); } @Override diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/service/DoService.java b/src/main/java/com/trendithon/timetris/domain/mainpage/service/DoService.java index 4c9914d..7c452ee 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/service/DoService.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/service/DoService.java @@ -9,6 +9,6 @@ @Service public interface DoService { Do createDo(long userId, DoRequestDTO doRequestDTO); - void updateDo(long userId, long doId, DoViewDTO doViewDTO); + void updateDo(long userId, long doId, DoRequestDTO doRequestDTO); void deleteDo(long userId, long doId); } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/service/DoServiceImpl.java b/src/main/java/com/trendithon/timetris/domain/mainpage/service/DoServiceImpl.java index 5b07e32..5a3727f 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/service/DoServiceImpl.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/service/DoServiceImpl.java @@ -17,6 +17,7 @@ import org.springframework.stereotype.Service; import java.time.LocalDate; +import java.util.concurrent.CancellationException; @Service @RequiredArgsConstructor @@ -34,19 +35,21 @@ public Do createDo(long userId, DoRequestDTO doRequestDTO) { UserDate userDate = userDateRepository.findByUser_IdAndDate_Id(userId, date.getId()); Category category = categoryRepository.findById(doRequestDTO.getCategoryId()) .orElseThrow(() -> new CustomException(ErrorStatus.CATEGORY_NOT_FOUND_ERROR)); - DoCreateDTO doCreateDTO = new DoCreateDTO(doRequestDTO.getTitle(), doRequestDTO.getStartTime(), doRequestDTO.getEndTime(), category, userDate); + DoCreateDTO doCreateDTO = new DoCreateDTO(doRequestDTO.getTitle(), doRequestDTO.getStartTime(), doRequestDTO.getEndTime(), category); Do done = new Do(doCreateDTO, userDate); return doRepository.save(done); } @Override - public void updateDo(long userId, long doId, DoViewDTO doViewDTO) { + public void updateDo(long userId, long doId, DoRequestDTO doRequestDTO) { Do done = doRepository.findById(doId) .orElseThrow(() -> new CustomException(ErrorStatus.DO_NOT_FOUND_ERROR)); if (done.getUserDate().getUser().getId() != userId){ throw new CustomException(ErrorStatus.NO_PERMISSION_ERROR); } - done.updateDo(doViewDTO.getTitle(), doViewDTO.getStartTime(), doViewDTO.getEndTime()); + Category category = categoryRepository.findById(doRequestDTO.getCategoryId()) + .orElseThrow(() -> new CustomException(ErrorStatus.CATEGORY_NOT_FOUND_ERROR)); + done.updateDo(doRequestDTO.getTitle(), doRequestDTO.getStartTime(), doRequestDTO.getEndTime(), category); } @Override diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/service/PlanService.java b/src/main/java/com/trendithon/timetris/domain/mainpage/service/PlanService.java index 85f947f..e8b8194 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/service/PlanService.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/service/PlanService.java @@ -10,7 +10,7 @@ public interface PlanService { Plan createPlan(long userId, PlanRequestDTO planRequestDTO); - void updatePlan(long userId, long planId, PlanViewDTO planViewDTO); + void updatePlan(long userId, long planId, PlanRequestDTO planRequestDTO); void deletePlan(long userId, long planId); void donePlan(long userId, long planId); diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/service/PlanServiceImpl.java b/src/main/java/com/trendithon/timetris/domain/mainpage/service/PlanServiceImpl.java index e3341a5..805ec1c 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/service/PlanServiceImpl.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/service/PlanServiceImpl.java @@ -34,19 +34,22 @@ public Plan createPlan(long userId, PlanRequestDTO planRequestDTO) { UserDate userDate = userDateRepository.findByUser_IdAndDate_Id(userId, date.getId()); Category category = categoryRepository.findById(planRequestDTO.getCategoryId()) .orElseThrow(() -> new CustomException(ErrorStatus.CATEGORY_NOT_FOUND_ERROR)); - PlanCreateDTO planCreateDTO = new PlanCreateDTO(planRequestDTO.getTitle(), planRequestDTO.getStartTime(), planRequestDTO.getEndTime(), planRequestDTO.isStatus(), category, userDate); + PlanCreateDTO planCreateDTO = new PlanCreateDTO(planRequestDTO.getTitle(), planRequestDTO.getStartTime(), planRequestDTO.getEndTime(), planRequestDTO.isStatus(), category); Plan plan = new Plan(planCreateDTO, userDate); return planRepository.save(plan); } @Override - public void updatePlan(long userId, long planId, PlanViewDTO planViewDTO) { + public void updatePlan(long userId, long planId, PlanRequestDTO planRequestDTO) { Plan plan = planRepository.findById(planId) .orElseThrow(() -> new CustomException(ErrorStatus.PLAN_NOT_FOUND_ERROR)); + long categoryId = planRequestDTO.getCategoryId(); + Category category = categoryRepository.findById(categoryId) + .orElseThrow(() -> new CustomException(ErrorStatus.CATEGORY_NOT_FOUND_ERROR)); if (plan.getUserDate().getUser().getId() != userId) { throw new CustomException(ErrorStatus.NO_PERMISSION_ERROR); } - plan.updatePlan(planViewDTO.getTitle(), planViewDTO.getStartTime(), planViewDTO.getEndTime()); + plan.updatePlan(planRequestDTO.getTitle(), planRequestDTO.getStartTime(), planRequestDTO.getEndTime(), category); } @Override diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/service/SeeService.java b/src/main/java/com/trendithon/timetris/domain/mainpage/service/SeeService.java index 4491b78..a39c7df 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/service/SeeService.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/service/SeeService.java @@ -9,6 +9,6 @@ @Service public interface SeeService { See createSee(long userId, SeeRequestDTO seeRequestDTO); - void updateSee(long userId, long seeId, SeeViewDTO seeViewDTO); + void updateSee(long userId, long seeId, SeeRequestDTO seeRequestDTO); void deleteSee(long userId, long seeId); } diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/service/SeeServiceImpl.java b/src/main/java/com/trendithon/timetris/domain/mainpage/service/SeeServiceImpl.java index 6e2ed49..dc4583c 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/service/SeeServiceImpl.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/service/SeeServiceImpl.java @@ -32,19 +32,19 @@ public See createSee(long userId, SeeRequestDTO seeRequestDTO) { LocalDate localDate = LocalDate.now(); Date date = dateRepository.findByDate(localDate); UserDate userDate = userDateRepository.findByUser_IdAndDate_Id(userId, date.getId()); - SeeCreateDTO seeCreateDTO = new SeeCreateDTO(seeRequestDTO.getContent(), userDate); + SeeCreateDTO seeCreateDTO = new SeeCreateDTO(seeRequestDTO.getContent()); See see = new See(seeCreateDTO, userDate); return seeRepository.save(see); } @Override - public void updateSee(long userId, long seeId, SeeViewDTO seeViewDTO) { + public void updateSee(long userId, long seeId, SeeRequestDTO seeRequestDTO) { See see = seeRepository.findById(seeId) .orElseThrow(() -> new CustomException(ErrorStatus.SEE_NOT_FOUND_ERROR)); if (see.getUserDate().getUser().getId() != userId){ throw new CustomException(ErrorStatus.NO_PERMISSION_ERROR); } - see.updateSee(seeViewDTO.getContent()); + see.updateSee(seeRequestDTO.getContent()); } @Override