Skip to content

Comment: comment 모듈 추가 및 application, api 작성 #68

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

seonghooni
Copy link

@seonghooni seonghooni commented May 3, 2025

Pull Request

Issues

Description

  • services/comment/api 모듈 추가

    • comment 및 reply에 대한 domain, excepltion, readmodel 모듈을 작성했습니다.
  • services/comment/application 모듈 추가

    • comment 및 reply에 대한 port를 작성했습니다.
  • services/comment/driven/rdb 모듈 추가

    • comment 및 reply에 대한 entity, persistence를 작성했습니다.
    • postgresql migration script를 작성했습니다. (미해결)

How Has This Been Tested?

Additional Notes

  • postgresql migration script를 작성한 후 실행해봤지만, 다음과 같은 에러를 마주했습니다.
    board랑 일일이 대조해보면서 똑같은 구조로 작성했다고 생각하는데, board 테이블은 생성이 되지만 comment 테이블은 생성이 안됩니다.. 혹시 문제 원인에 대해서 도움을 받을 수 있을까요 ?
***************************
APPLICATION FAILED TO START
***************************

Description:

Config data resource 'class path resource [properties/db/comment.database.yml]' via location 'properties/db/comment.database.yml' does not exist

Action:

Check that the value 'properties/db/comment.database.yml' at class path resource [comment.yml] - 4:9 is correct, or prefix it with 'optional:'


Process finished with exit code 1

@merge-simpson merge-simpson added review: required Reviews are required type: feature 새로운 기능 또는 기능적 개선 A new feature or enhancement in: comment Issues in the comment module labels May 5, 2025
Comment on lines 33 to 35
project(":comment:application").projectDir = comment("application")
project(":comment:rdb-adapter").projectDir = comment("rdb")
project(":comment:webmvc-adapter").projectDir = comment("web-mvc")
Copy link
Member

@merge-simpson merge-simpson May 5, 2025

Choose a reason for hiding this comment

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

❗️ "web-mvc" 폴더가 존재하지 않습니다.

단, 이것을 해결해도 다른 오류가 남아 있어 정상적으로 실행되지는 않습니다.
(자주 언급되고 있는 오류이므로 다른 리뷰보다 먼저 싱글 코멘트로 남기겠습니다.)

val comment = getDirectories("services", "comment")

// SERVICE/COMMENT
include(
Copy link
Contributor

Choose a reason for hiding this comment

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

타 도메인과 중복되는 모듈명으로 부터 main-runner 모듈에서 yml 파일 import 부분에 트러블슈팅이 있었습니다!

하기와 같은 수정을 요청 드립니다.

  • 수정 예시
include(
    ":comment",
    ":comment:comment-api",
    ":comment:comment-api-domain",
    ":comment:comment-api-exception",
    ":comment:comment-api-readmodel",
    ":comment:comment-application",
    ":comment:comment-rdb-adapter",
    ":comment:comment-webmvc-adapter",
)

project(":comment").projectDir = comment("comment")
project(":comment:comment-api").projectDir = comment("api")
project(":comment:comment-api-domain").projectDir = comment("domain")
project(":comment:comment-api-exception").projectDir = comment("exception")
project(":comment:comment-api-readmodel").projectDir = comment("readmodel")
project(":comment:comment-application").projectDir = comment("application")
project(":comment:comment-rdb-adapter").projectDir = comment("rdb")
project(":comment:comment-webmvc-adapter").projectDir = comment("web-mvc")

Comment on lines 13 to 26
@Getter
@DynamicUpdate
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity(name = "comment")
public class ReplyEntity extends LongBaseTimeEntity {

@Id
private Long id;

private String content;

@Convert
private ReplyEntityStatus status;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

엔티티 관련한 문의사항이 있습니다!

  1. 접근제한자 private
  • Entity 필드의 접근 제한자는 멀티 모듈 환경에서 public으로 지정하기로 하였습니다.
  • 모듈이란 스코프 내에서 코딩이 이루어지기 때문에 private는 불필요 했습니다.
  • 테스트 코드를 짤 때 더 유연해집니다.
  1. @convert에 컨버터를 위한 클래스 지칭
  • Convert는 따로 해당 필드를 위한 컨버터 클래스를 지칭해야 하는 것으로 알고 있습니다. 혹시 이 작업은 누락일까요?
  • board 예시
@Getter
@DynamicUpdate
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity(name = "board")
public class BoardEntity extends LongBaseTimeEntity {
    public String title;
    public String content;

    @Convert(converter = BoardEntityStatusConverter.class)
    public BoardEntityStatus status;

    @Builder
    public BoardEntity(String title, String content, BoardEntityStatus status) {
        this.title = title;
        this.content = content;
        this.status = status;
    }
}
  1. builder 패턴을 적용하지 않은 이유가 있을까요?

Comment on lines 8 to 9
// spring
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
Copy link
Contributor

Choose a reason for hiding this comment

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

❗ 중복된 라이브러리 생략

얼마 전 Snowflake ID 모듈을 개발하면서 jpa-core의 build.gradle.kts가 다음과 같이 수정되었습니다.

dependencies {
    api(project(":snowflake-id-hibernate"))
    api("org.springframework.boot:spring-boot-starter-data-jpa")

이에 JPA 라이브러리를 이용하기 위한 driven 모듈은 하기와 같은 라이브러리를 중복으로 등록할 필요가 없습니다 👍

    // ❌  삭제 대상
    // spring
    implementation("org.springframework.boot:spring-boot-starter-data-jpa")

@merge-simpson merge-simpson changed the title Comment - comment 모듈 추가 및 application, api 작성 Comment: comment 모듈 추가 및 application, api 작성 May 13, 2025
@merge-simpson merge-simpson added review: ing Reviews are in progress and taking time and removed review: required Reviews are required labels May 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: comment Issues in the comment module review: ing Reviews are in progress and taking time type: feature 새로운 기능 또는 기능적 개선 A new feature or enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SUB-ISSUE] Comment: 모듈별 베이스 패키지 구분 [MAIN] Comment, Reply Domain 구현
3 participants