forked from kakao-tech-campus-2nd-step3/Team29_BE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from kakao-tech-campus-2nd-step3/Weekly3
Feat: Member 기능 구현 (#15) Feat: 폴더, 문서 엔티티 생성, 연결 Feat: Summary, Problem, AITask 엔티티 생성 (#26) Feat: Post 기능 구현 Feat: Comment 기능구현
- Loading branch information
Showing
39 changed files
with
636 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package notai.aiTask.application; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.UUID; | ||
import lombok.RequiredArgsConstructor; | ||
import notai.aiTask.application.command.AITaskCommand; | ||
import notai.aiTask.domain.AITaskRepository; | ||
import notai.aiTask.presentation.response.AITaskResponse; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* SummaryService 와 ExamService 는 엔티티와 관련된 로직만 처리하고 | ||
* AI 요약 및 문제 생성 요청은 여기서 처리하는 식으로 생각했습니다. | ||
* AI 서버와의 통신은 별도 클래스에서 처리합니다. | ||
*/ | ||
@Service | ||
@RequiredArgsConstructor | ||
public class AITaskService { | ||
|
||
private final AITaskRepository aiTaskRepository; | ||
|
||
/** | ||
* 흐름 파악용 임시 메서드 | ||
*/ | ||
public AITaskResponse submitTask(AITaskCommand command) { | ||
command.pages().forEach(page -> { | ||
UUID taskId = sendRequestToAIServer(); | ||
// TODO: command 데이터를 이용해 content 만 null 인 Summary, Problem 생성 | ||
// TODO: Summary, Problem 과 매핑된 AITask 생성 -> 작업 상태는 모두 PENDING | ||
}); | ||
|
||
return AITaskResponse.of(command.documentId(), LocalDateTime.now()); | ||
} | ||
|
||
private UUID sendRequestToAIServer() { | ||
return UUID.randomUUID(); // 임시 값, 실제 구현에선 AI 서버에서 UUID 가 반환됨. | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/notai/aiTask/application/command/AITaskCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package notai.aiTask.application.command; | ||
|
||
import java.util.List; | ||
|
||
public record AITaskCommand( | ||
Long documentId, | ||
List<Integer> pages | ||
) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package notai.aiTask.domain; | ||
|
||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import java.util.UUID; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import notai.common.domain.RootEntity; | ||
import notai.problem.domain.Problem; | ||
import notai.summary.domain.Summary; | ||
|
||
@Getter | ||
@NoArgsConstructor(access = PROTECTED) | ||
@Entity | ||
@Table(name = "ai_task") | ||
public class AITask extends RootEntity<UUID> { | ||
|
||
@Id | ||
private UUID id; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "summary_id") | ||
private Summary summary; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "problem_id") | ||
private Problem problem; | ||
|
||
@NotNull | ||
@Enumerated(value = EnumType.STRING) | ||
@Column(length = 20) | ||
private TaskStatus status; | ||
|
||
public AITask(UUID id, Summary summary, Problem problem) { | ||
this.id = id; | ||
this.summary = summary; | ||
this.problem = problem; | ||
this.status = TaskStatus.PENDING; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package notai.aiTask.domain; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface AITaskRepository extends JpaRepository<AITask, Long> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package notai.aiTask.domain; | ||
|
||
public enum TaskStatus { | ||
PENDING, | ||
IN_PROGRESS, | ||
COMPLETED | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/notai/aiTask/presentation/AITaskController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package notai.aiTask.presentation; | ||
|
||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import notai.aiTask.application.AITaskService; | ||
import notai.aiTask.application.command.AITaskCommand; | ||
import notai.aiTask.presentation.request.AITaskRequest; | ||
import notai.aiTask.presentation.response.AITaskResponse; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api/ai/tasks") | ||
@RequiredArgsConstructor | ||
public class AITaskController { | ||
|
||
private final AITaskService aiTaskService; | ||
|
||
@PostMapping | ||
public ResponseEntity<AITaskResponse> submitTask(@RequestBody @Valid AITaskRequest request) { | ||
AITaskCommand command = request.toCommand(); | ||
AITaskResponse response = aiTaskService.submitTask(command); | ||
return ResponseEntity.accepted().body(response); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/notai/aiTask/presentation/request/AITaskRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package notai.aiTask.presentation.request; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Positive; | ||
import java.util.List; | ||
import notai.aiTask.application.command.AITaskCommand; | ||
|
||
public record AITaskRequest( | ||
|
||
@NotNull(message = "문서 ID는 필수 입력 값입니다.") | ||
Long documentId, | ||
|
||
List<@Positive(message = "페이지 번호는 양수여야 합니다.") Integer> pages | ||
) { | ||
public AITaskCommand toCommand() { | ||
return new AITaskCommand(documentId, pages); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/notai/aiTask/presentation/response/AITaskResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package notai.aiTask.presentation.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record AITaskResponse( | ||
Long documentId, | ||
LocalDateTime createdAt | ||
) { | ||
public static AITaskResponse of(Long documentId, LocalDateTime createdAt) { | ||
return new AITaskResponse(documentId, createdAt); | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/notai/comment/application/CommentQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package notai.comment.application; | ||
|
||
public class CommentQueryService { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package notai.comment.application; | ||
|
||
public class CommentService { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package notai.comment.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import notai.common.domain.RootEntity; | ||
import notai.member.domain.Member; | ||
|
||
import static jakarta.persistence.GenerationType.IDENTITY; | ||
import static lombok.AccessLevel.PROTECTED; | ||
|
||
@Entity | ||
@Table(name = "comment") | ||
@Getter | ||
@NoArgsConstructor(access = PROTECTED) | ||
@AllArgsConstructor | ||
public class Comment extends RootEntity<Long> { | ||
@Id | ||
@GeneratedValue(strategy = IDENTITY) | ||
private Long id; | ||
@ManyToOne | ||
@NotNull | ||
@JoinColumn(name = "member_id") | ||
private Member member; | ||
@NotNull | ||
@Column | ||
private Long postId; | ||
@NotNull | ||
@Column | ||
private Long parentCommentId; | ||
@NotNull | ||
@Column(length = 255) | ||
private String content; | ||
public Comment( | ||
Member member, | ||
Long postId, | ||
String content | ||
) { | ||
this.member = member; | ||
this.postId = postId; | ||
this.content = content; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package notai.comment.domain; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface CommentRepository extends JpaRepository<Comment, Long> { | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/notai/comment/presentation/CommentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package notai.comment.presentation; | ||
|
||
public class CommentController { | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/notai/document/application/DocumentQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package notai.document.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class DocumentQueryService { | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/notai/document/application/DocumentService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package notai.document.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class DocumentService { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package notai.document.domain; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AccessLevel; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import notai.common.domain.RootEntity; | ||
import notai.folder.domain.Folder; | ||
|
||
@Entity | ||
@Table(name = "document") | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Document extends RootEntity<Long> { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "folder_id", referencedColumnName = "id") | ||
private Folder folder; | ||
@NotNull | ||
@Column(name = "name", length = 50) | ||
private String name; | ||
@NotNull | ||
@Column(name = "size") | ||
private Integer size; | ||
@NotNull | ||
@Column(name = "total_page") | ||
private Integer totalPage; | ||
@NotNull | ||
@Enumerated(value = EnumType.STRING) | ||
@Column(name = "status") | ||
private DocumentStatus status; | ||
|
||
public Document(Folder folder, String name, Integer size, Integer totalPage, DocumentStatus status) { | ||
this.folder = folder; | ||
this.name = name; | ||
this.size = size; | ||
this.totalPage = totalPage; | ||
this.status = status; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package notai.document.domain; | ||
|
||
import notai.document.query.DocumentQueryRepository; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface DocumentRepository extends JpaRepository<Document, Long>, DocumentQueryRepository { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package notai.document.domain; | ||
|
||
public enum DocumentStatus { | ||
EXISTS, | ||
GARBAGE | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/notai/document/presentation/DocumentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package notai.document.presentation; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@Controller | ||
@RequestMapping("/api/documents") | ||
@RequiredArgsConstructor | ||
public class DocumentController { | ||
} |
4 changes: 4 additions & 0 deletions
4
src/main/java/notai/document/query/DocumentQueryRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package notai.document.query; | ||
|
||
public interface DocumentQueryRepository { | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/notai/document/query/DocumentQueryRepositoryImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package notai.document.query; | ||
|
||
import com.querydsl.jpa.impl.JPAQueryFactory; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
public class DocumentQueryRepositoryImpl implements DocumentQueryRepository { | ||
|
||
private final JPAQueryFactory jpaQueryFactory; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/notai/folder/application/FolderQueryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package notai.folder.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FolderQueryService { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package notai.folder.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class FolderService { | ||
} |
Oops, something went wrong.