feat: add Accessory and Tuning classes, update Modification to include accessories
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
package com.onixbyte.deltaforceguide.domain.entity;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Accessory {
|
||||||
|
|
||||||
|
private String slotName;
|
||||||
|
|
||||||
|
private String accessoryName;
|
||||||
|
|
||||||
|
private List<Tuning> tunings = new ArrayList<>();
|
||||||
|
|
||||||
|
public Accessory() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSlotName() {
|
||||||
|
return slotName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSlotName(String slotName) {
|
||||||
|
this.slotName = slotName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAccessoryName() {
|
||||||
|
return accessoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessoryName(String accessoryName) {
|
||||||
|
this.accessoryName = accessoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Tuning> getTunings() {
|
||||||
|
return tunings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTunings(List<Tuning> tunings) {
|
||||||
|
this.tunings = tunings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTuning(Tuning tuning) {
|
||||||
|
this.tunings.add(tuning);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeTuning(Tuning tuning) {
|
||||||
|
this.tunings.remove(tuning);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,7 @@
|
|||||||
package com.onixbyte.deltaforceguide.domain.entity;
|
package com.onixbyte.deltaforceguide.domain.entity;
|
||||||
|
|
||||||
import io.hypersistence.utils.hibernate.type.json.JsonType;
|
import io.hypersistence.utils.hibernate.type.json.JsonType;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.*;
|
||||||
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 org.hibernate.annotations.Type;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -41,9 +31,13 @@ public class Modification {
|
|||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@Type(JsonType.class)
|
@Type(JsonType.class)
|
||||||
@Column(name = "tags", columnDefinition = "json")
|
@Column(name = "tags", columnDefinition = "jsonb")
|
||||||
private List<String> tags = new ArrayList<>();
|
private List<String> tags = new ArrayList<>();
|
||||||
|
|
||||||
|
@Type(JsonType.class)
|
||||||
|
@Column(name = "accessories", columnDefinition = "jsonb")
|
||||||
|
private List<Accessory> accessories = new ArrayList<>();
|
||||||
|
|
||||||
@Column(name = "note", columnDefinition = "TEXT")
|
@Column(name = "note", columnDefinition = "TEXT")
|
||||||
private String note;
|
private String note;
|
||||||
|
|
||||||
@@ -93,6 +87,22 @@ public class Modification {
|
|||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Accessory> getAccessories() {
|
||||||
|
return accessories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccessories(List<Accessory> accessories) {
|
||||||
|
this.accessories = accessories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAccessory(Accessory modificationAccessory) {
|
||||||
|
this.accessories.add(modificationAccessory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAccessory(Accessory modificationAccessory) {
|
||||||
|
this.accessories.remove(modificationAccessory);
|
||||||
|
}
|
||||||
|
|
||||||
public String getNote() {
|
public String getNote() {
|
||||||
return note;
|
return note;
|
||||||
}
|
}
|
||||||
@@ -128,6 +138,7 @@ public class Modification {
|
|||||||
private String name;
|
private String name;
|
||||||
private String code;
|
private String code;
|
||||||
private List<String> tags;
|
private List<String> tags;
|
||||||
|
private List<Accessory> accessories;
|
||||||
private String note;
|
private String note;
|
||||||
private String author;
|
private String author;
|
||||||
private String videoUrl;
|
private String videoUrl;
|
||||||
@@ -157,6 +168,11 @@ public class Modification {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Builder accessories(List<Accessory> accessories) {
|
||||||
|
this.accessories = accessories;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder note(String note) {
|
public Builder note(String note) {
|
||||||
this.note = note;
|
this.note = note;
|
||||||
return this;
|
return this;
|
||||||
@@ -179,6 +195,7 @@ public class Modification {
|
|||||||
modification.name = this.name;
|
modification.name = this.name;
|
||||||
modification.code = this.code;
|
modification.code = this.code;
|
||||||
modification.tags = this.tags == null ? new ArrayList<>() : this.tags;
|
modification.tags = this.tags == null ? new ArrayList<>() : this.tags;
|
||||||
|
modification.accessories = this.accessories == null ? new ArrayList<>() : this.accessories;
|
||||||
modification.note = this.note;
|
modification.note = this.note;
|
||||||
modification.author = this.author;
|
modification.author = this.author;
|
||||||
modification.videoUrl = this.videoUrl;
|
modification.videoUrl = this.videoUrl;
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package com.onixbyte.deltaforceguide.domain.entity;
|
||||||
|
|
||||||
|
public class Tuning {
|
||||||
|
|
||||||
|
private String tuningName;
|
||||||
|
private Double tuningValue;
|
||||||
|
|
||||||
|
public Tuning() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTuningName() {
|
||||||
|
return tuningName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTuningName(String tuningName) {
|
||||||
|
this.tuningName = tuningName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getTuningValue() {
|
||||||
|
return tuningValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTuningValue(Double tuningValue) {
|
||||||
|
this.tuningValue = tuningValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE modification
|
||||||
|
ADD accessories JSONB NOT NULL DEFAULT '[]';
|
||||||
Reference in New Issue
Block a user