Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/main/java/org/runimo/runimo/item/domain/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/org/runimo/runimo/runimo/domain/Runimo.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
23 changes: 23 additions & 0 deletions src/main/java/org/runimo/runimo/runimo/domain/RunimoType.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
31 changes: 31 additions & 0 deletions src/main/java/org/runimo/runimo/runimo/domain/UserRunimo.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/runimo/runimo/user/domain/OAuthInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
40 changes: 31 additions & 9 deletions src/main/resources/sql/schema.sql
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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`);
6 changes: 3 additions & 3 deletions src/test/java/org/runimo/runimo/CleanUpUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/test/resources/sql/egg_data.sql
Original file line number Diff line number Diff line change
@@ -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());
8 changes: 4 additions & 4 deletions src/test/resources/sql/incubating_egg_test_data.sql
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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());
10 changes: 5 additions & 5 deletions src/test/resources/sql/main_view_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
41 changes: 32 additions & 9 deletions src/test/resources/sql/schema.sql
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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`);
6 changes: 3 additions & 3 deletions src/test/resources/sql/user_item_test_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
Loading