Checkpoints: WORKS but not for all

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
2021-01-06 16:50:08 +01:00
parent df7701ebc8
commit b633d2c2df
3 changed files with 24 additions and 3 deletions

View File

@ -1,11 +1,20 @@
package com.plannaplan.repositories;
import java.util.Optional;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Exchange;
import com.plannaplan.entities.Groups;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface ExchangeRepository extends JpaRepository<Exchange, Long>{
@Query("FROM Exchange WHERE owned_id = ?1 AND desired_id = ?2")
Optional<Exchange> checkForExchange(@Param("owned_id") Assignment assignment, @Param("desired_id") Groups group);
}

View File

@ -1,6 +1,10 @@
package com.plannaplan.services;
import java.util.Optional;
import com.plannaplan.entities.Assignment;
import com.plannaplan.entities.Exchange;
import com.plannaplan.entities.Groups;
import com.plannaplan.repositories.ExchangeRepository;
import org.springframework.beans.factory.annotation.Autowired;
@ -19,4 +23,8 @@ public class ExchangeService {
public Exchange save(Exchange exchange){
return this.repo.save(exchange);
}
public Optional<Exchange> checkForExchange(Assignment assignment, Groups group){
return this.repo.checkForExchange(assignment, group);
}
}