Merge branch 'backend' of https://github.com/TeamBNBN/edufocus into be/Registration

This commit is contained in:
kgc9007 2024-07-22 17:52:04 +09:00
commit 4ebed1ca3a
13 changed files with 59 additions and 25 deletions

View File

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

View File

@ -1,4 +1,4 @@
package com.edufocus.edufocus.report.entity;
package com.edufocus.edufocus.report.entity.dto;
public class QuizSubmissionDto {
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.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;

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.user.model.entity.User;

View File

@ -1,6 +1,6 @@
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;
public interface AnswerRepository extends JpaRepository<Answer,Long> {

View File

@ -1,6 +1,6 @@
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.stereotype.Repository;

View File

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

View File

@ -1,6 +1,6 @@
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 jakarta.transaction.Transactional;
import lombok.RequiredArgsConstructor;

View File

@ -1,13 +1,14 @@
package com.edufocus.edufocus.report.service;
import com.edufocus.edufocus.report.entity.Report;
import com.edufocus.edufocus.report.entity.ReportRequset;
import com.edufocus.edufocus.report.entity.dto.ReportResponse;
import com.edufocus.edufocus.report.entity.vo.Report;
import com.edufocus.edufocus.report.entity.dto.ReportRequset;
import org.springframework.stereotype.Service;
import java.sql.SQLException;
@Service
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.service.QuizService;
import com.edufocus.edufocus.quiz.service.QuizSetService;
import com.edufocus.edufocus.report.entity.Answer;
import com.edufocus.edufocus.report.entity.AnswerInput;
import com.edufocus.edufocus.report.entity.Report;
import com.edufocus.edufocus.report.entity.ReportRequset;
import com.edufocus.edufocus.report.entity.dto.ReportResponse;
import com.edufocus.edufocus.report.entity.vo.Answer;
import com.edufocus.edufocus.report.entity.dto.AnswerInput;
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.user.model.entity.User;
import com.edufocus.edufocus.user.model.repository.UserRepository;
@ -36,7 +37,7 @@ public class ReportServiceImpl implements ReportService {
@Override
public Report grading(ReportRequset reportRequset) throws SQLException {
public ReportResponse grading(ReportRequset reportRequset) throws SQLException {
QuizSet quizSet = quizSetService.findQuizSet(reportRequset.getQuizsetId());
@ -90,10 +91,15 @@ public class ReportServiceImpl implements ReportService {
.allCount(allCount)
.correctCount(correctCount)
.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 report;
return reportResponse;
}
}