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] contents 공통 코드 작성 #5

Merged
merged 1 commit into from
Aug 22, 2024
Merged

[feat] contents 공통 코드 작성 #5

merged 1 commit into from
Aug 22, 2024

Conversation

ssunnykku
Copy link
Contributor

@ssunnykku ssunnykku commented Aug 22, 2024

Issue

PR 타입(하나 이상의 PR 타입을 선택해주세요)

  • 기능 추가
  • 기능 삭제
  • 버그 수정
  • 의존성, 환경 변수, 빌드 관련 코드 업데이트

반영 브랜치

feat/contents -> dev

변경 사항

공통 코드 작성

@ssunnykku ssunnykku added the feat label Aug 22, 2024
@ssunnykku ssunnykku linked an issue Aug 22, 2024 that may be closed by this pull request
4 tasks
@ssunnykku ssunnykku merged commit d16ae82 into dev Aug 22, 2024
@ssunnykku ssunnykku deleted the feat/contents branch August 22, 2024 07:04
Copy link
Contributor

@pie2457 pie2457 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다 !
추가로 User와 Content의 커밋은 나누는게 좋을 것 같아요 ! 한 커밋에는 한가지 문제만 담는게 좋습니다!
브랜치명도 feat/contents 보다는 feat/create_content_entity 이런식으로 명확하게 작성하시는게 이해가 쉬울 것 같습니다~

@Controller
@RequestMapping("/contents")
public class ContentController {
}
Copy link
Contributor

Choose a reason for hiding this comment

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

혹시 EOL에 대해서 아시나용?

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
Copy link
Contributor

Choose a reason for hiding this comment

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

@RestController 대신 @Controller를 사용하신 이유가 있을까요??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RestController로 수정하겠습니다.


@Entity
@Getter
@Setter
Copy link
Contributor

Choose a reason for hiding this comment

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

@Setter를 사용하신 이유가 있을까요?

@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
Copy link
Contributor

Choose a reason for hiding this comment

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

@ToString도 당장은 사용할 필요가 없어보여요 !

@EntityListeners(AuditingEntityListener.class)
public class Content {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
Copy link
Contributor

Choose a reason for hiding this comment

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

GenerationType을 SEQUENCE로 하신 이유가 있을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

찾아보니 오라클 등은 sequence를 주로 사용하고 mysql의 경우에는 IDENTITY를 사용한다고 하네요! 수정하겠습니다.

@CreatedDate
private LocalDateTime createdAt;

@ManyToOne
Copy link
Contributor

Choose a reason for hiding this comment

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

@ManyToOne을 사용하실 때 즉시로딩과 지연로딩에 대해서 들어보신 적 있을까요!?

private Long id;
private Long likeCount;
@Size(max = 50)
private String type;
Copy link
Contributor

Choose a reason for hiding this comment

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

type은 String이 아니라 Enum이네요 !

@Column(name = "userId", nullable = false)
private UUID userId;

@OneToMany(mappedBy = "user")
Copy link
Contributor

Choose a reason for hiding this comment

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

이거는 단방향 연관관계와 양방향 연관관계를 알아보시고, 어떻게 사용할지 저희끼리 회의를 해야할 것 같습니다!

private UUID userId;

@OneToMany(mappedBy = "user")
@Builder.Default
Copy link
Contributor

Choose a reason for hiding this comment

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

@Builder.Default는 처음보네요 ! 왜 사용하셨는지 궁금합니당💭

Copy link
Contributor Author

Choose a reason for hiding this comment

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

현재는 필요없는 설정이라 삭제하겠습니다.

@Column(name = "userId", nullable = false)
private UUID userId;

@OneToMany(mappedBy = "user")
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
Contributor

@rhaehf rhaehf left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

@Getter
@Setter
@Table(name="contents")
@NoArgsConstructor
Copy link
Contributor

Choose a reason for hiding this comment

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

@NoArgsConstructor@NoArgsConstructor (access = AccessLevel.PROTECTED) 로 변경하면 어떨지 제안합니다.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

혹시 어떤 설정인가요?

Copy link
Contributor

Choose a reason for hiding this comment

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

기본 access 설정은 AccessLevel.PUBLIC이고, 별도로 access 속성을 설정하지 않으면 public 접근 수준으로 기본 생성자가 만들어진다고 합니다.
다른 패키지에서 엔티티에 대한 접근이 너무 자유로우면 안될것 같다고 생각해서 protected로 설정을 추가하자고 제안했던거였습니다.

Copy link
Contributor

@jeongeungyeong jeongeungyeong left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

public class User {
@Id
@GeneratedValue(strategy = GenerationType.UUID)
@Column(name = "userId", nullable = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

혹시 user_id로 통일해도 될까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

네 알겠습니다!

@K-0joo
Copy link
Contributor

K-0joo commented Aug 23, 2024

다 확인했습니다! 감사합니다!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

게시물 기능 공통 코드 작성
6 participants