Compare commits
2 Commits
499e3236e8
...
bc2b8322a4
Author | SHA1 | Date | |
---|---|---|---|
bc2b8322a4 | |||
99987067cc |
@ -324,12 +324,13 @@ public class DatabaseController {
|
|||||||
public String remove_entry(@RequestParam Map<String, String> params) {
|
public String remove_entry(@RequestParam Map<String, String> params) {
|
||||||
String section = params.get("section");
|
String section = params.get("section");
|
||||||
long entry_id = Long.parseLong(params.get("entry_id"));
|
long entry_id = Long.parseLong(params.get("entry_id"));
|
||||||
|
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case "agge" -> bioService.removeById(entry_id);
|
case "agge" -> { bioService.removeById(entry_id); synergyService.removeByEntityId(entry_id, SectionType.AGE); }
|
||||||
case "hobb" -> hobbyService.removeById(entry_id);
|
case "hobb" -> { hobbyService.removeById(entry_id); synergyService.removeByEntityId(entry_id, SectionType.HOBBY); }
|
||||||
case "lugg" -> luggageService.removeById(entry_id);
|
case "lugg" -> { luggageService.removeById(entry_id); synergyService.removeByEntityId(entry_id, SectionType.LUGGAGE); }
|
||||||
case "heal" -> healthService.removeById(entry_id);
|
case "heal" -> { healthService.removeById(entry_id); synergyService.removeByEntityId(entry_id, SectionType.HEALTH); }
|
||||||
case "prof" -> workService.removeById(entry_id);
|
case "prof" -> { workService.removeById(entry_id); synergyService.removeByEntityId(entry_id, SectionType.WORK); }
|
||||||
case "actions" -> actionService.removeById(entry_id);
|
case "actions" -> actionService.removeById(entry_id);
|
||||||
case "script_request" -> actionRequestService.removeById(entry_id);
|
case "script_request" -> actionRequestService.removeById(entry_id);
|
||||||
case "themes" -> themeService.removeById(entry_id);
|
case "themes" -> themeService.removeById(entry_id);
|
||||||
|
@ -2,6 +2,10 @@ package com.alterdekim.javabot.repository;
|
|||||||
|
|
||||||
import com.alterdekim.javabot.entities.Synergy;
|
import com.alterdekim.javabot.entities.Synergy;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Modifying;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -10,4 +14,9 @@ public interface SynergyRepository extends JpaRepository<Synergy, Long> {
|
|||||||
Optional<Synergy> findById(Long id);
|
Optional<Synergy> findById(Long id);
|
||||||
|
|
||||||
List<Synergy> findAll();
|
List<Synergy> findAll();
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Modifying
|
||||||
|
@Query("DELETE FROM Synergy s WHERE (s.firstEntityId = :uuid AND s.firstType = :sectionType) OR (s.secondEntityId = :uuid AND s.secondType = :sectionType)")
|
||||||
|
void deleteByEntityId(@Param("uuid") Long entityId, @Param("sectionType") Integer sectionType);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.alterdekim.javabot.service;
|
package com.alterdekim.javabot.service;
|
||||||
|
|
||||||
|
import com.alterdekim.javabot.bot.SectionType;
|
||||||
import com.alterdekim.javabot.entities.Luggage;
|
import com.alterdekim.javabot.entities.Luggage;
|
||||||
import com.alterdekim.javabot.entities.Synergy;
|
import com.alterdekim.javabot.entities.Synergy;
|
||||||
|
|
||||||
@ -11,4 +12,6 @@ public interface SynergyService {
|
|||||||
void saveSynergy(Synergy synergy);
|
void saveSynergy(Synergy synergy);
|
||||||
|
|
||||||
List<Synergy> getAllSynergies();
|
List<Synergy> getAllSynergies();
|
||||||
|
|
||||||
|
void removeByEntityId(Long entityId, SectionType sectionType);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.alterdekim.javabot.service;
|
package com.alterdekim.javabot.service;
|
||||||
|
|
||||||
|
import com.alterdekim.javabot.bot.SectionType;
|
||||||
import com.alterdekim.javabot.entities.Synergy;
|
import com.alterdekim.javabot.entities.Synergy;
|
||||||
import com.alterdekim.javabot.repository.SynergyRepository;
|
import com.alterdekim.javabot.repository.SynergyRepository;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -29,4 +30,9 @@ public class SynergyServiceImpl implements SynergyService {
|
|||||||
public List<Synergy> getAllSynergies() {
|
public List<Synergy> getAllSynergies() {
|
||||||
return repository.findAll();
|
return repository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeByEntityId(Long entityId, SectionType sectionType) {
|
||||||
|
repository.deleteByEntityId(entityId, sectionType.ordinal()+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user