Skip to content

Commit

Permalink
Merge pull request #81 from LetsCareer-A/refactor/#80
Browse files Browse the repository at this point in the history
#80 [refactor] paging 수정
  • Loading branch information
pkl0912 authored Sep 7, 2024
2 parents ef60457 + 96859e3 commit 39f5cf7
Show file tree
Hide file tree
Showing 11 changed files with 255 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,32 @@
public class ScheduleController {
private final ScheduleService scheduleService;

@GetMapping
public ApiResponse getSchedules(
@GetMapping("/coming")
public ApiResponse getSchedulesComing(
@RequestHeader("userId") Long userId,
@RequestParam("month") int month,
@RequestParam("page") int page,
@RequestParam("size") int size) {
try {
ScheduleResponse scheduleResponse = scheduleService.getSchedules(userId, month, page, size);
ScheduleResponse scheduleResponse = scheduleService.getSchedulesComing(userId, month, page, size);
return SuccessResponse.success(SuccessCode.SCHEDULE_SUCCESS, scheduleResponse);
}catch (NotFoundException | BadRequestException e) {
return ErrorResponse.error(e.getErrorCode());
}
}

@GetMapping("/calendar")
public ApiResponse getSchedulesCalendar(
@RequestHeader("userId") Long userId,
@RequestParam("month") int month) {
try {
CalendarResponse calendarResponse= scheduleService.getSchedulesCalendar(userId, month);
return SuccessResponse.success(SuccessCode.SCHEDULE_SUCCESS, calendarResponse);
}catch (NotFoundException | BadRequestException e) {
return ErrorResponse.error(e.getErrorCode());
}
}

@GetMapping("/date")
public ApiResponse getDateSchedules(
@RequestHeader("userId") Long userId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public record AlwaysResponse(
Integer page,
Integer size,
Long total,
List<AlwaysDTO> always
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.example.letscareer.schedule.domain.dto.response;

import com.example.letscareer.schedule.domain.dto.StageDTO;

import java.util.List;

public record CalendarResponse(
Integer docCount,
Integer midCount,
Integer interviewCount,
List<StageDTO> schedules
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public record CompanyReviewListResponse(
Integer page,
Integer size,
Long total,
List<CompanyReviewDTO> companies
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public record FastReviewListResponse(
Integer page,
Integer size,
Integer cnt,
Integer total,
List<FastDTO> fastReviews
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
public record ScheduleResponse(
Integer page,
Integer size,
Integer docCount,
Integer midCount,
Integer interviewCount,
Long total,
List<StageDTO> schedules

) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface ScheduleRepository extends JpaRepository<Schedule, Long> {
Page<Schedule> findAllByUserUserIdAndAlwaysTrue(Long userId, Pageable pageable);
Page<Schedule> findAllByUserUserId(Long userId, Pageable pageable);
List<Schedule> findAllByUserUserId(Long userId);
Optional<Schedule> findByUserAndScheduleId(User user, Long scheduleId);

@Query("SELECT DISTINCT s.company FROM Schedule s WHERE s.user = :user")
Page<String> findDistinctCompanyByUser(User user, Pageable pageable);
List<Schedule> findAllByUserAndCompany(User user, String company);

}
Loading

0 comments on commit 39f5cf7

Please sign in to comment.