Interface TemplatesRepository
- All Superinterfaces:
org.springframework.data.repository.CrudRepository<Template,,Integer> org.springframework.data.repository.Repository<Template,Integer>
@Repository
public interface TemplatesRepository
extends org.springframework.data.repository.CrudRepository<Template,Integer>
Spring Data repository used to access the templates in BBDD. See
Template.-
Method Summary
Modifier and TypeMethodDescriptionfindAllByMessageAndChannelAndLanguageOrderByPriority(Message message, int channelId, int language) Find all the templates for the given message in the given language.findOneByNotification(Notification notification) Find the template used to send a certain notification (used in testing).Methods inherited from interface org.springframework.data.repository.CrudRepository
count, delete, deleteAll, deleteAll, deleteAllById, deleteById, existsById, findAll, findAllById, findById, save, saveAll
-
Method Details
-
findAllByMessageAndChannelAndLanguageOrderByPriority
@Query(nativeQuery=true, value="SELECT t.id, t.external_id, t.name, t.user_language_id, t.text, t.provider_id, t.title, t.subject FROM template t INNER JOIN message_channel_priority p on p.template_id = t.id and p.message_id = :message and p.channel_id = :channelId WHERE t.user_language_id = :language ORDER BY p.\"order\" ASC") Set<Template> findAllByMessageAndChannelAndLanguageOrderByPriority(@Param("message") Message message, @Param("channelId") int channelId, @Param("language") int language) Find all the templates for the given message in the given language.- Parameters:
message- the message to send.channelId- the required channel identifier.language- the required language.- Returns:
- templates for the given message in the given language.
-
findOneByNotification
@Query("SELECT t FROM Notification n INNER JOIN n.template t WHERE n=:notification") Optional<Template> findOneByNotification(@Param("notification") Notification notification) Find the template used to send a certain notification (used in testing).- Parameters:
notification- the notification.- Returns:
- the template related to the notification.
-