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
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;
}
}
22 changes: 22 additions & 0 deletions src/main/resources/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,28 @@ 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`);

Expand Down
23 changes: 23 additions & 0 deletions src/test/resources/sql/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ 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`);

Expand Down