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

@Service public class CompanyService extends Object
Company related services.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final String
    Company rol name constant.
    Back office clients manager.
    private int
    Password length.
    private String
    Key used for generate RSA cipher.
    Rol repository.
    Component for handle SMTP communication inside backoffice.
    User repository.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto
    companyDetail(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Company company)
    Add detail data to company.
    companyUserCreation(es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.CompanyUserBackoffice companyUserBackoffice, Rol rol, User principal, Integer companyId)
    Create user on DB.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto>>
    createUser(String userBackofficeId, String userJwtToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.CompanyUserBackoffice companyUserBackoffice, Integer companyId)
    Create user for company.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto>>
    deleteCompanyUser(String userBackofficeId, String userJwtToken, Integer companyId, String userId)
    Delete User for Company.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.common.api.dtos.ResultsPageDto<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.BasicCompanyDto>>>
    findCompanies(String userBackofficeId, String userJwtToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.FilterUserRequestDto filterUserRequestDto, Integer pageNumber, Integer pageSize, String sortedBy)
    Find Company list service.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto>>
    getCompanyDetail(String userBackofficeId, String userJwtToken, Integer companyId)
    Company detail service.
    getCompanyLogo(String userBackofficeId, String userToken, Integer companyId, javax.servlet.http.HttpServletResponse response)
    Find Company logo.
    private es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto>
    returnDetailCompany(String userBackofficeId, String userJwtToken, Integer companyId)
    Return detailed Company.
    org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto>>
    updateCompany(String userBackofficeId, String userJwtToken, Integer companyId, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto companyDto)
    Company detail service.
    org.springframework.http.ResponseEntity<Object>
    updateCompanyLogo(Integer companyId, String userId, org.springframework.web.multipart.MultipartFile file, String userToken)
    Update company logo.

    Methods inherited from class java.lang.Object

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

    • passwordLength

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

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

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

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

      @Autowired private UserRepository userRepository
      User repository.
    • rolRepository

      @Autowired private RolRepository rolRepository
      Rol repository.
    • smtpMailNotificationHandler

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

    • CompanyService

      public CompanyService()
  • Method Details

    • findCompanies

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.common.api.dtos.ResultsPageDto<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.BasicCompanyDto>>> findCompanies(String userBackofficeId, String userJwtToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.FilterUserRequestDto filterUserRequestDto, Integer pageNumber, Integer pageSize, String sortedBy)
      Find Company list service.
      Parameters:
      userBackofficeId - backoffice user identifier
      userJwtToken - user token
      filterUserRequestDto - fields to filter
      pageNumber - the page to search
      pageSize - max number of rows per page
      sortedBy - field to sort
      Returns:
      company list.
    • getCompanyDetail

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto>> getCompanyDetail(String userBackofficeId, String userJwtToken, Integer companyId)
      Company detail service.
      Parameters:
      userBackofficeId - backoffice user identifier
      userJwtToken - user token
      companyId - company identifier
      Returns:
      company detail.
    • createUser

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto>> createUser(String userBackofficeId, String userJwtToken, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.CompanyUserBackoffice companyUserBackoffice, Integer companyId)
      Create user for company.
      Parameters:
      userBackofficeId - backoffice user identifier
      userJwtToken - user token
      companyUserBackoffice - user information
      companyId - company identifier
      Returns:
      Company User Creation response.
    • returnDetailCompany

      private es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto> returnDetailCompany(String userBackofficeId, String userJwtToken, Integer companyId) throws InterruptedException, ExecutionException
      Return detailed Company.
      Parameters:
      userBackofficeId - user backoffice identifier.
      userJwtToken - user token.
      companyId - company identifier.
      Returns:
      Detail Company Dto
      Throws:
      InterruptedException - Exception if find Company fails.
      ExecutionException - Exception if find Company fails.
    • companyUserCreation

      public User companyUserCreation(es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.CompanyUserBackoffice companyUserBackoffice, Rol rol, User principal, Integer companyId)
      Create user on DB.
      Parameters:
      companyUserBackoffice - request data
      rol - User Rol.
      principal - User Father.
      companyId - Company Identifier.
      Returns:
      Company User Backoffice Response object
    • updateCompany

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto>> updateCompany(String userBackofficeId, String userJwtToken, Integer companyId, es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto companyDto)
      Company detail service.
      Parameters:
      userBackofficeId - backoffice user identifier
      userJwtToken - user token
      companyId - company identifier
      companyDto - company data to update.
      Returns:
      company detail.
    • companyDetail

      private es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto companyDetail(es.kukenan.smartfi.microservice.backoffice.dtos.core.contract.Company company)
      Add detail data to company.
      Parameters:
      company - Company object.
      Returns:
      Detailed company.
    • deleteCompanyUser

      public org.springframework.http.ResponseEntity<es.kukenan.smartfi.dto.ResponseDTO<es.kukenan.smartfi.microservice.backoffice.dtos.backoffice.company.DetailCompanyDto>> deleteCompanyUser(String userBackofficeId, String userJwtToken, Integer companyId, String userId)
      Delete User for Company.
      Parameters:
      userBackofficeId - backoffice user identifier
      userJwtToken - user token
      companyId - company identifier
      userId - user identifier.
      Returns:
      Updated company detail.
    • getCompanyLogo

      public String getCompanyLogo(String userBackofficeId, String userToken, Integer companyId, javax.servlet.http.HttpServletResponse response) throws IOException
      Find Company logo.
      Parameters:
      userBackofficeId - user backoffice identifier.
      userToken - user credentials.
      companyId - company identifier
      response - response.
      Returns:
      Base64 logo image.
      Throws:
      IOException - file to write response.
    • updateCompanyLogo

      public org.springframework.http.ResponseEntity<Object> updateCompanyLogo(Integer companyId, String userId, org.springframework.web.multipart.MultipartFile file, String userToken)
      Update company logo.
      Parameters:
      companyId - company identifier.
      userId - user backoffice identifier.
      file - file received.
      userToken - user token.
      Returns:
      company Object.