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

[3차 세미나] : 과제 구현 #9

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

[3차 세미나] : 과제 구현 #9

wants to merge 10 commits into from

Conversation

sansan20535
Copy link
Collaborator

@sansan20535 sansan20535 commented Nov 4, 2024

⭐️ Entity 작성⭐️

🔧최대한 많은 정보 설정 및 제약🔧

  • @column, @table 등의 속성을 최대한 활용해서 제약을 걸어보기로 했습니다.
    @Entity
    @Getter
    @NoArgsConstructor
    @Table(name = "user")
    public class UserEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", columnDefinition = "bigint", nullable = false)
    private Long id;
    @Column(name = "username", columnDefinition = "varchar(255)", nullable = false, unique = true)
    private String username;
    @Column(name = "password", columnDefinition = "varchar(255)", nullable = false)
    private String password;
    @Column(name = "nickname", columnDefinition = "varchar(255)", nullable = false)
    private String nickname;

🔧Builder 패턴 사용🔧

  • 가독성과 필요한 정보만 설정할 수 있도록 Builder패턴을 사용하게 되었습니다.

⭐️ 정렬 기준⭐️

🔧정렬 기준 상수화🔧

  • enum을 통해 정렬 기준(카테고리 포함)을 상수로 사용했습니다.

public enum Criteria {
RECENT_DATE("date"),
CONTENT_LENGTH("contentLength");

⭐️유효성 검사⭐️

🔧최대한 많은 정보 설정 및 제약 🔧

  • @Valid, @notblank 등을 이용해서 입력하는 Controller layer에서 최대한 많은 정보를 설정하고 제약하기로 했습니다!

public record DiaryInformationRequest(
@Size(min = 1, max = 10)
@NotBlank
String title,
@Size(min = 1, max = 30)
@NotBlank
String content,
Category category,
boolean isVisible

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

Successfully merging this pull request may close these issues.

1 participant