Skip to content

Commit

Permalink
Merge branch 'release/v1.6.8'
Browse files Browse the repository at this point in the history
  • Loading branch information
shiido committed Apr 20, 2021
2 parents e62d255 + 0b6667a commit c83a38c
Show file tree
Hide file tree
Showing 23 changed files with 1,495 additions and 806 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ENV CLOUD_CONFIG=$CLOUD_CONFIG

VOLUME /tmp

ADD ./target/st-microservice-supplies-1.3.7.jar st-microservice-supplies.jar
ADD ./target/st-microservice-supplies-1.6.8.jar st-microservice-supplies.jar

EXPOSE 8080

Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<groupId>com.ai.st.microservice.supplies</groupId>
<artifactId>st-microservice-supplies</artifactId>
<version>1.3.7</version>
<version>1.6.8</version>
<name>st-microservice-supplies</name>
<description>Microservice Supplies</description>

Expand All @@ -39,6 +39,11 @@
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;

@EnableFeignClients
@SpringBootApplication
@EnableEurekaClient
public class StMicroserviceSuppliesApplication {

public static void main(String[] args) {
SpringApplication.run(StMicroserviceSuppliesApplication.class, args);
}
public static void main(String[] args) {
SpringApplication.run(StMicroserviceSuppliesApplication.class, args);
}

}
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;
}

}
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;

}
Loading

0 comments on commit c83a38c

Please sign in to comment.