Merge pull request #49 from Kitzanos/develop

Sync master with develop branch(15/10/2024)
This commit is contained in:
rbonazzo-KZ
2024-10-15 12:45:35 +02:00
committed by GitHub
34 changed files with 1041 additions and 15 deletions

View File

@@ -205,10 +205,26 @@ public class GepafinConstant {
public static final String APPLICATION_SUBMITTED_CANNOT_CHANGE = "application.submitted.cannot.change"; public static final String APPLICATION_SUBMITTED_CANNOT_CHANGE = "application.submitted.cannot.change";
public static final String CALL_DOCUMENTS_FETCH_SUCCESS_MSG = "call.documents.fetch.success"; public static final String CALL_DOCUMENTS_FETCH_SUCCESS_MSG = "call.documents.fetch.success";
public static final String CALL_DOCUMENTS_NOT_FOUND_MSG = "call.documents.not.found"; public static final String CALL_DOCUMENTS_NOT_FOUND_MSG = "call.documents.not.found";
public static final String BENEFICIARY_PREFERRED_CALL_CREATED_SUCCESS_MSG = "beneficiary.preferred.call.created.success";
public static final String GET_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG = "beneficiary.preferred.call.get.success";
public static final String DELETE_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG = "beneficiary.preferred.call.delete.success";
public static final String GET_BENEFICIARY_PREFERRED_CALLS_SUCCESS_MSG = "beneficiary.preferred.calls.get.success";
public static final String BENEFICIARY_PREFERRED_CALL_UPDATED_SUCCESS_MSG = "beneficiary.preferred.call.updated.success";
public static final String BENEFICIARY_CALL_NOT_FOUND = "beneficiary.preferred.call.not.found";
public static final String BENEFICIARY_PREFERRED_CALL_STATUS_UPDATED_SUCCESS_MSG = "beneficiary.preferred.call.status.updated.success";
public static final String GET_ALL_BENEFICIARY_PREFERRED_CALLS_SUCCESS_MSG = "beneficiary.preferred.calls.get.all.success";
public static final String USER_ID_AND_BENEFICIARY_ID_ERROR = "userId.and.beneficiaryId.error";
public static final String EITHER_USER_OR_BENEFICIARY_ID_REQUIRED = "either.user.or.beneficiary.id.required";
public static final String USER_NOT_FOUND_WITH_BENEFICIARYID_MSG = "User.not.found.with.the.given.beneficiaryID";
public static final String PERMISSION_DENIED = "permission.denied"; public static final String PERMISSION_DENIED = "permission.denied";
public static final String SIGNED_DOCUMENT_FILE_UPLOAD_SUCCESS = "signed.document.file.upload.success"; public static final String SIGNED_DOCUMENT_FILE_UPLOAD_SUCCESS = "signed.document.file.upload.success";
public static final String GET_SIGNED_DOCUMENT_FILE_SUCCESS = "get.signed.document.file.success"; public static final String GET_SIGNED_DOCUMENT_FILE_SUCCESS = "get.signed.document.file.success";
public static final String APPLICATION_SIGNED_DOCUMENT_NOT_FOUND = "application.signed.document.not.found"; public static final String APPLICATION_SIGNED_DOCUMENT_NOT_FOUND = "application.signed.document.not.found";
public static final String DELETE_SIGNED_DOCUMENT_FILE_SUCCESS = "delete.signed.document.file.success"; public static final String DELETE_SIGNED_DOCUMENT_FILE_SUCCESS = "delete.signed.document.file.success";
public static final String DD_MM_YYYY = "dd/MM/yyyy";
public static final String DASHBOARD_WIDGET_FETCHED_SUCCESSFULLY="dashboard.widget.fetched.successfully";
} }

View File

