diff --git a/src/main/java/org/runimo/runimo/item/domain/Item.java b/src/main/java/org/runimo/runimo/item/domain/Item.java index be77a43d..cc4af799 100644 --- a/src/main/java/org/runimo/runimo/item/domain/Item.java +++ b/src/main/java/org/runimo/runimo/item/domain/Item.java @@ -7,7 +7,7 @@ import org.hibernate.annotations.NaturalId; import org.runimo.runimo.common.BaseEntity; -@Table(name = "items") +@Table(name = "item") @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Inheritance(strategy = InheritanceType.SINGLE_TABLE) diff --git a/src/main/java/org/runimo/runimo/records/domain/RunningRecord.java b/src/main/java/org/runimo/runimo/records/domain/RunningRecord.java index 6921b160..a7523407 100644 --- a/src/main/java/org/runimo/runimo/records/domain/RunningRecord.java +++ b/src/main/java/org/runimo/runimo/records/domain/RunningRecord.java @@ -18,7 +18,7 @@ import java.util.Objects; import java.util.UUID; -@Table(name = "running_records") +@Table(name = "running_record") @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter diff --git a/src/main/java/org/runimo/runimo/runimo/domain/Runimo.java b/src/main/java/org/runimo/runimo/runimo/domain/Runimo.java new file mode 100644 index 00000000..89920f4e --- /dev/null +++ b/src/main/java/org/runimo/runimo/runimo/domain/Runimo.java @@ -0,0 +1,34 @@ +package org.runimo.runimo.runimo.domain; + +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.runimo.runimo.common.BaseEntity; + +@Entity +@Table(name = "runimo") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Getter +public class Runimo extends BaseEntity { + @Column(name = "name") + private String name; + + @Column(name = "code") + private String code; + + @Column(name = "description") + private String description; + + @Enumerated(EnumType.STRING) + @Column(name = "type", nullable = false) + private RunimoType type; + + @Builder + public Runimo(String name, String description, RunimoType type) { + this.name = name; + this.description = description; + this.type = type; + } +} diff --git a/src/main/java/org/runimo/runimo/runimo/domain/RunimoType.java b/src/main/java/org/runimo/runimo/runimo/domain/RunimoType.java new file mode 100644 index 00000000..47777520 --- /dev/null +++ b/src/main/java/org/runimo/runimo/runimo/domain/RunimoType.java @@ -0,0 +1,23 @@ +package org.runimo.runimo.runimo.domain; + +import lombok.Getter; + +import java.util.Arrays; +import java.util.List; + +@Getter +public enum RunimoType { + RABBIT("R-101", "토끼"), + DOG("R-102", "강아지"), + DUCK("R-103", "오리"), + WOLF("R-104", "늑대"), + ; + + private final String code; + private final String name; + + RunimoType(String code, String name) { + this.code = code; + this.name = name; + } +} diff --git a/src/main/java/org/runimo/runimo/runimo/domain/UserRunimo.java b/src/main/java/org/runimo/runimo/runimo/domain/UserRunimo.java new file mode 100644 index 00000000..cfd147e8 --- /dev/null +++ b/src/main/java/org/runimo/runimo/runimo/domain/UserRunimo.java @@ -0,0 +1,31 @@ +package org.runimo.runimo.runimo.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.runimo.runimo.common.BaseEntity; + +@Entity +@Table(name = "user_runimo") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Getter +public class UserRunimo extends BaseEntity { + + @Column(name = "user_id", nullable = false) + private Long userId; + + @Column(name = "runimo_id", nullable = false) + private Long runimoId; + + @Builder + public UserRunimo(Long id, Long userId, Long runimoId) { + this.id = id; + this.userId = userId; + this.runimoId = runimoId; + } +} diff --git a/src/main/java/org/runimo/runimo/user/domain/IncubatingEgg.java b/src/main/java/org/runimo/runimo/user/domain/IncubatingEgg.java index 46eb0f4b..a4b36656 100644 --- a/src/main/java/org/runimo/runimo/user/domain/IncubatingEgg.java +++ b/src/main/java/org/runimo/runimo/user/domain/IncubatingEgg.java @@ -8,7 +8,7 @@ import lombok.NoArgsConstructor; import org.runimo.runimo.common.BaseEntity; -@Table(name = "incubating_eggs") +@Table(name = "incubating_egg") @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/src/main/java/org/runimo/runimo/user/domain/OAuthInfo.java b/src/main/java/org/runimo/runimo/user/domain/OAuthInfo.java index d14c1323..d9527073 100644 --- a/src/main/java/org/runimo/runimo/user/domain/OAuthInfo.java +++ b/src/main/java/org/runimo/runimo/user/domain/OAuthInfo.java @@ -9,7 +9,7 @@ import org.runimo.runimo.common.BaseEntity; @Entity -@Table(name = "oauth_accounts") +@Table(name = "oauth_account") @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class OAuthInfo extends BaseEntity { diff --git a/src/main/resources/sql/schema.sql b/src/main/resources/sql/schema.sql index 9915da96..c9d6b710 100644 --- a/src/main/resources/sql/schema.sql +++ b/src/main/resources/sql/schema.sql @@ -1,17 +1,17 @@ SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF EXISTS user_token; -DROP TABLE IF EXISTS oauth_accounts; -DROP TABLE IF EXISTS running_records; +DROP TABLE IF EXISTS oauth_account; +DROP TABLE IF EXISTS running_record; DROP TABLE IF EXISTS user_item; DROP TABLE IF EXISTS incubator; DROP TABLE IF EXISTS user_runimo; DROP TABLE IF EXISTS item_activity; DROP TABLE IF EXISTS runimo; -DROP TABLE IF EXISTS items; +DROP TABLE IF EXISTS item; DROP TABLE IF EXISTS users; DROP TABLE IF EXISTS user_love_point; -DROP TABLE IF EXISTS incubating_eggs; +DROP TABLE IF EXISTS incubating_egg; SET FOREIGN_KEY_CHECKS = 1; @@ -49,7 +49,7 @@ CREATE TABLE `user_love_point` `deleted_at` TIMESTAMP ); -CREATE TABLE `oauth_accounts` +CREATE TABLE `oauth_account` ( `id` BIGINT PRIMARY KEY AUTO_INCREMENT, `user_id` BIGINT NOT NULL, @@ -62,7 +62,7 @@ CREATE TABLE `oauth_accounts` ); -CREATE TABLE `running_records` +CREATE TABLE `running_record` ( `id` integer PRIMARY KEY AUTO_INCREMENT, `user_id` integer NOT NULL, @@ -79,7 +79,7 @@ CREATE TABLE `running_records` `deleted_at` TIMESTAMP ); -CREATE TABLE `items` +CREATE TABLE item ( `id` integer PRIMARY KEY AUTO_INCREMENT, `name` varchar(255) NOT NULL, @@ -118,7 +118,7 @@ CREATE TABLE `user_item` `deleted_at` TIMESTAMP ); -CREATE TABLE `incubating_eggs` +CREATE TABLE `incubating_egg` ( `id` BIGINT PRIMARY KEY AUTO_INCREMENT, @@ -132,8 +132,30 @@ CREATE TABLE `incubating_eggs` `deleted_at` TIMESTAMP ); +CREATE TABLE `runimo` +( + `id` BIGINT PRIMARY KEY AUTO_INCREMENT, + `name` varchar(255), + `code` varchar(255), + `description` varchar(255), + `type` varchar(255) NOT NULL, + `created_at` timestamp, + `updated_at` timestamp, + `deleted_at` timestamp +); + +CREATE TABLE `user_runimo` +( + `id` BIGINT PRIMARY KEY AUTO_INCREMENT, + `user_id` BIGINT NOT NULL, + `runimo_id` BIGINT NOT NULL, + `created_at` timestamp, + `updated_at` timestamp, + `deleted_at` timestamp +); + ALTER TABLE `user_token` ADD FOREIGN KEY (`user_id`) REFERENCES `users` (`id`); -ALTER TABLE `oauth_accounts` +ALTER TABLE `oauth_account` ADD FOREIGN KEY (`user_id`) REFERENCES `users` (`id`); diff --git a/src/test/java/org/runimo/runimo/CleanUpUtil.java b/src/test/java/org/runimo/runimo/CleanUpUtil.java index c2afccf0..00f411fc 100644 --- a/src/test/java/org/runimo/runimo/CleanUpUtil.java +++ b/src/test/java/org/runimo/runimo/CleanUpUtil.java @@ -9,11 +9,11 @@ public class CleanUpUtil { private static final String[] USER_TABLES = { "user_item", - "oauth_accounts", + "oauth_account", "users", - "running_records", + "running_record", "user_love_point", - "incubating_eggs" + "incubating_egg" }; @Autowired diff --git a/src/test/resources/sql/egg_data.sql b/src/test/resources/sql/egg_data.sql index e0f6d792..4324ae35 100644 --- a/src/test/resources/sql/egg_data.sql +++ b/src/test/resources/sql/egg_data.sql @@ -1,9 +1,9 @@ -TRUNCATE TABLE items; +TRUNCATE TABLE item; -INSERT INTO items (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, +INSERT INTO item (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, updated_at) VALUES ('마당알', 'A100', '마당알: 기본 알', 'USABLE', 'example.url', 'EGG', 'MADANG', 10, NOW(), NOW()); -INSERT INTO items (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, +INSERT INTO item (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, updated_at) VALUES ('숲알', 'A101', '숲알: 기본 알', 'USABLE', 'example1.url', 'EGG', 'FOREST', 20, NOW(), NOW()); \ No newline at end of file diff --git a/src/test/resources/sql/incubating_egg_test_data.sql b/src/test/resources/sql/incubating_egg_test_data.sql index e6c15aa8..89f5ea52 100644 --- a/src/test/resources/sql/incubating_egg_test_data.sql +++ b/src/test/resources/sql/incubating_egg_test_data.sql @@ -1,7 +1,7 @@ SET FOREIGN_KEY_CHECKS = 0; TRUNCATE TABLE users; -TRUNCATE TABLE items; -TRUNCATE TABLE incubating_eggs; +TRUNCATE TABLE item; +TRUNCATE TABLE incubating_egg; TRUNCATE TABLE user_item; TRUNCATE TABLE user_love_point; SET FOREIGN_KEY_CHECKS = 1; @@ -18,8 +18,8 @@ INSERT INTO user_item (id, user_id, item_id, quantity, created_at, updated_at) VALUES (1001, 1, 1, 2, NOW(), NOW()), (1002, 1, 2, 1, NOW(), NOW()); -INSERT INTO items (id, name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, updated_at) +INSERT INTO item (id, name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, updated_at) VALUES (1, '마당알', 'A100', '기본 알', 'USABLE', 'https://example.com/images/egg.png', 'EGG', 'MADANG', 100, NOW(), NOW()); -INSERT INTO incubating_eggs (id, user_id, egg_id, current_love_point_amount, hatch_require_amount, egg_status, created_at, updated_at) +INSERT INTO incubating_egg (id, user_id, egg_id, current_love_point_amount, hatch_require_amount, egg_status, created_at, updated_at) VALUES (1, 1, 1, 50, 100, 'INCUBATING', NOW(), NOW()); diff --git a/src/test/resources/sql/main_view_data.sql b/src/test/resources/sql/main_view_data.sql index 409cf976..eaabe8cd 100644 --- a/src/test/resources/sql/main_view_data.sql +++ b/src/test/resources/sql/main_view_data.sql @@ -6,17 +6,17 @@ INSERT INTO users (id, public_id, nickname, img_url, total_distance_in_meters, t VALUES (1, 'test-user-uuid-1', 'Daniel', 'https://example.com/images/user1.png', 3000, 3600, NOW(), NOW()); SET FOREIGN_KEY_CHECKS = 1; -TRUNCATE TABLE items; -INSERT INTO items (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, +TRUNCATE TABLE item; +INSERT INTO item (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, updated_at) VALUES ('마당알', 'A100', '마당알: 기본 알', 'USABLE', 'example.url', 'EGG', 'MADANG', 10, NOW(), NOW()); -INSERT INTO items (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, +INSERT INTO item (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, updated_at) VALUES ('숲알', 'A101', '숲알: 기본 알', 'USABLE', 'example1.url', 'EGG', 'FOREST', 20, NOW(), NOW()); -TRUNCATE TABLE running_records; -INSERT INTO running_records (id, user_id, record_public_id, title, started_at, end_at, total_distance, pace_in_milli_seconds, is_rewarded, created_at, updated_at) +TRUNCATE TABLE running_record; +INSERT INTO running_record (id, user_id, record_public_id, title, started_at, end_at, total_distance, pace_in_milli_seconds, is_rewarded, created_at, updated_at) VALUES (1, 1, 'record-public-id-1', 'record-title-1', NOW(), NOW(), 1000, 100, false, NOW(), NOW()), (2, 1, 'record-public-id-2', 'record-title-2', NOW(), NOW(), 2000, 200, false, NOW(), NOW()); diff --git a/src/test/resources/sql/schema.sql b/src/test/resources/sql/schema.sql index 9915da96..f3f79773 100644 --- a/src/test/resources/sql/schema.sql +++ b/src/test/resources/sql/schema.sql @@ -1,17 +1,17 @@ SET FOREIGN_KEY_CHECKS = 0; DROP TABLE IF EXISTS user_token; -DROP TABLE IF EXISTS oauth_accounts; -DROP TABLE IF EXISTS running_records; +DROP TABLE IF EXISTS oauth_account; +DROP TABLE IF EXISTS running_record; DROP TABLE IF EXISTS user_item; DROP TABLE IF EXISTS incubator; DROP TABLE IF EXISTS user_runimo; DROP TABLE IF EXISTS item_activity; DROP TABLE IF EXISTS runimo; -DROP TABLE IF EXISTS items; +DROP TABLE IF EXISTS item; DROP TABLE IF EXISTS users; DROP TABLE IF EXISTS user_love_point; -DROP TABLE IF EXISTS incubating_eggs; +DROP TABLE IF EXISTS incubating_egg; SET FOREIGN_KEY_CHECKS = 1; @@ -49,7 +49,7 @@ CREATE TABLE `user_love_point` `deleted_at` TIMESTAMP ); -CREATE TABLE `oauth_accounts` +CREATE TABLE `oauth_account` ( `id` BIGINT PRIMARY KEY AUTO_INCREMENT, `user_id` BIGINT NOT NULL, @@ -62,7 +62,7 @@ CREATE TABLE `oauth_accounts` ); -CREATE TABLE `running_records` +CREATE TABLE `running_record` ( `id` integer PRIMARY KEY AUTO_INCREMENT, `user_id` integer NOT NULL, @@ -79,7 +79,7 @@ CREATE TABLE `running_records` `deleted_at` TIMESTAMP ); -CREATE TABLE `items` +CREATE TABLE `item` ( `id` integer PRIMARY KEY AUTO_INCREMENT, `name` varchar(255) NOT NULL, @@ -118,7 +118,7 @@ CREATE TABLE `user_item` `deleted_at` TIMESTAMP ); -CREATE TABLE `incubating_eggs` +CREATE TABLE `incubating_egg` ( `id` BIGINT PRIMARY KEY AUTO_INCREMENT, @@ -132,8 +132,31 @@ CREATE TABLE `incubating_eggs` `deleted_at` TIMESTAMP ); + +CREATE TABLE `runimo` +( + `id` BIGINT PRIMARY KEY AUTO_INCREMENT, + `name` varchar(255), + `code` varchar(255), + `description` varchar(255), + `type` varchar(255) NOT NULL, + `created_at` timestamp, + `updated_at` timestamp, + `deleted_at` timestamp +); + +CREATE TABLE `user_runimo` +( + `id` BIGINT PRIMARY KEY AUTO_INCREMENT, + `user_id` BIGINT NOT NULL, + `runimo_id` BIGINT NOT NULL, + `created_at` timestamp, + `updated_at` timestamp, + `deleted_at` timestamp +); + ALTER TABLE `user_token` ADD FOREIGN KEY (`user_id`) REFERENCES `users` (`id`); -ALTER TABLE `oauth_accounts` +ALTER TABLE `oauth_account` ADD FOREIGN KEY (`user_id`) REFERENCES `users` (`id`); diff --git a/src/test/resources/sql/user_item_test_data.sql b/src/test/resources/sql/user_item_test_data.sql index 641f572d..c3d05578 100644 --- a/src/test/resources/sql/user_item_test_data.sql +++ b/src/test/resources/sql/user_item_test_data.sql @@ -8,12 +8,12 @@ VALUES (1, 'test-user-uuid-1', 'Daniel', 'https://example.com/images/user1.png', SET FOREIGN_KEY_CHECKS = 1; -TRUNCATE TABLE items; -INSERT INTO items (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, +TRUNCATE TABLE item; +INSERT INTO item (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, updated_at) VALUES ('마당알', 'A100', '마당알: 기본 알', 'USABLE', 'example.url', 'EGG', 'MADANG', 10, NOW(), NOW()); -INSERT INTO items (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, +INSERT INTO item (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, updated_at) VALUES ('숲알', 'A101', '숲알: 기본 알', 'USABLE', 'example1.url', 'EGG', 'FOREST', 20, NOW(), NOW()); diff --git a/src/test/resources/sql/user_mypage_test_data.sql b/src/test/resources/sql/user_mypage_test_data.sql index 1abbb4b1..21f41c7d 100644 --- a/src/test/resources/sql/user_mypage_test_data.sql +++ b/src/test/resources/sql/user_mypage_test_data.sql @@ -7,8 +7,8 @@ VALUES (1, 'test-user-uuid-1', 'Daniel', 'https://example.com/images/user1.png', SET FOREIGN_KEY_CHECKS = 1; -TRUNCATE TABLE items; -INSERT INTO items (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, +TRUNCATE TABLE item; +INSERT INTO item (name, item_code, description, item_type, img_url, dtype, egg_type, hatch_require_amount, created_at, updated_at) VALUES ('마당알', 'A100', '마당알: 기본 알', 'USABLE', 'example.url', 'EGG', 'MADANG', 10, NOW(), NOW()); @@ -24,8 +24,8 @@ INSERT INTO user_love_point (id, user_id, amount, created_at, updated_at) VALUES (1001, 1, 0, NOW(), NOW()); -TRUNCATE TABLE running_records; -INSERT INTO running_records (id, user_id, record_public_id, title, started_at, end_at, total_distance, pace_in_milli_seconds, is_rewarded, created_at, updated_at) +TRUNCATE TABLE running_record; +INSERT INTO running_record (id, user_id, record_public_id, title, started_at, end_at, total_distance, pace_in_milli_seconds, is_rewarded, created_at, updated_at) VALUES (1, 1, 'record-public-id-1', 'record-title-1', '2025-03-20 13:00:00', '2025-03-20 13:00:00', 1234, 6666, false, NOW(), NOW()), (2, 1, 'record-public-id-2', 'record-title-2', '2025-03-29 13:00:00', '2025-03-29 14:00:00', 2345, 6700, false, NOW(), NOW());