Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor | CAKK-103 | Entity 네이밍 변경 및 애그리거트 추상 클래스 구현 #230

Merged
merged 4 commits into from
Dec 11, 2024

Conversation

lcomment
Copy link
Collaborator

@lcomment lcomment commented Dec 10, 2024

Issue Number

CAKK-103

Description

Entity 클래스 네임 suffix로 Entity를 추가했습니다. 도메인 모델 관련 추상 클래스도 구현해보았습니다. 각 추상 클래스에는 equals와 hashcode 메서드를 override 했습니다.

Core Code

abstract class AggregateRoot<T : Domain<T, TID>, TID>(
	@Transient
	private val domainEvents: MutableList<Any> = mutableListOf()
) : Domain<T, TID>() {

	protected fun registerEvent(event: T) {
		domainEvents.add(event)
	}

	@AfterDomainEventPublication
	protected fun clearEvents() {
		domainEvents.clear()
	}

	@DomainEvents
	protected fun events(): List<Any> {
		return domainEvents
	}
}

도메인 이벤트 발행 관련 메서드들을 템플릿에 맞춰 구현했는데, 어떻게 활용해볼지 생각해봐야겠네요

etc

@lcomment lcomment added the refactor 비즈니스 변경 없는 수정 label Dec 10, 2024
@lcomment lcomment requested a review from YongsHub December 10, 2024 09:38
@lcomment lcomment self-assigned this Dec 10, 2024
Copy link

Test Results

201 tests   201 ✅  44s ⏱️
 38 suites    0 💤
 38 files      0 ❌

Results for commit 3fd10e7.

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 98.33333% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...rc/main/kotlin/com/cakk/api/vo/OAuthUserDetails.kt 85.71% 1 Missing ⚠️

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #230      +/-   ##
=============================================
- Coverage      92.14%   90.19%   -1.95%     
+ Complexity       329      238      -91     
=============================================
  Files            109       59      -50     
  Lines            967      612     -355     
  Branches          34       17      -17     
=============================================
- Hits             891      552     -339     
+ Misses            58       51       -7     
+ Partials          18        9       -9     
Files with missing lines Coverage Δ Complexity Δ
...lin/com/cakk/api/controller/cake/CakeController.kt 100.00% <100.00%> (ø) 11.00 <5.00> (?)
...lin/com/cakk/api/controller/shop/ShopController.kt 100.00% <100.00%> (ø) 17.00 <10.00> (?)
...n/com/cakk/api/controller/user/MyPageController.kt 100.00% <100.00%> (ø) 6.00 <5.00> (?)
.../cakk/api/dispatcher/OidcProviderDispatcherImpl.kt 100.00% <100.00%> (ø) 5.00 <4.00> (?)
...com/cakk/api/dto/request/user/UserSignInRequest.kt 100.00% <100.00%> (ø) 3.00 <2.00> (?)
...com/cakk/api/dto/request/user/UserSignUpRequest.kt 100.00% <100.00%> (ø) 9.00 <6.00> (?)
.../src/main/kotlin/com/cakk/api/mapper/CakeMapper.kt 100.00% <100.00%> (ø) 0.00 <0.00> (?)
...rc/main/kotlin/com/cakk/api/mapper/SearchMapper.kt 100.00% <100.00%> (ø) 0.00 <0.00> (?)
.../src/main/kotlin/com/cakk/api/mapper/ShopMapper.kt 92.68% <100.00%> (ø) 0.00 <0.00> (?)
.../src/main/kotlin/com/cakk/api/mapper/UserMapper.kt 100.00% <100.00%> (ø) 0.00 <0.00> (?)
... and 3 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30d7bf7...3fd10e7. Read the comment docs.

@@ -0,0 +1,31 @@
package com.cakk.domain.base

abstract class ValueObject<T : ValueObject<T>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

ValueObject 추상 클래스 목적은 VO 관련 사용하려고 만드신건가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

네, 다음과 같은 값객체를 만들기 위함 입니다.

data class Device(
	val os: String,
	val token: String
) : ValueObject<Device>(){

	override fun getEqualityFields(): Array<Any> {
		return arrayOf(os, token)
	}

	companion object {

		fun of(os: String, token: String): Device {
			return Device(os, token)
		}
	}
}

VO는 도메인의 필드가 될 수 있습니다.

@lcomment lcomment merged commit aa9f2ad into develop Dec 11, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor 비즈니스 변경 없는 수정
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants