diff --git a/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java b/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java index c2a2519..0f7d34a 100644 --- a/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java +++ b/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java @@ -34,15 +34,17 @@ public class Board { @Column(nullable = false) private String category; - @Column(nullable = false) + @Column(columnDefinition = "TEXT", nullable = false) private String content; @Column(nullable = true) private int viewCount; + @Column(columnDefinition = "TIMESTAMP") @CreatedDate LocalDateTime createdAt; + @Column(columnDefinition = "TIMESTAMP") @LastModifiedDate LocalDateTime modifiedAt; diff --git a/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Comment.java b/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Comment.java index aa05c5b..9887128 100644 --- a/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Comment.java +++ b/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Comment.java @@ -9,6 +9,8 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.NoArgsConstructor; import lombok.Setter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; import java.time.LocalDateTime; @@ -22,13 +24,16 @@ public class Comment { @Id @GeneratedValue private long id; - @Column + + @Column(columnDefinition = "TEXT", nullable = false) private String content; - @Column + @Column(columnDefinition = "TIMESTAMP") + @CreatedDate private LocalDateTime createdAt; - @Column + @Column(columnDefinition = "TIMESTAMP") + @LastModifiedDate private LocalDateTime modifiedAt; @ManyToOne diff --git a/backend/src/main/java/com/edufocus/edufocus/lecture/entity/Lecture.java b/backend/src/main/java/com/edufocus/edufocus/lecture/entity/Lecture.java index 5db4488..734354a 100644 --- a/backend/src/main/java/com/edufocus/edufocus/lecture/entity/Lecture.java +++ b/backend/src/main/java/com/edufocus/edufocus/lecture/entity/Lecture.java @@ -27,10 +27,10 @@ public class Lecture { @Column private String title; - @Lob + @Column(columnDefinition = "text") private String description; - @Lob + @Column(columnDefinition = "text") private String plan; @Column diff --git a/backend/src/main/java/com/edufocus/edufocus/registration/controller/RegistrationController.java b/backend/src/main/java/com/edufocus/edufocus/registration/controller/RegistrationController.java index 4b8bba3..2b019c9 100644 --- a/backend/src/main/java/com/edufocus/edufocus/registration/controller/RegistrationController.java +++ b/backend/src/main/java/com/edufocus/edufocus/registration/controller/RegistrationController.java @@ -36,7 +36,7 @@ public class RegistrationController { } @PutMapping("/{registrationId}") - public ResponseEntity acceptRigistration(@RequestHeader("Authorization") String accessToken, @PathVariable long registrationId) { + public ResponseEntity acceptRegistration(@RequestHeader("Authorization") String accessToken, @PathVariable long registrationId) { Long userId = Long.parseLong(jwtUtil.getUserId(accessToken)); if (!registrationService.acceptRegistration(userId, registrationId)) { @@ -47,7 +47,7 @@ public class RegistrationController { } @DeleteMapping("/{registrationId}") - public ResponseEntity deleteRigistration(@RequestHeader("Authorization") String accessToken, @PathVariable long registrationId) { + public ResponseEntity deleteRegistration(@RequestHeader("Authorization") String accessToken, @PathVariable long registrationId) { Long userId = Long.parseLong(jwtUtil.getUserId(accessToken)); if (!registrationService.deleteRegistration(userId, registrationId)) { diff --git a/backend/src/main/java/com/edufocus/edufocus/report/controller/ReportController.java b/backend/src/main/java/com/edufocus/edufocus/report/controller/ReportController.java index c58483c..3feb224 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/controller/ReportController.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/controller/ReportController.java @@ -63,7 +63,10 @@ public class ReportController { return new ResponseEntity<>(detailReport, HttpStatus.OK); } +<<<<<<< HEAD +======= +>>>>>>> 935331e7e93d9c25ec6f32ba6155ed19b5fd60f9 @GetMapping("/teacher/reportSet/{lectureId}") public ResponseEntity> searchReportSets(@PathVariable("lectureId") long lectureId) { List reportSetResponses = reportService.findReportSets(lectureId); @@ -84,4 +87,13 @@ public class ReportController { return new ResponseEntity<>(reportResponses, HttpStatus.OK); } + @DeleteMapping("/teacher/report/{reportSetId}") + public ResponseEntity deleteReportSet(@PathVariable("reportSetId") UUID reportSetId, HttpServletRequest request){ + String token = request.getHeader("Authorization"); + long userId = Long.parseLong(jwtUtil.getUserId(token)); + + reportService.deleteReportSet(reportSetId, userId); + + return new ResponseEntity<>(HttpStatus.OK); + } } diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/dto/QuizDto.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/dto/QuizDto.java index d36281f..5dbc56e 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/dto/QuizDto.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/dto/QuizDto.java @@ -18,6 +18,6 @@ public class QuizDto { private String image; private String answer; private String userAnswer; - private boolean isCollect; + private boolean isCorrect; private List choices; } diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/dto/ReportSetResponse.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/dto/ReportSetResponse.java index ad300bf..a7ea791 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/dto/ReportSetResponse.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/dto/ReportSetResponse.java @@ -1,14 +1,14 @@ package com.edufocus.edufocus.report.entity.dto; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.NoArgsConstructor; +import lombok.*; import java.time.LocalDateTime; import java.util.UUID; @Builder +@Getter +@Setter @NoArgsConstructor @AllArgsConstructor public class ReportSetResponse { diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java index dcc4b95..9205532 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java @@ -3,9 +3,11 @@ package com.edufocus.edufocus.report.entity.vo; import com.edufocus.edufocus.quiz.entity.QuizSet; import com.edufocus.edufocus.report.entity.dto.ReportResponse; import com.edufocus.edufocus.user.model.entity.vo.User; +import com.fasterxml.jackson.annotation.JsonAutoDetect; import jakarta.persistence.*; import lombok.*; import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; import java.time.LocalDateTime; import java.util.Date; @@ -17,6 +19,8 @@ import java.util.List; @NoArgsConstructor @AllArgsConstructor @Builder +@EntityListeners(AuditingEntityListener.class) +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) public class Report { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -26,6 +30,7 @@ public class Report { private int correctCount; + @Column(columnDefinition = "TIMESTAMP") @CreatedDate private LocalDateTime testAt; diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java index 2dedc12..7f8f691 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java @@ -3,11 +3,13 @@ package com.edufocus.edufocus.report.entity.vo; import com.edufocus.edufocus.lecture.entity.Lecture; import com.edufocus.edufocus.quiz.entity.QuizSet; import com.edufocus.edufocus.report.entity.dto.ReportSetResponse; +import com.fasterxml.jackson.annotation.JsonAutoDetect; import jakarta.persistence.*; import lombok.*; import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.GenericGenerator; import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; import java.time.LocalDateTime; @@ -21,6 +23,8 @@ import java.util.UUID; @Builder @NoArgsConstructor @AllArgsConstructor +@EntityListeners(AuditingEntityListener.class) +@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY) public class ReportSet { @Id @GeneratedValue(generator = "UUID") @@ -30,6 +34,7 @@ public class ReportSet { ) private UUID id; + @Column(columnDefinition = "TIMESTAMP") @CreatedDate private LocalDateTime createAt; @@ -51,4 +56,8 @@ public class ReportSet { .testAt(createAt) .build(); } + + public long findUserId(){ + return lecture.getUser().getId(); + } } diff --git a/backend/src/main/java/com/edufocus/edufocus/report/service/ReportService.java b/backend/src/main/java/com/edufocus/edufocus/report/service/ReportService.java index 1e1b2b2..5c51ab5 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/service/ReportService.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/service/ReportService.java @@ -20,4 +20,6 @@ public interface ReportService { List findReports(long lectureId, long userid); UUID initReportSet(long lectureId, long quizSetId); + + void deleteReportSet(UUID reportSetId, long userId); } diff --git a/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java index 3ae6792..33d0a71 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java @@ -54,17 +54,17 @@ public class ReportServiceImpl implements ReportService { for (int idx = 0; idx < answerInputList.size(); idx++) { Quiz quiz = quizList.get(idx); String inputAnswer = answerInputList.get(idx); - boolean isCollect; + boolean isCorrect; Answer answer; if (quiz.getAnswer().equals(inputAnswer)) { correctCount++; - isCollect = true; + isCorrect = true; } else { - isCollect = false; + isCorrect = false; } answer = Answer.builder() .userAnswer(inputAnswer) - .isCorrect(isCollect) + .isCorrect(isCorrect) .report(report) .quiz(quiz) .build(); @@ -106,7 +106,7 @@ public class ReportServiceImpl implements ReportService { .question(quiz.getQuestion()) .answer(quiz.getAnswer()) .userAnswer(answer.getUserAnswer()) - .isCollect(answer.isCorrect()) + .isCorrect(answer.isCorrect()) .choices(choiceDtos) .build(); @@ -172,4 +172,11 @@ public class ReportServiceImpl implements ReportService { return reportSet.getId(); } + + @Override + public void deleteReportSet(UUID reportSetId, long userId) { + ReportSet reportSet = reportSetRepository.findById(reportSetId).orElseThrow(NoSuchElementException::new); + if(reportSet.findUserId() == userId) + reportSetRepository.delete(reportSet); + } }