diff --git a/src/main/java/edu/handong/csee/histudy/controller/form/ReportForm.java b/src/main/java/edu/handong/csee/histudy/controller/form/ReportForm.java index 1d939be..42df88e 100644 --- a/src/main/java/edu/handong/csee/histudy/controller/form/ReportForm.java +++ b/src/main/java/edu/handong/csee/histudy/controller/form/ReportForm.java @@ -1,6 +1,9 @@ package edu.handong.csee.histudy.controller.form; -import edu.handong.csee.histudy.domain.*; +import edu.handong.csee.histudy.domain.GroupCourse; +import edu.handong.csee.histudy.domain.GroupReport; +import edu.handong.csee.histudy.domain.StudyGroup; +import edu.handong.csee.histudy.domain.User; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; @@ -23,10 +26,10 @@ public class ReportForm { private Long totalMinutes; /** - * Contains student ID + * Contains student ID(PK) */ - @Schema(description = "Participant SIDs of the report", type = "array", example = "[\"20200001\", \"20200002\"]") - private List participants = new ArrayList<>(); + @Schema(description = "Participant ID(PK) of the report", type = "array", example = "[1, 2]") + private List participants = new ArrayList<>(); /** * Contains image URL diff --git a/src/main/java/edu/handong/csee/histudy/service/ReportService.java b/src/main/java/edu/handong/csee/histudy/service/ReportService.java index 5119a27..5aa5c47 100644 --- a/src/main/java/edu/handong/csee/histudy/service/ReportService.java +++ b/src/main/java/edu/handong/csee/histudy/service/ReportService.java @@ -31,7 +31,7 @@ public ReportDto.ReportInfo createReport(ReportForm form, String email) { List participants = form.getParticipants() .stream() - .map(userRepository::findUserBySid) + .map(userRepository::findById) .filter(Optional::isPresent) .map(Optional::get) .toList(); @@ -75,7 +75,7 @@ public List getAllReports() { public boolean updateReport(Long reportId, ReportForm form) { List participants = form.getParticipants() .stream() - .map(userRepository::findUserBySid) + .map(userRepository::findById) .filter(Optional::isPresent) .map(Optional::get) .toList(); diff --git a/src/test/java/edu/handong/csee/histudy/group/ReportGroupCourseServiceTest.java b/src/test/java/edu/handong/csee/histudy/group/ReportGroupCourseServiceTest.java index 2c3f7c1..4839276 100644 --- a/src/test/java/edu/handong/csee/histudy/group/ReportGroupCourseServiceTest.java +++ b/src/test/java/edu/handong/csee/histudy/group/ReportGroupCourseServiceTest.java @@ -173,7 +173,7 @@ public void teamReportViewTest() { .title("title") .content("content") .totalMinutes(60L) - .participants(List.of("22000328")) + .participants(List.of(savedB.getId())) .courses(List.of(1L, 2L, 3L)) .build(); reportService.createReport(form, "a@b.com"); diff --git a/src/test/java/edu/handong/csee/histudy/report/ReportCourseReportServiceTestGroup.java b/src/test/java/edu/handong/csee/histudy/report/ReportCourseReportServiceTestGroup.java index cc48db4..1c7c83d 100644 --- a/src/test/java/edu/handong/csee/histudy/report/ReportCourseReportServiceTestGroup.java +++ b/src/test/java/edu/handong/csee/histudy/report/ReportCourseReportServiceTestGroup.java @@ -84,7 +84,7 @@ public void reportServiceTest() { .title("title") .content("content") .totalMinutes(60L) - .participants(List.of("22000328")) + .participants(List.of(userA.getId())) .courses(List.of(course.getId(), courseB.getId(), courseC.getId())) .build(); @@ -119,19 +119,20 @@ public void reportDetailTest() { .semester(1) .build(); courseRepository.save(courseC); - ReportForm form = ReportForm.builder() - .title("title") - .content("content") - .totalMinutes(60L) - .participants(List.of("22000328")) - .courses(List.of(1L, 2L, 3L)) - .build(); User user = User.builder() .sid("22000328") .email("a@a.com") .role(Role.USER) .build(); User saved = userRepository.save(user); + ReportForm form = ReportForm.builder() + .title("title") + .content("content") + .totalMinutes(60L) + .participants(List.of(saved.getId())) + .courses(List.of(1L, 2L, 3L)) + .build(); + saved.selectCourse(List.of(course, courseB, courseC)); StudyGroup studyGroup = studyGroupRepository.save(new StudyGroup(1, List.of(saved))); diff --git a/src/test/java/edu/handong/csee/histudy/user/UserServiceTests.java b/src/test/java/edu/handong/csee/histudy/user/UserServiceTests.java index 01d0dd2..ee8e313 100644 --- a/src/test/java/edu/handong/csee/histudy/user/UserServiceTests.java +++ b/src/test/java/edu/handong/csee/histudy/user/UserServiceTests.java @@ -126,7 +126,7 @@ public void userListTest() { .title("title") .content("content") .totalMinutes(60L) - .participants(List.of("22000329")) + .participants(List.of(savedA.getId())) .courses(List.of(1L, 2L, 3L)) .build(); ReportDto.ReportInfo report = reportService.createReport(form, "a@a.com"); diff --git a/src/test/java/edu/handong/csee/integration/ReportTests.java b/src/test/java/edu/handong/csee/integration/ReportTests.java index 693efeb..d31b15d 100644 --- a/src/test/java/edu/handong/csee/integration/ReportTests.java +++ b/src/test/java/edu/handong/csee/integration/ReportTests.java @@ -69,7 +69,7 @@ void ReportTests_18(@Value("${custom.jwt.example.admin}") String adminToken) thr .title("title") .content("content") .totalMinutes(10L) - .participants(List.of(writer.getSid())) + .participants(List.of(writer.getId())) .courses(List.of()) .build();