Skip to content

Commit

Permalink
hotfix: 긴급 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Aug 18, 2024
1 parent f202ba3 commit 39d1ed7
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.whopper.domain.document.application.usecase;

import com.example.whopper.domain.document.domain.detail.CompletionElementLevel;
import com.example.whopper.domain.document.domain.detail.CompletionElementLevel;
import com.example.whopper.domain.document.dto.response.DocumentResponse;
import com.example.whopper.domain.document.dto.response.FullDocumentResponse;
import com.example.whopper.domain.document.dto.response.ReleasedDocumentResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public DataResponseInfo<FeedbackResponse> getFeedbackListByDocumentId(@PathVaria
return findFeedbackUseCase.getFeedbackListByDocumentId(documentId);
}

@OnlyTeacher
@GetMapping("/teacher")
public DataResponseInfo<FeedbackResponse> getFeedbacksWrittenByTeacher() {
return findFeedbackUseCase.getFeedbacksWrittenByTeacher();
}

@OnlyTeacher
@PostMapping
public void addFeedback(@RequestBody FeedbackRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public void addFeedback(FeedbackRequest request) {
feedbackMongoRepository.save(
FeedbackEntity.builder()
.comment(request.comment())
.writerName(teacherComponent.currentTeacher().getName())
.type(request.type())
.documentId(document.getId())
.teacher(teacherComponent.currentTeacher())
.build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.example.whopper.domain.feedback.application.usecase.FindFeedbackUseCase;
import com.example.whopper.domain.feedback.dao.FeedbackMongoRepository;
import com.example.whopper.domain.feedback.dto.FeedbackResponse;
import com.example.whopper.domain.teacher.application.component.TeacherComponent;
import com.example.whopper.global.utils.DataResponseInfo;
import com.example.whopper.global.utils.current.CurrentStudent;
import lombok.RequiredArgsConstructor;
Expand All @@ -20,6 +21,7 @@ public class FindFeedbackService implements FindFeedbackUseCase {
private final CurrentStudent currentStudent;
private final FeedbackMongoRepository feedbackMongoRepository;
private final DocumentRepository documentRepository;
private final TeacherComponent teacherComponent;

@Override
public DataResponseInfo<FeedbackResponse> getCurrentStudentFeedbackList() {
Expand Down Expand Up @@ -48,4 +50,15 @@ public DataResponseInfo<FeedbackResponse> getFeedbackListByDocumentId(String doc

return DataResponseInfo.of(feedbackList);
}

@Override
public DataResponseInfo<FeedbackResponse> getFeedbacksWrittenByTeacher() {
var teacher = teacherComponent.currentTeacher();

var result = feedbackMongoRepository.findAllByTeacherId(teacher.getId())
.map(FeedbackResponse::new)
.toList();

return DataResponseInfo.of(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
public interface FindFeedbackUseCase {
DataResponseInfo<FeedbackResponse> getCurrentStudentFeedbackList();
DataResponseInfo<FeedbackResponse> getFeedbackListByDocumentId(String documentId);
DataResponseInfo<FeedbackResponse> getFeedbacksWrittenByTeacher();
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import org.springframework.data.mongodb.repository.MongoRepository;

import java.util.List;
import java.util.stream.Stream;

public interface FeedbackMongoRepository extends MongoRepository<FeedbackEntity, String> {
List<FeedbackEntity> findAllByDocumentId(String documentId);
int countByDocumentId(String documentId);
void deleteAllByDocumentId(String documentId);
Stream<FeedbackEntity> findAllByTeacherId(String teacherId);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.example.whopper.domain.feedback.domain;

import com.example.whopper.domain.document.domain.element.type.DocumentElementType;
import com.example.whopper.domain.teacher.domain.TeacherEntity;
import lombok.Builder;
import lombok.Getter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.DBRef;
import org.springframework.data.mongodb.core.mapping.Document;

@Getter
Expand All @@ -12,20 +14,22 @@ public class FeedbackEntity {
@Id
private String id;
private String comment;
private String writerName;
private DocumentElementType type;

private String documentId;

private Status status;

@DBRef(lazy = true)
private TeacherEntity teacher;

@Builder
public FeedbackEntity(String comment, String writerName, DocumentElementType type, String documentId) {
public FeedbackEntity(String comment, DocumentElementType type, String documentId, TeacherEntity teacher) {
this.comment = comment;
this.writerName = writerName;
this.type = type;
this.documentId = documentId;
status = Status.PENDING;
this.teacher = teacher;
}

public void updateFeedback(String comment) {
Expand Down

0 comments on commit 39d1ed7

Please sign in to comment.