From 6b2ff233bdda3573a55d8a9a49f70d907340801d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 13:44:19 +0900 Subject: [PATCH 01/36] =?UTF-8?q?:sparkles:=20feature:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=83=9D=EC=84=B1=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index/controller/IndexController.kt | 25 ++++++++++++++++ .../domain/index/converter/IndexConverter.kt | 24 +++++++++++++++ .../domain/index/dto/IndexRequestDTO.kt | 25 ++++++++++++++++ .../domain/index/dto/IndexResponseDTO.kt | 5 ++++ .../index/repository/IndexRepository.kt | 7 +++++ .../domain/index/service/IndexService.kt | 29 +++++++++++++++++++ .../ragback/global/error/CustomException.kt | 5 ++++ .../ragback/global/error/ErrorCode.kt | 5 +++- 8 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt create mode 100644 src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt create mode 100644 src/main/kotlin/simplerag/ragback/domain/index/dto/IndexRequestDTO.kt create mode 100644 src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt create mode 100644 src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt create mode 100644 src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt diff --git a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt new file mode 100644 index 0000000..441c924 --- /dev/null +++ b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt @@ -0,0 +1,25 @@ +package simplerag.ragback.domain.index.controller + +import org.springframework.http.HttpStatus +import org.springframework.web.bind.annotation.* +import simplerag.ragback.domain.index.dto.IndexCreateRequest +import simplerag.ragback.domain.index.dto.IndexPreviewResponse +import simplerag.ragback.domain.index.service.IndexService +import simplerag.ragback.global.response.ApiResponse + +@RestController +@RequestMapping("/api/v1/indexes") +class IndexController( + private val indexService: IndexService +) { + + @PostMapping + @ResponseStatus(HttpStatus.CREATED) + fun createIndex( + @RequestBody indexCreateRequest: IndexCreateRequest + ): ApiResponse { + val createdIndex = indexService.createIndex(indexCreateRequest) + return ApiResponse.ok(createdIndex) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt new file mode 100644 index 0000000..768d833 --- /dev/null +++ b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt @@ -0,0 +1,24 @@ +package simplerag.ragback.domain.index.converter + +import simplerag.ragback.domain.index.dto.IndexCreateRequest +import simplerag.ragback.domain.index.dto.IndexPreviewResponse +import simplerag.ragback.domain.index.entity.Index + + +fun toIndex(createRequest: IndexCreateRequest): Index { + return Index( + snapshotName = createRequest.snapshotName, + overlapSize = createRequest.overlapSize, + chunkingSize = createRequest.chunkingSize, + similarityMetric = createRequest.similarityMetric, + topK = createRequest.topK, + embeddingModel = createRequest.embeddingModel, + reranker = createRequest.reranker + ) +} + +fun toIndexPreviewResponse(index: Index): IndexPreviewResponse { + return IndexPreviewResponse( + indexesId = index.id + ) +} \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexRequestDTO.kt b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexRequestDTO.kt new file mode 100644 index 0000000..33ba116 --- /dev/null +++ b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexRequestDTO.kt @@ -0,0 +1,25 @@ +package simplerag.ragback.domain.index.dto + +import org.hibernate.validator.constraints.Length +import simplerag.ragback.domain.index.entity.enums.EmbeddingModel +import simplerag.ragback.domain.index.entity.enums.SimilarityMetric + +data class IndexCreateRequest( + @Length(max = 255) + val snapshotName: String, + + @Length(min = 1) + val chunkingSize: Int, + + @Length(min = 0) + val overlapSize: Int, + + val similarityMetric: SimilarityMetric, + + @Length(min = 1) + val topK: Int, + + val embeddingModel: EmbeddingModel, + + val reranker: Boolean, +) \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt new file mode 100644 index 0000000..5021256 --- /dev/null +++ b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt @@ -0,0 +1,5 @@ +package simplerag.ragback.domain.index.dto + +data class IndexPreviewResponse( + var indexesId: Long?, +) \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt new file mode 100644 index 0000000..227864c --- /dev/null +++ b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt @@ -0,0 +1,7 @@ +package simplerag.ragback.domain.index.repository + +import org.springframework.data.jpa.repository.JpaRepository +import simplerag.ragback.domain.index.entity.Index + +interface IndexRepository: JpaRepository { +} \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt new file mode 100644 index 0000000..c1bb3aa --- /dev/null +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -0,0 +1,29 @@ +package simplerag.ragback.domain.index.service + +import org.springframework.stereotype.Service +import org.springframework.transaction.annotation.Transactional +import simplerag.ragback.domain.index.converter.toIndex +import simplerag.ragback.domain.index.converter.toIndexPreviewResponse +import simplerag.ragback.domain.index.dto.IndexCreateRequest +import simplerag.ragback.domain.index.dto.IndexPreviewResponse +import simplerag.ragback.domain.index.repository.IndexRepository +import simplerag.ragback.global.error.ErrorCode +import simplerag.ragback.global.error.IndexException + +@Service +class IndexService( + private val indexRepository: IndexRepository +) { + + @Transactional + fun createIndex(indexCreateRequest: IndexCreateRequest): IndexPreviewResponse { + + if (indexCreateRequest.overlapSize > indexCreateRequest.chunkingSize) { + throw IndexException(ErrorCode.OVERLAP_OVERFLOW) + } + + val createdIndex = indexRepository.save(toIndex(indexCreateRequest)) + return toIndexPreviewResponse(createdIndex) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/global/error/CustomException.kt b/src/main/kotlin/simplerag/ragback/global/error/CustomException.kt index 723a62c..c824906 100644 --- a/src/main/kotlin/simplerag/ragback/global/error/CustomException.kt +++ b/src/main/kotlin/simplerag/ragback/global/error/CustomException.kt @@ -11,6 +11,11 @@ class S3Exception( override val cause: Throwable? = null, ) : CustomException(errorCode, errorCode.message, cause) +class IndexException( + override val errorCode: ErrorCode, + override val cause: Throwable? = null, +) : CustomException(errorCode, errorCode.message, cause) + class FileException( override val errorCode: ErrorCode, override val message: String, diff --git a/src/main/kotlin/simplerag/ragback/global/error/ErrorCode.kt b/src/main/kotlin/simplerag/ragback/global/error/ErrorCode.kt index f1a2810..16e8c49 100644 --- a/src/main/kotlin/simplerag/ragback/global/error/ErrorCode.kt +++ b/src/main/kotlin/simplerag/ragback/global/error/ErrorCode.kt @@ -21,5 +21,8 @@ enum class ErrorCode( S3_INVALID_URL(HttpStatus.BAD_REQUEST, "S3_004", "유효하지 않은 S3 URL 입니다."), S3_EMPTY_FILE(HttpStatus.BAD_REQUEST, "S3_005", "빈 파일은 업로드할 수 없습니다."), S3_PRESIGN_FAIL(HttpStatus.INTERNAL_SERVER_ERROR, "S3_006", "프리사인 URL 발급 실패"), - S3_UNSUPPORTED_CONTENT_TYPE(HttpStatus.BAD_REQUEST, "S3_007", "지원하지 않는 Content-Type 입니다.") + S3_UNSUPPORTED_CONTENT_TYPE(HttpStatus.BAD_REQUEST, "S3_007", "지원하지 않는 Content-Type 입니다."), + + // index + OVERLAP_OVERFLOW(HttpStatus.BAD_REQUEST, "INDEX_001", "overlap 크기는 chunking 크기를 넘을 수 없습니다.") } From 675f87c886405d26b3be03ea1c4d8080d311178f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 13:55:08 +0900 Subject: [PATCH 02/36] =?UTF-8?q?:sparkles:=20feature:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index/controller/IndexController.kt | 7 ++++++ .../domain/index/converter/IndexConverter.kt | 22 +++++++++++++++++++ .../domain/index/dto/IndexResponseDTO.kt | 18 +++++++++++++++ .../index/repository/IndexRepository.kt | 3 +++ .../domain/index/service/IndexService.kt | 8 +++++++ 5 files changed, 58 insertions(+) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt index 441c924..b22edf6 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt @@ -3,6 +3,7 @@ package simplerag.ragback.domain.index.controller import org.springframework.http.HttpStatus import org.springframework.web.bind.annotation.* import simplerag.ragback.domain.index.dto.IndexCreateRequest +import simplerag.ragback.domain.index.dto.IndexDetailResponseList import simplerag.ragback.domain.index.dto.IndexPreviewResponse import simplerag.ragback.domain.index.service.IndexService import simplerag.ragback.global.response.ApiResponse @@ -22,4 +23,10 @@ class IndexController( return ApiResponse.ok(createdIndex) } + @GetMapping + fun getIndexes(): ApiResponse { + val indexDetailResponseList = indexService.getIndexes() + return ApiResponse.ok(indexDetailResponseList) + } + } \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt index 768d833..047ac23 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt @@ -1,6 +1,8 @@ package simplerag.ragback.domain.index.converter import simplerag.ragback.domain.index.dto.IndexCreateRequest +import simplerag.ragback.domain.index.dto.IndexDetailResponse +import simplerag.ragback.domain.index.dto.IndexDetailResponseList import simplerag.ragback.domain.index.dto.IndexPreviewResponse import simplerag.ragback.domain.index.entity.Index @@ -21,4 +23,24 @@ fun toIndexPreviewResponse(index: Index): IndexPreviewResponse { return IndexPreviewResponse( indexesId = index.id ) +} + +fun toIndexDetailResponseList( + indexes: List +): IndexDetailResponseList { + val indexList = indexes.map { toIndexDetailResponse(it) } + return IndexDetailResponseList(indexList) +} + +fun toIndexDetailResponse(index: Index): IndexDetailResponse { + return IndexDetailResponse( + indexesId = index.id, + chunkingSize = index.chunkingSize, + overlapSize = index.overlapSize, + similarityMetric = index.similarityMetric, + topK = index.topK, + embeddingModel = index.embeddingModel, + reranker = index.reranker, + snapshotName = index.snapshotName, + ) } \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt index 5021256..2b360f1 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt @@ -1,5 +1,23 @@ package simplerag.ragback.domain.index.dto +import simplerag.ragback.domain.index.entity.enums.EmbeddingModel +import simplerag.ragback.domain.index.entity.enums.SimilarityMetric + data class IndexPreviewResponse( var indexesId: Long?, +) + +data class IndexDetailResponseList( + val indexDetailResponse: List, +) + +data class IndexDetailResponse( + var indexesId: Long?, + val snapshotName: String, + val chunkingSize: Int, + val overlapSize: Int, + val similarityMetric: SimilarityMetric, + val topK: Int, + val embeddingModel: EmbeddingModel, + val reranker: Boolean, ) \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt index 227864c..4e20396 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt @@ -4,4 +4,7 @@ import org.springframework.data.jpa.repository.JpaRepository import simplerag.ragback.domain.index.entity.Index interface IndexRepository: JpaRepository { + + fun findAllByOrderByCreatedAt(): List + } \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index c1bb3aa..e4c052e 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -3,8 +3,10 @@ package simplerag.ragback.domain.index.service import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import simplerag.ragback.domain.index.converter.toIndex +import simplerag.ragback.domain.index.converter.toIndexDetailResponseList import simplerag.ragback.domain.index.converter.toIndexPreviewResponse import simplerag.ragback.domain.index.dto.IndexCreateRequest +import simplerag.ragback.domain.index.dto.IndexDetailResponseList import simplerag.ragback.domain.index.dto.IndexPreviewResponse import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.ErrorCode @@ -26,4 +28,10 @@ class IndexService( return toIndexPreviewResponse(createdIndex) } + @Transactional(readOnly = true) + fun getIndexes(): IndexDetailResponseList { + val indexes = indexRepository.findAllByOrderByCreatedAt() + return toIndexDetailResponseList(indexes) + } + } \ No newline at end of file From 88dcf54d09e5cec6f2cd473f787905176f164868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:08:39 +0900 Subject: [PATCH 03/36] =?UTF-8?q?:sparkles:=20feature:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=88=98=EC=A0=95=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index/controller/IndexController.kt | 13 +++++++ .../domain/index/dto/IndexRequestDTO.kt | 31 +++++++++++++--- .../ragback/domain/index/entity/Index.kt | 36 ++++++++++++++----- .../index/repository/IndexRepository.kt | 1 + .../domain/index/service/IndexService.kt | 17 +++++++++ 5 files changed, 85 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt index b22edf6..2f990bb 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt @@ -1,15 +1,19 @@ package simplerag.ragback.domain.index.controller +import jakarta.validation.Valid import org.springframework.http.HttpStatus +import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.* import simplerag.ragback.domain.index.dto.IndexCreateRequest import simplerag.ragback.domain.index.dto.IndexDetailResponseList import simplerag.ragback.domain.index.dto.IndexPreviewResponse +import simplerag.ragback.domain.index.dto.IndexUpdateRequest import simplerag.ragback.domain.index.service.IndexService import simplerag.ragback.global.response.ApiResponse @RestController @RequestMapping("/api/v1/indexes") +@Validated class IndexController( private val indexService: IndexService ) { @@ -29,4 +33,13 @@ class IndexController( return ApiResponse.ok(indexDetailResponseList) } + @PutMapping("/{indexesId}") + fun updateIndexes( + @PathVariable indexesId: Long, + @RequestBody @Valid indexUpdateRequest: IndexUpdateRequest, + ): ApiResponse { + val indexPreviewResponse = indexService.updateIndexes(indexesId, indexUpdateRequest) + return ApiResponse.ok(indexPreviewResponse) + } + } \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexRequestDTO.kt b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexRequestDTO.kt index 33ba116..568c8bf 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexRequestDTO.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexRequestDTO.kt @@ -1,25 +1,48 @@ package simplerag.ragback.domain.index.dto +import jakarta.validation.constraints.NotBlank +import jakarta.validation.constraints.Positive +import jakarta.validation.constraints.PositiveOrZero import org.hibernate.validator.constraints.Length import simplerag.ragback.domain.index.entity.enums.EmbeddingModel import simplerag.ragback.domain.index.entity.enums.SimilarityMetric data class IndexCreateRequest( - @Length(max = 255) + @field:Length(max = 255) + @field:NotBlank val snapshotName: String, - @Length(min = 1) + @field:Positive val chunkingSize: Int, - @Length(min = 0) + @field:PositiveOrZero val overlapSize: Int, val similarityMetric: SimilarityMetric, - @Length(min = 1) + @field:Positive val topK: Int, val embeddingModel: EmbeddingModel, + val reranker: Boolean, +) + +data class IndexUpdateRequest( + @field:Length(max = 255) + @field:NotBlank + val snapshotName: String, + + @field:Positive + val chunkingSize: Int, + + @field:PositiveOrZero + val overlapSize: Int, + + val similarityMetric: SimilarityMetric, + + @field:Positive + val topK: Int, + val reranker: Boolean, ) \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt index 630783a..7519aeb 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt @@ -2,6 +2,7 @@ package simplerag.ragback.domain.index.entity import jakarta.persistence.* import jakarta.validation.constraints.Min +import simplerag.ragback.domain.index.dto.IndexUpdateRequest import simplerag.ragback.domain.index.entity.enums.EmbeddingModel import simplerag.ragback.domain.index.entity.enums.SimilarityMetric import simplerag.ragback.global.entity.BaseEntity @@ -11,32 +12,49 @@ import simplerag.ragback.global.entity.BaseEntity class Index( @Column(name = "snapshot_name", length = 255, nullable = false) - val snapshotName: String, + var snapshotName: String, @Column(name = "chunking_size", nullable = false) @Min(1) - val chunkingSize: Int, + var chunkingSize: Int, @Column(name = "overlap_size", nullable = false) @Min(0) - val overlapSize: Int, + var overlapSize: Int, @Column(name = "similarity_metric", nullable = false) @Enumerated(EnumType.STRING) - val similarityMetric: SimilarityMetric, + var similarityMetric: SimilarityMetric, @Column(name = "top_k", nullable = false) @Min(1) - val topK: Int, + var topK: Int, @Column(name = "embedding_model", nullable = false, length = 255) @Enumerated(EnumType.STRING) - val embeddingModel: EmbeddingModel, + var embeddingModel: EmbeddingModel, @Column(name = "reranker", nullable = false) - val reranker: Boolean, + var reranker: Boolean, @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "indexes_id") - val id: Long? = null, -): BaseEntity() \ No newline at end of file + var id: Long? = null, +): BaseEntity() { + + fun update(req: IndexUpdateRequest) { + require(req.chunkingSize >= 1) { "chunkingSize는 1 이상이어야 합니다." } + require(req.overlapSize >= 0) { "overlapSize는 0 이상이어야 합니다." } + require(req.overlapSize < req.chunkingSize) { "overlapSize는 chunkingSize보다 작아야 합니다." } + require(req.topK >= 1) { "topK는 1 이상이어야 합니다." } + require(req.snapshotName.isNotBlank()) { "snapshotName은 비어 있을 수 없습니다." } + + snapshotName = req.snapshotName.trim() + chunkingSize = req.chunkingSize + overlapSize = req.overlapSize + similarityMetric = req.similarityMetric + topK = req.topK + reranker = req.reranker + } + +} \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt index 4e20396..a095c03 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt @@ -7,4 +7,5 @@ interface IndexRepository: JpaRepository { fun findAllByOrderByCreatedAt(): List + fun findIndexById(indexesId: Long): Index? } \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index e4c052e..0903d7e 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -8,6 +8,7 @@ import simplerag.ragback.domain.index.converter.toIndexPreviewResponse import simplerag.ragback.domain.index.dto.IndexCreateRequest import simplerag.ragback.domain.index.dto.IndexDetailResponseList import simplerag.ragback.domain.index.dto.IndexPreviewResponse +import simplerag.ragback.domain.index.dto.IndexUpdateRequest import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.ErrorCode import simplerag.ragback.global.error.IndexException @@ -34,4 +35,20 @@ class IndexService( return toIndexDetailResponseList(indexes) } + @Transactional + fun updateIndexes( + indexesId: Long, + indexUpdateRequest: IndexUpdateRequest + ): IndexPreviewResponse { + val index = indexRepository.findIndexById(indexesId) ?: throw IndexException(ErrorCode.NOT_FOUND) + + if (indexUpdateRequest.overlapSize > indexUpdateRequest.chunkingSize) { + throw IndexException(ErrorCode.OVERLAP_OVERFLOW) + } + + index.update(indexUpdateRequest) + + return toIndexPreviewResponse(index) + } + } \ No newline at end of file From f91166aa03f509070c914f7cdc45042a804114fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:13:52 +0900 Subject: [PATCH 04/36] =?UTF-8?q?:sparkles:=20feature:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index/controller/IndexController.kt | 19 ++++++++++------ .../domain/index/converter/IndexConverter.kt | 22 +++++++++---------- .../domain/index/dto/IndexResponseDTO.kt | 9 ++++---- .../domain/index/service/IndexService.kt | 20 +++++++++-------- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt index 2f990bb..5183744 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt @@ -4,10 +4,7 @@ import jakarta.validation.Valid import org.springframework.http.HttpStatus import org.springframework.validation.annotation.Validated import org.springframework.web.bind.annotation.* -import simplerag.ragback.domain.index.dto.IndexCreateRequest -import simplerag.ragback.domain.index.dto.IndexDetailResponseList -import simplerag.ragback.domain.index.dto.IndexPreviewResponse -import simplerag.ragback.domain.index.dto.IndexUpdateRequest +import simplerag.ragback.domain.index.dto.* import simplerag.ragback.domain.index.service.IndexService import simplerag.ragback.global.response.ApiResponse @@ -28,9 +25,17 @@ class IndexController( } @GetMapping - fun getIndexes(): ApiResponse { - val indexDetailResponseList = indexService.getIndexes() - return ApiResponse.ok(indexDetailResponseList) + fun getIndexes(): ApiResponse { + val indexPreviewResponseList = indexService.getIndexes() + return ApiResponse.ok(indexPreviewResponseList) + } + + @GetMapping("/{indexesId}") + fun getIndex( + @PathVariable indexesId: Long + ): ApiResponse { + val indexDetailResponse = indexService.getIndex(indexesId) + return ApiResponse.ok(indexDetailResponse) } @PutMapping("/{indexesId}") diff --git a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt index 047ac23..20c202b 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt @@ -1,9 +1,6 @@ package simplerag.ragback.domain.index.converter -import simplerag.ragback.domain.index.dto.IndexCreateRequest -import simplerag.ragback.domain.index.dto.IndexDetailResponse -import simplerag.ragback.domain.index.dto.IndexDetailResponseList -import simplerag.ragback.domain.index.dto.IndexPreviewResponse +import simplerag.ragback.domain.index.dto.* import simplerag.ragback.domain.index.entity.Index @@ -19,19 +16,20 @@ fun toIndex(createRequest: IndexCreateRequest): Index { ) } +fun toIndexPreviewResponseList( + indexes: List +): IndexPreviewResponseList { + val indexList = indexes.map { toIndexPreviewResponse(it) } + return IndexPreviewResponseList(indexList) +} + fun toIndexPreviewResponse(index: Index): IndexPreviewResponse { return IndexPreviewResponse( - indexesId = index.id + indexesId = index.id, + snapshotName = index.snapshotName, ) } -fun toIndexDetailResponseList( - indexes: List -): IndexDetailResponseList { - val indexList = indexes.map { toIndexDetailResponse(it) } - return IndexDetailResponseList(indexList) -} - fun toIndexDetailResponse(index: Index): IndexDetailResponse { return IndexDetailResponse( indexesId = index.id, diff --git a/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt index 2b360f1..b894554 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt @@ -3,12 +3,13 @@ package simplerag.ragback.domain.index.dto import simplerag.ragback.domain.index.entity.enums.EmbeddingModel import simplerag.ragback.domain.index.entity.enums.SimilarityMetric -data class IndexPreviewResponse( - var indexesId: Long?, +data class IndexPreviewResponseList( + val indexDetailResponse: List, ) -data class IndexDetailResponseList( - val indexDetailResponse: List, +data class IndexPreviewResponse( + var indexesId: Long?, + val snapshotName: String ) data class IndexDetailResponse( diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index 0903d7e..f9cba6d 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -2,13 +2,8 @@ package simplerag.ragback.domain.index.service import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional -import simplerag.ragback.domain.index.converter.toIndex -import simplerag.ragback.domain.index.converter.toIndexDetailResponseList -import simplerag.ragback.domain.index.converter.toIndexPreviewResponse -import simplerag.ragback.domain.index.dto.IndexCreateRequest -import simplerag.ragback.domain.index.dto.IndexDetailResponseList -import simplerag.ragback.domain.index.dto.IndexPreviewResponse -import simplerag.ragback.domain.index.dto.IndexUpdateRequest +import simplerag.ragback.domain.index.converter.* +import simplerag.ragback.domain.index.dto.* import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.ErrorCode import simplerag.ragback.global.error.IndexException @@ -30,9 +25,16 @@ class IndexService( } @Transactional(readOnly = true) - fun getIndexes(): IndexDetailResponseList { + fun getIndexes(): IndexPreviewResponseList { val indexes = indexRepository.findAllByOrderByCreatedAt() - return toIndexDetailResponseList(indexes) + return toIndexPreviewResponseList(indexes) + } + + @Transactional(readOnly = true) + fun getIndex(indexesId: Long): IndexDetailResponse? { + val index = indexRepository.findIndexById(indexesId) ?: throw IndexException(ErrorCode.NOT_FOUND) + + return toIndexDetailResponse(index) } @Transactional From 562da35b8d202851099549cee04d1e8f8abda92a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:15:47 +0900 Subject: [PATCH 05/36] =?UTF-8?q?:sparkles:=20feature:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=82=AD=EC=A0=9C=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ragback/domain/index/controller/IndexController.kt | 9 +++++++++ .../ragback/domain/index/service/IndexService.kt | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt index 5183744..a0a1ba8 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt @@ -47,4 +47,13 @@ class IndexController( return ApiResponse.ok(indexPreviewResponse) } + @DeleteMapping("/{indexesId}") + fun deleteIndex( + @PathVariable indexesId: Long + ): ApiResponse { + indexService.deleteIndex(indexesId) + return ApiResponse.ok(null, "인덱스가 삭제 되었습니다.") + } + + } \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index f9cba6d..84f63b7 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -53,4 +53,11 @@ class IndexService( return toIndexPreviewResponse(index) } + @Transactional + fun deleteIndex(indexesId: Long) { + val index = indexRepository.findIndexById(indexesId) ?: throw IndexException(ErrorCode.NOT_FOUND) + + indexRepository.delete(index) + } + } \ No newline at end of file From 9d2952c6f0e49730a0596863aec837288c3741a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:23:18 +0900 Subject: [PATCH 06/36] =?UTF-8?q?:recycle:=20refactor:=20indexId=20?= =?UTF-8?q?=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/index/controller/IndexController.kt | 18 +++++++++--------- .../domain/index/converter/IndexConverter.kt | 4 ++-- .../domain/index/dto/IndexResponseDTO.kt | 4 ++-- .../domain/index/service/IndexService.kt | 12 ++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt index a0a1ba8..fa66874 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt @@ -30,28 +30,28 @@ class IndexController( return ApiResponse.ok(indexPreviewResponseList) } - @GetMapping("/{indexesId}") + @GetMapping("/{indexId}") fun getIndex( - @PathVariable indexesId: Long + @PathVariable indexId: Long ): ApiResponse { - val indexDetailResponse = indexService.getIndex(indexesId) + val indexDetailResponse = indexService.getIndex(indexId) return ApiResponse.ok(indexDetailResponse) } - @PutMapping("/{indexesId}") + @PutMapping("/{indexId}") fun updateIndexes( - @PathVariable indexesId: Long, + @PathVariable indexId: Long, @RequestBody @Valid indexUpdateRequest: IndexUpdateRequest, ): ApiResponse { - val indexPreviewResponse = indexService.updateIndexes(indexesId, indexUpdateRequest) + val indexPreviewResponse = indexService.updateIndexes(indexId, indexUpdateRequest) return ApiResponse.ok(indexPreviewResponse) } - @DeleteMapping("/{indexesId}") + @DeleteMapping("/{indexId}") fun deleteIndex( - @PathVariable indexesId: Long + @PathVariable indexId: Long ): ApiResponse { - indexService.deleteIndex(indexesId) + indexService.deleteIndex(indexId) return ApiResponse.ok(null, "인덱스가 삭제 되었습니다.") } diff --git a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt index 20c202b..298883a 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt @@ -25,14 +25,14 @@ fun toIndexPreviewResponseList( fun toIndexPreviewResponse(index: Index): IndexPreviewResponse { return IndexPreviewResponse( - indexesId = index.id, + indexId = index.id, snapshotName = index.snapshotName, ) } fun toIndexDetailResponse(index: Index): IndexDetailResponse { return IndexDetailResponse( - indexesId = index.id, + indexId = index.id, chunkingSize = index.chunkingSize, overlapSize = index.overlapSize, similarityMetric = index.similarityMetric, diff --git a/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt index b894554..7ec19ff 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/dto/IndexResponseDTO.kt @@ -8,12 +8,12 @@ data class IndexPreviewResponseList( ) data class IndexPreviewResponse( - var indexesId: Long?, + var indexId: Long?, val snapshotName: String ) data class IndexDetailResponse( - var indexesId: Long?, + var indexId: Long?, val snapshotName: String, val chunkingSize: Int, val overlapSize: Int, diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index 84f63b7..e500bb1 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -31,18 +31,18 @@ class IndexService( } @Transactional(readOnly = true) - fun getIndex(indexesId: Long): IndexDetailResponse? { - val index = indexRepository.findIndexById(indexesId) ?: throw IndexException(ErrorCode.NOT_FOUND) + fun getIndex(indexId: Long): IndexDetailResponse? { + val index = indexRepository.findIndexById(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) return toIndexDetailResponse(index) } @Transactional fun updateIndexes( - indexesId: Long, + indexId: Long, indexUpdateRequest: IndexUpdateRequest ): IndexPreviewResponse { - val index = indexRepository.findIndexById(indexesId) ?: throw IndexException(ErrorCode.NOT_FOUND) + val index = indexRepository.findIndexById(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) if (indexUpdateRequest.overlapSize > indexUpdateRequest.chunkingSize) { throw IndexException(ErrorCode.OVERLAP_OVERFLOW) @@ -54,8 +54,8 @@ class IndexService( } @Transactional - fun deleteIndex(indexesId: Long) { - val index = indexRepository.findIndexById(indexesId) ?: throw IndexException(ErrorCode.NOT_FOUND) + fun deleteIndex(indexId: Long) { + val index = indexRepository.findIndexById(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) indexRepository.delete(index) } From 5a3c8aa4533ec6e83ffaecce6d9a01df43f52cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:34:55 +0900 Subject: [PATCH 07/36] =?UTF-8?q?:bug:=20fix:=20createIndex=20valid=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ragback/domain/index/controller/IndexController.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt index fa66874..392d54f 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt @@ -18,7 +18,7 @@ class IndexController( @PostMapping @ResponseStatus(HttpStatus.CREATED) fun createIndex( - @RequestBody indexCreateRequest: IndexCreateRequest + @RequestBody @Valid indexCreateRequest: IndexCreateRequest ): ApiResponse { val createdIndex = indexService.createIndex(indexCreateRequest) return ApiResponse.ok(createdIndex) From 3c0a4391e1e10a69273b86964773b946721f01a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:35:51 +0900 Subject: [PATCH 08/36] =?UTF-8?q?:recycle:=20refactor:=20getIndex=20null?= =?UTF-8?q?=20=ED=97=88=EC=9A=A9=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simplerag/ragback/domain/index/service/IndexService.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index e500bb1..bfbbca7 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -31,7 +31,7 @@ class IndexService( } @Transactional(readOnly = true) - fun getIndex(indexId: Long): IndexDetailResponse? { + fun getIndex(indexId: Long): IndexDetailResponse { val index = indexRepository.findIndexById(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) return toIndexDetailResponse(index) From 47529f8371c825bc087f4ba448ba855c5d568ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:36:47 +0900 Subject: [PATCH 09/36] =?UTF-8?q?:recycle:=20refactor:=20updateIndexes=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ragback/domain/index/controller/IndexController.kt | 2 +- .../simplerag/ragback/domain/index/service/IndexService.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt index 392d54f..72cb889 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt @@ -43,7 +43,7 @@ class IndexController( @PathVariable indexId: Long, @RequestBody @Valid indexUpdateRequest: IndexUpdateRequest, ): ApiResponse { - val indexPreviewResponse = indexService.updateIndexes(indexId, indexUpdateRequest) + val indexPreviewResponse = indexService.updateIndex(indexId, indexUpdateRequest) return ApiResponse.ok(indexPreviewResponse) } diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index bfbbca7..73e9ae7 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -38,7 +38,7 @@ class IndexService( } @Transactional - fun updateIndexes( + fun updateIndex( indexId: Long, indexUpdateRequest: IndexUpdateRequest ): IndexPreviewResponse { From de99d880075e2005d60ee6844d349a6c2b9902ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:37:15 +0900 Subject: [PATCH 10/36] =?UTF-8?q?:recycle:=20refactor:=20deleteIndex=20?= =?UTF-8?q?=EC=83=81=ED=83=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simplerag/ragback/domain/index/controller/IndexController.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt index 72cb889..f6a85e7 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt @@ -48,6 +48,7 @@ class IndexController( } @DeleteMapping("/{indexId}") + @ResponseStatus(HttpStatus.NO_CONTENT) fun deleteIndex( @PathVariable indexId: Long ): ApiResponse { From 7e5f981d21e8e782f0f227401e775701d68f4f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:38:27 +0900 Subject: [PATCH 11/36] =?UTF-8?q?:recycle:=20refactor:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=83=9D=EC=84=B1=EC=8B=9C=20trim=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simplerag/ragback/domain/index/converter/IndexConverter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt index 298883a..da03853 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt @@ -6,7 +6,7 @@ import simplerag.ragback.domain.index.entity.Index fun toIndex(createRequest: IndexCreateRequest): Index { return Index( - snapshotName = createRequest.snapshotName, + snapshotName = createRequest.snapshotName.trim(), overlapSize = createRequest.overlapSize, chunkingSize = createRequest.chunkingSize, similarityMetric = createRequest.similarityMetric, From 498a209bf364cf7a16154a10f0475b05b23f174f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:39:58 +0900 Subject: [PATCH 12/36] =?UTF-8?q?:recycle:=20refactor:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20embeddingModel=20val=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt index 7519aeb..f447240 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt @@ -32,7 +32,7 @@ class Index( @Column(name = "embedding_model", nullable = false, length = 255) @Enumerated(EnumType.STRING) - var embeddingModel: EmbeddingModel, + val embeddingModel: EmbeddingModel, @Column(name = "reranker", nullable = false) var reranker: Boolean, From 9ad88a86f2228630774075a9e72ebbb808048126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:41:04 +0900 Subject: [PATCH 13/36] =?UTF-8?q?:recycle:=20refactor:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=A0=95=EB=A0=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ragback/domain/index/repository/IndexRepository.kt | 2 +- .../simplerag/ragback/domain/index/service/IndexService.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt index a095c03..b352e61 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt @@ -5,7 +5,7 @@ import simplerag.ragback.domain.index.entity.Index interface IndexRepository: JpaRepository { - fun findAllByOrderByCreatedAt(): List + fun findAllByOrderByCreatedAtDesc(): List fun findIndexById(indexesId: Long): Index? } \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index 73e9ae7..881ca35 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -26,7 +26,7 @@ class IndexService( @Transactional(readOnly = true) fun getIndexes(): IndexPreviewResponseList { - val indexes = indexRepository.findAllByOrderByCreatedAt() + val indexes = indexRepository.findAllByOrderByCreatedAtDesc() return toIndexPreviewResponseList(indexes) } From 9dddf802eddb4a9986e346d07055d1d4dde373c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:42:16 +0900 Subject: [PATCH 14/36] =?UTF-8?q?:recycle:=20refactor:=20index=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=EB=B3=B8=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ragback/domain/index/repository/IndexRepository.kt | 2 -- .../simplerag/ragback/domain/index/service/IndexService.kt | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt index b352e61..2b6bc6a 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt @@ -6,6 +6,4 @@ import simplerag.ragback.domain.index.entity.Index interface IndexRepository: JpaRepository { fun findAllByOrderByCreatedAtDesc(): List - - fun findIndexById(indexesId: Long): Index? } \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index 881ca35..2f699dc 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -1,5 +1,6 @@ package simplerag.ragback.domain.index.service +import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import simplerag.ragback.domain.index.converter.* @@ -32,7 +33,7 @@ class IndexService( @Transactional(readOnly = true) fun getIndex(indexId: Long): IndexDetailResponse { - val index = indexRepository.findIndexById(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) + val index = indexRepository.findByIdOrNull(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) return toIndexDetailResponse(index) } @@ -42,7 +43,7 @@ class IndexService( indexId: Long, indexUpdateRequest: IndexUpdateRequest ): IndexPreviewResponse { - val index = indexRepository.findIndexById(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) + val index = indexRepository.findByIdOrNull(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) if (indexUpdateRequest.overlapSize > indexUpdateRequest.chunkingSize) { throw IndexException(ErrorCode.OVERLAP_OVERFLOW) @@ -55,7 +56,7 @@ class IndexService( @Transactional fun deleteIndex(indexId: Long) { - val index = indexRepository.findIndexById(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) + val index = indexRepository.findByIdOrNull(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) indexRepository.delete(index) } From 4d77119f68d3e3ef0abffe2f16ed37628bdd5597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:43:08 +0900 Subject: [PATCH 15/36] =?UTF-8?q?:recycle:=20refactor:=20chunking=20size?= =?UTF-8?q?=20=EB=B3=B4=EA=B0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simplerag/ragback/domain/index/service/IndexService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index 2f699dc..7f3cd05 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -17,7 +17,7 @@ class IndexService( @Transactional fun createIndex(indexCreateRequest: IndexCreateRequest): IndexPreviewResponse { - if (indexCreateRequest.overlapSize > indexCreateRequest.chunkingSize) { + if (indexCreateRequest.overlapSize >= indexCreateRequest.chunkingSize) { throw IndexException(ErrorCode.OVERLAP_OVERFLOW) } @@ -45,7 +45,7 @@ class IndexService( ): IndexPreviewResponse { val index = indexRepository.findByIdOrNull(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) - if (indexUpdateRequest.overlapSize > indexUpdateRequest.chunkingSize) { + if (indexUpdateRequest.overlapSize >= indexUpdateRequest.chunkingSize) { throw IndexException(ErrorCode.OVERLAP_OVERFLOW) } From 83c1099fc483c8222d17f23082e51aaf22fd1e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:44:05 +0900 Subject: [PATCH 16/36] =?UTF-8?q?:recycle:=20refactor:=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=8B=9C=20=EA=B2=80=EC=A6=9D=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/simplerag/ragback/domain/index/entity/Index.kt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt index f447240..723c6f3 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt @@ -43,12 +43,6 @@ class Index( ): BaseEntity() { fun update(req: IndexUpdateRequest) { - require(req.chunkingSize >= 1) { "chunkingSize는 1 이상이어야 합니다." } - require(req.overlapSize >= 0) { "overlapSize는 0 이상이어야 합니다." } - require(req.overlapSize < req.chunkingSize) { "overlapSize는 chunkingSize보다 작아야 합니다." } - require(req.topK >= 1) { "topK는 1 이상이어야 합니다." } - require(req.snapshotName.isNotBlank()) { "snapshotName은 비어 있을 수 없습니다." } - snapshotName = req.snapshotName.trim() chunkingSize = req.chunkingSize overlapSize = req.overlapSize From e70fe40987b75291b6c2ef4edcb6030a7545a153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 14:52:34 +0900 Subject: [PATCH 17/36] =?UTF-8?q?:test=5Ftube:=20test:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=83=9D=EC=84=B1=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/index/service/IndexServiceTest.kt | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt new file mode 100644 index 0000000..01171fd --- /dev/null +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -0,0 +1,59 @@ +package simplerag.ragback.domain.index.service + +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.DisplayName +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.context.SpringBootTest +import org.springframework.test.context.ActiveProfiles +import simplerag.ragback.domain.index.dto.IndexCreateRequest +import simplerag.ragback.domain.index.entity.enums.EmbeddingModel +import simplerag.ragback.domain.index.entity.enums.SimilarityMetric +import simplerag.ragback.domain.index.repository.IndexRepository +import simplerag.ragback.global.error.IndexException + +@SpringBootTest +@ActiveProfiles("test") +class IndexServiceTest ( + @Autowired private val indexRepository: IndexRepository, + @Autowired private val indexService: IndexService, +) { + + @AfterEach + fun cleanUp() { + indexRepository.deleteAll() + } + + @Test + @DisplayName("인덱스 생성이 정상 작동한다") + fun createIndexTest() { + // given + val indexCreateRequest = IndexCreateRequest("test", 1, 0, SimilarityMetric.COSINE, 1, EmbeddingModel.TEXT_EMBEDDING_3_LARGE, true) + + // when + val createIndexResponse = indexService.createIndex(indexCreateRequest); + + // then + val indices = indexRepository.findAll() + val index = indices[0] + assertEquals(index.id, createIndexResponse.indexId) + assertEquals(index.snapshotName, createIndexResponse.snapshotName) + } + + @Test + @DisplayName("인덱스 생성 시 overlap 크기가 chunking 크기를 넘어가면 에러가 터진다") + fun getIndexesTest() { + // given + val indexCreateRequest = IndexCreateRequest("test", 1, 1, SimilarityMetric.COSINE, 1, EmbeddingModel.TEXT_EMBEDDING_3_LARGE, true) + + // when * then + val message = assertThrows { + indexService.createIndex(indexCreateRequest) + }.message + + assertEquals(message, "overlap 크기는 chunking 크기를 넘을 수 없습니다.") + } + +} \ No newline at end of file From 372ef3fa8b671a830b41e8d379bc9a6b360a0250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:04:24 +0900 Subject: [PATCH 18/36] =?UTF-8?q?:test=5Ftube:=20test:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EB=A6=AC=EC=8A=A4=ED=8A=B8=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/index/service/IndexServiceTest.kt | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index 01171fd..00212bc 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -9,10 +9,12 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.ActiveProfiles import simplerag.ragback.domain.index.dto.IndexCreateRequest +import simplerag.ragback.domain.index.entity.Index import simplerag.ragback.domain.index.entity.enums.EmbeddingModel import simplerag.ragback.domain.index.entity.enums.SimilarityMetric import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.IndexException +import org.assertj.core.api.Assertions.assertThat @SpringBootTest @ActiveProfiles("test") @@ -44,7 +46,7 @@ class IndexServiceTest ( @Test @DisplayName("인덱스 생성 시 overlap 크기가 chunking 크기를 넘어가면 에러가 터진다") - fun getIndexesTest() { + fun createIndexTestWithOverlapSize() { // given val indexCreateRequest = IndexCreateRequest("test", 1, 1, SimilarityMetric.COSINE, 1, EmbeddingModel.TEXT_EMBEDDING_3_LARGE, true) @@ -56,4 +58,38 @@ class IndexServiceTest ( assertEquals(message, "overlap 크기는 chunking 크기를 넘을 수 없습니다.") } + @Test + @DisplayName("인덱스 리스트 조회가 된다") + fun getIndexesTest() { + // given + indexRepository.saveAll( + listOf( + Index( + "test", + 1, + 0, + SimilarityMetric.COSINE, + 1, + EmbeddingModel.TEXT_EMBEDDING_3_LARGE, + true + ), + Index( + "test2", + 1, + 0, + SimilarityMetric.COSINE, + 1, + EmbeddingModel.TEXT_EMBEDDING_3_LARGE, + true + ) + ) + ) + + // when + val indexes = indexService.getIndexes() + + // then + assertThat(indexes.indexDetailResponse.size).isEqualTo(2) + } + } \ No newline at end of file From 462fff46493c3dca6f56319f23707d7494b55e2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:07:48 +0900 Subject: [PATCH 19/36] =?UTF-8?q?:test=5Ftube:=20test:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/index/service/IndexServiceTest.kt | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index 00212bc..50ba848 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -92,4 +92,34 @@ class IndexServiceTest ( assertThat(indexes.indexDetailResponse.size).isEqualTo(2) } + @Test + @DisplayName("인덱스 상세 조회가 된다") + fun getIndexTest() { + // given + val savedIndex = indexRepository.save( + Index( + "test", + 1, + 0, + SimilarityMetric.COSINE, + 1, + EmbeddingModel.TEXT_EMBEDDING_3_LARGE, + true + ) + ) + + // when + val index = indexService.getIndex(savedIndex.id!!) + + // then + assertThat(index.indexId).isEqualTo(savedIndex.id) + assertThat(index.snapshotName).isEqualTo(savedIndex.snapshotName) + assertThat(index.chunkingSize).isEqualTo(savedIndex.chunkingSize) + assertThat(index.overlapSize).isEqualTo(savedIndex.overlapSize) + assertThat(index.topK).isEqualTo(savedIndex.topK) + assertThat(index.embeddingModel).isEqualTo(savedIndex.embeddingModel) + assertThat(index.similarityMetric).isEqualTo(savedIndex.similarityMetric) + assertThat(index.reranker).isEqualTo(savedIndex.reranker) + } + } \ No newline at end of file From de400203155603524f782d91d8f5460259acf62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:14:02 +0900 Subject: [PATCH 20/36] =?UTF-8?q?:test=5Ftube:=20test:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=8B=9C=20=EC=9E=98=EB=AA=BB=EB=90=9C=20=EA=B0=92=EC=9D=B4=20?= =?UTF-8?q?=EB=93=A4=EC=96=B4=EA=B0=88=20=EB=95=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/index/service/IndexServiceTest.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index 50ba848..dbbfa6b 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -15,6 +15,7 @@ import simplerag.ragback.domain.index.entity.enums.SimilarityMetric import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.IndexException import org.assertj.core.api.Assertions.assertThat +import org.springframework.transaction.annotation.Transactional @SpringBootTest @ActiveProfiles("test") @@ -122,4 +123,27 @@ class IndexServiceTest ( assertThat(index.reranker).isEqualTo(savedIndex.reranker) } + @Test + @DisplayName("인덱스 상세 조회 시 없는 인덱스를 조회하면 에러가 터진다.") + @Transactional + fun getIndexTestWithInvalidIndex() { + // given + val savedIndex = indexRepository.save( + Index( + "test", + 1, + 0, + SimilarityMetric.COSINE, + 1, + EmbeddingModel.TEXT_EMBEDDING_3_LARGE, + true + ) + ) + + // when * then + val message = assertThrows { indexService.getIndex(savedIndex.id!! + 1L) }.message + + assertEquals(message, "리소스를 찾을 수 없습니다.") + } + } \ No newline at end of file From a963ab4e30d9b15302eb4a16a7f386686aa3f37f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:18:36 +0900 Subject: [PATCH 21/36] =?UTF-8?q?:test=5Ftube:=20test:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/index/service/IndexServiceTest.kt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index dbbfa6b..1f6a882 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -16,6 +16,7 @@ import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.IndexException import org.assertj.core.api.Assertions.assertThat import org.springframework.transaction.annotation.Transactional +import simplerag.ragback.domain.index.dto.IndexUpdateRequest @SpringBootTest @ActiveProfiles("test") @@ -146,4 +147,39 @@ class IndexServiceTest ( assertEquals(message, "리소스를 찾을 수 없습니다.") } + @Test + @DisplayName("인덱스 수정이 잘 된다") + fun updateIndexTest() { + // given + val savedIndex = indexRepository.save( + Index( + "test", + 1, + 0, + SimilarityMetric.COSINE, + 1, + EmbeddingModel.TEXT_EMBEDDING_3_LARGE, + true + ) + ) + + val indexUpdateRequest = IndexUpdateRequest("fixedTest", 2, 1, SimilarityMetric.EUCLIDEAN, 3, false) + + // when + indexService.updateIndex(savedIndex.id!!, indexUpdateRequest) + + // then + val optionalIndex = indexRepository.findById(savedIndex.id!!) + val index = optionalIndex.get() + + assertThat(savedIndex.id).isEqualTo(index.id) + assertThat(indexUpdateRequest.snapshotName).isEqualTo(index.snapshotName) + assertThat(indexUpdateRequest.chunkingSize).isEqualTo(index.chunkingSize) + assertThat(indexUpdateRequest.overlapSize).isEqualTo(index.overlapSize) + assertThat(indexUpdateRequest.topK).isEqualTo(index.topK) + assertThat(savedIndex.embeddingModel).isEqualTo(index.embeddingModel) + assertThat(indexUpdateRequest.similarityMetric).isEqualTo(index.similarityMetric) + assertThat(indexUpdateRequest.reranker).isEqualTo(index.reranker) + } + } \ No newline at end of file From 001e6d451ece191d7d8093c77917f79e54afd36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:21:05 +0900 Subject: [PATCH 22/36] =?UTF-8?q?:test=5Ftube:=20test:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/index/service/IndexServiceTest.kt | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index 1f6a882..2c8b1d5 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -182,4 +182,54 @@ class IndexServiceTest ( assertThat(indexUpdateRequest.reranker).isEqualTo(index.reranker) } + @Test + @DisplayName("인덱스 수정 시 없는 인덱스를 조회하면 에러가 터진다.") + fun getUpdateTestWithInvalidIndex() { + // given + val savedIndex = indexRepository.save( + Index( + "test", + 1, + 0, + SimilarityMetric.COSINE, + 1, + EmbeddingModel.TEXT_EMBEDDING_3_LARGE, + true + ) + ) + + val indexUpdateRequest = IndexUpdateRequest("fixedTest", 2, 1, SimilarityMetric.EUCLIDEAN, 3, false) + + // when * then + val message = assertThrows { indexService.updateIndex(savedIndex.id!! + 1L, indexUpdateRequest) }.message + + assertEquals(message, "리소스를 찾을 수 없습니다.") + } + + @Test + @DisplayName("인덱스 수정 시 overlap 크기가 chunking 크기를 넘어가면 에러가 터진다") + fun updateIndexTestWithOverlapSize() { + // given + val savedIndex = indexRepository.save( + Index( + "test", + 1, + 0, + SimilarityMetric.COSINE, + 1, + EmbeddingModel.TEXT_EMBEDDING_3_LARGE, + true + ) + ) + + val indexUpdateRequest = IndexUpdateRequest("fixedTest", 2, 2, SimilarityMetric.EUCLIDEAN, 3, false) + + // when * then + val message = assertThrows { + indexService.updateIndex(savedIndex.id!!, indexUpdateRequest) + }.message + + assertEquals(message, "overlap 크기는 chunking 크기를 넘을 수 없습니다.") + } + } \ No newline at end of file From c10896afa0a99a47d3ac044cc343ba9cc46031bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:24:13 +0900 Subject: [PATCH 23/36] =?UTF-8?q?:test=5Ftube:=20test:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/index/service/IndexServiceTest.kt | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index 2c8b1d5..d6fa62a 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -15,6 +15,7 @@ import simplerag.ragback.domain.index.entity.enums.SimilarityMetric import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.IndexException import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Assertions.assertNull import org.springframework.transaction.annotation.Transactional import simplerag.ragback.domain.index.dto.IndexUpdateRequest @@ -232,4 +233,50 @@ class IndexServiceTest ( assertEquals(message, "overlap 크기는 chunking 크기를 넘을 수 없습니다.") } + @Test + @DisplayName("인덱스 삭제가 잘 된다") + fun deleteIndexTest() { + // given + val savedIndex = indexRepository.save( + Index( + "test", + 1, + 0, + SimilarityMetric.COSINE, + 1, + EmbeddingModel.TEXT_EMBEDDING_3_LARGE, + true + ) + ) + + // when + indexService.deleteIndex(savedIndex.id!!) + + // then + val indexes = indexRepository.findAll() + assertThat(indexes.size).isEqualTo(0) + } + + @Test + @DisplayName("인덱스 삭제 시 없는 인덱스를 조회하면 에러가 터진다.") + fun deleteTestWithInvalidIndex() { + // given + val savedIndex = indexRepository.save( + Index( + "test", + 1, + 0, + SimilarityMetric.COSINE, + 1, + EmbeddingModel.TEXT_EMBEDDING_3_LARGE, + true + ) + ) + + // when * then + val message = assertThrows { indexService.deleteIndex(savedIndex.id!! + 1L) }.message + + assertEquals(message, "리소스를 찾을 수 없습니다.") + } + } \ No newline at end of file From b376f5cea232967233a304be37fb646b54cb47af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:25:10 +0900 Subject: [PATCH 24/36] =?UTF-8?q?:test=5Ftube:=20test:=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=ED=8F=AC=EB=A9=94=ED=8C=85=20=ED=86=B5?= =?UTF-8?q?=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simplerag/ragback/domain/index/service/IndexServiceTest.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index d6fa62a..492ac65 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -15,7 +15,6 @@ import simplerag.ragback.domain.index.entity.enums.SimilarityMetric import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.IndexException import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Assertions.assertNull import org.springframework.transaction.annotation.Transactional import simplerag.ragback.domain.index.dto.IndexUpdateRequest @@ -254,7 +253,7 @@ class IndexServiceTest ( // then val indexes = indexRepository.findAll() - assertThat(indexes.size).isEqualTo(0) + assertEquals(indexes.size, 0) } @Test From bf3a5b6604c354fe14104b79003ec2afb63221ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:36:00 +0900 Subject: [PATCH 25/36] =?UTF-8?q?:recycle:=20refactor:=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=EB=90=9C=20overlap=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=EC=9D=84=20=ED=97=AC=ED=8D=BC=EB=A1=9C=20=EC=B6=94?= =?UTF-8?q?=EC=B6=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ragback/domain/index/service/IndexService.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index 7f3cd05..f3b4b5b 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -17,9 +17,7 @@ class IndexService( @Transactional fun createIndex(indexCreateRequest: IndexCreateRequest): IndexPreviewResponse { - if (indexCreateRequest.overlapSize >= indexCreateRequest.chunkingSize) { - throw IndexException(ErrorCode.OVERLAP_OVERFLOW) - } + validateOverlap(indexCreateRequest.overlapSize, indexCreateRequest.chunkingSize) val createdIndex = indexRepository.save(toIndex(indexCreateRequest)) return toIndexPreviewResponse(createdIndex) @@ -45,9 +43,7 @@ class IndexService( ): IndexPreviewResponse { val index = indexRepository.findByIdOrNull(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) - if (indexUpdateRequest.overlapSize >= indexUpdateRequest.chunkingSize) { - throw IndexException(ErrorCode.OVERLAP_OVERFLOW) - } + validateOverlap(indexUpdateRequest.overlapSize, indexUpdateRequest.chunkingSize) index.update(indexUpdateRequest) @@ -61,4 +57,8 @@ class IndexService( indexRepository.delete(index) } + private fun validateOverlap(overlapSize: Int, chunkingSize: Int) { + if (overlapSize >= chunkingSize) throw IndexException(ErrorCode.OVERLAP_OVERFLOW) + } + } \ No newline at end of file From 3db1d9f63313e1834fc386c097d37ec8942f8b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:36:37 +0900 Subject: [PATCH 26/36] =?UTF-8?q?:recycle:=20refactor:=20=EC=84=B8?= =?UTF-8?q?=EB=AF=B8=20=EC=BD=9C=EB=A1=A0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simplerag/ragback/domain/index/service/IndexServiceTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index 492ac65..539c403 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -37,7 +37,7 @@ class IndexServiceTest ( val indexCreateRequest = IndexCreateRequest("test", 1, 0, SimilarityMetric.COSINE, 1, EmbeddingModel.TEXT_EMBEDDING_3_LARGE, true) // when - val createIndexResponse = indexService.createIndex(indexCreateRequest); + val createIndexResponse = indexService.createIndex(indexCreateRequest) // then val indices = indexRepository.findAll() From 222d0389bd9ea279e05aee60217269af3f1af0f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:38:51 +0900 Subject: [PATCH 27/36] =?UTF-8?q?:recycle:=20refactor:=20=EC=98=88?= =?UTF-8?q?=EC=B8=A1=EA=B0=92,=20=EC=8B=A4=EC=B8=A1=EA=B0=92=20=EC=88=98?= =?UTF-8?q?=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ragback/domain/index/service/IndexServiceTest.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index 539c403..4ab249b 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -57,7 +57,7 @@ class IndexServiceTest ( indexService.createIndex(indexCreateRequest) }.message - assertEquals(message, "overlap 크기는 chunking 크기를 넘을 수 없습니다.") + assertEquals("overlap 크기는 chunking 크기를 넘을 수 없습니다.", message) } @Test @@ -144,7 +144,7 @@ class IndexServiceTest ( // when * then val message = assertThrows { indexService.getIndex(savedIndex.id!! + 1L) }.message - assertEquals(message, "리소스를 찾을 수 없습니다.") + assertEquals("리소스를 찾을 수 없습니다.", message) } @Test @@ -203,7 +203,7 @@ class IndexServiceTest ( // when * then val message = assertThrows { indexService.updateIndex(savedIndex.id!! + 1L, indexUpdateRequest) }.message - assertEquals(message, "리소스를 찾을 수 없습니다.") + assertEquals("리소스를 찾을 수 없습니다.", message) } @Test @@ -229,7 +229,7 @@ class IndexServiceTest ( indexService.updateIndex(savedIndex.id!!, indexUpdateRequest) }.message - assertEquals(message, "overlap 크기는 chunking 크기를 넘을 수 없습니다.") + assertEquals("overlap 크기는 chunking 크기를 넘을 수 없습니다.", message) } @Test @@ -275,7 +275,7 @@ class IndexServiceTest ( // when * then val message = assertThrows { indexService.deleteIndex(savedIndex.id!! + 1L) }.message - assertEquals(message, "리소스를 찾을 수 없습니다.") + assertEquals("리소스를 찾을 수 없습니다.", message) } } \ No newline at end of file From 31c2066cbc12d76055e4e7302afb9029f99b1f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:39:11 +0900 Subject: [PATCH 28/36] =?UTF-8?q?:recycle:=20refactor:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=88=98=EC=A0=95=20=EC=97=90=EB=9F=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simplerag/ragback/domain/index/service/IndexServiceTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index 4ab249b..c0f5c45 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -184,7 +184,7 @@ class IndexServiceTest ( @Test @DisplayName("인덱스 수정 시 없는 인덱스를 조회하면 에러가 터진다.") - fun getUpdateTestWithInvalidIndex() { + fun updateTestWithInvalidIndex() { // given val savedIndex = indexRepository.save( Index( From 480f4d8a456ed9227bfcefea0fb87d342f2495a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:39:48 +0900 Subject: [PATCH 29/36] =?UTF-8?q?:test=5Ftube:=20test:=20size=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simplerag/ragback/domain/index/service/IndexServiceTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index c0f5c45..72a7e74 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -253,7 +253,7 @@ class IndexServiceTest ( // then val indexes = indexRepository.findAll() - assertEquals(indexes.size, 0) + assertEquals(0, indexes.size) } @Test From 8b8ee56d5514d2c4e7c6f995574541fec7907b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:41:19 +0900 Subject: [PATCH 30/36] =?UTF-8?q?:recycle:=20refactor:=20sonarqube=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/simplerag/ragback/domain/chat/entity/Model.kt | 2 +- .../simplerag/ragback/domain/document/entity/DataFile.kt | 1 - .../ragback/domain/document/entity/DataFileTag.kt | 2 +- .../simplerag/ragback/domain/document/entity/Tag.kt | 2 +- .../domain/document/repository/DataFileTagRepository.kt | 6 ++++-- .../ragback/domain/document/service/DataFileService.kt | 8 ++------ .../ragback/domain/index/converter/IndexConverter.kt | 5 ++++- .../ragback/domain/index/entity/ChunkEmbedding.kt | 2 +- .../ragback/domain/index/entity/DataFileIndex.kt | 2 +- .../kotlin/simplerag/ragback/domain/index/entity/Index.kt | 2 +- .../ragback/domain/index/repository/IndexRepository.kt | 2 +- .../ragback/domain/index/service/IndexService.kt | 5 ++++- .../simplerag/ragback/domain/prompt/entity/FewShot.kt | 2 +- .../simplerag/ragback/domain/prompt/entity/Prompt.kt | 2 +- 14 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/chat/entity/Model.kt b/src/main/kotlin/simplerag/ragback/domain/chat/entity/Model.kt index 5d7a193..093aa50 100644 --- a/src/main/kotlin/simplerag/ragback/domain/chat/entity/Model.kt +++ b/src/main/kotlin/simplerag/ragback/domain/chat/entity/Model.kt @@ -26,4 +26,4 @@ class Model( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "models_id") val id: Long? = null, -): BaseEntity() \ No newline at end of file +) : BaseEntity() \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/document/entity/DataFile.kt b/src/main/kotlin/simplerag/ragback/domain/document/entity/DataFile.kt index 1169374..724f10a 100644 --- a/src/main/kotlin/simplerag/ragback/domain/document/entity/DataFile.kt +++ b/src/main/kotlin/simplerag/ragback/domain/document/entity/DataFile.kt @@ -2,7 +2,6 @@ package simplerag.ragback.domain.document.entity import jakarta.persistence.* import simplerag.ragback.global.entity.BaseEntity -import java.time.LocalDateTime @Entity @Table( diff --git a/src/main/kotlin/simplerag/ragback/domain/document/entity/DataFileTag.kt b/src/main/kotlin/simplerag/ragback/domain/document/entity/DataFileTag.kt index 6994eed..a00b9a6 100644 --- a/src/main/kotlin/simplerag/ragback/domain/document/entity/DataFileTag.kt +++ b/src/main/kotlin/simplerag/ragback/domain/document/entity/DataFileTag.kt @@ -21,4 +21,4 @@ class DataFileTag( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "data_files_tags_id") val id: Long? = null, -): BaseEntity() \ No newline at end of file +) : BaseEntity() \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/document/entity/Tag.kt b/src/main/kotlin/simplerag/ragback/domain/document/entity/Tag.kt index fe17647..0ce9934 100644 --- a/src/main/kotlin/simplerag/ragback/domain/document/entity/Tag.kt +++ b/src/main/kotlin/simplerag/ragback/domain/document/entity/Tag.kt @@ -16,4 +16,4 @@ class Tag( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "tags_id") val id: Long? = null, -): BaseEntity() \ No newline at end of file +) : BaseEntity() \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/document/repository/DataFileTagRepository.kt b/src/main/kotlin/simplerag/ragback/domain/document/repository/DataFileTagRepository.kt index 847d51d..68c9b0f 100644 --- a/src/main/kotlin/simplerag/ragback/domain/document/repository/DataFileTagRepository.kt +++ b/src/main/kotlin/simplerag/ragback/domain/document/repository/DataFileTagRepository.kt @@ -9,12 +9,14 @@ import simplerag.ragback.domain.document.entity.DataFileTag interface DataFileTagRepository : JpaRepository { fun existsByDataFileIdAndTagId(dataFileId: Long, tagId: Long): Boolean - @Query(""" + @Query( + """ SELECT dft FROM DataFileTag dft JOIN FETCH dft.tag t WHERE dft.dataFile = :dataFile - """) + """ + ) fun findTagsByDataFile(@Param("dataFile") dataFile: DataFile): List fun deleteAllByDataFile(dataFile: DataFile) diff --git a/src/main/kotlin/simplerag/ragback/domain/document/service/DataFileService.kt b/src/main/kotlin/simplerag/ragback/domain/document/service/DataFileService.kt index cdf180a..5bb1671 100644 --- a/src/main/kotlin/simplerag/ragback/domain/document/service/DataFileService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/document/service/DataFileService.kt @@ -2,7 +2,6 @@ package simplerag.ragback.domain.document.service import org.springframework.dao.DataIntegrityViolationException import org.springframework.data.domain.PageRequest -import org.springframework.data.domain.Pageable import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import org.springframework.transaction.support.TransactionSynchronization @@ -22,9 +21,7 @@ import simplerag.ragback.global.util.S3Type import simplerag.ragback.global.util.S3Util import simplerag.ragback.global.util.computeMetricsStreaming import simplerag.ragback.global.util.resolveContentType -import java.time.LocalDateTime import java.util.* -import kotlin.collections.ArrayList @Service class DataFileService( @@ -83,11 +80,10 @@ class DataFileService( val dataSlice = dataFileRepository.findByIdGreaterThanOrderById(cursor, PageRequest.of(0, take)) val dataFileList: MutableList = ArrayList() - dataSlice.forEach{ dataFile -> + dataSlice.forEach { dataFile -> val dataFileTags: List = dataFileTagRepository.findTagsByDataFile(dataFile) - val tagDtos: List = dataFileTags.map{ - dataFileTag -> + val tagDtos: List = dataFileTags.map { dataFileTag -> val tag = dataFileTag.tag TagDTO(tag.id, tag.name) } diff --git a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt index da03853..a4f1ca0 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/converter/IndexConverter.kt @@ -1,6 +1,9 @@ package simplerag.ragback.domain.index.converter -import simplerag.ragback.domain.index.dto.* +import simplerag.ragback.domain.index.dto.IndexCreateRequest +import simplerag.ragback.domain.index.dto.IndexDetailResponse +import simplerag.ragback.domain.index.dto.IndexPreviewResponse +import simplerag.ragback.domain.index.dto.IndexPreviewResponseList import simplerag.ragback.domain.index.entity.Index diff --git a/src/main/kotlin/simplerag/ragback/domain/index/entity/ChunkEmbedding.kt b/src/main/kotlin/simplerag/ragback/domain/index/entity/ChunkEmbedding.kt index 3c1862f..127770b 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/entity/ChunkEmbedding.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/entity/ChunkEmbedding.kt @@ -27,7 +27,7 @@ class ChunkEmbedding( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "chunk_embeddings_id") val id: Long? = null, -): BaseEntity() { +) : BaseEntity() { @get:Transient val embedding: FloatArray get() = _embedding.copyOf() diff --git a/src/main/kotlin/simplerag/ragback/domain/index/entity/DataFileIndex.kt b/src/main/kotlin/simplerag/ragback/domain/index/entity/DataFileIndex.kt index 060722c..2e60163 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/entity/DataFileIndex.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/entity/DataFileIndex.kt @@ -19,4 +19,4 @@ class DataFileIndex( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "data_files_indexes_id") val id: Long? = null, -): BaseEntity() \ No newline at end of file +) : BaseEntity() \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt index 723c6f3..8391658 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt @@ -40,7 +40,7 @@ class Index( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "indexes_id") var id: Long? = null, -): BaseEntity() { +) : BaseEntity() { fun update(req: IndexUpdateRequest) { snapshotName = req.snapshotName.trim() diff --git a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt index 2b6bc6a..60af885 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/repository/IndexRepository.kt @@ -3,7 +3,7 @@ package simplerag.ragback.domain.index.repository import org.springframework.data.jpa.repository.JpaRepository import simplerag.ragback.domain.index.entity.Index -interface IndexRepository: JpaRepository { +interface IndexRepository : JpaRepository { fun findAllByOrderByCreatedAtDesc(): List } \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index f3b4b5b..537beef 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -3,7 +3,10 @@ package simplerag.ragback.domain.index.service import org.springframework.data.repository.findByIdOrNull import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional -import simplerag.ragback.domain.index.converter.* +import simplerag.ragback.domain.index.converter.toIndex +import simplerag.ragback.domain.index.converter.toIndexDetailResponse +import simplerag.ragback.domain.index.converter.toIndexPreviewResponse +import simplerag.ragback.domain.index.converter.toIndexPreviewResponseList import simplerag.ragback.domain.index.dto.* import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.ErrorCode diff --git a/src/main/kotlin/simplerag/ragback/domain/prompt/entity/FewShot.kt b/src/main/kotlin/simplerag/ragback/domain/prompt/entity/FewShot.kt index 270be2f..3a4cec4 100644 --- a/src/main/kotlin/simplerag/ragback/domain/prompt/entity/FewShot.kt +++ b/src/main/kotlin/simplerag/ragback/domain/prompt/entity/FewShot.kt @@ -25,4 +25,4 @@ class FewShot( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "few_shots_id") val id: Long? = null, -): BaseEntity() \ No newline at end of file +) : BaseEntity() \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/prompt/entity/Prompt.kt b/src/main/kotlin/simplerag/ragback/domain/prompt/entity/Prompt.kt index 17a920e..1a787e5 100644 --- a/src/main/kotlin/simplerag/ragback/domain/prompt/entity/Prompt.kt +++ b/src/main/kotlin/simplerag/ragback/domain/prompt/entity/Prompt.kt @@ -22,4 +22,4 @@ class Prompt( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "prompts_id") val id: Long? = null, -): BaseEntity() \ No newline at end of file +) : BaseEntity() \ No newline at end of file From 37da14f1625d2a745dd439c26cce0db315ff5ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:41:49 +0900 Subject: [PATCH 31/36] =?UTF-8?q?:recycle:=20refactor:=20sonarqube=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../document/service/DataFileServiceTest.kt | 13 ++++---- .../domain/index/service/IndexServiceTest.kt | 31 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/test/kotlin/simplerag/ragback/domain/document/service/DataFileServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/document/service/DataFileServiceTest.kt index 3ac7b70..8003c7d 100644 --- a/src/test/kotlin/simplerag/ragback/domain/document/service/DataFileServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/document/service/DataFileServiceTest.kt @@ -1,6 +1,5 @@ package simplerag.ragback.domain.document.service -import jakarta.annotation.PostConstruct import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.DisplayName @@ -228,12 +227,12 @@ class DataFileServiceTest( dataFileRepository.saveAll( listOf( DataFile( - title = "exists", - type = "text/plain", - sizeBytes = 0, - sha256 = sha1, - fileUrl = "fake://original/exists.txt", - ), + title = "exists", + type = "text/plain", + sizeBytes = 0, + sha256 = sha1, + fileUrl = "fake://original/exists.txt", + ), DataFile( title = "exists2", type = "text/pdf", diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index 72a7e74..54f62a4 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -1,5 +1,6 @@ package simplerag.ragback.domain.index.service +import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.DisplayName @@ -8,19 +9,18 @@ import org.junit.jupiter.api.assertThrows import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.ActiveProfiles +import org.springframework.transaction.annotation.Transactional import simplerag.ragback.domain.index.dto.IndexCreateRequest +import simplerag.ragback.domain.index.dto.IndexUpdateRequest import simplerag.ragback.domain.index.entity.Index import simplerag.ragback.domain.index.entity.enums.EmbeddingModel import simplerag.ragback.domain.index.entity.enums.SimilarityMetric import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.IndexException -import org.assertj.core.api.Assertions.assertThat -import org.springframework.transaction.annotation.Transactional -import simplerag.ragback.domain.index.dto.IndexUpdateRequest @SpringBootTest @ActiveProfiles("test") -class IndexServiceTest ( +class IndexServiceTest( @Autowired private val indexRepository: IndexRepository, @Autowired private val indexService: IndexService, ) { @@ -34,7 +34,8 @@ class IndexServiceTest ( @DisplayName("인덱스 생성이 정상 작동한다") fun createIndexTest() { // given - val indexCreateRequest = IndexCreateRequest("test", 1, 0, SimilarityMetric.COSINE, 1, EmbeddingModel.TEXT_EMBEDDING_3_LARGE, true) + val indexCreateRequest = + IndexCreateRequest("test", 1, 0, SimilarityMetric.COSINE, 1, EmbeddingModel.TEXT_EMBEDDING_3_LARGE, true) // when val createIndexResponse = indexService.createIndex(indexCreateRequest) @@ -50,7 +51,8 @@ class IndexServiceTest ( @DisplayName("인덱스 생성 시 overlap 크기가 chunking 크기를 넘어가면 에러가 터진다") fun createIndexTestWithOverlapSize() { // given - val indexCreateRequest = IndexCreateRequest("test", 1, 1, SimilarityMetric.COSINE, 1, EmbeddingModel.TEXT_EMBEDDING_3_LARGE, true) + val indexCreateRequest = + IndexCreateRequest("test", 1, 1, SimilarityMetric.COSINE, 1, EmbeddingModel.TEXT_EMBEDDING_3_LARGE, true) // when * then val message = assertThrows { @@ -67,13 +69,13 @@ class IndexServiceTest ( indexRepository.saveAll( listOf( Index( - "test", - 1, - 0, - SimilarityMetric.COSINE, - 1, - EmbeddingModel.TEXT_EMBEDDING_3_LARGE, - true + "test", + 1, + 0, + SimilarityMetric.COSINE, + 1, + EmbeddingModel.TEXT_EMBEDDING_3_LARGE, + true ), Index( "test2", @@ -201,7 +203,8 @@ class IndexServiceTest ( val indexUpdateRequest = IndexUpdateRequest("fixedTest", 2, 1, SimilarityMetric.EUCLIDEAN, 3, false) // when * then - val message = assertThrows { indexService.updateIndex(savedIndex.id!! + 1L, indexUpdateRequest) }.message + val message = + assertThrows { indexService.updateIndex(savedIndex.id!! + 1L, indexUpdateRequest) }.message assertEquals("리소스를 찾을 수 없습니다.", message) } From 0906b3921e0c2dab41883727ad42e2c3a032d501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 15:45:12 +0900 Subject: [PATCH 32/36] =?UTF-8?q?:sparkles:=20feature:=20=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4=20=EC=82=AD=EC=A0=9C=EC=8B=9C=20chunkingEmbe?= =?UTF-8?q?dding=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../index/repository/ChunkingEmbeddingRepository.kt | 11 +++++++++++ .../ragback/domain/index/service/IndexService.kt | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkingEmbeddingRepository.kt diff --git a/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkingEmbeddingRepository.kt b/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkingEmbeddingRepository.kt new file mode 100644 index 0000000..b977abe --- /dev/null +++ b/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkingEmbeddingRepository.kt @@ -0,0 +1,11 @@ +package simplerag.ragback.domain.index.repository + +import org.springframework.data.jpa.repository.JpaRepository +import simplerag.ragback.domain.index.entity.ChunkEmbedding +import simplerag.ragback.domain.index.entity.Index + +interface ChunkingEmbeddingRepository: JpaRepository { + + fun deleteAllByIndex(index: Index) + +} \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index 537beef..32edfa5 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -8,13 +8,15 @@ import simplerag.ragback.domain.index.converter.toIndexDetailResponse import simplerag.ragback.domain.index.converter.toIndexPreviewResponse import simplerag.ragback.domain.index.converter.toIndexPreviewResponseList import simplerag.ragback.domain.index.dto.* +import simplerag.ragback.domain.index.repository.ChunkingEmbeddingRepository import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.ErrorCode import simplerag.ragback.global.error.IndexException @Service class IndexService( - private val indexRepository: IndexRepository + private val indexRepository: IndexRepository, + private val chunkingEmbeddingRepository: ChunkingEmbeddingRepository, ) { @Transactional @@ -57,6 +59,8 @@ class IndexService( fun deleteIndex(indexId: Long) { val index = indexRepository.findByIdOrNull(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) + chunkingEmbeddingRepository.deleteAllByIndex(index) + indexRepository.delete(index) } From d0375ab3517d3cfb78a0a1b5bbc798bf99e0f92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 16:15:39 +0900 Subject: [PATCH 33/36] =?UTF-8?q?:recycle:=20refactor:=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ragback/domain/index/controller/IndexController.kt | 1 - src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt | 3 +++ .../simplerag/ragback/domain/index/service/IndexService.kt | 2 -- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt index f6a85e7..72cb889 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/controller/IndexController.kt @@ -48,7 +48,6 @@ class IndexController( } @DeleteMapping("/{indexId}") - @ResponseStatus(HttpStatus.NO_CONTENT) fun deleteIndex( @PathVariable indexId: Long ): ApiResponse { diff --git a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt index 8391658..060ec04 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt @@ -37,6 +37,9 @@ class Index( @Column(name = "reranker", nullable = false) var reranker: Boolean, + @OneToMany(cascade = [CascadeType.ALL], orphanRemoval = true, mappedBy = "index") + val chunkingEmbeddingList: MutableList = mutableListOf(), + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "indexes_id") var id: Long? = null, diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index 32edfa5..36d5d30 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -59,8 +59,6 @@ class IndexService( fun deleteIndex(indexId: Long) { val index = indexRepository.findByIdOrNull(indexId) ?: throw IndexException(ErrorCode.NOT_FOUND) - chunkingEmbeddingRepository.deleteAllByIndex(index) - indexRepository.delete(index) } From 11531c3e7840324d0b0a38c57668a329de6895b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 16:16:46 +0900 Subject: [PATCH 34/36] =?UTF-8?q?:recycle:=20refactor:=20transactional=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simplerag/ragback/domain/index/service/IndexServiceTest.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index 54f62a4..fb8e29e 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -128,7 +128,6 @@ class IndexServiceTest( @Test @DisplayName("인덱스 상세 조회 시 없는 인덱스를 조회하면 에러가 터진다.") - @Transactional fun getIndexTestWithInvalidIndex() { // given val savedIndex = indexRepository.save( From 7b64209a69951a738c7d9c5b4d1a2f92f252f9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 16:35:35 +0900 Subject: [PATCH 35/36] =?UTF-8?q?:recycle:=20refactor:=20=ED=8F=AC?= =?UTF-8?q?=EB=A9=94=ED=8C=85=20=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/simplerag/ragback/domain/index/entity/Index.kt | 2 +- ...gEmbeddingRepository.kt => ChunkEmbeddingRepository.kt} | 7 +------ .../simplerag/ragback/domain/index/service/IndexService.kt | 2 -- 3 files changed, 2 insertions(+), 9 deletions(-) rename src/main/kotlin/simplerag/ragback/domain/index/repository/{ChunkingEmbeddingRepository.kt => ChunkEmbeddingRepository.kt} (50%) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt index 060ec04..2f7c71f 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/entity/Index.kt @@ -38,7 +38,7 @@ class Index( var reranker: Boolean, @OneToMany(cascade = [CascadeType.ALL], orphanRemoval = true, mappedBy = "index") - val chunkingEmbeddingList: MutableList = mutableListOf(), + val chunkEmbeddings: MutableList = mutableListOf(), @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "indexes_id") diff --git a/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkingEmbeddingRepository.kt b/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkEmbeddingRepository.kt similarity index 50% rename from src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkingEmbeddingRepository.kt rename to src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkEmbeddingRepository.kt index b977abe..0aea69d 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkingEmbeddingRepository.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkEmbeddingRepository.kt @@ -2,10 +2,5 @@ package simplerag.ragback.domain.index.repository import org.springframework.data.jpa.repository.JpaRepository import simplerag.ragback.domain.index.entity.ChunkEmbedding -import simplerag.ragback.domain.index.entity.Index -interface ChunkingEmbeddingRepository: JpaRepository { - - fun deleteAllByIndex(index: Index) - -} \ No newline at end of file +interface ChunkEmbeddingRepository: JpaRepository \ No newline at end of file diff --git a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt index 36d5d30..b93ffba 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/service/IndexService.kt @@ -8,7 +8,6 @@ import simplerag.ragback.domain.index.converter.toIndexDetailResponse import simplerag.ragback.domain.index.converter.toIndexPreviewResponse import simplerag.ragback.domain.index.converter.toIndexPreviewResponseList import simplerag.ragback.domain.index.dto.* -import simplerag.ragback.domain.index.repository.ChunkingEmbeddingRepository import simplerag.ragback.domain.index.repository.IndexRepository import simplerag.ragback.global.error.ErrorCode import simplerag.ragback.global.error.IndexException @@ -16,7 +15,6 @@ import simplerag.ragback.global.error.IndexException @Service class IndexService( private val indexRepository: IndexRepository, - private val chunkingEmbeddingRepository: ChunkingEmbeddingRepository, ) { @Transactional From 5ae2ac3c52969070e0144770d0998d33e50694be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A4=80=ED=99=98?= Date: Mon, 18 Aug 2025 16:36:12 +0900 Subject: [PATCH 36/36] =?UTF-8?q?:recycle:=20refactor:=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ragback/domain/index/repository/ChunkEmbeddingRepository.kt | 2 +- .../simplerag/ragback/domain/index/service/IndexServiceTest.kt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkEmbeddingRepository.kt b/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkEmbeddingRepository.kt index 0aea69d..0060955 100644 --- a/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkEmbeddingRepository.kt +++ b/src/main/kotlin/simplerag/ragback/domain/index/repository/ChunkEmbeddingRepository.kt @@ -3,4 +3,4 @@ package simplerag.ragback.domain.index.repository import org.springframework.data.jpa.repository.JpaRepository import simplerag.ragback.domain.index.entity.ChunkEmbedding -interface ChunkEmbeddingRepository: JpaRepository \ No newline at end of file +interface ChunkEmbeddingRepository : JpaRepository \ No newline at end of file diff --git a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt index fb8e29e..ea26cea 100644 --- a/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt +++ b/src/test/kotlin/simplerag/ragback/domain/index/service/IndexServiceTest.kt @@ -9,7 +9,6 @@ import org.junit.jupiter.api.assertThrows import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.ActiveProfiles -import org.springframework.transaction.annotation.Transactional import simplerag.ragback.domain.index.dto.IndexCreateRequest import simplerag.ragback.domain.index.dto.IndexUpdateRequest import simplerag.ragback.domain.index.entity.Index