Merge branch 'Be/Report' into 'backend'

feat : report 정렬

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

View File

@ -9,13 +9,10 @@ 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> findByReportSetIdDesc(UUID reportSetId);
List<Report> findByLectureIdAndUserId(long lectureId, long userId); List<Report> findByLectureIdAndUserIdDesc(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> findByLectureIdDesc(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.findByLectureIdDesc(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.findByReportSetIdDesc(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.findByLectureIdAndUserIdDesc(lectureId, userId);
return reports.stream() return reports.stream()
.map(Report::makeReportResponse) .map(Report::makeReportResponse)