Code for dashbaord API
This commit is contained in:
@@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -24,7 +25,6 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
||||
|
||||
public Optional<ApplicationEntity> findByIdAndUserIdAndIsDeletedFalse(Long id,Long userId);
|
||||
|
||||
Optional<ApplicationEntity> findByUserIdAndUserWithCompanyIdAndCallIdAndIsDeletedFalse(Long userId, Long userWithCompanyId, Long callId);
|
||||
|
||||
public Optional<ApplicationEntity> findByIdAndUserIdAndCallIdAndIsDeletedFalse(Long applicationId, Long userId,
|
||||
Long callId);
|
||||
@@ -44,4 +44,15 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
||||
|
||||
@Query("SELECT a.call.id FROM ApplicationEntity a WHERE a.id = :id AND a.isDeleted = false")
|
||||
Long findCallIdById(@Param("id") Long id);
|
||||
|
||||
@Query("SELECT a.call.name, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.call.hub.id = :hubId GROUP BY a.call.name")
|
||||
List<Object[]> findApplicationsPerCallWithName(@Param("hubId") Long hubId);
|
||||
|
||||
// Count Applications by Status by Hub ID
|
||||
@Query("SELECT a.status, COUNT(a.id) FROM ApplicationEntity a WHERE a.isDeleted = false AND a.call.hub.id = :hubId GROUP BY a.status")
|
||||
List<Object[]> findApplicationsByStatus(@Param("hubId") Long hubId);
|
||||
|
||||
// Total Amount of Approved Applications by Hub ID
|
||||
@Query("SELECT SUM(a.call.amount) FROM ApplicationEntity a WHERE a.status = 'APPROVED' AND a.isDeleted = false AND a.call.hub.id = :hubId")
|
||||
BigDecimal findTotalApprovedApplicationAmount(@Param("hubId") Long hubId);
|
||||
}
|
||||
|
||||
@@ -47,4 +47,9 @@ public interface CallRepository extends JpaRepository<CallEntity, Long> {
|
||||
BigDecimal findTotalAmountOfPublishedCallsAndHubId(@Param("hubId") Long hubId);
|
||||
@Query("SELECT c FROM CallEntity c WHERE c.id IN :ids AND c.status IN :status")
|
||||
List<CallEntity> findByIdInAndStatusIn(@Param("ids") List<Long> ids, @Param("status") List<String> status);
|
||||
|
||||
@Query("SELECT SUM(c.amount) FROM CallEntity c WHERE c.hub.id = :hubId AND c.status = 'PUBLISH'")
|
||||
BigDecimal findTotalAmountOfPublishedCalls(@Param("hubId") Long hubId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,38 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.UserActionEntity;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface UserActionsRepository extends JpaRepository<UserActionEntity, Long> {
|
||||
UserActionEntity findUserActionById(Long id);
|
||||
|
||||
//
|
||||
// @Query("SELECT ua FROM UserActionEntity ua " +
|
||||
// "JOIN ua.user u " +
|
||||
// "WHERE u.roleEntity.roleType IN :roleNames " +
|
||||
// "AND ua.hub.id = :hubId " +
|
||||
// "AND ua.isDeleted = false")
|
||||
// Page<UserActionEntity> findActionsByRoleNamesAndHubId(
|
||||
// @Param("roleNames") List<String> roleNames,
|
||||
// @Param("hubId") Long hubId, Pageable pageable);
|
||||
|
||||
@Query("SELECT ua FROM UserActionEntity ua " +
|
||||
"JOIN UserEntity u ON ua.userId = u.id " + // Join on userId field
|
||||
"JOIN u.roleEntity r " + // Join the RoleEntity via the UserEntity
|
||||
"WHERE r.roleType IN :roleNames " + // Filter by role name
|
||||
"AND ua.hubId = :hubId " + // Filter by hubId
|
||||
"AND ua.isDeleted = false")
|
||||
Page<UserActionEntity> findActionsByRoleNamesAndHubId(
|
||||
@Param("roleNames") List<String> roleNames,
|
||||
@Param("hubId") Long hubId,
|
||||
Pageable pageable);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user