@@ -603,7 +603,7 @@ public class ApplicationDao {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG)); throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.APPLICATION_IS_INCOMPLETE_MSG));
} }
Integer maxProtocolNumber=protocolRepository.findMaxProtocolNumber(); Integer maxProtocolNumber=protocolRepository.findMaxProtocolNumber();
Integer protocolNumber = (maxProtocolNumber != null) ? maxProtocolNumber + 1 : 10000; Integer protocolNumber = (maxProtocolNumber != null) ? maxProtocolNumber + 1 : 1;
ProtocolEntity protocolEntity=createProtocolEntity(applicationEntity,protocolNumber); ProtocolEntity protocolEntity=createProtocolEntity(applicationEntity,protocolNumber);
applicationEntity.setProtocol(protocolEntity); applicationEntity.setProtocol(protocolEntity);
applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue()); applicationEntity.setStatus(ApplicationStatusTypeEnum.SUBMIT.getValue());
@@ -719,7 +719,7 @@ public class ApplicationDao {
Map<String, String> bodyPlaceholders = new HashMap<>(); Map<String, String> bodyPlaceholders = new HashMap<>();
bodyPlaceholders.put("{{call_name}}", call.getName()); bodyPlaceholders.put("{{call_name}}", call.getName());
bodyPlaceholders.put("{{protocol_number}}", protocol.getProtocolNumber().toString()); bodyPlaceholders.put("{{protocol_number}}", protocol.getProtocolNumber().toString());
bodyPlaceholders.put("{{date}}", DateTimeUtil.formatLocalDateTime(protocol.getCreatedDate(), GepafinConstant.YYYY_MM_DD_SLASH)); bodyPlaceholders.put("{{date}}", DateTimeUtil.formatLocalDateTime(protocol.getCreatedDate(), GepafinConstant.DD_MM_YYYY));
bodyPlaceholders.put("{{time}}", DateTimeUtil.parseLocalTimeToString(protocol.getTime(), GepafinConstant.HH_MM_SS)); bodyPlaceholders.put("{{time}}", DateTimeUtil.parseLocalTimeToString(protocol.getTime(), GepafinConstant.HH_MM_SS));
// Replace placeholders in the subject and body // Replace placeholders in the subject and body
@@ -752,7 +752,7 @@ public class ApplicationDao {
Map<String, String> bodyPlaceholders = new HashMap<>(); Map<String, String> bodyPlaceholders = new HashMap<>();
bodyPlaceholders.put("{{call_name}}", call.getName()); bodyPlaceholders.put("{{call_name}}", call.getName());
bodyPlaceholders.put("{{protocol_number}}", protocol.getProtocolNumber().toString()); bodyPlaceholders.put("{{protocol_number}}", protocol.getProtocolNumber().toString());
bodyPlaceholders.put("{{date}}", DateTimeUtil.formatLocalDateTime(protocol.getCreatedDate(), GepafinConstant.YYYY_MM_DD_SLASH)); bodyPlaceholders.put("{{date}}", DateTimeUtil.formatLocalDateTime(protocol.getCreatedDate(), GepafinConstant.DD_MM_YYYY));
bodyPlaceholders.put("{{time}}", DateTimeUtil.parseLocalTimeToString(protocol.getTime(), GepafinConstant.HH_MM_SS)); bodyPlaceholders.put("{{time}}", DateTimeUtil.parseLocalTimeToString(protocol.getTime(), GepafinConstant.HH_MM_SS));
// Replace placeholders in the subject and body // Replace placeholders in the subject and body

View File

@@ -0,0 +1,131 @@
package net.gepafin.tendermanagement.dao;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.entities.BeneficiaryPreferredCallEntity;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
import net.gepafin.tendermanagement.enums.UserStatusEnum;
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository;
import net.gepafin.tendermanagement.service.UserService;
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.stream.Collectors;
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
@Component
public class BeneficiaryPreferredCallDao {
private final Logger log = LoggerFactory.getLogger(BeneficiaryPreferredCallDao.class);
@Autowired
private BeneficiaryPreferredCallRepository beneficiaryPreferredCallRepository;
@Autowired
private UserService userService;
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(BeneficiaryPreferredCallReq request,UserEntity user) {
log.info("Creating new beneficiary preferred call with details: {}", request);
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request,user);
entity = beneficiaryPreferredCallRepository.save(entity);
log.info("Beneficiary preferred call created with ID: {}", entity.getId());
return convertEntityToResponse(entity);
}
private BeneficiaryPreferredCallEntity convertRequestToEntity(BeneficiaryPreferredCallReq request,UserEntity userEntity) {
BeneficiaryPreferredCallEntity entity = new BeneficiaryPreferredCallEntity();
UserEntity user= userService.validateUser(userEntity.getId());
if (user.getBeneficiary()!=null) {
entity.setBeneficiaryId(user.getBeneficiary().getId());
}
entity.setStatus(BeneficiaryCallStatus.ENABLED.getValue());
entity.setCallId(request.getCallId());
entity.setUserId(userEntity.getId());
entity.setCompanyId(request.getCompanyId());
return entity;
}
public BeneficiaryPreferredCallResponseBean getBeneficiaryPreferredCallById(Long id) {
log.info("Fetching beneficiary preferred call with ID: {}", id);
BeneficiaryPreferredCallEntity entity = validateBeneficiaryPreferredCall(id);
log.info("Beneficiary preferred call found: {}", entity);
return convertEntityToResponse(entity);
}
// public BeneficiaryPreferredCallResponseBean updateBeneficiaryPreferredCall(Long id, BeneficiaryPreferredCallReq request,
// UserEntity userEntity) {
// log.info("Updating beneficiary preferred call with ID: {}", id);
// BeneficiaryPreferredCallEntity existingEntity = validateBeneficiaryPreferredCall(id);
// setIfUpdated(existingEntity::getCallId, existingEntity::setCallId, request.getCallId());
// setIfUpdated(existingEntity::getCompanyId, existingEntity::setCompanyId, request.getCompanyId());
//
// existingEntity = beneficiaryPreferredCallRepository.save(existingEntity);
//
// log.info("Beneficiary preferred call updated with ID: {}", existingEntity.getId());
// return convertEntityToResponse(existingEntity);
// }
private boolean isUserABeneficiary(Long userId) {
UserEntity user=userService.validateUser(userId);
return RoleStatusEnum.ROLE_BENEFICIARY.getValue().equals(user.getRoleEntity().getRoleType());
}
public void deleteBeneficiaryPreferredCallById(Long id) {
log.info("Deleting beneficiary preferred call with ID: {}", id);
validateBeneficiaryPreferredCall(id);
beneficiaryPreferredCallRepository.deleteById(id);
log.info("Beneficiary preferred call deleted with ID: {}", id);
}
public List<BeneficiaryPreferredCallResponseBean> getAllBeneficiaryPreferredCalls() {
log.info("Fetching all beneficiary preferred calls");
List<BeneficiaryPreferredCallResponseBean> calls = beneficiaryPreferredCallRepository.findAll()
.stream()
.map(this::convertEntityToResponse)
.collect(Collectors.toList());
log.info("Total beneficiary preferred calls found: {}", calls.size());
return calls;
}
private BeneficiaryPreferredCallEntity validateBeneficiaryPreferredCall(Long id) {
log.info("Validating beneficiary preferred call with ID: {}", id);
return beneficiaryPreferredCallRepository.findById(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.BENEFICIARY_CALL_NOT_FOUND)));
}
private BeneficiaryPreferredCallResponseBean convertEntityToResponse(BeneficiaryPreferredCallEntity entity) {
BeneficiaryPreferredCallResponseBean response = new BeneficiaryPreferredCallResponseBean();
response.setId(entity.getId());
response.setBeneficiaryId(entity.getBeneficiaryId());
response.setStatus(BeneficiaryCallStatus.valueOf(entity.getStatus()));
response.setCallId(entity.getCallId());
response.setUserId(entity.getUserId());
response.setCompanyId(entity.getCompanyId());
response.setCreatedDate(entity.getCreatedDate());
response.setUpdatedDate(entity.getUpdatedDate());
return response;
}
public void updateBeneficiaryPreferredCallStatus(Long id, BeneficiaryCallStatus status) {
log.info("Updating status for beneficiary preferred call with ID: {}", id);
BeneficiaryPreferredCallEntity existingEntity = validateBeneficiaryPreferredCall(id);
existingEntity.setStatus(status.getValue());
beneficiaryPreferredCallRepository.save(existingEntity);
log.info("Beneficiary preferred call status updated with ID: {}", existingEntity.getId());
}
public List<BeneficiaryPreferredCallResponseBean> getBeneficiaryPreferredCallByUserId(UserEntity userEntity, Long companyId) {
List<BeneficiaryPreferredCallEntity> calls = beneficiaryPreferredCallRepository.findByUserIdAndCompanyId(userEntity.getId(), companyId);
return calls.stream()
.map(this::convertEntityToResponse)
.collect(Collectors.toList());
}
}

