Skip to content

Commit

Permalink
Fix: 보고서 작성시 참여한 학생 정보가 기록되지 않는 버그 수정 (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
zionhann committed Sep 18, 2023
1 parent 7407655 commit 7ccd2aa
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -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.*;

Expand All @@ -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<String> participants = new ArrayList<>();
@Schema(description = "Participant ID(PK) of the report", type = "array", example = "[1, 2]")
private List<Long> participants = new ArrayList<>();

/**
* Contains image URL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ReportDto.ReportInfo createReport(ReportForm form, String email) {

List<User> participants = form.getParticipants()
.stream()
.map(userRepository::findUserBySid)
.map(userRepository::findById)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
Expand Down Expand Up @@ -75,7 +75,7 @@ public List<ReportDto.ReportInfo> getAllReports() {
public boolean updateReport(Long reportId, ReportForm form) {
List<User> participants = form.getParticipants()
.stream()
.map(userRepository::findUserBySid)
.map(userRepository::findById)
.filter(Optional::isPresent)
.map(Optional::get)
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, "[email protected]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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("[email protected]")
.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)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, "[email protected]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 7ccd2aa

Please sign in to comment.