-
Notifications
You must be signed in to change notification settings - Fork 1
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
프로젝트 저장 유효성 검사 완료 및 테스트 코드 일부 작성 #71
Changes from all commits
88cf32e
693b90b
3ee6502
b4b3eda
413a173
88781ca
a3ae300
7e7d9bb
c2f184f
e9e8eb1
e1b6acb
4cfe9b0
986a732
87c352c
156db91
911447f
1b0f35e
418b6cc
0c2b4f9
2b68614
fc4ffe2
e5bf6d8
3dfce0f
9a60d50
fbadabb
3dddfc2
6b46d12
e9949ed
58aa4b0
c72ba9e
1585c99
053a161
5bdfdf4
1120fc2
750f7de
d673a5e
4d361c6
4f1a22c
ba84c1b
7feab3a
4fc1dfe
4f66d9e
b92d292
efe24f6
396ea3d
ac1ff3a
f20d355
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package sixgaezzang.sidepeek.common.util; | ||
|
||
public class CommonConstant { | ||
public static final long MIN_ID = 1; | ||
public static final int MAX_TEXT_LENGTH = 21_844; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package sixgaezzang.sidepeek.common.util; | ||
|
||
public class Regex { | ||
public static final String URL_REGEXP = | ||
"^(https?)://([^:/\\s]+)(:([^/]*))?((/[^\\s/]+)*)?/?([^#\\s?]*)(\\?([^#\\s]*))?(#(\\w*))?$"; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
package sixgaezzang.sidepeek.projects.domain; | ||
|
||
import static sixgaezzang.sidepeek.projects.util.ProjectConstant.MAX_OVERVIEW_LENGTH; | ||
import static sixgaezzang.sidepeek.projects.util.ProjectConstant.MAX_PROJECT_NAME_LENGTH; | ||
import static sixgaezzang.sidepeek.projects.util.validation.ProjectValidator.validateDeployUrl; | ||
import static sixgaezzang.sidepeek.projects.util.validation.ProjectValidator.validateDescription; | ||
import static sixgaezzang.sidepeek.projects.util.validation.ProjectValidator.validateDuration; | ||
import static sixgaezzang.sidepeek.projects.util.validation.ProjectValidator.validateGithubUrl; | ||
import static sixgaezzang.sidepeek.projects.util.validation.ProjectValidator.validateName; | ||
import static sixgaezzang.sidepeek.projects.util.validation.ProjectValidator.validateOverview; | ||
import static sixgaezzang.sidepeek.projects.util.validation.ProjectValidator.validateOwnerId; | ||
import static sixgaezzang.sidepeek.projects.util.validation.ProjectValidator.validateSubName; | ||
import static sixgaezzang.sidepeek.projects.util.validation.ProjectValidator.validateThumbnailUrl; | ||
import static sixgaezzang.sidepeek.projects.util.validation.ProjectValidator.validateTroubleshooting; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Convert; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import java.time.LocalDateTime; | ||
import java.time.YearMonth; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.hibernate.annotations.SQLRestriction; | ||
import sixgaezzang.sidepeek.common.domain.BaseTimeEntity; | ||
import sixgaezzang.sidepeek.projects.util.converter.YearMonthDateAttributeConverter; | ||
|
||
@Entity | ||
@Table(name = "project") | ||
|
@@ -25,20 +41,22 @@ public class Project extends BaseTimeEntity { | |
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(name = "name", nullable = false, length = 300) | ||
@Column(name = "name", nullable = false, length = MAX_PROJECT_NAME_LENGTH) | ||
private String name; | ||
|
||
@Column(name = "sub_name", length = 300) | ||
@Column(name = "sub_name", length = MAX_PROJECT_NAME_LENGTH) | ||
private String subName; | ||
|
||
@Column(name = "overview", nullable = false, length = 1000) | ||
@Column(name = "overview", nullable = false, length = MAX_OVERVIEW_LENGTH) | ||
private String overview; | ||
|
||
@Column(name = "start_date", columnDefinition = "TIMESTAMP") | ||
private LocalDateTime startDate; | ||
@Column(name = "start_date", columnDefinition = "DATE") | ||
@Convert(converter = YearMonthDateAttributeConverter.class) | ||
Sehee-Lee-01 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private YearMonth startDate; | ||
|
||
@Column(name = "end_date", columnDefinition = "TIMESTAMP") | ||
private LocalDateTime endDate; | ||
@Column(name = "end_date", columnDefinition = "DATE") | ||
@Convert(converter = YearMonthDateAttributeConverter.class) | ||
private YearMonth endDate; | ||
|
||
@Column(name = "thumbnail_url", columnDefinition = "TEXT") | ||
private String thumbnailUrl; | ||
|
@@ -49,8 +67,8 @@ public class Project extends BaseTimeEntity { | |
@Column(name = "github_url", columnDefinition = "TEXT") | ||
private String githubUrl; | ||
|
||
@Column(name = "owner_id", columnDefinition = "BIGINT") | ||
private Long ownerId; | ||
@Column(name = "owner_id", columnDefinition = "BIGINT", nullable = false) | ||
private Long ownerId; // TODO: User로 설정하는 것이 좋을까요? 놓는다면 [accessToken id 일치 확인 + 유저 존재 확인(추가 발생)] 해야합니다! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 전 개인적으로 저희가 ORM을 사용하고 있기 때문에 객체를 사용하는 것이 좋을 것 같다곤 생각합니당..! 객체지향 vs 효율(복잡성) 차이일 것 같긴합니당! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 개인적으로 ownerId라는 컬럼이 프론트단에서 프로젝트의 유저인지 확인하는 용도로만 쓰이기 때문에 User 객체보다는 ownerId를 그대로 유지하는 것이 좋다고 생각해요..! 혹시 프로젝트 게시글 작성자에 대한 추가 정보가 요구되는 일이 있을까요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 추가 정보를 요구하는 일은 없습니다! |
||
|
||
@Column(name = "description", nullable = false, columnDefinition = "TEXT") | ||
private String description; | ||
|
@@ -68,21 +86,28 @@ public class Project extends BaseTimeEntity { | |
private LocalDateTime deletedAt; | ||
|
||
@Builder | ||
public Project(String name, String subName, String overview, LocalDateTime startDate, | ||
LocalDateTime endDate, Long ownerId, | ||
String thumbnailUrl, String deployUrl, String githubUrl, String description, | ||
String troubleshooting) { | ||
public Project(String name, String subName, String overview, YearMonth startDate, YearMonth endDate, Long ownerId, | ||
String thumbnailUrl, String deployUrl, String githubUrl, String description, | ||
String troubleshooting) { | ||
validateConstructorRequiredArguments(name, overview, githubUrl, description, ownerId); | ||
validateConstructorOptionArguments(subName, thumbnailUrl, deployUrl, troubleshooting, startDate, endDate); | ||
|
||
// Required | ||
this.name = name; | ||
this.subName = subName; | ||
this.overview = overview; | ||
this.githubUrl = githubUrl; | ||
this.description = description; | ||
this.ownerId = ownerId; | ||
|
||
// Option | ||
this.subName = subName; | ||
this.startDate = startDate; | ||
this.endDate = endDate; | ||
this.ownerId = ownerId; | ||
this.thumbnailUrl = thumbnailUrl; | ||
this.deployUrl = deployUrl; | ||
this.githubUrl = githubUrl; | ||
this.description = description; | ||
this.troubleshooting = troubleshooting; | ||
|
||
// Etc | ||
Sehee-Lee-01 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.likeCount = 0L; | ||
this.viewCount = 0L; | ||
} | ||
|
@@ -91,4 +116,22 @@ public void increaseViewCount() { | |
this.viewCount++; | ||
} | ||
|
||
private void validateConstructorRequiredArguments(String name, String overview, String githubUrl, | ||
String description, Long ownerId) { | ||
validateName(name); | ||
validateOverview(overview); | ||
validateGithubUrl(githubUrl); | ||
validateDescription(description); | ||
validateOwnerId(ownerId); | ||
} | ||
|
||
private void validateConstructorOptionArguments(String subName, String thumbnailUrl, String deployUrl, | ||
String troubleshooting, YearMonth startDate, YearMonth endDate) { | ||
validateSubName(subName); | ||
validateThumbnailUrl(thumbnailUrl); | ||
validateDeployUrl(deployUrl); | ||
validateTroubleshooting(troubleshooting); | ||
validateDuration(startDate, endDate); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QueryDSL에서 만들어주는
generated
폴더는.gitignore
에 추가해도 될 것 같긴 하네용!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
엇 제가 테스트 코드 작성하면서 QClass 관련 파일들 .gitignore에 추가할게요!