38 lines
1.2 KiB
Java
Executable File
38 lines
1.2 KiB
Java
Executable File
package com.plannaplan.repositories;
|
|
|
|
import java.util.List;
|
|
|
|
import com.plannaplan.entities.Commision;
|
|
|
|
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;
|
|
|
|
/**
|
|
* CommisionRepository.getUsers: Return list of: SELECT * FROM Commision WHERE
|
|
* owner_id = i .
|
|
*
|
|
* Where i, ?1 are equale to variables.
|
|
*
|
|
* CommisionRepository.getNewestCommision Return list of: SELECT * FROM
|
|
* Commision WHERE owner_id = i Order by commisionDate desc.
|
|
*
|
|
* Where i, ?1 are equale to variables.
|
|
*/
|
|
@Repository
|
|
public interface CommisionRepository extends JpaRepository<Commision, Long> {
|
|
@Query("FROM Commision WHERE owner_id = ?1")
|
|
List<Commision> getUsers(@Param("owner_id") Long id);
|
|
|
|
@Query("FROM Commision WHERE owner_id = ?1 order by commisionDate desc")
|
|
List<Commision> getNewestCommision(@Param("owner_id") Long id);
|
|
|
|
/**
|
|
* @return ammount of uniqe users that have a commision placed on first array
|
|
* element
|
|
*/
|
|
@Query("SELECT COUNT(DISTINCT owner_id) AS count FROM Commision")
|
|
Object[] getUsersAssigned();
|
|
}
|