Updated code for super admin dashboard api

This commit is contained in:
nisha
2024-10-14 17:16:20 +05:30
parent 6f54ed0fad
commit 4133b4f9dc
4 changed files with 46 additions and 9 deletions

View File

@@ -10,6 +10,7 @@ import net.gepafin.tendermanagement.model.response.Widget1;
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
import net.gepafin.tendermanagement.repositories.ApplicationRepository;
import net.gepafin.tendermanagement.repositories.CallRepository;
import net.gepafin.tendermanagement.repositories.CompanyRepository;
import net.gepafin.tendermanagement.repositories.UserRepository;
import net.gepafin.tendermanagement.util.FieldValidator;
import org.springframework.beans.factory.annotation.Autowired;
@@ -30,11 +31,14 @@ public class DashboardDao {
@Autowired
private ApplicationRepository applicationRepository;
@Autowired
private CompanyRepository companyRepository;
public SuperAdminWidgetResponseBean getDashboardWidget() {
SuperAdminWidgetResponseBean widgetResponseBean = new SuperAdminWidgetResponseBean();
widgetResponseBean.setWidget1(createWidget1());
List<Object[]> widgetBars = callRepository.findApplicationsPerCall();
widgetResponseBean.setWidgetBars(widgetBars);
// widgetResponseBean.setWidgetBars(widgetBars);
return widgetResponseBean;
}
@@ -42,17 +46,31 @@ public class DashboardDao {
Widget1 widget1 = new Widget1();
Long activeCalls = callRepository.countByStatus(CallStatusEnum.PUBLISH.getValue());
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());
if (Boolean.FALSE.equals(FieldValidator.isNullOrZero(activeUsers))) {
widget1.setResgisteredUsers(activeUsers);
widget1.setNumberOfResgisteredUsers(activeUsers);
}
BigDecimal totalActiveFinancing = callRepository.findTotalAmountOfPublishedCalls();
widget1.setTotalActiveFinancing(totalActiveFinancing);
Long preInvestigationQuestions = callRepository.countByStatus(CallStatusEnum.DRAFT.getValue());
if (Boolean.FALSE.equals(FieldValidator.isNullOrZero(preInvestigationQuestions))) {
widget1.setPreInvestigationQuestions(preInvestigationQuestions);
// Long preInvestigationQuestions = callRepository.countByStatus(CallStatusEnum.DRAFT.getValue());
// if (Boolean.FALSE.equals(FieldValidator.isNullOrZero(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;
}