Skip to content

Commit

Permalink
Merge pull request #22 from Timetris-Trendithon/mainpage
Browse files Browse the repository at this point in the history
βͺFix: λ©”μΈνŽ˜μ΄μ§€ 접속 κ°€λŠ₯ν•˜κ²Œ λ‹€μ‹œ μˆ˜μ •
  • Loading branch information
Zena0128 authored Feb 20, 2024
2 parents 7e02c48 + 30fb856 commit 6cd9d25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class MainPageController {
private final MainPageService mainPageService;
private final TokenProvider tokenProvider;

@GetMapping
// @GetMapping
public ApiResponse<MyPageResponse.getMyPageDTO> getMainPage(HttpServletRequest request) {

Long userId = tokenProvider.getUserId(request);
Expand All @@ -33,7 +33,7 @@ public ApiResponse<MyPageResponse.getMyPageDTO> getMainPage(HttpServletRequest r
return ApiResponse.success(SuccessStatus.OK, mainPageDTO);
}

@GetMapping("/test")
@GetMapping("")
public ApiResponse<MainPageDTO> getMainPage2(HttpServletRequest request) {

Long userId = tokenProvider.getUserId(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ public class MainPageServiceImpl implements MainPageService{
public MainPageDTO getMainPage(long userId) {
LocalDate localDate = LocalDate.now();
Date date = dateRepository.findByDate(localDate);
User user = userRepository.findById(userId)
.orElseThrow(() -> new CustomException(ErrorStatus.USER_NOT_FOUND_ERROR));

if (userRepository.findById(userId).isEmpty()){
throw new CustomException(ErrorStatus.USER_NOT_FOUND_ERROR);
}
UserDate userDate = userDateRepository.findByUser_IdAndDate_Id(userId, date.getId());
if (userDate == null){
UserDateCreateDTO userDateCreateDTO = new UserDateCreateDTO(user, date);
UserDate userDate1 = new UserDate(userDateCreateDTO);
userDateRepository.save(userDate1);
}

List<Plan> planList = planRepository.findAllByUserDate(userDate);
List<Do> doList = doRepository.findAllByUserDate(userDate);
Expand All @@ -63,6 +67,7 @@ public void createUserDate() {
DateCreateDTO dateCreateDTO = new DateCreateDTO(localDate);
Date date = new Date(dateCreateDTO);
dateRepository.save(date);
System.out.println("created Date: "+localDate);
users.stream()
.forEach(user -> {
UserDateCreateDTO userDateCreateDTO = new UserDateCreateDTO(user, date);
Expand Down

0 comments on commit 6cd9d25

Please sign in to comment.