Merge branch 'Be/Report' into 'backend'

[Back-End] feat : report 정렬 변경

See merge request s11-webmobile1-sub2/S11P12A701!130
This commit is contained in:
박정민 2024-08-09 10:57:02 +09:00
commit 9ac747c1d1
3 changed files with 6 additions and 10 deletions

View File

@ -9,13 +9,9 @@ import java.util.UUID;
@Repository @Repository
public interface ReportRepository extends JpaRepository<Report, Long> { public interface ReportRepository extends JpaRepository<Report, Long> {
List<Report> findByUserId(long userId);
List<Report> findByLectureId(long lectureId);
Report findByReportSetIdAndUserId(UUID reportSetId, long userId); Report findByReportSetIdAndUserId(UUID reportSetId, long userId);
List<Report> findByReportSetId(UUID reportSetId); List<Report> findByReportSetIdOrderById(UUID reportSetId);
List<Report> findByLectureIdAndUserId(long lectureId, long userId); List<Report> findByLectureIdAndUserIdOrderById(long lectureId, long userId);
} }

View File

@ -9,5 +9,5 @@ import java.util.UUID;
@Repository @Repository
public interface ReportSetRepository extends JpaRepository<ReportSet, UUID> { public interface ReportSetRepository extends JpaRepository<ReportSet, UUID> {
List<ReportSet> findByLectureId(long userId); List<ReportSet> findByLectureIdOrderById(long userId);
} }

View File

@ -125,7 +125,7 @@ public class ReportServiceImpl implements ReportService {
@Override @Override
public List<ReportSetResponse> findReportSets(long lectureId) { public List<ReportSetResponse> findReportSets(long lectureId) {
List<ReportSet> reportSets = reportSetRepository.findByLectureId(lectureId); List<ReportSet> reportSets = reportSetRepository.findByLectureIdOrderById(lectureId);
return reportSets.stream() return reportSets.stream()
.map(ReportSet::makeReportSetResponse) .map(ReportSet::makeReportSetResponse)
@ -134,7 +134,7 @@ public class ReportServiceImpl implements ReportService {
@Override @Override
public List<ReportResponse> findReports(UUID reportSetId) { public List<ReportResponse> findReports(UUID reportSetId) {
List<Report> reports = reportRepository.findByReportSetId(reportSetId); List<Report> reports = reportRepository.findByReportSetIdOrderById(reportSetId);
return reports.stream() return reports.stream()
.map(Report::makeReportResponse) .map(Report::makeReportResponse)
@ -143,7 +143,7 @@ public class ReportServiceImpl implements ReportService {
@Override @Override
public List<ReportResponse> findReports(long lectureId, long userId) { public List<ReportResponse> findReports(long lectureId, long userId) {
List<Report> reports = reportRepository.findByLectureIdAndUserId(lectureId, userId); List<Report> reports = reportRepository.findByLectureIdAndUserIdOrderById(lectureId, userId);
return reports.stream() return reports.stream()
.map(Report::makeReportResponse) .map(Report::makeReportResponse)