From b71976815e700601bd15479794a2a8bd8383b2d6 Mon Sep 17 00:00:00 2001 From: alterdekim Date: Wed, 27 Nov 2024 21:37:15 +0300 Subject: [PATCH] Theme add_entry functionality --- .../controller/DatabaseController.java | 24 ++++++++++++++----- .../com/alterdekim/javabot/entities/Bio.java | 3 ++- .../alterdekim/javabot/entities/Disaster.java | 3 ++- .../alterdekim/javabot/entities/Health.java | 3 ++- .../alterdekim/javabot/entities/Hobby.java | 3 ++- .../alterdekim/javabot/entities/Luggage.java | 3 ++- .../com/alterdekim/javabot/entities/Work.java | 3 ++- 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/alterdekim/javabot/controller/DatabaseController.java b/src/main/java/com/alterdekim/javabot/controller/DatabaseController.java index b896e18..dfeaa7a 100644 --- a/src/main/java/com/alterdekim/javabot/controller/DatabaseController.java +++ b/src/main/java/com/alterdekim/javabot/controller/DatabaseController.java @@ -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 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 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 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 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 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 params) { diff --git a/src/main/java/com/alterdekim/javabot/entities/Bio.java b/src/main/java/com/alterdekim/javabot/entities/Bio.java index d495553..adea87c 100644 --- a/src/main/java/com/alterdekim/javabot/entities/Bio.java +++ b/src/main/java/com/alterdekim/javabot/entities/Bio.java @@ -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) diff --git a/src/main/java/com/alterdekim/javabot/entities/Disaster.java b/src/main/java/com/alterdekim/javabot/entities/Disaster.java index 13cc0ec..07b3ac2 100644 --- a/src/main/java/com/alterdekim/javabot/entities/Disaster.java +++ b/src/main/java/com/alterdekim/javabot/entities/Disaster.java @@ -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; } } diff --git a/src/main/java/com/alterdekim/javabot/entities/Health.java b/src/main/java/com/alterdekim/javabot/entities/Health.java index 5bfe6cd..701da5a 100644 --- a/src/main/java/com/alterdekim/javabot/entities/Health.java +++ b/src/main/java/com/alterdekim/javabot/entities/Health.java @@ -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; } } diff --git a/src/main/java/com/alterdekim/javabot/entities/Hobby.java b/src/main/java/com/alterdekim/javabot/entities/Hobby.java index eeba170..01d0076 100644 --- a/src/main/java/com/alterdekim/javabot/entities/Hobby.java +++ b/src/main/java/com/alterdekim/javabot/entities/Hobby.java @@ -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 diff --git a/src/main/java/com/alterdekim/javabot/entities/Luggage.java b/src/main/java/com/alterdekim/javabot/entities/Luggage.java index 5f90e16..9a7828a 100644 --- a/src/main/java/com/alterdekim/javabot/entities/Luggage.java +++ b/src/main/java/com/alterdekim/javabot/entities/Luggage.java @@ -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) diff --git a/src/main/java/com/alterdekim/javabot/entities/Work.java b/src/main/java/com/alterdekim/javabot/entities/Work.java index 3f9b6ad..770f3a9 100644 --- a/src/main/java/com/alterdekim/javabot/entities/Work.java +++ b/src/main/java/com/alterdekim/javabot/entities/Work.java @@ -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() {