View File

@@ -0,0 +1,118 @@
package net.gepafin.tendermanagement.dao;
import net.gepafin.tendermanagement.entities.CompanyEntity;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.CallStatusEnum;
import net.gepafin.tendermanagement.enums.RoleStatusEnum;
import net.gepafin.tendermanagement.enums.UserStatusEnum;
import net.gepafin.tendermanagement.model.response.BeneficiaryWidgetResponseBean;
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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
@Component
public class DashboardDao {
@Autowired
private CallRepository callRepository;
@Autowired
private UserRepository userRepository;
@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);
return widgetResponseBean;
}
private Widget1 createWidget1() {
Widget1 widget1 = initializeWidget1();
setActiveCalls(widget1);
setRegisteredUsers(widget1);
setTotalActiveFinancing(widget1);
setSubmittedApplications(widget1);
setDraftApplications(widget1);
setNumberOfCompanies(widget1);
return widget1;
}
private Widget1 initializeWidget1() {
return Widget1.builder().numberOfActiveCalls(0L).numberOfCompany(0L).numberOfDraftApplications(0L)
.numberOfResgisteredUsers(0L).numberOfSubmittedApplications(0L).totalActiveFinancing(BigDecimal.ZERO)
.build();
}
private void setActiveCalls(Widget1 widget1) {
Long activeCalls = callRepository.countByStatus(CallStatusEnum.PUBLISH.getValue());
if (activeCalls != null) {
widget1.setNumberOfActiveCalls(activeCalls);
}
}
private void setRegisteredUsers(Widget1 widget1) {
Long activeUsers = userRepository.countByStatusAndRoleEntity_RoleType(UserStatusEnum.ACTIVE.getValue(),
RoleStatusEnum.ROLE_BENEFICIARY.getValue());
if (activeUsers != null) {
widget1.setNumberOfResgisteredUsers(activeUsers);
}
}
private void setTotalActiveFinancing(Widget1 widget1) {
BigDecimal totalActiveFinancing = callRepository.findTotalAmountOfPublishedCalls();
widget1.setTotalActiveFinancing(totalActiveFinancing);
}
private void setSubmittedApplications(Widget1 widget1) {
Long submittedApplications = applicationRepository.countSubmittedApplications();
if (submittedApplications != null) {
widget1.setNumberOfSubmittedApplications(submittedApplications);
}
}
private void setDraftApplications(Widget1 widget1) {
Long draftApplications = applicationRepository.countDraftApplications();
if (draftApplications != null) {
widget1.setNumberOfDraftApplications(draftApplications);
}
}
private void setNumberOfCompanies(Widget1 widget1) {
Long numberOfCompanies = companyRepository.countTotalCompanies();
if (numberOfCompanies != null) {
widget1.setNumberOfCompany(numberOfCompanies);
}
}
public BeneficiaryWidgetResponseBean getDashboardWidgetForBeneficiary(UserEntity userEntity,
CompanyEntity company) {
BeneficiaryWidgetResponseBean beneficiaryWidgetResponseBean = BeneficiaryWidgetResponseBean.builder()
.numberOfApplications(0L).numberOfCalls(0L).numberOfIntegratedDocuments(0L).build();
Long activeCalls = callRepository.countByStatus(CallStatusEnum.PUBLISH.getValue());
if (activeCalls != null) {
beneficiaryWidgetResponseBean.setNumberOfCalls(activeCalls);
}
Long activeApplication = applicationRepository.countSubmittedApplicationsByUserId(userEntity.getId(),
company.getId());
if (activeApplication != null) {
beneficiaryWidgetResponseBean.setNumberOfApplications(activeApplication);
}
return beneficiaryWidgetResponseBean;
}
}

View File

