Merge branch 'Be/Report' into 'backend'
[Back-End] Be/report See merge request s11-webmobile1-sub2/S11P12A701!121
This commit is contained in:
commit
862ed541a0
@ -34,7 +34,7 @@ public class Board {
|
||||
@Column(nullable = false)
|
||||
private String category;
|
||||
|
||||
@Column(nullable = false)
|
||||
@Column(columnDefinition = "TEXT", nullable = false)
|
||||
private String content;
|
||||
|
||||
@Column(nullable = true)
|
||||
|
@ -22,7 +22,8 @@ public class Comment {
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private long id;
|
||||
@Column
|
||||
|
||||
@Column(columnDefinition = "TEXT", nullable = false)
|
||||
private String content;
|
||||
|
||||
@Column
|
||||
|
@ -87,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);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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")
|
||||
@ -51,4 +55,8 @@ public class ReportSet {
|
||||
.testAt(createAt)
|
||||
.build();
|
||||
}
|
||||
|
||||
public long findUserId(){
|
||||
return lecture.getUser().getId();
|
||||
}
|
||||
}
|
||||
|
@ -20,4 +20,6 @@ public interface ReportService {
|
||||
List<ReportResponse> findReports(long lectureId, long userid);
|
||||
|
||||
UUID initReportSet(long lectureId, long quizSetId);
|
||||
|
||||
void deleteReportSet(UUID reportSetId, long userId);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user