Skip to content

Conversation

@koosco
Copy link
Member

@koosco koosco commented Dec 23, 2025

Summary

  • jasypt 설정을 spring test profile에서 제거
  • BaseTimeEntity 추가 (생성일, 수정일)
  • JpaAuditingConfig 추가
  • FakeS3Media 추가
  • Folder CRUD API 추가 / E2E Test 추가
  • Folder, PhotoImage 엔티티 추가
  • E2E Test를 위한 TestBase 추가

Details

jasypt 설정을 spring test profile에서 제거

테스트 편의를 위해 test 환경에서 jasypt bean을 초기화하지 않도록 변경하였습니다.

@Profile("!test")
@Configuration
class JasyptConfig

BaseTimeEntity 추가 (생성일, 수정일)

@MappedSuperclass
@EntityListeners(AuditingEntityListener::class)
abstract class BaseTimeEntity(
    @CreatedDate
    @Column(name = "created_at", nullable = false, updatable = false)
    var createdAt: LocalDateTime? = null,

    @LastModifiedDate
    @Column(name = "updated_at", nullable = false)
    var updatedAt: LocalDateTime? = null,
)

jpa 엔티티를 도메인 모델로 사용하고 있어 common/domain 하위에 위치시켰습니다. 기존 User Entity도 적용이 필요합니다.

JpaAuditingConfig 추가

FakeS3Media 추가

@Profile("test")
@Configuration
class FakeS3MediaStorage

test profile에서 S3 bean 초기화용 Fake 객체입니다. 이미지 업로드 E2E Test가 필요한 경우 testcontainer + localstack으로 변경 가능합니다. 현재는 S3 관련 E2E Test를 포함하지 않고 있어 Fake bean을 선언하였습니다.

Folder CRUD API 추가

기본적인 중복 검사를 추가하였습니다. Port의 메서드 시그니처에서 최대한 드러내지 않도록 메서드명을 수정하였습니다.
e.g)

  • findByIdAndUserId -> getOwnedFolder
  • deleteByIdAndUserId -> deleteOwnedFolder
  • findAllByUserId -> listOwnedFolders

c..c 메서드 시그니처에 대해서는 논의를 통해 얘기해보면 좋을 것 같습니다. @Darren4641

Folder, PhotoImage 엔티티 추가

PhotoImage는 Folder의 연관관계를 나타내기 위해 임시로 추가한 엔티티로, 추후 변동될 가능성이 높습니다.
Folder가 삭제될 때 포함되는 사진들을 폴더에서 제거하기 위한 목적으로 OneToMany를 정의하였습니다.

@OneToMany(mappedBy = "folder")
    val photoImages: MutableList<PhotoImage> = mutableListOf(),

) : BaseTimeEntity() {

  fun detachPhotos() {
      photoImages.forEach { it.detachFolder() 
      photoImages.clear()
  }
}

E2E Test를 위한 TestBase 추가

E2E Test를 진행할 때 대부분의 API Test에 사용자 생성과 토큰 발행 과정이 포함될 것이라 판단하여 TestBase를 만들었습니다. 테스트를 진행할 때는 TestBase를 상속하여 사용하면 됩니다.

e.g.

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
class CreateFolderE2ETest : E2ETestBase()

aggregate에 대한 반복 코드가 필요한 경우 E2ETestBase를 상속받은 TestBase를 만들어 사용할 수 있습니다.

abstract class FolderE2ETestBase : E2ETestBase() {

    @Autowired
    protected lateinit var folderRepository: JpaFolderRepository

    @AfterEach
    override fun tearDown() {
        folderRepository.deleteAllInBatch()
        super.tearDown()
    }
}

c.c. 이 방식은 처음 사용해보는건데 어떤지 의견 여쭙고 싶습니다. @Darren4641

변경 내역이 많기 때문에 PR merge시 squash merge 부탁드립니다.

Code 리뷰 반영

  • RequiresSecurity : class target 추가
  • DeleteFolderUseCase N + 1 문제 수정 : OneToMany 관계를 제거하고 Folder만 제거하도록 변경 (PhotoImage의 경우 folderId가 그대로 남지만 폴더가 삭제되어 더 이상 폴더 접근 불가)
  • Folder flyway schema cover_image_id 추가
  • flyway schema media 추가

@koosco koosco self-assigned this Dec 23, 2025
@Darren4641 Darren4641 linked an issue Dec 24, 2025 that may be closed by this pull request
Base automatically changed from feat/#6 to staging December 26, 2025 08:25
@github-actions
Copy link

Code Format Check ✅ PASSED

Spotless Check: success

✨ All code formatting checks passed!


Pushed by: @koosco, Action: pull_request

@koosco koosco marked this pull request as ready for review December 30, 2025 16:39
@koosco koosco requested a review from Darren4641 December 30, 2025 16:39
Copy link
Contributor

@Darren4641 Darren4641 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koosco Comment 남겼습니다!

@Darren4641
Copy link
Contributor

aggregate에 대한 반복 코드가 필요한 경우 E2ETestBase를 상속받은 TestBase를 만들어 사용할 수 있습니다.

회사에서 저두 이런식으로 Customer에 대해서 테스트 했더니 중복된 코드가 많이 사라져서 좋았습니다! 이대로 가도 좋을 것 같아요~

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Code Format Check ✅ PASSED

Spotless Check: success

✨ All code formatting checks passed!


Pushed by: @koosco, Action: pull_request

@koosco koosco requested a review from Darren4641 January 8, 2026 07:08
@koosco koosco linked an issue Jan 8, 2026 that may be closed by this pull request
@github-actions
Copy link

github-actions bot commented Jan 8, 2026

Code Format Check ✅ PASSED

Spotless Check: success

✨ All code formatting checks passed!


Pushed by: @koosco, Action: pull_request

Copy link
Contributor

@Darren4641 Darren4641 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다! LGTM

@Darren4641 Darren4641 merged commit cef3d3e into staging Jan 8, 2026
1 check passed
@Darren4641 Darren4641 deleted the feat/#11 branch January 8, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Media 엔티티 feat: 폴더 기본 API

3 participants