-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,495 additions
and
806 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/main/java/com/ai/st/microservice/supplies/business/ManagerBusiness.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.ai.st.microservice.supplies.business; | ||
|
||
import com.ai.st.microservice.supplies.clients.ManagerFeignClient; | ||
import com.ai.st.microservice.supplies.dto.managers.MicroserviceManagerDto; | ||
import com.ai.st.microservice.supplies.dto.managers.MicroserviceManagerProfileDto; | ||
|
||
import feign.FeignException; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.List; | ||
|
||
@Component | ||
public class ManagerBusiness { | ||
|
||
private final Logger log = LoggerFactory.getLogger(ManagerBusiness.class); | ||
|
||
@Autowired | ||
private ManagerFeignClient managerClient; | ||
|
||
public MicroserviceManagerDto getManagerById(Long managerId) { | ||
MicroserviceManagerDto managerDto = null; | ||
try { | ||
managerDto = managerClient.findById(managerId); | ||
} catch (Exception e) { | ||
log.error("No se ha podido consultar el gestor: " + e.getMessage()); | ||
} | ||
return managerDto; | ||
} | ||
|
||
public MicroserviceManagerDto getManagerByUserCode(Long userCode) { | ||
MicroserviceManagerDto managerDto = null; | ||
try { | ||
managerDto = managerClient.findByUserCode(userCode); | ||
} catch (Exception e) { | ||
log.error("No se ha podido consultar el gestor: " + e.getMessage()); | ||
} | ||
return managerDto; | ||
} | ||
|
||
|
||
public boolean userManagerIsDirector(Long userCode) { | ||
|
||
Boolean isDirector = false; | ||
|
||
try { | ||
|
||
List<MicroserviceManagerProfileDto> managerProfiles = managerClient.findProfilesByUser(userCode); | ||
|
||
MicroserviceManagerProfileDto profileDirector = managerProfiles.stream() | ||
.filter(profileDto -> profileDto.getId().equals(RoleBusiness.SUB_ROLE_DIRECTOR)).findAny() | ||
.orElse(null); | ||
|
||
if (profileDirector instanceof MicroserviceManagerProfileDto) { | ||
isDirector = true; | ||
} | ||
|
||
} catch (FeignException e) { | ||
log.error("No se ha podido verificar si el usuario es un director(gestor): " + e.getMessage()); | ||
} | ||
|
||
return isDirector; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/ai/st/microservice/supplies/business/RoleBusiness.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.ai.st.microservice.supplies.business; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class RoleBusiness { | ||
|
||
public static final Long ROLE_ADMINISTRATOR = (long) 1; | ||
public static final Long ROLE_MANAGER = (long) 2; | ||
public static final Long ROLE_OPERATOR = (long) 3; | ||
public static final Long ROLE_SUPPLY_SUPPLIER = (long) 4; | ||
public static final Long ROLE_SUPER_ADMINISTRATOR = (long) 5; | ||
|
||
public static final Long SUB_ROLE_DIRECTOR = (long) 1; | ||
public static final Long SUB_ROLE_INTEGRATOR = (long) 2; | ||
|
||
public static final Long SUB_ROLE_DIRECTOR_PROVIDER = (long) 1; | ||
public static final Long SUB_ROLE_DELEGATE_PROVIDER = (long) 2; | ||
|
||
} |
Oops, something went wrong.