Updated code for notification
This commit is contained in:
@@ -2,18 +2,25 @@ package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEntity;
|
||||
import net.gepafin.tendermanagement.entities.ApplicationEvaluationEntity;
|
||||
import net.gepafin.tendermanagement.entities.NotificationEntity;
|
||||
import net.gepafin.tendermanagement.entities.NotificationTypeEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.NotificationEnum;
|
||||
import net.gepafin.tendermanagement.enums.NotificationTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.NotificationReq;
|
||||
import net.gepafin.tendermanagement.repositories.NotificationRepository;
|
||||
import net.gepafin.tendermanagement.repositories.NotificationTypeRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserWithCompanyRepository;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -33,6 +40,9 @@ public class NotificationDao {
|
||||
@Autowired
|
||||
private UserWithCompanyRepository userWithCompanyRepository;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
public NotificationReq sendNotification(NotificationReq notificationReq) {
|
||||
|
||||
// Ensure userId is properly set in notificationReq if not already
|
||||
@@ -113,4 +123,28 @@ public class NotificationDao {
|
||||
notificationReq.setUserId(userId);
|
||||
return notificationReq;
|
||||
}
|
||||
public Map<String, String> sendNotificationToBeneficiary(ApplicationEntity application, NotificationTypeEnum notificationTypeEnum) {
|
||||
Map<String, String> placeHolders = new HashMap<>();
|
||||
placeHolders.put("{{call_name}}", application.getCall().getName());
|
||||
placeHolders.put("{{protocol_number}}", String.valueOf(application.getProtocol().getProtocolNumber()));
|
||||
NotificationReq notificationReq = createNotificationReq(notificationTypeEnum.getValue(), placeHolders, application.getUserId());
|
||||
sendNotification(notificationReq);
|
||||
return placeHolders;
|
||||
}
|
||||
|
||||
public void sendNotificationToInstructor(Map<String, String> placeHolders, ApplicationEvaluationEntity applicationEvaluationEntity, NotificationTypeEnum notificationTypeEnum) {
|
||||
Long instructorId=applicationEvaluationEntity.getUserId();
|
||||
if(instructorId != null){
|
||||
NotificationReq notificationreq = createNotificationReq(notificationTypeEnum.getValue(), placeHolders,instructorId);
|
||||
sendNotification(notificationreq);
|
||||
}
|
||||
}
|
||||
public void sendNotificationToSuperUser(ApplicationEntity application,Map<String,String> placeHolders,NotificationTypeEnum notificationTypeEnum) {
|
||||
List<UserEntity> user=userRepository.findByRoleEntity_RoleTypeAndHubId(RoleStatusEnum.ROLE_SUPER_ADMIN.getValue(), application.getHubId());
|
||||
UserEntity userEntity1=user.get(0);
|
||||
if(userEntity1 != null) {
|
||||
NotificationReq notificationreq = createNotificationReq(notificationTypeEnum.getValue(), placeHolders,userEntity1.getId());
|
||||
sendNotification(notificationreq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user