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/recommendation 223] 탑승/하차 코드 리팩토링 #232

Open
wants to merge 4 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package kr.co.antoon.webtoon.facade;

import kr.co.antoon.coin.application.AntCoinService;
import kr.co.antoon.error.exception.webtoon.AlreadyJoinedException;
import kr.co.antoon.error.exception.webtoon.AlreadyLeavedException;
import kr.co.antoon.webtoon.application.WebtoonStatusCountService;
Expand All @@ -16,21 +17,21 @@
public class WebtoonStatusFacade {
private final WebtoonStatusService webtoonStatusService;
private final WebtoonStatusCountService webtoonStatusCountService;
private final AntCoinService antCoinService;

@Transactional
public WebtoonStatusResponse saveOrUpdate(WebtoonStatusType status, Long userId, Long webtoonId) {
statusCheck(userId, webtoonId);

WebtoonStatusCount webtoonStatusCount = webtoonStatusCountService.findByWebtoonId(webtoonId)
.orElseGet(() -> webtoonStatusCountService.save(webtoonId));
webtoonStatusCount.updateCount(status);

status = WebtoonStatusType.of(status);
webtoonStatusService.save(webtoonId, userId, status);
WebtoonStatusResponse response = new WebtoonStatusResponse(webtoonStatusCount, status);

return new WebtoonStatusResponse(
webtoonStatusCount,
status
);
return antCoinService.joinWebtoon(userId, webtoonId, response, status);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return antCoinService.joinWebtoon(userId, webtoonId, response, status);
return antCoinService.joinWebtoon(joinWebtoonDto);

이런식으로 dto 객체를 만들어서 하는 건 어떠신가요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

넵! 객채로 만들어서 전달하는 것이 더 깔끔하고 가독성도 좋을 것 같아용! 리뷰 감사합니다. 수정해서 올릴게여

}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class WebtoonController {
private final WebtoonFacade webtoonFacade;
private final WebtoonStatusFacade webtoonStatusFacade;
private final WebtoonService webtoonService;
private final AntCoinService antCoinService;


@ApiOperation(value = "웹툰 상세 조회 API", notes = SwaggerNote.WEBTOON_READ_DETAIL)
@GetMapping(value = "/{webtoonId}")
Expand Down Expand Up @@ -110,9 +110,8 @@ public ResponseEntity<WebtoonStatusResponse> createWebtoonStatus(
@AuthUser AuthInfo info,
@RequestParam("status") WebtoonStatusType status
) {
// TODO 해당 로직 처리는 여기서 하는게 이상해보이네요 response가 두번 사용되는 것도...

var response = webtoonStatusFacade.saveOrUpdate(status, info.userId(), webtoonId);
response = antCoinService.joinWebtoon(info.userId(), webtoonId, response, status);
return ResponseDto.ok(response);
}
}
Expand Down