@@ -94,15 +94,14 @@ public class PdfDao {
// Application ID section (Centered) // Application ID section (Centered)
// pageEvent.setTotalPages(writer.getPageNumber()); // pageEvent.setTotalPages(writer.getPageNumber());
Paragraph appId = new Paragraph("ID domanda :" +"XX00"); String protocolNumber="XX00";
if(applicationEntity.getProtocol()!=null) {
protocolNumber= String.valueOf(applicationEntity.getProtocol().getProtocolNumber());
}
Paragraph appId = new Paragraph("ID domanda :" +protocolNumber);
appId.setAlignment(Element.ALIGN_RIGHT); appId.setAlignment(Element.ALIGN_RIGHT);
document.add(appId); document.add(appId);
if(applicationEntity.getProtocol()!=null) {
appId = new Paragraph("ID domanda :"+String.valueOf(applicationEntity.getProtocol().getProtocolNumber()), valueFont);
appId.setAlignment(Element.ALIGN_RIGHT);
document.add(appId);
}
document.add(new Paragraph(" ")); document.add(new Paragraph(" "));
addColoredLines(writer,document,greenColor); addColoredLines(writer,document,greenColor);
@@ -346,14 +345,17 @@ public class PdfDao {
return totalPages; return totalPages;
} }
private Document createPdfTable(List<Map<String, String>> extractedData,Document document) throws DocumentException { // Create a PdfPTable with 2 columns private Document createPdfTable(List<Map<String, String>> extractedData,Document document) throws DocumentException {
// Create a PdfPTable with 2 columns
PdfPTable table = new PdfPTable(2); // Initial assumption for 2 columns PdfPTable table = new PdfPTable(2); // Initial assumption for 2 columns
table.setWidthPercentage(100); // Set table width to 100% table.setWidthPercentage(100); // Set table width to 100%
table.setTableEvent(new RoundedBorderEvent());
Font textFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(105, 105, 105)); // Gray text Font textFont = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new BaseColor(105, 105, 105)); // Gray text
boolean combinedHeaderAdded = false; // Flag to track if headers for combined have been added boolean combinedHeaderAdded = false; // Flag to track if headers for combined have been added
float rowHeight = 50f; // Example row height, adjust as necessary float rowHeight = 50f; // Example row height, adjust as necessary
float maxTableHeight = 700f; // Maximum height of the table before a page break float maxTableHeight = 700f; // Maximum height of the table before a page break
int rowCount = 0; // Counter for rows float[] columnWidths = {0.7f, 0.3f};
table.setWidths(columnWidths);
// Add table header // Add table header
@@ -484,7 +486,26 @@ public class PdfDao {
// Return the populated table // Return the populated table
return document; return document;
} }
public static class RoundedBorderEvent implements PdfPTableEvent {
@Override
public void tableLayout(PdfPTable table, float[][] widths, float[] heights,
int headerRows, int rowStart, PdfContentByte[] canvases) {
PdfContentByte canvas = canvases[PdfPTable.BASECANVAS];
// Get the table boundaries
float left = widths[0][0];
float right = widths[0][widths[0].length - 1];
float top = heights[0];
float bottom = heights[heights.length - 1];
// Define the corner radius
float radius = 20f;
// Draw a rounded rectangle around the table
canvas.roundRectangle(left, bottom, right - left, top - bottom, radius);
canvas.stroke();
}
}
public List<FieldLabelValuePairRequest> getFormFieldsToLabels(FormApplicationResponse responseBean) { public List<FieldLabelValuePairRequest> getFormFieldsToLabels(FormApplicationResponse responseBean) {
List<FieldLabelValuePairRequest> labelValuePairs = new ArrayList<>(); List<FieldLabelValuePairRequest> labelValuePairs = new ArrayList<>();

View File

@@ -269,6 +269,14 @@ public class UserDao {
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, .orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG))); Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
} }
public UserEntity getUserByBeneficiaryId(Long beneficiaryId) {
UserEntity user = userRepository.findByBeneficiaryId(beneficiaryId);
if (user == null) {
throw new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_WITH_BENEFICIARYID_MSG));
}
return user;
}
public String initiatePasswordReset(InitiatePasswordResetReq resetReq) { public String initiatePasswordReset(InitiatePasswordResetReq resetReq) {
UserEntity user = userRepository.findByEmail(resetReq.getEmail()); UserEntity user = userRepository.findByEmail(resetReq.getEmail());

View File

@@ -0,0 +1,37 @@
package net.gepafin.tendermanagement.entities;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Entity
@Table(name = "beneficiary_preferred_call")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class BeneficiaryPreferredCallEntity extends BaseEntity{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "beneficiary_id")
private Long beneficiaryId;
@Column(name = "user_id")
private Long userId;
@Column(name = "company_id")
private Long companyId;
@Column(name = "call_id")
private Long callId;
@Column(name = "STATUS", length = 255)
private String status;
}

View File

@@ -0,0 +1,21 @@
package net.gepafin.tendermanagement.enums;
import com.fasterxml.jackson.annotation.JsonValue;
public enum BeneficiaryCallStatus {
ENABLED("ENABLED"),
DISABLED("DISABLED"),
APPLIED("APPLIED");
private String value;
BeneficiaryCallStatus(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
}

View File

@@ -0,0 +1,12 @@
package net.gepafin.tendermanagement.model.request;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
public class BeneficiaryPreferredCallReq {
private Long companyId;
private Long callId;
}

View File

@@ -0,0 +1,25 @@
package net.gepafin.tendermanagement.model.response;
import lombok.Data;
import lombok.NoArgsConstructor;
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
import net.gepafin.tendermanagement.enums.UserStatusEnum;
import java.time.LocalDateTime;
@NoArgsConstructor
@Data
public class BeneficiaryPreferredCallResponseBean {
private Long id;
private Long beneficiaryId;
private Long userId;
private Long companyId;
private Long callId;
private BeneficiaryCallStatus status;
private LocalDateTime createdDate;
private LocalDateTime updatedDate;
}

View File

@@ -0,0 +1,17 @@
package net.gepafin.tendermanagement.model.response;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class BeneficiaryWidgetResponseBean {
private Long numberOfApplications;
private Long numberOfCalls;
private Long numberOfIntegratedDocuments;
}

View File

@@ -0,0 +1,14 @@
package net.gepafin.tendermanagement.model.response;
import lombok.Data;
import java.util.List;
@Data
public class SuperAdminWidgetResponseBean {
private Widget1 widget1;
// private List<Object[]> widgetBars;
}

View File

@@ -0,0 +1,26 @@
package net.gepafin.tendermanagement.model.response;
import lombok.Builder;
import lombok.Data;
import java.math.BigDecimal;
@Data
@Builder
public class Widget1 {
private Long numberOfActiveCalls;
private Long numberOfResgisteredUsers;
// private Long preInvestigationQuestions;
private Long numberOfSubmittedApplications;
private Long numberOfDraftApplications;
private Long numberOfCompany;
private BigDecimal totalActiveFinancing;
}

View File

@@ -29,4 +29,15 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
public Optional<ApplicationEntity> findByIdAndUserIdAndCallIdAndIsDeletedFalse(Long applicationId, Long userId, public Optional<ApplicationEntity> findByIdAndUserIdAndCallIdAndIsDeletedFalse(Long applicationId, Long userId,
Long callId); Long callId);
@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);
@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();
} }

View File

@@ -0,0 +1,18 @@
package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.BeneficiaryPreferredCallEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface BeneficiaryPreferredCallRepository extends JpaRepository<BeneficiaryPreferredCallEntity, Long> {
List<BeneficiaryPreferredCallEntity> findByBeneficiaryId(Long beneficiaryId);
List<BeneficiaryPreferredCallEntity> findByUserId(Long userId);
@Query("SELECT preferredCall FROM BeneficiaryPreferredCallEntity preferredCall where preferredCall.userId=:userId AND (:companyId is null OR preferredCall.companyId=:companyId)")
List<BeneficiaryPreferredCallEntity> findByUserIdAndCompanyId(@Param("userId") Long userId, @Param("companyId") Long companyId);
List<BeneficiaryPreferredCallEntity> findByBeneficiaryIdAndCompanyId(Long beneficiaryId,Long companyId);
}

View File

@@ -2,8 +2,10 @@ package net.gepafin.tendermanagement.repositories;
import net.gepafin.tendermanagement.entities.CallEntity; import net.gepafin.tendermanagement.entities.CallEntity;
import net.gepafin.tendermanagement.enums.CallStatusEnum; import net.gepafin.tendermanagement.enums.CallStatusEnum;
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 java.math.BigDecimal;
import java.util.List; import java.util.List;
@Repository @Repository
@@ -13,4 +15,14 @@ public interface CallRepository extends JpaRepository<CallEntity, Long> {
List<CallEntity> findByStatusIn(List<String> callStatus); List<CallEntity> findByStatusIn(List<String> callStatus);
public CallEntity findByIdAndStatus(Long id,String status); public CallEntity findByIdAndStatus(Long id,String status);
public Long countByStatus(String status);
@Query("SELECT COALESCE(SUM(c.amount), 0) FROM CallEntity c WHERE c.status = 'PUBLISH'")
BigDecimal findTotalAmountOfPublishedCalls();
@Query("SELECT c.name, COUNT(a.id) " +
"FROM CallEntity c LEFT JOIN ApplicationEntity a ON c.id = a.call.id " +
"GROUP BY c.name")
List<Object[]> findApplicationsPerCall();
} }

