Merge pull request #85 from TeamBNBN/BE/report

feat: report 수정
This commit is contained in:
Jungmin 2024-07-22 17:34:38 +09:00 committed by GitHub
commit 418490abee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 59 additions and 25 deletions

View File

@ -1,7 +1,8 @@
package com.edufocus.edufocus.report.controller; package com.edufocus.edufocus.report.controller;
import com.edufocus.edufocus.report.entity.Report; import com.edufocus.edufocus.report.entity.dto.ReportResponse;
import com.edufocus.edufocus.report.entity.ReportRequset; import com.edufocus.edufocus.report.entity.vo.Report;
import com.edufocus.edufocus.report.entity.dto.ReportRequset;
import com.edufocus.edufocus.report.service.ReportService; import com.edufocus.edufocus.report.service.ReportService;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -27,8 +28,8 @@ public class ReportController{
@PostMapping("/submit") @PostMapping("/submit")
public ResponseEntity<Report> submit(@RequestBody ReportRequset reportRequset) throws SQLException { public ResponseEntity<ReportResponse> submit(@RequestBody ReportRequset reportRequset) throws SQLException {
Report report = reportService.grading(reportRequset); ReportResponse report = reportService.grading(reportRequset);
return new ResponseEntity<>(report,HttpStatus.CREATED); return new ResponseEntity<>(report,HttpStatus.CREATED);
} }

View File

@ -1,4 +1,4 @@
package com.edufocus.edufocus.report.entity; package com.edufocus.edufocus.report.entity.dto;
import lombok.Getter; import lombok.Getter;

View File

@ -1,4 +1,4 @@
package com.edufocus.edufocus.report.entity; package com.edufocus.edufocus.report.entity.dto;
public class QuizSubmissionDto { public class QuizSubmissionDto {
private Long quizSetId; private Long quizSetId;

View File

@ -1,4 +1,4 @@
package com.edufocus.edufocus.report.entity; package com.edufocus.edufocus.report.entity.dto;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;

View File

@ -0,0 +1,26 @@
package com.edufocus.edufocus.report.entity.dto;
import com.edufocus.edufocus.report.entity.vo.Answer;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import java.util.Date;
import java.util.List;
@Getter
@Setter
@Builder
public class ReportResponse {
private Long quizesetId;
private Long userId;
private String title;
private int allCount;
private int correctCount;
private Date testAt;
}

View File

@ -1,4 +1,4 @@
package com.edufocus.edufocus.report.entity; package com.edufocus.edufocus.report.entity.vo;
import com.edufocus.edufocus.quiz.entity.Quiz; import com.edufocus.edufocus.quiz.entity.Quiz;

View File

@ -1,4 +1,4 @@
package com.edufocus.edufocus.report.entity; package com.edufocus.edufocus.report.entity.vo;
import com.edufocus.edufocus.quiz.entity.QuizSet; import com.edufocus.edufocus.quiz.entity.QuizSet;
import com.edufocus.edufocus.user.model.entity.User; import com.edufocus.edufocus.user.model.entity.User;

View File

@ -1,6 +1,6 @@
package com.edufocus.edufocus.report.repository; package com.edufocus.edufocus.report.repository;
import com.edufocus.edufocus.report.entity.Answer; import com.edufocus.edufocus.report.entity.vo.Answer;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
public interface AnswerRepository extends JpaRepository<Answer,Long> { public interface AnswerRepository extends JpaRepository<Answer,Long> {

View File

@ -1,6 +1,6 @@
package com.edufocus.edufocus.report.repository; package com.edufocus.edufocus.report.repository;
import com.edufocus.edufocus.report.entity.Report; import com.edufocus.edufocus.report.entity.vo.Report;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;

View File

@ -1,6 +1,6 @@
package com.edufocus.edufocus.report.service; package com.edufocus.edufocus.report.service;
import com.edufocus.edufocus.report.entity.Answer; import com.edufocus.edufocus.report.entity.vo.Answer;
public interface AnswerService { public interface AnswerService {

View File

@ -1,6 +1,6 @@
package com.edufocus.edufocus.report.service; package com.edufocus.edufocus.report.service;
import com.edufocus.edufocus.report.entity.Answer; import com.edufocus.edufocus.report.entity.vo.Answer;
import com.edufocus.edufocus.report.repository.AnswerRepository; import com.edufocus.edufocus.report.repository.AnswerRepository;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;

View File

@ -1,13 +1,14 @@
package com.edufocus.edufocus.report.service; package com.edufocus.edufocus.report.service;
import com.edufocus.edufocus.report.entity.Report; import com.edufocus.edufocus.report.entity.dto.ReportResponse;
import com.edufocus.edufocus.report.entity.ReportRequset; import com.edufocus.edufocus.report.entity.vo.Report;
import com.edufocus.edufocus.report.entity.dto.ReportRequset;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.sql.SQLException; import java.sql.SQLException;
@Service @Service
public interface ReportService { public interface ReportService {
Report grading(ReportRequset reportRequset) throws SQLException; ReportResponse grading(ReportRequset reportRequset) throws SQLException;
} }

View File

@ -5,10 +5,11 @@ import com.edufocus.edufocus.quiz.entity.QuizSet;
import com.edufocus.edufocus.quiz.repository.QuizRepository; import com.edufocus.edufocus.quiz.repository.QuizRepository;
import com.edufocus.edufocus.quiz.service.QuizService; import com.edufocus.edufocus.quiz.service.QuizService;
import com.edufocus.edufocus.quiz.service.QuizSetService; import com.edufocus.edufocus.quiz.service.QuizSetService;
import com.edufocus.edufocus.report.entity.Answer; import com.edufocus.edufocus.report.entity.dto.ReportResponse;
import com.edufocus.edufocus.report.entity.AnswerInput; import com.edufocus.edufocus.report.entity.vo.Answer;
import com.edufocus.edufocus.report.entity.Report; import com.edufocus.edufocus.report.entity.dto.AnswerInput;
import com.edufocus.edufocus.report.entity.ReportRequset; import com.edufocus.edufocus.report.entity.vo.Report;
import com.edufocus.edufocus.report.entity.dto.ReportRequset;
import com.edufocus.edufocus.report.repository.ReportRepository; import com.edufocus.edufocus.report.repository.ReportRepository;
import com.edufocus.edufocus.user.model.entity.User; import com.edufocus.edufocus.user.model.entity.User;
import com.edufocus.edufocus.user.model.repository.UserRepository; import com.edufocus.edufocus.user.model.repository.UserRepository;
@ -36,7 +37,7 @@ public class ReportServiceImpl implements ReportService {
@Override @Override
public Report grading(ReportRequset reportRequset) throws SQLException { public ReportResponse grading(ReportRequset reportRequset) throws SQLException {
QuizSet quizSet = quizSetService.findQuizSet(reportRequset.getQuizsetId()); QuizSet quizSet = quizSetService.findQuizSet(reportRequset.getQuizsetId());
@ -90,10 +91,15 @@ public class ReportServiceImpl implements ReportService {
.allCount(allCount) .allCount(allCount)
.correctCount(correctCount) .correctCount(correctCount)
.testAt(new Date()).build(); .testAt(new Date()).build();
ReportResponse reportResponse = ReportResponse.builder()
.quizesetId(quizSet.getId())
.userId(testuser.getId())
.title(quizSet.getTitle())
.allCount(allCount)
.correctCount(correctCount)
.testAt(new Date())
.build();
reportRepository.save(report); return reportResponse;
return report;
} }
} }