updated code for super user dashboard

This commit is contained in:
harish
2024-10-24 23:02:01 +05:30
parent 5f8f464799
commit 5beea7132e
3 changed files with 15 additions and 8 deletions

View File

@@ -80,14 +80,14 @@ public class DashboardDao {
} }
private void setSubmittedApplications(Widget1 widget1, UserEntity requestedUserEntity) { private void setSubmittedApplications(Widget1 widget1, UserEntity requestedUserEntity) {
Long submittedApplications = applicationRepository.countSubmittedApplications(); Long submittedApplications = applicationRepository.countSubmittedApplicationsByHubId(requestedUserEntity.getHub().getId());
if (submittedApplications != null) { if (submittedApplications != null) {
widget1.setNumberOfSubmittedApplications(submittedApplications); widget1.setNumberOfSubmittedApplications(submittedApplications);
} }
} }
private void setDraftApplications(Widget1 widget1, UserEntity requestedUserEntity) { private void setDraftApplications(Widget1 widget1, UserEntity requestedUserEntity) {
Long draftApplications = applicationRepository.countDraftApplications(); Long draftApplications = applicationRepository.countDraftApplicationsByHubId(requestedUserEntity.getHub().getId());
if (draftApplications != null) { if (draftApplications != null) {
widget1.setNumberOfDraftApplications(draftApplications); widget1.setNumberOfDraftApplications(draftApplications);
} }

View File

@@ -32,13 +32,13 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.userId = :userId AND a.company.id = :companyId AND a.status = 'SUBMIT' ") @Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.userId = :userId AND a.company.id = :companyId AND a.status = 'SUBMIT' ")
Long countSubmittedApplicationsByUserId(@Param("userId") Long userId, @Param("companyId") Long companyId); Long countSubmittedApplicationsByUserId(@Param("userId") Long userId, @Param("companyId") Long companyId);
@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();
List<ApplicationEntity> findByCompanyIdAndUserIdAndIsDeletedFalse(Long companyId,Long userId); List<ApplicationEntity> findByCompanyIdAndUserIdAndIsDeletedFalse(Long companyId,Long userId);
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'SUBMIT' And a.hubId = :hubId")
public Long countSubmittedApplicationsByHubId(@Param("hubId") Long hubId);
@Query("SELECT COUNT(a) FROM ApplicationEntity a WHERE a.status = 'DRAFT' And a.hubId = :hubId")
public Long countDraftApplicationsByHubId(@Param("hubId") Long hubId);
} }

View File

@@ -5,6 +5,8 @@ import net.gepafin.tendermanagement.dao.FlowDao;
import net.gepafin.tendermanagement.model.request.FlowRequestBean; import net.gepafin.tendermanagement.model.request.FlowRequestBean;
import net.gepafin.tendermanagement.model.response.FlowResponseBean; import net.gepafin.tendermanagement.model.response.FlowResponseBean;
import net.gepafin.tendermanagement.service.FlowService; import net.gepafin.tendermanagement.service.FlowService;
import net.gepafin.tendermanagement.util.Validator;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -15,15 +17,20 @@ public class FlowServiceImpl implements FlowService {
@Autowired @Autowired
private FlowDao flowDao; private FlowDao flowDao;
@Autowired
private Validator validator;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public FlowResponseBean createOrUpdateFlow(HttpServletRequest httpServletRequest, FlowRequestBean flowRequestBean, Long callId) { public FlowResponseBean createOrUpdateFlow(HttpServletRequest httpServletRequest, FlowRequestBean flowRequestBean, Long callId) {
validator.validateUserWithCall(validator.validateUser(httpServletRequest), callId);
return flowDao.createOrUpdateFlow(flowRequestBean,callId); return flowDao.createOrUpdateFlow(flowRequestBean,callId);
} }
@Override @Override
@org.springframework.transaction.annotation.Transactional(readOnly = true) @org.springframework.transaction.annotation.Transactional(readOnly = true)
public FlowResponseBean getFlowByCallId(HttpServletRequest request, Long callId) { public FlowResponseBean getFlowByCallId(HttpServletRequest request, Long callId) {
validator.validateUserWithCall(validator.validateUser(request), callId);
return flowDao.getFlowByCallId(callId); return flowDao.getFlowByCallId(callId);
} }
} }