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

feat: add portfolio, portfolio stock entity #89

Merged
merged 11 commits into from
Apr 1, 2024
Merged

feat: add portfolio, portfolio stock entity #89

merged 11 commits into from
Apr 1, 2024

Conversation

chominho96
Copy link
Member

@chominho96 chominho96 commented Mar 30, 2024

Issue Number

close: #88

작업 내역

구현 내용 및 작업 했던 내역

  • 포트폴리오-주식 엔티티 구현
  • 포트폴리오 엔티티 구현

변경사항

  • 의존성 목록

PR 특이 사항

PR을 볼 때 주의깊게 봐야하거나 말하고 싶은 점

  • 포트폴리오-주식 엔티티에서 stock 정보를 가지고 있을 때 ticker을 가지고 있을지, id를 가지고 있을지 고민을 하는 과정에서 알게 된 사실인데 티커가 변경될 수 있더라구요..?? (2022년 메타의 티커가 변경됨) 그래서 일단 id를 가지고 있도록 구현했는데, stock이나 dividend 파트에서 티커가 변경되었을 경우 어떻게 해아할지 생각해야 할것 같습니다 (stock은 매일 스케쥴링할 것 같으니 큰 상관 없을 것 같기도 한데 dividend는 일중일마다 과거 데이터를 스케쥴링하니까 만약 티커가 변경된다면 일주일간은 정보가 안 나올 수도 있을 것 같아요!)

@chominho96 chominho96 added the enhancement New feature or request label Mar 30, 2024
@chominho96 chominho96 self-assigned this Mar 30, 2024
@Getter
public class PortfolioStock extends BaseEntity {

private UUID portfolioId;
Copy link
Member

Choose a reason for hiding this comment

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

PortfolioStock 같은 경우에는 Portfolio와 동일한 애그리거트로 보여서 id 참조보다는 값 타입 컬렉션으로 elementCollection 사용해서 객체 참조로 만들어주는 것이 관리하기 더 편할 것 같아요!
생명주기가 동일하니 repository를 따로 만들고 별개로 삭제해주지 않아도 되구요 :)

Copy link
Member Author

Choose a reason for hiding this comment

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

아하 그렇게 관리하는게 더 나을거 같네요!! 수정하겠습니다

this.shares = shares;
}

public PortfolioStock create(final UUID portfolioId, final UUID stockId, final Integer shares) {
Copy link
Member

Choose a reason for hiding this comment

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

생성 메서드 따로 만들어주신 이유가 있을까요?? 생성자와 동일한 매개변수를 받는 것으로 보여서 생성자를 사용해도 될 것 같아서요!!

Copy link
Member Author

Choose a reason for hiding this comment

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

개인적으로 객체를 생성할 때 정적 팩토리 메서드를 이용하는 편인데, 다른 클래스와의 일관성을 유지하기 위해 생성했어요!! 그냥 생성자를 사용하는게 더 나을까요?! 🤔

Copy link
Member

Choose a reason for hiding this comment

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

저는 정적 팩터리 메서드는 생성을 위한 로직이 복잡한 경우에 주로 사용하고 아니라면 기본 생성자를 이용하는 편이긴 합니다!!
매개변수 개수가 많지 않고 생성자를 쓰는 것과 동일한 상황같아서 기본 생성자를 쓰는 것도 좋아보여요 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

오 팩토리 메서드를 경우에 따라 나눠쓰시는군요!! 그 방식이 오히려 더 직관적으로 보일 수도 있을것 같아요! 해당 방향으로 수정하겠습니다!!

@@ -81,7 +81,7 @@ class StockDividendAnalysisServiceTest {

Dividend pastDividend = DividendFixture.createDividendWithExDividendDate(
UUID.randomUUID(),
LocalDate.of(now.getYear(), now.getMonth().minus(1), now.getDayOfMonth())
LocalDate.of(now.getYear(), now.getMonth().minus(1), 1)
Copy link
Member

Choose a reason for hiding this comment

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

ㅋ ㅋ ㅋ 🤯🤯

Copy link
Member

@songyi00 songyi00 left a comment

Choose a reason for hiding this comment

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

고생하셨슴닷 코멘트 확인 부탁드려요 !-!

+)
호오 티커명이 변경되는 경우가 있군요..?!?? stock 부분은 문제없을 것 같긴 한데 배당금 부분은 스케줄링 주기를 짧게 하던지 이벤트를 보내던지 따로 논의가 필요하겠네용!

Copy link
Member

@songyi00 songyi00 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 🫡🫡

@chominho96 chominho96 merged commit ae2d7d9 into develop Apr 1, 2024
1 check passed
@chominho96 chominho96 deleted the feat/#88 branch April 1, 2024 01:30
chominho96 added a commit that referenced this pull request Apr 26, 2024
* refactor: change dependency direction (#87)

* chore: add auto generated qclass to .gitignore

* fix: failed test by current time

* refactor: apply dip for package dependency

* chore: update interface name

* test: modify test data

* fix: test code

* feat: add portfolio, portfolio stock entity (#89)

* fix: fix test date time issue

* feat: add portfolio, portfolio stock entity

* feat: add portfolio, portfolio stock repository

* refactor: refactor package structure

* test: add test fixture

* setting: add db configuration

* fix: add @entity annotation

* fix: fix portfolio stock to element collection

* fix: remove portfolio id from PoltfolioStock

* setting: fix db configuration

* refactor: delete create method from portfolio entity

* feat: implement portfolio batch service (#92)

* refactor: divide client package

* feat: implement portfolio batch service

* test: add test code

* test: update test code

* chore: update delete query

* refactor: refactor portfolio stock domain

* feat: implement portfolio api (#93)

* chore: remove unnecessary import

* feat: add portfolio command service

* feat: add portfolio query service

* feat: add portfolio controller

* docs: add portfolio controller docs

* fix: remove portfolio command service

* test: add test for create portfolio api

* feat: add monthly/yearly dividend api

* feat: add monthly/yearly dividend api

* docs: add swagger docs

* feat: implement dividend repository custom

* test: add portfolio query service test

* test: add portfolio controller test

* feat: add sector-ratio service

* feat: update portfolio controller

* test: add test code

* test: add service test code

* feat: update swagger docs

---------

Co-authored-by: Songyi Kim <ksl2950@o.cnu.ac.kr>

* feat: implement read portfolio event (#95)

* feat:wip add portfolio event

* feat: add hits to portfolio

* feat:wip add portfolio event

* feat: add increment hits consumer

* feat: add read portfolio event

* feat: implement lock for portfolio hits (concurrency)

* feat: set version initial value

* feat: set version initial value

* test: add read portfolio test

* test: fix latch

* test: fix concurrency test

* test: remove event test from portfolio query service test

* chore: add event log

* chore: fix order of log

---------

Co-authored-by: Songyi Kim <ksl2950@o.cnu.ac.kr>

---------

Co-authored-by: Songyi Kim <52441906+songyi00@users.noreply.github.com>
Co-authored-by: Songyi Kim <ksl2950@o.cnu.ac.kr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants