Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 보고서 작성시 참여한 학생 정보가 기록되지 않는 버그 수정 (#136) #137

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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