java.lang.Object
es.kukenan.smartfi.microservice.backoffice.service.UserService

@Service public class UserService extends Object
Users related services.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final String
    Advance constant.
    private AuditService
    Backoffice endpoints implementation.
    Comment repository.
    private static final String
    Company rol name constant.
    Company service.
    private static final String
    Consultant rol name constant.
    private static final String
    Credit constant.
    private final org.springframework.data.domain.ExampleMatcher
    Example matcher configuration.
    Back office clients manager.
    private int
    Password length.
    private String
    Key used for generate RSA cipher.
    private es.kukenan.smartfi.common.context.RequestContextManager
    Request context manager.
    Rol repository.
    Component for handle SMTP communication inside backoffice.
    User repository.
    private static final List<String>
    Advance constant.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.DetailUserDto>
    addComments(es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.DetailUserDto> responseDto)
    Add comments to client detail response.
    private es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract
    addSponsor(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract contract)
    Add Sponsor data to given Contract.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<List<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>>
    changeApplicationToPayed(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.UpdateListOfContractsRequestDto updateListOfContractsRequestDto, String userId, String userJwtToken, String product)
    Change a list of application identifier from PAYMENT_PENDING (credit) or APPROVED_PAYMENT_PENDING_NAME (advance) to PAYED (advance) or ACTIVE (credit).
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.CountInfoDto>>
    countApplications(String userToken, es.kukenan.smartfi.common.security.WalletAuthentication authentication)
    Application count.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<Map<String,Long>>>
    countClientsUsers(String userId, String userToken, es.kukenan.smartfi.common.security.WalletAuthentication authentication)
    Count clients and users service.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<List<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.CompanyUserBackofficeResponse>>>
    createUser(String userBackofficeId, String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.CreateCompanyBackofficeRequestDto createUserBackofficeRequestDto)
    Create new backoffice consultant or company user.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>
    findApplicationDetail(String userToken, String applicationId)
    Application detail service.
    org.springframework.http.ResponseEntity<Object>
    findApplications(String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.GetApplicationsRequestDto getApplicationsRequestDto, Integer pageNumber, Integer pageSize, String sortedBy, es.kukenan.smartfi.common.security.WalletAuthentication authentication)
    Application list service.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.DetailUserDto>>
    findClient(String userToken, String clientId)
    Find User by Document id endpoint.
    org.springframework.http.ResponseEntity<Object>
    findClientByDocument(String userId, String userToken, es.kukenan.smartfi.dto.backoffice.UserBackofficeRequestDTO userBackofficeRequest)
    Find Client by Document id.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.common.api.dtos.ResultsPageDto<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.BasicUserDto>>>
    findClients(String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.FilterUserRequestDto filterUserRequestDto, Integer pageNumber, Integer pageSize, String sortedBy, es.kukenan.smartfi.common.security.WalletAuthentication authentication)
    Clients list endpoint.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<List<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.requestedfiles.DataObject>>>
    Find available roles for create users.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.DetailUserDto>>
    findUser(String userId, String userToken)
    Find User endpoint.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.common.api.dtos.ResultsPageDto<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.BasicUserDto>>>
    findUsers(String userId, String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.FilterUserRequestDto filterUserRequestDto, Integer pageNumber, Integer pageSize, String sortedBy, String type)
    Users list endpoint.
    void
    getContractDocumentFile(String userId, String userToken, String contractDocumentId, javax.servlet.http.HttpServletResponse response, boolean generate)
    Get contract document file.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>
    saveApplication(String backofficeUserId, String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.NewUserAndApplicationRequestDto requestDto, es.kukenan.smartfi.common.security.WalletAuthentication authentication, String userIp, String userAgent)
    Create new application.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.DetailUserDto>>
    updateClient(es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.UpdateUserDto updateUserDto, String userToken, String clientId, String userId)
    Update some client data.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>
    updateContractDocumentStatus(String userId, String userToken, String contractDocumentId, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.UpdateContractDocumentRequestDto updateContractDocumentRequestDto)
    Update application document status.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>
    updateContractStatus(String userId, String contractId, String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.ContractStatusRequestDto contractStatusRequestDto)
    Update application status.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>
    uploadContractualFile(String contractId, String userId, org.springframework.web.multipart.MultipartFile file, String userToken, String process)
    Upload contractual files.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>
    uploadFile(String contractId, String userId, List<org.springframework.web.multipart.MultipartFile> files, String userToken)
    Upload specific contract document file.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>
    uploadFile(String contractDocumentId, String userId, org.springframework.web.multipart.MultipartFile file, String userToken)
    Upload files.
    private es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>
    validContractResponse(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract contract)
    Validate if the contract response is not null to add Sponsor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • exampleMatcher

      private final org.springframework.data.domain.ExampleMatcher exampleMatcher
      Example matcher configuration.
    • passwordLength

      @Value("${backoffice.password.length}") private int passwordLength
      Password length.
    • publicKey

      @Value("${kukenfi.publicKey}") private String publicKey
      Key used for generate RSA cipher.
    • CREDIT_PRODUCT

      private static final String CREDIT_PRODUCT
      Credit constant.
      See Also:
    • ADVANCE_PRODUCT

      private static final String ADVANCE_PRODUCT
      Advance constant.
      See Also:
    • CONSULTANT_ROL_NAME

      private static final String CONSULTANT_ROL_NAME
      Consultant rol name constant.
      See Also:
    • COMPANY_ROL_NAME

      private static final String COMPANY_ROL_NAME
      Company rol name constant.
      See Also:
    • VALID_NEW_USER_ROLES

      private static final List<String> VALID_NEW_USER_ROLES
      Advance constant.
    • internalApiClient

      @Autowired private InternalApiClient internalApiClient
      Back office clients manager.
    • userRepository

      @Autowired private UserRepository userRepository
      User repository.
    • rolRepository

      @Autowired private RolRepository rolRepository
      Rol repository.
    • commentRepository

      @Autowired private CommentRepository commentRepository
      Comment repository.
    • auditService

      @Autowired private AuditService auditService
      Backoffice endpoints implementation.
    • requestContextManager

      @Autowired private es.kukenan.smartfi.common.context.RequestContextManager requestContextManager
      Request context manager.
    • smtpMailNotificationHandler

      @Autowired private SmtpMailNotificationHandler smtpMailNotificationHandler
      Component for handle SMTP communication inside backoffice.
    • companyService

      @Autowired private CompanyService companyService
      Company service.
  • Constructor Details

    • UserService

      public UserService()
  • Method Details

    • findClients

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.common.api.dtos.ResultsPageDto<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.BasicUserDto>>> findClients(String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.FilterUserRequestDto filterUserRequestDto, Integer pageNumber, Integer pageSize, String sortedBy, es.kukenan.smartfi.common.security.WalletAuthentication authentication)
      Clients list endpoint.
      Parameters:
      userToken - user token generated.
      filterUserRequestDto - fields to filter.
      pageNumber - the page to search
      pageSize - max number of rows per page
      sortedBy - field to sort
      authentication - user credentials.
      Returns:
      user list.
    • findClient

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.DetailUserDto>> findClient(String userToken, String clientId)
      Find User by Document id endpoint.
      Parameters:
      userToken - user token generated.
      clientId - client identifier.
      Returns:
      user list.
    • findApplications

      public org.springframework.http.ResponseEntity<Object> findApplications(String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.GetApplicationsRequestDto getApplicationsRequestDto, Integer pageNumber, Integer pageSize, String sortedBy, es.kukenan.smartfi.common.security.WalletAuthentication authentication)
      Application list service.
      Parameters:
      userToken - token generated.
      getApplicationsRequestDto - fields to filter.
      pageNumber - the page to search.
      pageSize - max number of rows per page.
      sortedBy - field to sort.
      authentication - user credentials.
      Returns:
      user list.
    • addSponsor

      private es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract addSponsor(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract contract)
      Add Sponsor data to given Contract.
      Parameters:
      contract - contract to update.
      Returns:
      updated contract with sponsor data.
    • validContractResponse

      private es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract> validContractResponse(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract contract)
      Validate if the contract response is not null to add Sponsor.
      Parameters:
      contract - contract from Core.
      Returns:
      ResponseDTO.
    • findApplicationDetail

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> findApplicationDetail(String userToken, String applicationId)
      Application detail service.
      Parameters:
      userToken - token generated.
      applicationId - application identifier.
      Returns:
      user list.
    • saveApplication

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> saveApplication(String backofficeUserId, String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.NewUserAndApplicationRequestDto requestDto, es.kukenan.smartfi.common.security.WalletAuthentication authentication, String userIp, String userAgent)
      Create new application.
      Parameters:
      backofficeUserId - user identifier.
      userToken - user bearer token.
      requestDto - new application data.
      authentication - user credentials.
      userIp - user real ip
      userAgent - user-agent header
      Returns:
      ContractResponseDto.
    • uploadFile

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> uploadFile(String contractDocumentId, String userId, org.springframework.web.multipart.MultipartFile file, String userToken)
      Upload files.
      Parameters:
      contractDocumentId - application identifier.
      userId - user identifier.
      file - file uploaded.
      userToken - user token.
      Returns:
      upload files response.
    • uploadFile

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> uploadFile(String contractId, String userId, List<org.springframework.web.multipart.MultipartFile> files, String userToken)
      Upload specific contract document file.
      Parameters:
      contractId - application identifier.
      userId - user identifier.
      files - files uploaded.
      userToken - user token.
      Returns:
      upload files response.
    • countApplications

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.CountInfoDto>> countApplications(String userToken, es.kukenan.smartfi.common.security.WalletAuthentication authentication)
      Application count.
      Parameters:
      userToken - user credentials.
      authentication - user credentials.
      Returns:
      user list.
    • updateContractStatus

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> updateContractStatus(String userId, String contractId, String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.ContractStatusRequestDto contractStatusRequestDto)
      Update application status.
      Parameters:
      userId - user identifier.
      contractId - application identifier.
      userToken - user token.
      contractStatusRequestDto - list of files received.
      Returns:
      change status response.
    • updateContractDocumentStatus

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> updateContractDocumentStatus(String userId, String userToken, String contractDocumentId, es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.UpdateContractDocumentRequestDto updateContractDocumentRequestDto)
      Update application document status.
      Parameters:
      userId - user identifier.
      userToken - user token.
      contractDocumentId - application document identifier.
      updateContractDocumentRequestDto - update application document data.
      Returns:
      change status response.
    • getContractDocumentFile

      public void getContractDocumentFile(String userId, String userToken, String contractDocumentId, javax.servlet.http.HttpServletResponse response, boolean generate) throws IOException
      Get contract document file.
      Parameters:
      userId - user identifier.
      userToken - user credentials.
      contractDocumentId - contract document identifier.
      response - response.
      generate - flag for download generated contract pdf file.
      Throws:
      IOException - file to write response.
    • uploadContractualFile

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>> uploadContractualFile(String contractId, String userId, org.springframework.web.multipart.MultipartFile file, String userToken, String process)
      Upload contractual files.
      Parameters:
      contractId - application identifier.
      userId - user identifier.
      file - file uploaded.
      userToken - user token.
      process - process to call.
      Returns:
      upload files response.
    • createUser

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<List<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.CompanyUserBackofficeResponse>>> createUser(String userBackofficeId, String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.CreateCompanyBackofficeRequestDto createUserBackofficeRequestDto)
      Create new backoffice consultant or company user.
      Parameters:
      userBackofficeId - user backoffice identifier creating the new user.
      userToken - user authentication token.
      createUserBackofficeRequestDto - request dto.
      Returns:
      creation message.
    • findRoles

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<List<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.requestedfiles.DataObject>>> findRoles()
      Find available roles for create users.
      Returns:
      roles list.
    • findUsers

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.common.api.dtos.ResultsPageDto<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.BasicUserDto>>> findUsers(String userId, String userToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.FilterUserRequestDto filterUserRequestDto, Integer pageNumber, Integer pageSize, String sortedBy, String type)
      Users list endpoint.
      Parameters:
      userId - user identifier.
      userToken - user token generated.
      filterUserRequestDto - fields to filter.
      pageNumber - the page to search
      pageSize - max number of rows per page
      sortedBy - field to sort
      type - Type of user to search
      Returns:
      user list.
    • findUser

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.DetailUserDto>> findUser(String userId, String userToken)
      Find User endpoint.
      Parameters:
      userId - user identifier.
      userToken - user token generated.
      Returns:
      user list.
    • changeApplicationToPayed

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<List<es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Contract>>> changeApplicationToPayed(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.UpdateListOfContractsRequestDto updateListOfContractsRequestDto, String userId, String userJwtToken, String product)
      Change a list of application identifier from PAYMENT_PENDING (credit) or APPROVED_PAYMENT_PENDING_NAME (advance) to PAYED (advance) or ACTIVE (credit).
      Parameters:
      updateListOfContractsRequestDto - contract id list.
      userId - user identifier.
      userJwtToken - user credentials.
      product - application type.
      Returns:
      ok.
    • countClientsUsers

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<Map<String,Long>>> countClientsUsers(String userId, String userToken, es.kukenan.smartfi.common.security.WalletAuthentication authentication)
      Count clients and users service.
      Parameters:
      userId - user identifier.
      userToken - user token generated.
      authentication - user credentials.
      Returns:
      clients and users count list.
    • findClientByDocument

      public org.springframework.http.ResponseEntity<Object> findClientByDocument(String userId, String userToken, es.kukenan.smartfi.dto.backoffice.UserBackofficeRequestDTO userBackofficeRequest)
      Find Client by Document id.
      Parameters:
      userId - core user id.
      userToken - user token generated.
      userBackofficeRequest - client document filter.
      Returns:
      client object.
    • updateClient

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.DetailUserDto>> updateClient(es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.UpdateUserDto updateUserDto, String userToken, String clientId, String userId)
      Update some client data.
      Parameters:
      updateUserDto - update information.
      userToken - user token.
      clientId - client identifier
      userId - user identifier
      Returns:
      user detail.
    • addComments

      private es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.DetailUserDto> addComments(es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.user.DetailUserDto> responseDto)
      Add comments to client detail response.
      Parameters:
      responseDto - Client Detail Response.
      Returns:
      Client detail response updated with comments.