feat: add Firearm and Modification entities with database schema
This commit is contained in:
7 files changed
+441
-32
No files matched your search
@@ -0,0 +1,96 @@
|
||||
package com.onixbyte.deltaforceguide.domain.entity;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(name = "firearm")
|
||||
public class Firearm {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "name", nullable = false, length = 64)
|
||||
private String name;
|
||||
|
||||
@Column(name = "type", nullable = false)
|
||||
private Integer type;
|
||||
|
||||
@Column(name = "level", nullable = false)
|
||||
private Integer level;
|
||||
|
||||
@Column(name = "review", columnDefinition = "TEXT")
|
||||
private String review;
|
||||
|
||||
@OneToMany(mappedBy = "firearm", cascade = CascadeType.ALL, orphanRemoval = true)
|
||||
private List<Modification> modifications = new ArrayList<>();
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Integer type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(Integer level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getReview() {
|
||||
return review;
|
||||
}
|
||||
|
||||
public void setReview(String review) {
|
||||
this.review = review;
|
||||
}
|
||||
|
||||
public List<Modification> getModifications() {
|
||||
return modifications;
|
||||
}
|
||||
|
||||
public void setModifications(List<Modification> modifications) {
|
||||
this.modifications = modifications;
|
||||
}
|
||||
|
||||
public void addModification(Modification modification) {
|
||||
this.modifications.add(modification);
|
||||
modification.setFirearm(this);
|
||||
}
|
||||
|
||||
public void removeModification(Modification modification) {
|
||||
this.modifications.remove(modification);
|
||||
modification.setFirearm(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.onixbyte.deltaforceguide.domain.entity;
|
||||
|
||||
import io.hypersistence.utils.hibernate.type.json.JsonType;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.Index;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Table(
|
||||
name = "modification",
|
||||
indexes = {
|
||||
@Index(name = "idx_modification_firearm_id", columnList = "firearm_id")
|
||||
}
|
||||
)
|
||||
public class Modification {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "firearm_id", nullable = false, foreignKey = @ForeignKey(name = "fk_modification_firearm"))
|
||||
private Firearm firearm;
|
||||
|
||||
@Column(name = "name", nullable = false, length = 64)
|
||||
private String name;
|
||||
|
||||
@Column(name = "code", nullable = false, length = 64)
|
||||
private String code;
|
||||
|
||||
@Type(JsonType.class)
|
||||
@Column(name = "tags", columnDefinition = "json")
|
||||
private List<String> tags = new ArrayList<>();
|
||||
|
||||
@Column(name = "note", columnDefinition = "TEXT")
|
||||
private String note;
|
||||
|
||||
@Column(name = "author", length = 64)
|
||||
private String author;
|
||||
|
||||
@Column(name = "video_url", length = 512)
|
||||
private String videoUrl;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Firearm getFirearm() {
|
||||
return firearm;
|
||||
}
|
||||
|
||||
public void setFirearm(Firearm firearm) {
|
||||
this.firearm = firearm;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(List<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public String getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(String author) {
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
public String getVideoUrl() {
|
||||
return videoUrl;
|
||||
}
|
||||
|
||||
public void setVideoUrl(String videoUrl) {
|
||||
this.videoUrl = videoUrl;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user