Updated code for super admin dashboard api
This commit is contained in:
@@ -10,6 +10,7 @@ import net.gepafin.tendermanagement.model.response.Widget1;
|
|||||||
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
|
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
|
||||||
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.CallRepository;
|
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.CompanyRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||||
import net.gepafin.tendermanagement.util.FieldValidator;
|
import net.gepafin.tendermanagement.util.FieldValidator;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -30,11 +31,14 @@ public class DashboardDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationRepository applicationRepository;
|
private ApplicationRepository applicationRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CompanyRepository companyRepository;
|
||||||
|
|
||||||
public SuperAdminWidgetResponseBean getDashboardWidget() {
|
public SuperAdminWidgetResponseBean getDashboardWidget() {
|
||||||
SuperAdminWidgetResponseBean widgetResponseBean = new SuperAdminWidgetResponseBean();
|
SuperAdminWidgetResponseBean widgetResponseBean = new SuperAdminWidgetResponseBean();
|
||||||
widgetResponseBean.setWidget1(createWidget1());
|
widgetResponseBean.setWidget1(createWidget1());
|
||||||
List<Object[]> widgetBars = callRepository.findApplicationsPerCall();
|
List<Object[]> widgetBars = callRepository.findApplicationsPerCall();
|
||||||
widgetResponseBean.setWidgetBars(widgetBars);
|
// widgetResponseBean.setWidgetBars(widgetBars);
|
||||||
return widgetResponseBean;
|
return widgetResponseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,17 +46,31 @@ public class DashboardDao {
|
|||||||
Widget1 widget1 = new Widget1();
|
Widget1 widget1 = new Widget1();
|
||||||
Long activeCalls = callRepository.countByStatus(CallStatusEnum.PUBLISH.getValue());
|
Long activeCalls = callRepository.countByStatus(CallStatusEnum.PUBLISH.getValue());
|
||||||
if (Boolean.FALSE.equals(FieldValidator.isNullOrZero(activeCalls))) {
|
if (Boolean.FALSE.equals(FieldValidator.isNullOrZero(activeCalls))) {
|
||||||
widget1.setActiveCalls(activeCalls);
|
widget1.setNumberOfActiveCalls(activeCalls);
|
||||||
}
|
}
|
||||||
Long activeUsers = userRepository.countByStatusAndRoleEntity_RoleType(UserStatusEnum.ACTIVE.getValue(), RoleStatusEnum.ROLE_BENEFICIARY.getValue());
|
Long activeUsers = userRepository.countByStatusAndRoleEntity_RoleType(UserStatusEnum.ACTIVE.getValue(), RoleStatusEnum.ROLE_BENEFICIARY.getValue());
|
||||||
if (Boolean.FALSE.equals(FieldValidator.isNullOrZero(activeUsers))) {
|
if (Boolean.FALSE.equals(FieldValidator.isNullOrZero(activeUsers))) {
|
||||||
widget1.setResgisteredUsers(activeUsers);
|
widget1.setNumberOfResgisteredUsers(activeUsers);
|
||||||
}
|
}
|
||||||
BigDecimal totalActiveFinancing = callRepository.findTotalAmountOfPublishedCalls();
|
BigDecimal totalActiveFinancing = callRepository.findTotalAmountOfPublishedCalls();
|
||||||
widget1.setTotalActiveFinancing(totalActiveFinancing);
|
widget1.setTotalActiveFinancing(totalActiveFinancing);
|
||||||
Long preInvestigationQuestions = callRepository.countByStatus(CallStatusEnum.DRAFT.getValue());
|
// Long preInvestigationQuestions = callRepository.countByStatus(CallStatusEnum.DRAFT.getValue());
|
||||||
if (Boolean.FALSE.equals(FieldValidator.isNullOrZero(preInvestigationQuestions))) {
|
// if (Boolean.FALSE.equals(FieldValidator.isNullOrZero(preInvestigationQuestions))) {
|
||||||
widget1.setPreInvestigationQuestions(preInvestigationQuestions);
|
// widget1.setPreInvestigationQuestions(preInvestigationQuestions);
|
||||||
|
// }
|
||||||
|
Long submittedApplications=applicationRepository.countSubmittedApplications();
|
||||||
|
if(Boolean.FALSE.equals(FieldValidator.isNullOrZero(submittedApplications)))
|
||||||
|
{
|
||||||
|
widget1.setNumberOfSubmittedApplications(submittedApplications);
|
||||||
|
}
|
||||||
|
Long draftApplications=applicationRepository.countSubmittedApplications();
|
||||||
|
if(Boolean.FALSE.equals(FieldValidator.isNullOrZero(draftApplications)))
|
||||||
|
{
|
||||||
|
widget1.setNumberOfDraftApplications(draftApplications);
|
||||||
|
}
|
||||||
|
Long numberOfCompany=companyRepository.countTotalCompanies();
|
||||||
|
if (Boolean.FALSE.equals(FieldValidator.isNullOrZero(numberOfCompany))) {
|
||||||
|
widget1.setNumberOfCompany(numberOfCompany);
|
||||||
}
|
}
|
||||||
return widget1;
|
return widget1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,17 @@ import java.math.BigDecimal;
|
|||||||
@Data
|
@Data
|
||||||
public class Widget1 {
|
public class Widget1 {
|
||||||
|
|
||||||
private Long activeCalls;
|
private Long numberOfActiveCalls;
|
||||||
|
|
||||||
private Long resgisteredUsers;
|
private Long numberOfResgisteredUsers;
|
||||||
|
|
||||||
private Long preInvestigationQuestions;
|
// private Long preInvestigationQuestions;
|
||||||
|
|
||||||
|
private Long numberOfSubmittedApplications;
|
||||||
|
|
||||||
|
private Long numberOfDraftApplications;
|
||||||
|
|
||||||
|
private Long numberOfCompany;
|
||||||
|
|
||||||
private BigDecimal totalActiveFinancing;
|
private BigDecimal totalActiveFinancing;
|
||||||
|
|
||||||
|
|||||||
@@ -33,4 +33,12 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
|
|||||||
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.userId = :userId AND a.status = 'SUBMIT' ")
|
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.userId = :userId AND a.status = 'SUBMIT' ")
|
||||||
Long countSubmittedApplicationsByUserId(@Param("userId") Long userId);
|
Long countSubmittedApplicationsByUserId(@Param("userId") Long userId);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'SUBMIT'")
|
||||||
|
Long countSubmittedApplications();
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'DRAFT'")
|
||||||
|
Long countDraftApplications();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.repositories;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||||
@@ -15,4 +16,8 @@ public interface CompanyRepository extends JpaRepository<CompanyEntity, Long> {
|
|||||||
Boolean existsByVatNumber(String vatNumber);
|
Boolean existsByVatNumber(String vatNumber);
|
||||||
CompanyEntity findByVatNumber(String vatNumber);
|
CompanyEntity findByVatNumber(String vatNumber);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(c) FROM CompanyEntity c")
|
||||||
|
long countTotalCompanies();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user