View File

@@ -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();
} }

View File

@@ -18,4 +18,8 @@ public interface UserRepository extends JpaRepository<UserEntity, Long> {
Optional<UserEntity> findByBeneficiaryCodiceFiscale(String codiceFiscale); Optional<UserEntity> findByBeneficiaryCodiceFiscale(String codiceFiscale);
boolean existsByBeneficiaryCodiceFiscale(String codiceFiscale); boolean existsByBeneficiaryCodiceFiscale(String codiceFiscale);
UserEntity findByBeneficiaryId(Long beneficiaryId);
Long countByStatusAndRoleEntity_RoleType(String status, String roleName);
} }

View File

@@ -0,0 +1,25 @@
package net.gepafin.tendermanagement.service;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
import java.util.List;
public interface BeneficiaryPreferredCallService {
BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest request, BeneficiaryPreferredCallReq beneficiaryPreferredCallRequest);
BeneficiaryPreferredCallResponseBean getBeneficiaryPreferredCallById(HttpServletRequest request, Long id);
void deleteBeneficiaryPreferredCall(HttpServletRequest request, Long id);
List<BeneficiaryPreferredCallResponseBean> getAllBeneficiaryPreferredCalls(HttpServletRequest request);
// BeneficiaryPreferredCallResponseBean updateBeneficiaryPreferredCall(HttpServletRequest request, Long id, BeneficiaryPreferredCallReq beneficiaryPreferredCallRequest);
void updateBeneficiaryPreferredCallStatus(HttpServletRequest request, Long id, BeneficiaryCallStatus status);
List<BeneficiaryPreferredCallResponseBean> getBeneficiaryPreferredCallByUserId(HttpServletRequest request,Long userId,Long beneficiaryId,Long companyId);
}

View File

@@ -0,0 +1,13 @@
package net.gepafin.tendermanagement.service;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.model.response.BeneficiaryWidgetResponseBean;
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
public interface DashboardService {
public SuperAdminWidgetResponseBean getDashboardWidgetForSuperAdmin(HttpServletRequest request);
public BeneficiaryWidgetResponseBean getDashboardWidgetForBeneficiary(HttpServletRequest request, Long companyId);
}

View File

@@ -40,4 +40,5 @@ public interface UserService {
JWTToken validateExistingUserToken(HttpServletRequest request, String token); JWTToken validateExistingUserToken(HttpServletRequest request, String token);
UserSamlResponse validateNewUserToken(HttpServletRequest request, String token); UserSamlResponse validateNewUserToken(HttpServletRequest request, String token);
UserEntity getUserByBeneficiaryId(Long beneficiaryId);
} }

View File

@@ -0,0 +1,90 @@
package net.gepafin.tendermanagement.service.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.dao.BeneficiaryPreferredCallDao;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
import net.gepafin.tendermanagement.repositories.UserRepository;
import net.gepafin.tendermanagement.service.BeneficiaryPreferredCallService;
import net.gepafin.tendermanagement.service.UserService;
import net.gepafin.tendermanagement.util.Validator;
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
@Service
public class BeneficiaryPreferredCallServiceImpl implements BeneficiaryPreferredCallService {
@Autowired
private BeneficiaryPreferredCallDao beneficiaryPreferredCallDao;
@Autowired
private Validator validator;
@Autowired
private UserRepository userRepository;
@Autowired
private UserService userService;
@Override
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest request, BeneficiaryPreferredCallReq beneficiaryPreferredCallRequest) {
UserEntity userEntity = validator.validateUser(request);
return beneficiaryPreferredCallDao.createBeneficiaryPreferredCall(beneficiaryPreferredCallRequest,userEntity);
}
@Override
public BeneficiaryPreferredCallResponseBean getBeneficiaryPreferredCallById(HttpServletRequest request, Long id) {
return beneficiaryPreferredCallDao.getBeneficiaryPreferredCallById(id);
}
@Override
public void deleteBeneficiaryPreferredCall(HttpServletRequest request, Long id) {
beneficiaryPreferredCallDao.deleteBeneficiaryPreferredCallById(id);
}
@Override
public List<BeneficiaryPreferredCallResponseBean> getAllBeneficiaryPreferredCalls(HttpServletRequest request) {
return beneficiaryPreferredCallDao.getAllBeneficiaryPreferredCalls();
}
// @Override
// public BeneficiaryPreferredCallResponseBean updateBeneficiaryPreferredCall(HttpServletRequest request, Long id,
// BeneficiaryPreferredCallReq beneficiaryPreferredCallRequest) {
// UserEntity userEntity = validator.validateUser(request);
// return beneficiaryPreferredCallDao.updateBeneficiaryPreferredCall(id, beneficiaryPreferredCallRequest,userEntity);
// }
@Override
public void updateBeneficiaryPreferredCallStatus(HttpServletRequest request, Long id, BeneficiaryCallStatus status) {
beneficiaryPreferredCallDao.updateBeneficiaryPreferredCallStatus(id, status);
}
@Override
public List<BeneficiaryPreferredCallResponseBean> getBeneficiaryPreferredCallByUserId(HttpServletRequest request,Long userId,Long beneficiaryId,Long companyId) {
UserEntity userEntity =validateGetBeneficiaryPreferredCallrequest(request,userId,beneficiaryId);
return beneficiaryPreferredCallDao.getBeneficiaryPreferredCallByUserId(userEntity,companyId);
}
private UserEntity validateGetBeneficiaryPreferredCallrequest(HttpServletRequest request, Long userId, Long beneficiaryId) {
if (userId == null && beneficiaryId == null) {
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.EITHER_USER_OR_BENEFICIARY_ID_REQUIRED));
}
if(userId!=null&&beneficiaryId!=null){
throw new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.USER_ID_AND_BENEFICIARY_ID_ERROR));
}
if(beneficiaryId!=null){
UserEntity user = userService.getUserByBeneficiaryId(beneficiaryId);
return validator.validateUserId(request,user.getId());
}
else{
return validator.validateUserId(request, userId);
}
}
}

