Skip to content

[Feat] 1단계 MVP 도메인 Entity 및 Enum 생성 #5

Description

@Gimini-3

📌 작업 내용

1단계 MVP에서 사용할 도메인 Entity와 Enum을 생성합니다.

이번 작업은 실제 기능 구현이 아니라,
업로드 → 인덱싱 → 권한 기반 검색 → 출처 반환 흐름에 필요한 JPA Entity 구조를 먼저 잡는 작업입니다.


✅ 할 일

  • BaseTimeEntity 생성 또는 기존 공통 Entity 확인
  • 1단계 MVP용 Entity 생성
  • 필요한 Enum 생성
  • 모든 Entity에 한글 JavaDoc 주석 추가
  • 중요 필드에 한글 주석 추가
  • 주요 unique 제약 설정
  • 주요 index 설정
  • 연관관계는 기본적으로 @ManyToOne(fetch = FetchType.LAZY) 사용
  • @ManyToMany 사용하지 않기
  • 엔티티 전체에 @Setter 사용하지 않기

🧩 생성 대상 Entity

사용자 / 권한

  • User
  • Department
  • Role
  • UserRole

문서 / 파일 / 버전

  • Document
  • DocumentVersion
  • FileObject

컬렉션 / 권한

  • DocumentCollection
  • CollectionDocument
  • CollectionPermission
  • DocumentPermission
  • UserDocumentAccessCache

임베딩 / 인덱싱

  • EmbeddingModel
  • EmbeddingJob
  • DocumentChunk
  • Embedding

검색 / RAG

  • SearchQuery
  • SearchResult
  • RagResponse
  • ResponseCitation

Worker / 장애 복구 / HA

  • WorkerNode
  • EmbeddingJobAttempt
  • IndexingEvent
  • FailoverEvent

🧾 생성 대상 Enum

  • UserStatus
  • CommonStatus
  • CollectionStatus
  • VisibilityType
  • PermissionTargetType
  • PermissionType
  • DocumentType
  • DocumentSourceType
  • DocumentStatus
  • DocumentVersionStatus
  • StorageProvider
  • EmbeddingProvider
  • DistanceMetric
  • VectorStorageStrategy
  • EmbeddingJobStatus
  • EmbeddingStatus
  • SearchType
  • ResultStatus
  • WorkerStatus
  • AttemptStatus
  • FailoverEventType
  • FailoverStatus

필요하면 추가:

  • AccessSourceType
  • IndexingEventType

⚠️ 중요 설계 기준

  • collections 테이블 Entity 이름은 Collection이 아니라 DocumentCollection으로 생성합니다.

  • @ManyToMany는 사용하지 않고, 중간 Entity를 사용합니다.

    • usersrolesUserRole
    • collectionsdocumentsCollectionDocument
  • 연관관계는 기본적으로 단방향 LAZY ManyToOne으로 설정합니다.

  • documents.current_version_id는 nullable이어야 합니다.

  • DocumentDocumentVersion은 순환 FK 구조이므로 최초 저장 시 currentVersion = null로 생성합니다.

  • user_document_access_cache는 권한 원본이 아니라 검색 가속 캐시입니다.

  • ROLE, DEPARTMENT, PUBLIC 권한은 캐시에 저장하지 않고 검색 시점에 판단합니다.

  • embeddings.vector, search_queries.query_vector는 추후 OpenSQL vector 타입으로 교체할 TODO 주석을 남깁니다.

  • JSON 성격 필드는 우선 String으로 두고, 추후 JSON 타입 매핑을 고려합니다.


🧷 주요 unique 제약

  • users.email
  • departments.code
  • roles.code
  • user_roles(user_id, role_id)
  • document_versions(document_id, version_no)
  • file_objects(storage_provider, bucket_name, object_key)
  • collection_documents(collection_id, document_id)
  • user_document_access_cache(user_id, document_id, source_type, source_id)
  • embedding_models(provider, model_name, model_version)
  • document_chunks(document_version_id, chunk_index)
  • embeddings(chunk_id, embedding_model_id)
  • search_results(query_id, chunk_id)
  • response_citations(response_id, chunk_id)
  • embedding_job_attempts(embedding_job_id, attempt_no)

🚫 이번 이슈에서 하지 않는 작업

  • Repository 생성
  • Service 생성
  • Controller 생성
  • DTO 생성
  • API 구현
  • Flyway migration 작성
  • 문서 업로드 기능 구현
  • Worker 구현
  • 검색 기능 구현
  • 권한 검색 SQL 구현
  • 실제 OpenSQL vector index 생성

✅ 완료 기준

  • 24개 Entity가 생성되었다.
  • 필요한 Enum이 생성되었다.
  • jakarta.persistence를 사용한다.
  • Entity와 중요 필드에 한글 주석이 있다.
  • @ManyToMany를 사용하지 않았다.
  • DocumentCollection 이름을 사용했다.
  • Document.currentVersion은 nullable이다.
  • 주요 unique/index가 반영되었다.
  • vector 필드에 TODO 주석이 있다.
  • 전체 컴파일이 성공한다.

🧪 검증 방법

./gradlew compileJava

또는

./gradlew build

🌿 브랜치명

feat/mvp-domain-entities

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions