Done changes related to instructor dashboard API
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CompanyEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
@@ -10,6 +12,9 @@ import net.gepafin.tendermanagement.model.response.*;
|
||||
import net.gepafin.tendermanagement.repositories.*;
|
||||
import net.gepafin.tendermanagement.service.CompanyService;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ForbiddenAccessException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -278,14 +283,16 @@ public class DashboardDao {
|
||||
AmendmentWidgetResponseBean amendmentWidgetResponseBean = initializeAmendmentResponseBean();
|
||||
|
||||
Long hubId = userEntity.getHub().getId();
|
||||
List<Long> applicationIds = getApplicationIdsForUserOrHub(userEntity,hubId);
|
||||
List<Long> applicationIds = getApplicationIdsForUserOrHub(userEntity,hubId,null);
|
||||
setAmendmentCounts(applicationIds,amendmentWidgetResponseBean, hubId);
|
||||
calculateExpiringRequestsIn48Hours(applicationIds,amendmentWidgetResponseBean, hubId);
|
||||
calculateAverageResponseDays(applicationIds,amendmentWidgetResponseBean,hubId);
|
||||
return amendmentWidgetResponseBean;
|
||||
}
|
||||
public List<Long> getApplicationIdsForUserOrHub(UserEntity userEntity, Long hubId) {
|
||||
if (validator.checkIsPreInstructor()) {
|
||||
public List<Long> getApplicationIdsForUserOrHub(UserEntity userEntity, Long hubId , Long userId) {
|
||||
if (userId != null) {
|
||||
return assignedApplicationsRepository.findApplicationIdsByUserIdAndIsDeletedFalse(userId);
|
||||
} else if (validator.checkIsPreInstructor()) {
|
||||
return assignedApplicationsRepository.findApplicationIdsByUserIdAndIsDeletedFalse(userEntity.getId());
|
||||
} else {
|
||||
return applicationRepository.findApplicationIdsByHubId(hubId);
|
||||
@@ -423,10 +430,21 @@ public AssignedApplicationWidgetResponseBean getApplicationDetailsForEvaluation(
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
public PreInstructorWidgetResponseBean getDashboardWidgetForPreInstructor(UserEntity userEntity) {
|
||||
public PreInstructorWidgetResponseBean getDashboardWidgetForPreInstructor(HttpServletRequest request, Long userId) {
|
||||
UserEntity userEntity = validator.validateUser(request);
|
||||
if (validator.checkIsPreInstructor() && userId == null) {
|
||||
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
|
||||
}
|
||||
if (userId != null) {
|
||||
validator.validatePreInstructor(request, userId);
|
||||
if (validator.checkIsInstructorManager() && !userEntity.getId().equals(userId)) {
|
||||
throw new ForbiddenAccessException(Status.FORBIDDEN,
|
||||
Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||
}
|
||||
}
|
||||
PreInstructorWidgetResponseBean preInstructorWidgetResponseBean = initializeDashboardPreInstructorResponseBean();
|
||||
Long hubId = userEntity.getHub().getId();
|
||||
List<Long> applicationIds = getApplicationIdsForUserOrHub(userEntity, hubId);
|
||||
List<Long> applicationIds = getApplicationIdsForUserOrHub(userEntity, hubId,userId);
|
||||
setPreInstructorWidgets(applicationIds, preInstructorWidgetResponseBean,hubId);
|
||||
calculateAverageEvaluationTime(applicationIds, preInstructorWidgetResponseBean, hubId);
|
||||
return preInstructorWidgetResponseBean;
|
||||
|
||||
Reference in New Issue
Block a user