View File

@@ -0,0 +1,34 @@
package net.gepafin.tendermanagement.service.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.dao.DashboardDao;
import net.gepafin.tendermanagement.entities.CompanyEntity;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.model.response.BeneficiaryWidgetResponseBean;
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
import net.gepafin.tendermanagement.service.DashboardService;
import net.gepafin.tendermanagement.util.Validator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DashboardServiceImpl implements DashboardService {
@Autowired
private DashboardDao dashboardDao;
@Autowired
private Validator validator;
@Override
public SuperAdminWidgetResponseBean getDashboardWidgetForSuperAdmin(HttpServletRequest request) {
return dashboardDao.getDashboardWidget();
}
@Override
public BeneficiaryWidgetResponseBean getDashboardWidgetForBeneficiary(HttpServletRequest request, Long companyId) {
UserEntity userEntity=validator.validateUser(request);
CompanyEntity company = validator.validateUserWithCompany(request, companyId);
return dashboardDao.getDashboardWidgetForBeneficiary(userEntity, company);
}
}

View File

@@ -115,4 +115,8 @@ public class UserServiceImpl implements UserService {
public UserSamlResponse validateNewUserToken(HttpServletRequest request, String token) { public UserSamlResponse validateNewUserToken(HttpServletRequest request, String token) {
return userDao.validateNewUserToken(token); return userDao.validateNewUserToken(token);
} }
@Override
public UserEntity getUserByBeneficiaryId(Long beneficiaryId) {
return userDao.getUserByBeneficiaryId(beneficiaryId);
}
} }

View File

@@ -0,0 +1,102 @@
package net.gepafin.tendermanagement.web.rest.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
import net.gepafin.tendermanagement.enums.CallStatusEnum;
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Validated
@RequestMapping("/v1/beneficiaryPreferredCall")
public interface BeneficiaryPreferredCallApi {
@Operation(summary = "Create a new beneficiary preferred call",
responses = {
@ApiResponse(responseCode = "201", description = "Created"),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)}))})
@PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> createBeneficiaryPreferredCall(HttpServletRequest request,
@Parameter(required = true)
@Valid @RequestBody BeneficiaryPreferredCallReq beneficiaryPreferredCallReq);
/* @Operation(summary = "Update an existing beneficiary preferred call",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)})),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)}))})
@PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> updateBeneficiaryPreferredCall(HttpServletRequest request,
@Parameter( required = true)
@PathVariable("id") Long id,
@Valid @RequestBody BeneficiaryPreferredCallReq beneficiaryPreferredCallReq);
*/
@Operation(summary = "Get a beneficiary preferred call by ID",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)}))})
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> getBeneficiaryPreferredCallById(HttpServletRequest request,
@Parameter( required = true)
@PathVariable("id") Long id);
@Operation(summary = "Delete a beneficiary preferred call",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)}))})
@DeleteMapping(value = "/{id}")
ResponseEntity<Response<Void>> deleteBeneficiaryPreferredCall(HttpServletRequest request,
@Parameter(required = true)
@PathVariable("id") Long id);
@Operation(summary = "Update status of a beneficiary preferred call",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)}))})
@PutMapping(value = "/{id}/status", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<Void>> updateBeneficiaryPreferredCallStatus(HttpServletRequest request,
@Parameter( required = true)
@PathVariable("id") Long id,
@Parameter(description = "New status for the preferred call", required = true)
@RequestParam(value = "status", required = true) BeneficiaryCallStatus status);
@Operation(summary = "Get all beneficiary preferred calls",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)}))})
@GetMapping(value = "/user", produces = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<Response<List<BeneficiaryPreferredCallResponseBean>>> getBeneficiaryPreferredCallByUserId(
HttpServletRequest request,
@RequestParam(value = "userId",required = false) Long userId,
@RequestParam(value = "beneficiaryId",required = false) Long beneficiaryId,
@RequestParam(value = "companyId",required = false) Long companyId
);
}

View File

@@ -0,0 +1,52 @@
package net.gepafin.tendermanagement.web.rest.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.model.response.BeneficiaryWidgetResponseBean;
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
public interface DashboardApi {
@Operation(summary = "Api to get dashboard widget for super admin",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "",
produces = { "application/json" })
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
ResponseEntity<Response<SuperAdminWidgetResponseBean>> getDashboardWidgetForSuperAdmin(HttpServletRequest request);
@Operation(summary = "Api to get dashboard widget for beneficiary",
responses = {
@ApiResponse(responseCode = "200", description = "OK"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "/beneficiary/company/{companyId}",
produces = { "application/json" })
ResponseEntity<Response<BeneficiaryWidgetResponseBean>> getDashboardWidgetForBeneficiary(HttpServletRequest request,
@Parameter(description = "The company id", required = true) @PathVariable(value = "companyId", required = true) Long companyId);
}

View File

@@ -0,0 +1,78 @@
package net.gepafin.tendermanagement.web.rest.api.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.enums.BeneficiaryCallStatus;
import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.BeneficiaryPreferredCallService;
import net.gepafin.tendermanagement.web.rest.api.BeneficiaryPreferredCallApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class BeneficiaryPreferredCallApiController implements BeneficiaryPreferredCallApi {
private final Logger log = LoggerFactory.getLogger(BeneficiaryPreferredCallApiController.class);
@Autowired
private BeneficiaryPreferredCallService beneficiaryPreferredCallService;
@Override
public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> createBeneficiaryPreferredCall(HttpServletRequest request, BeneficiaryPreferredCallReq beneficiaryPreferredCallReq) {
log.info("Creating Beneficiary Preferred Call");
BeneficiaryPreferredCallResponseBean responseBean = beneficiaryPreferredCallService.createBeneficiaryPreferredCall(request, beneficiaryPreferredCallReq);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_CREATED_SUCCESS_MSG)));
}
// @Override
// public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> updateBeneficiaryPreferredCall(HttpServletRequest request, Long id, BeneficiaryPreferredCallReq beneficiaryPreferredCallReq) {
// log.info("Updating Beneficiary Preferred Call - ID: {}", id);
// BeneficiaryPreferredCallResponseBean response = beneficiaryPreferredCallService.updateBeneficiaryPreferredCall(request, id, beneficiaryPreferredCallReq);
// return ResponseEntity.status(HttpStatus.OK)
// .body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_UPDATED_SUCCESS_MSG)));
// }
@Override
public ResponseEntity<Response<BeneficiaryPreferredCallResponseBean>> getBeneficiaryPreferredCallById(HttpServletRequest request, Long id) {
log.info("Fetching Beneficiary Preferred Call by ID - ID: {}", id);
BeneficiaryPreferredCallResponseBean response = beneficiaryPreferredCallService.getBeneficiaryPreferredCallById(request, id);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<Void>> deleteBeneficiaryPreferredCall(HttpServletRequest request, Long id) {
log.info("Deleting Beneficiary Preferred Call - ID: {}", id);
beneficiaryPreferredCallService.deleteBeneficiaryPreferredCall(request, id);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.DELETE_BENEFICIARY_PREFERRED_CALL_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<Void>> updateBeneficiaryPreferredCallStatus(HttpServletRequest request, Long id, BeneficiaryCallStatus status) {
log.info("Updating status of Beneficiary Preferred Call - ID: {}, Status: {}", id, status);
beneficiaryPreferredCallService.updateBeneficiaryPreferredCallStatus(request, id, status);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.BENEFICIARY_PREFERRED_CALL_STATUS_UPDATED_SUCCESS_MSG)));
}
@Override
public ResponseEntity<Response<List<BeneficiaryPreferredCallResponseBean>>> getBeneficiaryPreferredCallByUserId(HttpServletRequest request,Long userId,Long beneficiaryId,Long companyId) {
log.info("Fetching all Beneficiary Preferred Calls for User ID");
List<BeneficiaryPreferredCallResponseBean> response = beneficiaryPreferredCallService.getBeneficiaryPreferredCallByUserId(request, userId,beneficiaryId,companyId);
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_ALL_BENEFICIARY_PREFERRED_CALLS_SUCCESS_MSG)));
}
}

