Theme add_entry functionality

This commit is contained in:
Michael Wain 2024-11-27 21:37:15 +03:00
parent b3746b66be
commit b71976815e
7 changed files with 30 additions and 12 deletions

View File

@ -39,7 +39,8 @@ public class DatabaseController {
Boolean isfemale = Boolean.parseBoolean(params.get("isfemale"));
String gender_text = new String(HashUtils.decodeHexString(params.get("gender_text")));
TextDataVal t = textDataValService.save(new TextDataVal(gender_text));
bioService.saveBio(new Bio(ismale, isfemale, canDie, t.getId()));
Long themeId = Long.parseLong(params.get("object_selected_theme"));
bioService.saveBio(new Bio(ismale, isfemale, canDie, t.getId(), themeId));
}
private void saveHobby(Map<String, String> params) {
@ -49,7 +50,10 @@ public class DatabaseController {
Float foodRange = Float.parseFloat(params.get("foodRange"));
String hobby_text = new String(HashUtils.decodeHexString(params.get("hobby_text")));
TextDataVal t = textDataValService.save(new TextDataVal(hobby_text));
hobbyService.saveHobby(new Hobby(foodRange, powerRange, violenceRange, healRange, t.getId()));
Long themeId = Long.parseLong(params.get("object_selected_theme"));
hobbyService.saveHobby(new Hobby(foodRange, powerRange, violenceRange, healRange, t.getId(), themeId));
}
private void saveLuggage(Map<String, String> params) {
@ -65,7 +69,9 @@ public class DatabaseController {
String desc_text = new String(HashUtils.decodeHexString(params.get("luggage_desc_text")));
TextDataVal t2 = textDataValService.save(new TextDataVal(desc_text));
luggageService.saveLuggage(new Luggage(violenceRange, powerRange, healRange, foodRange, isGarbage, t1.getId(), t2.getId()));
Long themeId = Long.parseLong(params.get("object_selected_theme"));
luggageService.saveLuggage(new Luggage(violenceRange, powerRange, healRange, foodRange, isGarbage, t1.getId(), t2.getId(), themeId));
}
private void saveHealth(Map<String, String> params) {
@ -77,7 +83,9 @@ public class DatabaseController {
String desc_text = new String(HashUtils.decodeHexString(params.get("heal_desc_text")));
TextDataVal t2 = textDataValService.save(new TextDataVal(desc_text));
healthService.saveHealth(new Health(health_index, t1.getId(), t2.getId(), childFree));
Long themeId = Long.parseLong(params.get("object_selected_theme"));
healthService.saveHealth(new Health(health_index, t1.getId(), t2.getId(), childFree, themeId));
}
private void saveTheme(Map<String, String> params) {
@ -98,7 +106,9 @@ public class DatabaseController {
String desc_text = new String(HashUtils.decodeHexString(params.get("work_desc_text")));
TextDataVal t2 = textDataValService.save(new TextDataVal(desc_text));
workService.saveWork(new Work(healRange, powerRange, violenceRange, foodRange, t1.getId(), t2.getId()));
Long themeId = Long.parseLong(params.get("object_selected_theme"));
workService.saveWork(new Work(healRange, powerRange, violenceRange, foodRange, t1.getId(), t2.getId(), themeId));
}
private void saveDiss(Map<String, String> params) {
@ -108,7 +118,9 @@ public class DatabaseController {
String desc_text = new String(HashUtils.decodeHexString(params.get("diss_desc_text")));
TextDataVal t2 = textDataValService.save(new TextDataVal(desc_text));
disasterService.saveDisaster(new Disaster(t1.getId(), t2.getId()));
Long themeId = Long.parseLong(params.get("object_selected_theme"));
disasterService.saveDisaster(new Disaster(t1.getId(), t2.getId(), themeId));
}
private void saveAction(Map<String, String> params) {

View File

@ -19,11 +19,12 @@ public class Bio {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
public Bio(Boolean isMale, Boolean isFemale, Boolean canDie, Long genderTextId) {
public Bio(Boolean isMale, Boolean isFemale, Boolean canDie, Long genderTextId, Long theme) {
this.isMale = isMale;
this.isFemale = isFemale;
this.canDie = canDie;
this.genderTextId = genderTextId;
this.theme = theme;
}
@Column(nullable = false)

View File

@ -27,8 +27,9 @@ public class Disaster {
@Column(nullable = false)
private Long theme = 1L;
public Disaster(Long nameTextId, Long descTextId) {
public Disaster(Long nameTextId, Long descTextId, Long theme) {
this.nameTextId = nameTextId;
this.descTextId = descTextId;
this.theme = theme;
}
}

View File

@ -35,10 +35,11 @@ public class Health {
@Column(nullable = false)
private Long theme = 1L;
public Health(Float health_index, Long textNameId, Long textDescId, Boolean isChildfree) {
public Health(Float health_index, Long textNameId, Long textDescId, Boolean isChildfree, Long theme) {
this.health_index = health_index;
this.textNameId = textNameId;
this.textDescId = textDescId;
this.isChildfree = isChildfree;
this.theme = theme;
}
}

View File

@ -15,12 +15,13 @@ import java.util.List;
@Table(name = "hobby")
public class Hobby {
public Hobby(Float foodstuffs, Float power, Float violence, Float asocial, Long textDescId) {
public Hobby(Float foodstuffs, Float power, Float violence, Float asocial, Long textDescId, Long theme) {
this.foodstuffs = foodstuffs;
this.power = power;
this.violence = violence;
this.asocial = asocial;
this.textDescId = textDescId;
this.theme = theme;
}
@Id

View File

@ -21,7 +21,7 @@ public class Luggage {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
public Luggage(Float violence, Float power, Float asocial, Float foodstuffs, Boolean garbage, Long textNameId, Long textDescId) {
public Luggage(Float violence, Float power, Float asocial, Float foodstuffs, Boolean garbage, Long textNameId, Long textDescId, Long theme) {
this.violence = violence;
this.power = power;
this.asocial = asocial;
@ -29,6 +29,7 @@ public class Luggage {
this.garbage = garbage;
this.textNameId = textNameId;
this.textDescId = textDescId;
this.theme = theme;
}
@Column(nullable=false)

View File

@ -40,13 +40,14 @@ public class Work {
@Column(nullable = false)
private Long theme = 1L;
public Work(Float asocial, Float power, Float violence, Float foodstuffs, Long textNameId, Long textDescId) {
public Work(Float asocial, Float power, Float violence, Float foodstuffs, Long textNameId, Long textDescId, Long theme) {
this.asocial = asocial;
this.power = power;
this.violence = violence;
this.foodstuffs = foodstuffs;
this.textNameId = textNameId;
this.textDescId = textDescId;
this.theme = theme;
}
public Double getValue() {