Skip to content

Commit d648ab6

Browse files
committed
feat: Article 도메인 구현
1 parent a5e79e8 commit d648ab6

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package eatda.domain.article;
2+
3+
import jakarta.persistence.Column;
4+
import jakarta.persistence.Entity;
5+
import jakarta.persistence.GeneratedValue;
6+
import jakarta.persistence.GenerationType;
7+
import jakarta.persistence.Id;
8+
import jakarta.persistence.Table;
9+
import java.time.LocalDateTime;
10+
import lombok.AccessLevel;
11+
import lombok.Getter;
12+
import lombok.NoArgsConstructor;
13+
14+
@Table(name = "article")
15+
@Entity
16+
@Getter
17+
@NoArgsConstructor(access = AccessLevel.PROTECTED)
18+
public class Article {
19+
20+
@Id
21+
@GeneratedValue(strategy = GenerationType.IDENTITY)
22+
private Long id;
23+
24+
@Column(nullable = false)
25+
private String title;
26+
27+
@Column(nullable = false)
28+
private String subtitle;
29+
30+
@Column(name = "article_url", nullable = false, length = 511)
31+
private String articleUrl;
32+
33+
@Column(name = "image_key", nullable = false, length = 511)
34+
private String imageKey;
35+
36+
@Column(name = "created_at", nullable = false)
37+
private LocalDateTime createdAt;
38+
39+
public Article(String title, String subtitle, String articleUrl, String imageKey) {
40+
this.title = title;
41+
this.subtitle = subtitle;
42+
this.articleUrl = articleUrl;
43+
this.imageKey = imageKey;
44+
this.createdAt = LocalDateTime.now();
45+
}
46+
}

src/main/resources/db/migration/V1__init.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,14 @@ CREATE TABLE `cheer`
3939
FOREIGN KEY (`member_id`) REFERENCES `member` (`id`) ON DELETE CASCADE,
4040
FOREIGN KEY (`store_id`) REFERENCES `store` (`id`) ON DELETE CASCADE
4141
);
42+
43+
CREATE TABLE `article`
44+
(
45+
`id` BIGINT NOT NULL AUTO_INCREMENT,
46+
`title` VARCHAR(255) NOT NULL,
47+
`subtitle` VARCHAR(255) NOT NULL,
48+
`article_url` VARCHAR(511) NOT NULL,
49+
`image_key` VARCHAR(511) NOT NULL,
50+
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
51+
PRIMARY KEY (`id`)
52+
);

src/main/resources/db/seed/dev/V2__dev_init_data.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ VALUES (1, 1, 1, '정말 맛있어요! 강추합니다!', 'default.jpg', true),
3232
(5, 5, 5, '디저트가 정말 맛있어요!', 'default.jpg', true),
3333
(6, 6, 6, '커피가 정말 맛있어요!', 'default.jpg', false),
3434
(7, 7, 7, '패스트푸드가 빠르고 맛있어요!', 'default.jpg', false);
35+
36+
INSERT INTO article (id, title, subtitle, article_url, image_key)
37+
VALUES (1, '첫 번째 기사', '서브타이틀 1', 'https://example.com/article1', 'default.jpg'),
38+
(2, '두 번째 기사', '서브타이틀 2', 'https://example.com/article2', 'default.jpg'),
39+
(3, '세 번째 기사', '서브타이틀 3', 'https://example.com/article3', 'default.jpg');

src/main/resources/db/seed/local/V2__local_init_data.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ VALUES (1, 1, 1, '정말 맛있어요! 강추합니다!', 'default.jpg', true),
2424
(5, 5, 5, '디저트가 정말 맛있어요!', 'default.jpg', true),
2525
(6, 6, 6, '커피가 정말 맛있어요!', 'default.jpg', false),
2626
(7, 7, 7, '패스트푸드가 빠르고 맛있어요!', 'default.jpg', false);
27+
28+
INSERT INTO article (id, title, subtitle, article_url, image_key)
29+
VALUES (1, '첫 번째 기사', '서브타이틀 1', 'https://example.com/article1', 'default.jpg'),
30+
(2, '두 번째 기사', '서브타이틀 2', 'https://example.com/article2', 'default.jpg'),
31+
(3, '세 번째 기사', '서브타이틀 3', 'https://example.com/article3', 'default.jpg');

0 commit comments

Comments
 (0)