View File

@@ -0,0 +1,38 @@
package net.gepafin.tendermanagement.web.rest.api.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.model.response.BeneficiaryWidgetResponseBean;
import net.gepafin.tendermanagement.model.response.SuperAdminWidgetResponseBean;
import net.gepafin.tendermanagement.model.util.Response;
import net.gepafin.tendermanagement.service.DashboardService;
import net.gepafin.tendermanagement.web.rest.api.DashboardApi;
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("${openapi.gepafin.base-path:/v1/dashboard}")
public class DashboardApiController implements DashboardApi {
@Autowired
private DashboardService dashboardService;
@Override
public ResponseEntity<Response<SuperAdminWidgetResponseBean>> getDashboardWidgetForSuperAdmin(HttpServletRequest request) {
SuperAdminWidgetResponseBean widgetResponseBean= dashboardService.getDashboardWidgetForSuperAdmin(request);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(widgetResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.DASHBOARD_WIDGET_FETCHED_SUCCESSFULLY))); }
@Override
public ResponseEntity<Response<BeneficiaryWidgetResponseBean>> getDashboardWidgetForBeneficiary(HttpServletRequest request, Long companyId) {
BeneficiaryWidgetResponseBean widgetResponseBean= dashboardService.getDashboardWidgetForBeneficiary(request, companyId);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Response<>(widgetResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.DASHBOARD_WIDGET_FETCHED_SUCCESSFULLY)));
}
}

View File

@@ -60,7 +60,7 @@ mailGun_base_url=https://api.eu.mailgun.net/
apiKey=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 apiKey=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
#senderEmail=mailer@bflows.net #senderEmail=mailer@bflows.net
isMailSendingEnabled = false isMailSendingEnabled = false
default_System_Receiver_Email=attivazione@bflows.net default_System_Receiver_Email=antonio.manca@bflows.net
gepafin_email=bandi@pec.gepafin.it gepafin_email=bandi@pec.gepafin.it
rinaldo_email=rinaldo.bonazzo@bflows.net rinaldo_email=rinaldo.bonazzo@bflows.net
carlo_email=carlo.mancosu@bflows.net carlo_email=carlo.mancosu@bflows.net

View File

