Slowly adding themes x4
This commit is contained in:
parent
8b7e89c67c
commit
5ce90afe55
@ -33,9 +33,6 @@ public class Synergy {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Float probabilityValue;
|
private Float probabilityValue;
|
||||||
|
|
||||||
@Column(nullable = false)
|
|
||||||
private Long theme = 1L;
|
|
||||||
|
|
||||||
public Synergy(Long firstEntityId, SectionType firstType, Long secondEntityId, SectionType secondType, Float probabilityValue) {
|
public Synergy(Long firstEntityId, SectionType firstType, Long secondEntityId, SectionType secondType, Float probabilityValue) {
|
||||||
this.firstEntityId = firstEntityId;
|
this.firstEntityId = firstEntityId;
|
||||||
this.firstType = firstType;
|
this.firstType = firstType;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.alterdekim.javabot.repository;
|
package com.alterdekim.javabot.repository;
|
||||||
|
|
||||||
import com.alterdekim.javabot.entities.Bio;
|
import com.alterdekim.javabot.entities.Bio;
|
||||||
|
import com.alterdekim.javabot.entities.Disaster;
|
||||||
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.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
@ -16,4 +17,7 @@ public interface BioRepository extends JpaRepository<Bio, Long> {
|
|||||||
|
|
||||||
@Query(value = "SELECT new Synergy(s.id, s.firstEntityId, s.firstType, s.secondEntityId, s.secondType, s.probabilityValue) FROM Synergy s WHERE (s.firstType = 0 AND s.firstEntityId = :uuid) OR (s.secondType = 0 AND s.secondEntityId = :uuid)")
|
@Query(value = "SELECT new Synergy(s.id, s.firstEntityId, s.firstType, s.secondEntityId, s.secondType, s.probabilityValue) FROM Synergy s WHERE (s.firstType = 0 AND s.firstEntityId = :uuid) OR (s.secondType = 0 AND s.secondEntityId = :uuid)")
|
||||||
List<Synergy> getSynergies(@Param(value = "uuid") Long bioId);
|
List<Synergy> getSynergies(@Param(value = "uuid") Long bioId);
|
||||||
|
|
||||||
|
@Query("SELECT b FROM Bio b WHERE b.theme = :th")
|
||||||
|
List<Bio> findByTheme(@Param(value = "th") Long theme);
|
||||||
}
|
}
|
@ -2,6 +2,7 @@ package com.alterdekim.javabot.repository;
|
|||||||
|
|
||||||
import com.alterdekim.javabot.entities.Health;
|
import com.alterdekim.javabot.entities.Health;
|
||||||
import com.alterdekim.javabot.entities.Synergy;
|
import com.alterdekim.javabot.entities.Synergy;
|
||||||
|
import com.alterdekim.javabot.entities.Work;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
@ -16,4 +17,7 @@ public interface HealthRepository extends JpaRepository<Health, Long> {
|
|||||||
|
|
||||||
@Query(value = "SELECT new Synergy(s.id, s.firstEntityId, s.firstType, s.secondEntityId, s.secondType, s.probabilityValue) FROM Synergy s WHERE (s.firstType = 1 AND s.firstEntityId = :uuid) OR (s.secondType = 1 AND s.secondEntityId = :uuid)")
|
@Query(value = "SELECT new Synergy(s.id, s.firstEntityId, s.firstType, s.secondEntityId, s.secondType, s.probabilityValue) FROM Synergy s WHERE (s.firstType = 1 AND s.firstEntityId = :uuid) OR (s.secondType = 1 AND s.secondEntityId = :uuid)")
|
||||||
List<Synergy> getSynergies(@Param(value = "uuid") Long healthId);
|
List<Synergy> getSynergies(@Param(value = "uuid") Long healthId);
|
||||||
|
|
||||||
|
@Query("SELECT h FROM Health h WHERE h.theme = :th")
|
||||||
|
List<Health> findByTheme(@Param(value = "th") Long theme);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.alterdekim.javabot.repository;
|
package com.alterdekim.javabot.repository;
|
||||||
|
|
||||||
|
import com.alterdekim.javabot.entities.Health;
|
||||||
import com.alterdekim.javabot.entities.Hobby;
|
import com.alterdekim.javabot.entities.Hobby;
|
||||||
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;
|
||||||
@ -16,4 +17,7 @@ public interface HobbyRepository extends JpaRepository<Hobby, Long> {
|
|||||||
|
|
||||||
@Query(value = "SELECT new Synergy(s.id, s.firstEntityId, s.firstType, s.secondEntityId, s.secondType, s.probabilityValue) FROM Synergy s WHERE (s.firstType = 2 AND s.firstEntityId = :uuid) OR (s.secondType = 2 AND s.secondEntityId = :uuid)")
|
@Query(value = "SELECT new Synergy(s.id, s.firstEntityId, s.firstType, s.secondEntityId, s.secondType, s.probabilityValue) FROM Synergy s WHERE (s.firstType = 2 AND s.firstEntityId = :uuid) OR (s.secondType = 2 AND s.secondEntityId = :uuid)")
|
||||||
List<Synergy> getSynergies(@Param(value = "uuid") Long hobbId);
|
List<Synergy> getSynergies(@Param(value = "uuid") Long hobbId);
|
||||||
|
|
||||||
|
@Query("SELECT h FROM Hobby h WHERE h.theme = :th")
|
||||||
|
List<Hobby> findByTheme(@Param(value = "th") Long theme);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.alterdekim.javabot.repository;
|
package com.alterdekim.javabot.repository;
|
||||||
|
|
||||||
|
import com.alterdekim.javabot.entities.Hobby;
|
||||||
import com.alterdekim.javabot.entities.Luggage;
|
import com.alterdekim.javabot.entities.Luggage;
|
||||||
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;
|
||||||
@ -16,4 +17,7 @@ public interface LuggageRepository extends JpaRepository<Luggage, Long> {
|
|||||||
|
|
||||||
@Query(value = "SELECT new Synergy(s.id, s.firstEntityId, s.firstType, s.secondEntityId, s.secondType, s.probabilityValue) FROM Synergy s WHERE (s.firstType = 3 AND s.firstEntityId = :uuid) OR (s.secondType = 3 AND s.secondEntityId = :uuid)")
|
@Query(value = "SELECT new Synergy(s.id, s.firstEntityId, s.firstType, s.secondEntityId, s.secondType, s.probabilityValue) FROM Synergy s WHERE (s.firstType = 3 AND s.firstEntityId = :uuid) OR (s.secondType = 3 AND s.secondEntityId = :uuid)")
|
||||||
List<Synergy> getSynergies(@Param(value = "uuid") Long luggId);
|
List<Synergy> getSynergies(@Param(value = "uuid") Long luggId);
|
||||||
|
|
||||||
|
@Query("SELECT l FROM Luggage l WHERE l.theme = :th")
|
||||||
|
List<Luggage> findByTheme(@Param(value = "th") Long theme);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.alterdekim.javabot.repository;
|
package com.alterdekim.javabot.repository;
|
||||||
|
|
||||||
|
import com.alterdekim.javabot.entities.Disaster;
|
||||||
import com.alterdekim.javabot.entities.Synergy;
|
import com.alterdekim.javabot.entities.Synergy;
|
||||||
import com.alterdekim.javabot.entities.Work;
|
import com.alterdekim.javabot.entities.Work;
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
@ -16,4 +17,7 @@ public interface WorkRepository extends JpaRepository<Work, Long> {
|
|||||||
|
|
||||||
@Query(value = "SELECT new Synergy(s.id, s.firstEntityId, s.firstType, s.secondEntityId, s.secondType, s.probabilityValue) FROM Synergy s WHERE (s.firstType = 4 AND s.firstEntityId = :uuid) OR (s.secondType = 4 AND s.secondEntityId = :uuid)")
|
@Query(value = "SELECT new Synergy(s.id, s.firstEntityId, s.firstType, s.secondEntityId, s.secondType, s.probabilityValue) FROM Synergy s WHERE (s.firstType = 4 AND s.firstEntityId = :uuid) OR (s.secondType = 4 AND s.secondEntityId = :uuid)")
|
||||||
List<Synergy> getSynergies(@Param(value = "uuid") Long workId);
|
List<Synergy> getSynergies(@Param(value = "uuid") Long workId);
|
||||||
|
|
||||||
|
@Query("SELECT w FROM Work w WHERE w.theme = :th")
|
||||||
|
List<Work> findByTheme(@Param(value = "th") Long theme);
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,20 @@ package com.alterdekim.javabot.service;
|
|||||||
import com.alterdekim.javabot.entities.Bio;
|
import com.alterdekim.javabot.entities.Bio;
|
||||||
import com.alterdekim.javabot.entities.Synergy;
|
import com.alterdekim.javabot.entities.Synergy;
|
||||||
import com.alterdekim.javabot.repository.BioRepository;
|
import com.alterdekim.javabot.repository.BioRepository;
|
||||||
|
import com.alterdekim.javabot.repository.GameThemeRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class BioServiceImpl implements BioService {
|
public class BioServiceImpl implements BioService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GameThemeRepository themeRepository;
|
||||||
|
|
||||||
private BioRepository repository;
|
private BioRepository repository;
|
||||||
|
|
||||||
public BioServiceImpl(BioRepository repository) {
|
public BioServiceImpl(BioRepository repository) {
|
||||||
@ -18,7 +25,11 @@ public class BioServiceImpl implements BioService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Bio> getAllBios() {
|
public List<Bio> getAllBios() {
|
||||||
return repository.findAll();
|
return themeRepository.findAllSelected()
|
||||||
|
.stream()
|
||||||
|
.map(t -> repository.findByTheme(t.getId()))
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,14 +2,21 @@ package com.alterdekim.javabot.service;
|
|||||||
|
|
||||||
import com.alterdekim.javabot.entities.Health;
|
import com.alterdekim.javabot.entities.Health;
|
||||||
import com.alterdekim.javabot.entities.Synergy;
|
import com.alterdekim.javabot.entities.Synergy;
|
||||||
|
import com.alterdekim.javabot.repository.GameThemeRepository;
|
||||||
import com.alterdekim.javabot.repository.HealthRepository;
|
import com.alterdekim.javabot.repository.HealthRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class HealthServiceImpl implements HealthService {
|
public class HealthServiceImpl implements HealthService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GameThemeRepository themeRepository;
|
||||||
|
|
||||||
private final HealthRepository repository;
|
private final HealthRepository repository;
|
||||||
|
|
||||||
public HealthServiceImpl(HealthRepository repository) {
|
public HealthServiceImpl(HealthRepository repository) {
|
||||||
@ -18,7 +25,11 @@ public class HealthServiceImpl implements HealthService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Health> getAllHealth() {
|
public List<Health> getAllHealth() {
|
||||||
return repository.findAll();
|
return themeRepository.findAllSelected()
|
||||||
|
.stream()
|
||||||
|
.map(t -> repository.findByTheme(t.getId()))
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,14 +2,21 @@ package com.alterdekim.javabot.service;
|
|||||||
|
|
||||||
import com.alterdekim.javabot.entities.Hobby;
|
import com.alterdekim.javabot.entities.Hobby;
|
||||||
import com.alterdekim.javabot.entities.Synergy;
|
import com.alterdekim.javabot.entities.Synergy;
|
||||||
|
import com.alterdekim.javabot.repository.GameThemeRepository;
|
||||||
import com.alterdekim.javabot.repository.HobbyRepository;
|
import com.alterdekim.javabot.repository.HobbyRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class HobbyServiceImpl implements HobbyService {
|
public class HobbyServiceImpl implements HobbyService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GameThemeRepository themeRepository;
|
||||||
|
|
||||||
private final HobbyRepository repository;
|
private final HobbyRepository repository;
|
||||||
|
|
||||||
public HobbyServiceImpl(HobbyRepository repository) {
|
public HobbyServiceImpl(HobbyRepository repository) {
|
||||||
@ -18,7 +25,11 @@ public class HobbyServiceImpl implements HobbyService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Hobby> getAllHobbies() {
|
public List<Hobby> getAllHobbies() {
|
||||||
return repository.findAll();
|
return themeRepository.findAllSelected()
|
||||||
|
.stream()
|
||||||
|
.map(t -> repository.findByTheme(t.getId()))
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,21 +2,32 @@ package com.alterdekim.javabot.service;
|
|||||||
|
|
||||||
import com.alterdekim.javabot.entities.Luggage;
|
import com.alterdekim.javabot.entities.Luggage;
|
||||||
import com.alterdekim.javabot.entities.Synergy;
|
import com.alterdekim.javabot.entities.Synergy;
|
||||||
|
import com.alterdekim.javabot.repository.GameThemeRepository;
|
||||||
import com.alterdekim.javabot.repository.LuggageRepository;
|
import com.alterdekim.javabot.repository.LuggageRepository;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class LuggageServiceImpl implements LuggageService {
|
public class LuggageServiceImpl implements LuggageService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GameThemeRepository themeRepository;
|
||||||
|
|
||||||
private final LuggageRepository repository;
|
private final LuggageRepository repository;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Luggage> getAllLuggages() {
|
public List<Luggage> getAllLuggages() {
|
||||||
return repository.findAll();
|
return themeRepository.findAllSelected()
|
||||||
|
.stream()
|
||||||
|
.map(t -> repository.findByTheme(t.getId()))
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,14 +2,21 @@ package com.alterdekim.javabot.service;
|
|||||||
|
|
||||||
import com.alterdekim.javabot.entities.Synergy;
|
import com.alterdekim.javabot.entities.Synergy;
|
||||||
import com.alterdekim.javabot.entities.Work;
|
import com.alterdekim.javabot.entities.Work;
|
||||||
|
import com.alterdekim.javabot.repository.GameThemeRepository;
|
||||||
import com.alterdekim.javabot.repository.WorkRepository;
|
import com.alterdekim.javabot.repository.WorkRepository;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class WorkServiceImpl implements WorkService {
|
public class WorkServiceImpl implements WorkService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GameThemeRepository themeRepository;
|
||||||
|
|
||||||
private final WorkRepository repository;
|
private final WorkRepository repository;
|
||||||
|
|
||||||
public WorkServiceImpl(WorkRepository repository) {
|
public WorkServiceImpl(WorkRepository repository) {
|
||||||
@ -18,7 +25,11 @@ public class WorkServiceImpl implements WorkService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Work> getAllWorks() {
|
public List<Work> getAllWorks() {
|
||||||
return repository.findAll();
|
return themeRepository.findAllSelected()
|
||||||
|
.stream()
|
||||||
|
.map(t -> repository.findByTheme(t.getId()))
|
||||||
|
.flatMap(Collection::stream)
|
||||||
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user