Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/main/java/com/springboot/springbooturlshortner/domain/Url.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.springboot.springbooturlshortner.domain;

import com.springboot.springbooturlshortner.exception.UrlException;
import com.springboot.springbooturlshortner.exception.UrlExceptionCode;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.regex.Pattern;

@Entity
@Table(name = "urls")
@NoArgsConstructor
@Getter
public class Url {

Choose a reason for hiding this comment

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

생성/수정 일시는 따로 필요없을까요?


private static final String ORIGIN_URL_PATTERN = "^(https?://).*";
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "indexGenerator")

Choose a reason for hiding this comment

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

Mysql로 사용하는데 SEQUENCE 전략으로 설정하신 이유가 있나요?

@SequenceGenerator(name = "indexGenerator", initialValue = 10000)
private Long id;
@Column(name = "originUrl")
private String originUrl;
Comment on lines +24 to +25

Choose a reason for hiding this comment

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

originUrl는 유니크가 보장되지 않아도 되는건가요? 여러개의 originUrl에 대한 값이 생길 수 있을 것 같네요.

public Url(String originUrl) {
this.originUrl = originUrl;
}
}