@@ -0,0 +1,6 @@
____ __ _
/ ___| ___ _ __ __ _ / _(_)_ __
| | _ / _ \ '_ \ / _` | |_| | '_ \
| |_| | __/ |_) | (_| | _| | | | |
\____|\___| .__/ \__,_|_| |_|_| |_|
|_|

View File

@@ -972,6 +972,26 @@
</column> </column>
</addColumn> </addColumn>
</changeSet> </changeSet>
<changeSet id="11-10-2024_1" author="Harish Bagora">
<createTable tableName="beneficiary_preferred_call">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true" primaryKeyName="beneficiary_preferred_call_pkey"/>
</column>
<column name="beneficiary_id" type="BIGINT"/>
<column name="user_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="company_id" type="BIGINT"/>
<column name="call_id" type="BIGINT"/>
<column name="status" type="VARCHAR(255)"/>
<column name="created_date" type="TIMESTAMP WITHOUT TIME ZONE">
<constraints nullable="true"/>
</column>
<column name="updated_date" type="TIMESTAMP WITHOUT TIME ZONE">
<constraints nullable="true"/>
</column>
</createTable>
</changeSet>
<changeSet id="10-10-2024_1" author="Rajesh Khore"> <changeSet id="10-10-2024_1" author="Rajesh Khore">
<createTable tableName="system_email_template"> <createTable tableName="system_email_template">
@@ -1026,6 +1046,27 @@
<where>name='table'</where> <where>name='table'</where>
</update> </update>
</changeSet> </changeSet>
<changeSet id="14-10-2024_1" author="Harish Bagora">
<sqlFile dbms="postgresql"
path="db/dump/update_system_email_template_of_application_submission.sql" />
</changeSet>
<changeSet id="15-10-2024_1" author="Harish Bagora">
<insert tableName="gepafin_user">
<column name="password" value="$2a$10$doUyOcEm8WPuFfpFT5y18.1DvZzF7exbqgy9X0P27cUBK7YWbfzzS"/>
<column name="email" value="instructor@test.test"/>
<column name="first_name" value="Test"/>
<column name="last_name" value="Instructor"/>
<column name="phone_number" value="9876543210"/>
<column name="role_id" valueComputed="3"/>
<column name="status" value="ACTIVE"/>
<column name="last_login" value="2024-10-15 00:00:00"/>
<column name="created_date" value="2024-10-15 00:00:00"/>
<column name="updated_date" value="2024-10-15 00:00:00"/>
<column name="organization" value="PreInstructorOrg"/>
<column name="address" value="789 Victory Road"/>
<column name="city" value="Naples"/>
<column name="country" value="Italy"/>
</insert>
</changeSet>
</databaseChangeLog> </databaseChangeLog>

View File

@@ -0,0 +1,19 @@
UPDATE gepafin_schema.system_email_template
SET html_content = '<html>
<body style="font-family: Arial, sans-serif; color: #333; line-height: 1.6;">
<div style="padding: 20px; border: 1px solid #ddd; border-radius: 8px; max-width: 600px; margin: auto;">
<p>
In riferimento alla domanda di concessione di Finanziamento agevolato a valere sul Fondo prestiti
<strong>{{call_name}}</strong> di cui alloggetto, la stessa è stata regolarmente acquisita ed è stata
registrata con Protocollo n. <strong>{{protocol_number}}</strong> del <strong>{{date}}</strong> alle <strong>{{time}}</strong>.
</p>
<p>Distinti Saluti,</p>
<p>
<strong>Gepafin S.p.a.</strong>
</p>
</div>
</body>
</html>',
updated_date = '2024-10-14 10:00:00'
WHERE type = 'APPLICATION_SUBMISSION_TO_GEPAFIN';

View File

@@ -229,10 +229,24 @@ application.submitted.cannot.change=The submitted application cannot be changed.
# Call Document Messages # Call Document Messages
call.documents.fetch.success=Documents fetched successfully. call.documents.fetch.success=Documents fetched successfully.
call.documents.not.found=No documents found for the specified call. call.documents.not.found=No documents found for the specified call.
# Beneficiary Preferred Call messages
beneficiary.preferred.call.status.updated.success=Beneficiary preferred call status updated successfully.
beneficiary.preferred.calls.get.all.success=All beneficiary preferred calls fetched successfully.
beneficiary.preferred.call.created.success=Beneficiary preferred call created successfully.
beneficiary.preferred.call.get.success=Beneficiary preferred call retrieved successfully.
beneficiary.preferred.call.delete.success=Beneficiary preferred call deleted successfully.
beneficiary.preferred.calls.get.success=All beneficiary preferred calls retrieved successfully.
beneficiary.preferred.call.updated.success=Beneficiary preferred call updated successfully.
beneficiary.preferred.call.not.found=Beneficiary preferred call not found.
either.user.or.beneficiary.id.required = User ID or Beneficiary ID not present.
userId.and.beneficiaryId.error = Both userId and beneficiaryId cannot be provided at the same time.
User.not.found.with.the.given.beneficiaryID=User not found with the given beneficiary ID.
permission.denied=You are not authorized to access this data. permission.denied=You are not authorized to access this data.
signed.document.file.upload.success=Signed document file uploaded successfully. signed.document.file.upload.success=Signed document file uploaded successfully.
get.signed.document.file.success=Signed document file retrieved successfully. get.signed.document.file.success=Signed document file retrieved successfully.
application.signed.document.not.found=Signed document for the application not found. application.signed.document.not.found=Signed document for the application not found.
delete.signed.document.file.success=Signed document deleted successfully. delete.signed.document.file.success=Signed document deleted successfully.
dashboard.widget.fetched.successfully=Dasboard widget fetched sucessfully.

View File

@@ -220,15 +220,28 @@ delegation.not.found=Delega non trovata.
user.company.relation.not.found=Relazione utente con l'azienda specificata non trovata. user.company.relation.not.found=Relazione utente con l'azienda specificata non trovata.
delegation.delete.success=Delega eliminata con successo. delegation.delete.success=Delega eliminata con successo.
user.not.authorized.create.application=L'utente deve essere un rappresentante legale o avere una delega. user.not.authorized.create.application=L'utente deve essere un rappresentante legale o avere una delega.
application.submitted.cannot.change=La domanda inviata non può essere modificata. application.submitted.cannot.change=La domanda inviata non pu<EFBFBD> essere modificata.
# Call Document Messages # Call Document Messages
call.documents.fetch.success=Documenti recuperati con successo. call.documents.fetch.success=Documenti recuperati con successo.
call.documents.not.found=Nessun documento trovato per la chiamata specificata. call.documents.not.found=Nessun documento trovato per la chiamata specificata.
# Beneficiary Preferred Call messages
beneficiary.preferred.call.status.updated.success=Lo stato della chiamata preferita del beneficiario <20> stato aggiornato con successo.
beneficiary.preferred.calls.get.all.success=Tutte le chiamate preferite del beneficiario sono state recuperate con successo.
beneficiary.preferred.call.created.success=Chiamata preferita del beneficiario creata con successo.
beneficiary.preferred.call.get.success=Chiamata preferita del beneficiario recuperata con successo.
beneficiary.preferred.call.delete.success=Chiamata preferita del beneficiario eliminata con successo.
beneficiary.preferred.calls.get.success=Tutte le chiamate preferite del beneficiario recuperate con successo.
beneficiary.preferred.call.updated.success=Chiamata preferita del beneficiario aggiornata con successo.
beneficiary.preferred.call.not.found=Chiamata preferita del beneficiario non trovata.
either.user.or.beneficiary.id.required = ID utente o ID beneficiario non presente.
userId.and.beneficiaryId.error = Non <20> possibile fornire contemporaneamente sia userId che beneficiaryId.
User.not.found.with.the.given.beneficiaryID=Utente non trovato con l'ID beneficiario fornito.
permission.denied=Non sei autorizzato ad accedere a questi dati. permission.denied=Non sei autorizzato ad accedere a questi dati.
signed.document.file.upload.success=File del documento firmato caricato con successo. signed.document.file.upload.success=File del documento firmato caricato con successo.
get.signed.document.file.success=File del documento firmato recuperato con successo. get.signed.document.file.success=File del documento firmato recuperato con successo.
application.signed.document.not.found=Documento firmato per l'applicazione non trovato. application.signed.document.not.found=Documento firmato per l'applicazione non trovato.
delete.signed.document.file.success=Documento firmato eliminato con successo. delete.signed.document.file.success=Documento firmato eliminato con successo.
dashboard.widget.fetched.successfully=Widget dashboard recuperato correttamente.