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-54 | 케이크 하트 기능 리팩토링 #193

Merged
merged 9 commits into from
Aug 26, 2024

Conversation

lcomment
Copy link
Collaborator

Issue Number

CAKK-54

Description

케이크 하트 기능이 트랜잭션 스크립트 패턴으로 작성돼있다고 생각들어 객체지향적으로 리팩토링(도메인 모델 패턴) 해보았습니다. 리뷰 후에 케이크 샵 하트 및 기대돼요 기능까지 비슷하게 적용하겠습니다.

Core Code

	@DistributedLock(key = "#cakeId")
	public void heartCake(final User user, final Long cakeId) {
		final Cake cake = cakeReader.findById(cakeId);

		if (!cake.isHeartedBy(user)) {
			user.heartCake(cake);
		} else {
			user.unHeartCake(cake);
		}
	}

etc

@lcomment lcomment added the refactor 비즈니스 변경 없는 수정 label Aug 25, 2024
@lcomment lcomment requested a review from YongsHub August 25, 2024 06:17
@lcomment lcomment self-assigned this Aug 25, 2024
Copy link

github-actions bot commented Aug 25, 2024

Test Results

197 tests  +1   197 ✅ +1   17s ⏱️ -2s
 34 suites ±0     0 💤 ±0 
 34 files   ±0     0 ❌ ±0 

Results for commit 9c574cf. ± Comparison against base commit 7cb28c9.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Aug 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #193      +/-   ##
=============================================
+ Coverage      88.88%   90.11%   +1.22%     
- Complexity       324      330       +6     
=============================================
  Files            110      110              
  Lines            990      991       +1     
  Branches          37       38       +1     
=============================================
+ Hits             880      893      +13     
+ Misses            89       81       -8     
+ Partials          21       17       -4     
Files Coverage Δ Complexity Δ
...n/java/com/cakk/api/service/like/HeartService.java 100.00% <100.00%> (ø) 7.00 <3.00> (+1.00)

... and 2 files with indirect coverage changes


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 7cb28c9...9c574cf. Read the comment docs.

Copy link
Contributor

@YongsHub YongsHub left a comment

Choose a reason for hiding this comment

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

Service Layer에서 도메인으로 책임 이동으로 인해 훨씬 깔끔하고 보기 좋은 것 같네요

Comment on lines 140 to 142
private void decreaseHeartCount() {
this.heartCount--;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

음수 방지를 위해 검증 로직 필요 없을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

db에서 막으려고 했는데, 서버에도 validation 체크를 추가해야겠네요

@lcomment lcomment merged commit 6dc02ff into develop Aug 26, 2024
3 checks passed
@lcomment lcomment deleted the refactor/CAKK-54 branch August 26, 2024 03:13
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