diff --git a/acquisition/.gitignore b/acquisition/.gitignore deleted file mode 100644 index 4ea51ba3..00000000 --- a/acquisition/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -HELP.md -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ -mvnw -mvnw.cmd - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/acquisition/pom.xml b/acquisition/pom.xml deleted file mode 100644 index f468af6d..00000000 --- a/acquisition/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.4.2 - - - com.example - acquisition - 0.0.1-SNAPSHOT - acquisition - Microserviço de Vendas - - 1.8 - 2020.0.1 - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - org.springframework.boot - spring-boot-starter-amqp - - - - mysql - mysql-connector-java - runtime - - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - org.springframework.boot - spring-boot-starter-test - test - - - io.springfox - springfox-swagger2 - 2.9.2 - - - io.springfox - springfox-swagger2 - 2.9.2 - - - io.springfox - springfox-swagger-ui - 2.9.2 - - - org.projectlombok - lombok - - - org.modelmapper - modelmapper - 2.3.5 - compile - - - org.modelmapper - modelmapper - 2.3.5 - compile - - - org.projectlombok - lombok - - - org.projectlombok - lombok - - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/acquisition/src/main/java/com/example/acquisition/AcquisitionApplication.java b/acquisition/src/main/java/com/example/acquisition/AcquisitionApplication.java deleted file mode 100644 index b14514aa..00000000 --- a/acquisition/src/main/java/com/example/acquisition/AcquisitionApplication.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.example.acquisition; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@SpringBootApplication -@EnableSwagger2 -public class AcquisitionApplication { - - public static void main(String[] args) { - SpringApplication.run(AcquisitionApplication.class, args); - } - -} diff --git a/acquisition/src/main/java/com/example/acquisition/config/AppConf.java b/acquisition/src/main/java/com/example/acquisition/config/AppConf.java deleted file mode 100644 index fbd133b6..00000000 --- a/acquisition/src/main/java/com/example/acquisition/config/AppConf.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.example.acquisition.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -@Configuration -public class AppConf implements WebMvcConfigurer { - - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") - .allowedOrigins("http://localhost:3000") - .allowedMethods("PUT", "GET", "POST", "DELETE"); - } -} diff --git a/acquisition/src/main/java/com/example/acquisition/config/MessageConfig.java b/acquisition/src/main/java/com/example/acquisition/config/MessageConfig.java deleted file mode 100644 index 682dcff3..00000000 --- a/acquisition/src/main/java/com/example/acquisition/config/MessageConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.example.acquisition.config; - -import org.springframework.amqp.core.Exchange; -import org.springframework.amqp.core.ExchangeBuilder; -import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; -import org.springframework.amqp.support.converter.MessageConverter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class MessageConfig { - - @Value("${crud.rabbitmq.exchange}") - String exchange; - - @Bean - public Exchange declareExchange() { - return ExchangeBuilder.directExchange(exchange).durable(true).build(); - } - - @Bean - public MessageConverter jsonMessageConverter() { - return new Jackson2JsonMessageConverter(); - } - -} diff --git a/acquisition/src/main/java/com/example/acquisition/controller/AcquisitionController.java b/acquisition/src/main/java/com/example/acquisition/controller/AcquisitionController.java deleted file mode 100644 index 8ce67e30..00000000 --- a/acquisition/src/main/java/com/example/acquisition/controller/AcquisitionController.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.example.acquisition.controller; - -import com.example.acquisition.enums.Status; -import com.example.acquisition.service.ValidaCpfServiceImp; -import com.example.acquisition.service.ValidaRendaServiceImp; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import io.swagger.annotations.ApiOperation; -import java.time.LocalDate; -import java.util.List; -import com.example.acquisition.model.Acquisition; -import com.example.acquisition.model.Property; -import com.example.acquisition.model.User; -import com.example.acquisition.interfaces.services.IAcquisitionService; -import com.example.acquisition.interfaces.services.IPropertyService; -import com.example.acquisition.interfaces.services.IUserService; - -@RestController -@RequestMapping("/acquisition") -public class AcquisitionController { - - ValidaRendaServiceImp vrenda; - private IAcquisitionService acquisitionService; - private IPropertyService propertyService; - private IUserService userService; - - public AcquisitionController(IAcquisitionService service, IPropertyService propertyService, IUserService userService) { - this.acquisitionService = service; - this.propertyService = propertyService; - this.userService = userService; - } - - @PostMapping("/save") - @ApiOperation(value = "Salva uma compra") - public ResponseEntity saveAcquisition(Long idProperty, Long idUser) { - Property property = propertyService.findPropertyById(idProperty); - User user = userService.findUserById(idUser); - Acquisition acquisition = null; - - userService.validateUser(user, property); - - acquisition = Acquisition.builder() - .data(LocalDate.now()) - .property(property) - .user(user) - .value(property.getPrice()) - .build(); - - acquisitionService.save(acquisition); - property.setStatus(Status.SOLD); - propertyService.updateProperty(property); - return ResponseEntity.status(HttpStatus.CREATED).body(acquisition); - } - - @GetMapping("/user/find/{id}") - @ApiOperation(value = "Encontra acquisitions através do id de um usuário") - public ResponseEntity getAcquisitionsByUserId(@PathVariable("id") Long id) { - User user = userService.findUserById(id); - List acquisitions = acquisitionService.findAllAcquisitionsByUser(user); - return new ResponseEntity<>(acquisitions, HttpStatus.OK); - } - - @GetMapping("/property/find/{id}") - @ApiOperation(value = "Encontra acquisitions através do id de um imóvel") - public ResponseEntity getAcquisitionsByPropertyId(@PathVariable("id") Long id) { - Property property = propertyService.findPropertyById(id); - Acquisition acquisition = acquisitionService.findAcquisitionByProperty(property); - return new ResponseEntity<>(acquisition, HttpStatus.OK); - } - -} diff --git a/acquisition/src/main/java/com/example/acquisition/dto/AcquisitionDTO.java b/acquisition/src/main/java/com/example/acquisition/dto/AcquisitionDTO.java deleted file mode 100644 index af63fbfc..00000000 --- a/acquisition/src/main/java/com/example/acquisition/dto/AcquisitionDTO.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.example.acquisition.dto; - - -import java.util.Date; - -public class AcquisitionDTO { - - private Long id; - private Date data; - private Double value; - private Long idProperty; - private Long idUser; - - public AcquisitionDTO() { - } - public AcquisitionDTO(Long id, Date data, Double value, Long idProperty, Long idUser) { - this.id = id; - this.data = data; - this.value = value; - this.idProperty = idProperty; - this.idUser = idUser; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Date getData() { - return data; - } - - public void setData(Date data) { - this.data = data; - } - - public Long getIdProperty() { - return idProperty; - } - - public void setIdProperty(Long idProperty) { - this.idProperty = idProperty; - } - - public Long getIdUser() { - return idUser; - } - - public void setIdUser(Long idUser) { - this.idUser = idUser; - } - - public Double getValue() { - return value; - } - - public void setValue(Double value) { - this.value = value; - } - -} diff --git a/acquisition/src/main/java/com/example/acquisition/enums/Status.java b/acquisition/src/main/java/com/example/acquisition/enums/Status.java deleted file mode 100644 index 4461461f..00000000 --- a/acquisition/src/main/java/com/example/acquisition/enums/Status.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.example.acquisition.enums; - -public enum Status { - SOLD, - AVAILABLE -} diff --git a/acquisition/src/main/java/com/example/acquisition/exceptions/ValidacaoException.java b/acquisition/src/main/java/com/example/acquisition/exceptions/ValidacaoException.java deleted file mode 100644 index 8b312734..00000000 --- a/acquisition/src/main/java/com/example/acquisition/exceptions/ValidacaoException.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.acquisition.exceptions; - -public class ValidacaoException extends RuntimeException { - - public ValidacaoException(String message){ - super(message); - } -} diff --git a/acquisition/src/main/java/com/example/acquisition/interfaces/services/IAcquisitionService.java b/acquisition/src/main/java/com/example/acquisition/interfaces/services/IAcquisitionService.java deleted file mode 100644 index ecbfbfb3..00000000 --- a/acquisition/src/main/java/com/example/acquisition/interfaces/services/IAcquisitionService.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.acquisition.interfaces.services; - -import java.util.List; -import com.example.acquisition.model.Acquisition; -import com.example.acquisition.model.Property; -import com.example.acquisition.model.User; - -public interface IAcquisitionService{ - void save(Acquisition acquisition); - List findAllAcquisitionsByUser(User user); - Acquisition findAcquisitionByProperty(Property property); - Acquisition findAcquisitionById(Long id); - - /*Boolean validarCpf(User user); - Boolean validaRenda(User user, Property property); - Double calculaParteDoLucroPraImobiliaria(AcquisitionDTO acquisiton); - Double calcularValorIPTU(AcquisitionDTO acquisition);*/ - //void calculaSeguro(Acquisition acquisition); - - //void calculaSeguro(Acquisition acquisition); - //void validaRenda(User user); - //Boolean possuiFiador(User user); - - -} diff --git a/acquisition/src/main/java/com/example/acquisition/interfaces/services/IPropertyService.java b/acquisition/src/main/java/com/example/acquisition/interfaces/services/IPropertyService.java deleted file mode 100644 index 815e4bca..00000000 --- a/acquisition/src/main/java/com/example/acquisition/interfaces/services/IPropertyService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.example.acquisition.interfaces.services; - -import com.example.acquisition.model.Property; - -public interface IPropertyService{ - Property findPropertyById(Long id); - Double calculaParcela(Property property); - void updateProperty(Property property); -} diff --git a/acquisition/src/main/java/com/example/acquisition/interfaces/services/IUserService.java b/acquisition/src/main/java/com/example/acquisition/interfaces/services/IUserService.java deleted file mode 100644 index de1d48fa..00000000 --- a/acquisition/src/main/java/com/example/acquisition/interfaces/services/IUserService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.acquisition.interfaces.services; - -import com.example.acquisition.model.Property; -import com.example.acquisition.model.User; - -public interface IUserService{ - - User findUserById(Long id); - - void validateUser(User user, Property property); -} diff --git a/acquisition/src/main/java/com/example/acquisition/interfaces/services/IValidacaoService.java b/acquisition/src/main/java/com/example/acquisition/interfaces/services/IValidacaoService.java deleted file mode 100644 index 346f5d68..00000000 --- a/acquisition/src/main/java/com/example/acquisition/interfaces/services/IValidacaoService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.acquisition.interfaces.services; - -import com.example.acquisition.model.Property; -import com.example.acquisition.model.User; - -import java.util.Collection; - -public interface IValidacaoService { - - void validate(User user, Property property); -} diff --git a/acquisition/src/main/java/com/example/acquisition/model/Acquisition.java b/acquisition/src/main/java/com/example/acquisition/model/Acquisition.java deleted file mode 100644 index 22d5d8a4..00000000 --- a/acquisition/src/main/java/com/example/acquisition/model/Acquisition.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.example.acquisition.model; - -import java.io.Serializable; -import java.time.LocalDate; - -import lombok.Builder; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToOne; -import javax.persistence.JoinColumn; -import javax.persistence.FetchType; - -import org.springframework.format.annotation.DateTimeFormat; - -@Entity -@Builder -public class Acquisition implements Serializable{ - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @DateTimeFormat(pattern = "MM/dd/yyy") - @Column(name = "data", nullable = false) - private LocalDate data; - - @Column(name = "value", nullable = false) - private Double value; - - @OneToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "id_property") - private Property property; - - @OneToOne(fetch = FetchType.EAGER) - @JoinColumn(name = "id_user") - private User user; - - public Acquisition() { - } - - public Acquisition(Long id, LocalDate data, Double value,Property property,User user) { - this.id = id; - this.data = data; - this.value = value; - this.property = property; - this.user = user; - } - - public Long getId() { - return id; - } - - public LocalDate getData() { - return data; - } - - public void setData(LocalDate localDate) { - this.data = localDate; - } - - public Property getProperty() { - return property; - } - - public void setProperty(Property property) { - this.property = property; - } - - public User getUser() { - return user; - } - - public void setUser(User user) { - this.user = user; - } - - public Double getValue() { - return value; - } - - public void setValue(Double value) { - this.value = value; - } -} diff --git a/acquisition/src/main/java/com/example/acquisition/model/Property.java b/acquisition/src/main/java/com/example/acquisition/model/Property.java deleted file mode 100644 index d342ab4e..00000000 --- a/acquisition/src/main/java/com/example/acquisition/model/Property.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.example.acquisition.model; - - -import com.example.acquisition.enums.Status; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; - -import javax.persistence.*; - -@Entity -@SuperBuilder -public class Property { - - @Id - private Long id; - - @Column(name = "price") - private double price; - - @Column(name = "status") - @Enumerated(EnumType.STRING) - private Status status; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public double getPrice() { - return price; - } - - public void setPrice(double price) { - this.price = price; - } - - public Status getStatus() { return status; } - - public void setStatus(Status status) { this.status = status; } -} diff --git a/acquisition/src/main/java/com/example/acquisition/model/User.java b/acquisition/src/main/java/com/example/acquisition/model/User.java deleted file mode 100644 index f60b660f..00000000 --- a/acquisition/src/main/java/com/example/acquisition/model/User.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.example.acquisition.model; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import lombok.AllArgsConstructor; -import lombok.Builder; - -@Entity -@Builder -@AllArgsConstructor -public class User { - - @Id - private Long id; - - @Column(name = "name") - private String name; - - @Column(name = "cpf") - private String cpf; - - @Column(name = "renda") - private Double renda; - - public Double getRenda() { - return renda; - } - - public void setRenda(Double renda) { - this.renda = renda; - } - - public User(String name) { - this.name = name; - } - - public User() { - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCpf() { - return cpf; - } - - public void setCpf(String cpf) { - this.cpf = cpf; - } -} diff --git a/acquisition/src/main/java/com/example/acquisition/receiver/PropertyReceiver.java b/acquisition/src/main/java/com/example/acquisition/receiver/PropertyReceiver.java deleted file mode 100644 index 49417abd..00000000 --- a/acquisition/src/main/java/com/example/acquisition/receiver/PropertyReceiver.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.example.acquisition.receiver; - - -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.messaging.handler.annotation.Payload; -import org.springframework.stereotype.Component; - -import com.example.acquisition.model.Property; -import com.example.acquisition.repository.PropertyRepository; - - - - -@Component -public class PropertyReceiver { - - private PropertyRepository propertyRepository; - - - @Autowired - public PropertyReceiver(PropertyRepository propertyRepository) { - this.propertyRepository = propertyRepository; - } - - @RabbitListener(queues = {"${crud.rabbitmq.queueProperty}"}) - public void receive(@Payload Property property) { - propertyRepository.save(property); - } -} diff --git a/acquisition/src/main/java/com/example/acquisition/receiver/UserReceiver.java b/acquisition/src/main/java/com/example/acquisition/receiver/UserReceiver.java deleted file mode 100644 index 6cc5eeed..00000000 --- a/acquisition/src/main/java/com/example/acquisition/receiver/UserReceiver.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.example.acquisition.receiver; - - -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.messaging.handler.annotation.Payload; -import org.springframework.stereotype.Component; - -import com.example.acquisition.model.User; -import com.example.acquisition.repository.UserRepository; - - -@Component -public class UserReceiver { - - private UserRepository userRepository; - - @Autowired - public UserReceiver(UserRepository userRepository) { - this.userRepository = userRepository; - } - - @RabbitListener(queues = {"${crud.rabbitmq.queueUser}"}) - public void receive(@Payload User user) { - userRepository.save(user); - } - -} diff --git a/acquisition/src/main/java/com/example/acquisition/repository/AcquisitionRepository.java b/acquisition/src/main/java/com/example/acquisition/repository/AcquisitionRepository.java deleted file mode 100644 index 365a4924..00000000 --- a/acquisition/src/main/java/com/example/acquisition/repository/AcquisitionRepository.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.example.acquisition.repository; - -import lombok.NoArgsConstructor; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; - -import com.example.acquisition.model.Acquisition; -import com.example.acquisition.model.Property; -import com.example.acquisition.model.User; - -@Repository -public interface AcquisitionRepository extends JpaRepository { - - List findAllAcquisitionsByUser(User user); - - Acquisition findAcquisitionByProperty(Property property); - - Acquisition findAcquisitionById(Long id); - -} \ No newline at end of file diff --git a/acquisition/src/main/java/com/example/acquisition/repository/PropertyRepository.java b/acquisition/src/main/java/com/example/acquisition/repository/PropertyRepository.java deleted file mode 100644 index 11c04e58..00000000 --- a/acquisition/src/main/java/com/example/acquisition/repository/PropertyRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.acquisition.repository; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import com.example.acquisition.model.Property; - -@Repository -public interface PropertyRepository extends JpaRepository { - Property findPropertyById(Long id); -} diff --git a/acquisition/src/main/java/com/example/acquisition/repository/UserRepository.java b/acquisition/src/main/java/com/example/acquisition/repository/UserRepository.java deleted file mode 100644 index b570a01f..00000000 --- a/acquisition/src/main/java/com/example/acquisition/repository/UserRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.acquisition.repository; - - -import org.springframework.data.jpa.repository.JpaRepository; - -import com.example.acquisition.model.User; - - -public interface UserRepository extends JpaRepository { - User findUserById(Long id); -} diff --git a/acquisition/src/main/java/com/example/acquisition/service/ValidaCpfServiceImp.java b/acquisition/src/main/java/com/example/acquisition/service/ValidaCpfServiceImp.java deleted file mode 100644 index ceaec84b..00000000 --- a/acquisition/src/main/java/com/example/acquisition/service/ValidaCpfServiceImp.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.example.acquisition.service; - -import java.util.InputMismatchException; -import com.example.acquisition.exceptions.ValidacaoException; -import com.example.acquisition.interfaces.services.IValidacaoService; -import com.example.acquisition.model.Property; -import com.example.acquisition.model.User; - -public class ValidaCpfServiceImp implements IValidacaoService { - - public static boolean isCPF(String CPF) { - CPF = CPF.replaceAll("\\.", "").replaceAll("\\/","").replaceAll("\\-",""); - - if (CPF.equals("00000000000") || - CPF.equals("11111111111") || - CPF.equals("22222222222") || CPF.equals("33333333333") || - CPF.equals("44444444444") || CPF.equals("55555555555") || - CPF.equals("66666666666") || CPF.equals("77777777777") || - CPF.equals("88888888888") || CPF.equals("99999999999") || - (CPF.length() != 11)) - return(false); - char dig10, dig11; - int sm, i, r, num, peso; - - try { - sm = 0; - peso = 10; - for (i=0; i<9; i++) { - num = (int)(CPF.charAt(i) - 48); - sm = sm + (num * peso); - peso = peso - 1; - } - r = 11 - (sm % 11); - if ((r == 10) || (r == 11)) - dig10 = '0'; - else dig10 = (char)(r + 48); // converte no respectivo caractere numerico - - sm = 0; - peso = 11; - for(i=0; i<10; i++) { - num = (int)(CPF.charAt(i) - 48); - sm = sm + (num * peso); - peso = peso - 1; - } - - r = 11 - (sm % 11); - if ((r == 10) || (r == 11)) - dig11 = '0'; - else dig11 = (char)(r + 48); - - // Verifica se os digitos calculados conferem com os digitos informados. - if ((dig10 == CPF.charAt(9)) && (dig11 == CPF.charAt(10))) - return(true); - else return(false); - } catch (InputMismatchException erro) { - return(false); - } - } - - @Override - public void validate(User user, Property property) throws ValidacaoException { - if(isCPF(user.getCpf()) != true) { - throw new ValidacaoException("Seu CPF é inválido!"); - } - } - -} diff --git a/acquisition/src/main/java/com/example/acquisition/service/ValidaRendaServiceImp.java b/acquisition/src/main/java/com/example/acquisition/service/ValidaRendaServiceImp.java deleted file mode 100644 index 45ced4df..00000000 --- a/acquisition/src/main/java/com/example/acquisition/service/ValidaRendaServiceImp.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.example.acquisition.service; - -import com.example.acquisition.exceptions.ValidacaoException; -import com.example.acquisition.interfaces.services.IPropertyService; -import com.example.acquisition.interfaces.services.IValidacaoService; -import com.example.acquisition.model.Property; -import com.example.acquisition.model.User; - -public class ValidaRendaServiceImp implements IValidacaoService { - - private IPropertyService propertyService; - - @Override - public void validate(User user, Property property) throws ValidacaoException { //tem mais coisas pra levar em conta, mais pra frente REVER!!! - if(user.getRenda() * 0.3 < propertyService.calculaParcela(property)){ - throw new ValidacaoException("Sua renda mensal é insuficiente para a compra!"); - } - } -} diff --git a/acquisition/src/main/java/com/example/acquisition/service/ValidaStatusServiceImp.java b/acquisition/src/main/java/com/example/acquisition/service/ValidaStatusServiceImp.java deleted file mode 100644 index d7bfd221..00000000 --- a/acquisition/src/main/java/com/example/acquisition/service/ValidaStatusServiceImp.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.example.acquisition.service; - -import com.example.acquisition.enums.Status; -import com.example.acquisition.exceptions.ValidacaoException; -import com.example.acquisition.interfaces.services.IPropertyService; -import com.example.acquisition.interfaces.services.IValidacaoService; -import com.example.acquisition.model.Property; -import com.example.acquisition.model.User; - -public class ValidaStatusServiceImp implements IValidacaoService { - - private IPropertyService propertyService; - - @Override - public void validate(User user, Property property) throws ValidacaoException { - if(!property.getStatus().equals(Status.AVAILABLE)) { - throw new ValidacaoException("Essa casa não esta disponível, ja foi vendida!"); - } - } -} diff --git a/acquisition/src/main/java/com/example/acquisition/service/impl/AcquisitionServiceImp.java b/acquisition/src/main/java/com/example/acquisition/service/impl/AcquisitionServiceImp.java deleted file mode 100644 index d4d6b710..00000000 --- a/acquisition/src/main/java/com/example/acquisition/service/impl/AcquisitionServiceImp.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.example.acquisition.service.impl; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import java.util.List; - -import com.example.acquisition.model.Acquisition; -import com.example.acquisition.model.Property; -import com.example.acquisition.model.User; -import com.example.acquisition.repository.AcquisitionRepository; -import com.example.acquisition.interfaces.services.IAcquisitionService; - -@Service -public class AcquisitionServiceImp implements IAcquisitionService{ - - private AcquisitionRepository acquisitionRepository; - - @Autowired - public AcquisitionServiceImp(AcquisitionRepository repository) { - this.acquisitionRepository = repository; - } - - @Override - public void save(Acquisition acquisition) { - acquisitionRepository.save(acquisition); - } - - @Override - public List findAllAcquisitionsByUser(User user) { - return acquisitionRepository.findAllAcquisitionsByUser(user); - } - - @Override - public Acquisition findAcquisitionByProperty(Property property) { - return acquisitionRepository.findAcquisitionByProperty(property); - } - - @Override - public Acquisition findAcquisitionById(Long id) { - return acquisitionRepository.findAcquisitionById(id); - } -} diff --git a/acquisition/src/main/java/com/example/acquisition/service/impl/PropertyServiceImp.java b/acquisition/src/main/java/com/example/acquisition/service/impl/PropertyServiceImp.java deleted file mode 100644 index f62468c5..00000000 --- a/acquisition/src/main/java/com/example/acquisition/service/impl/PropertyServiceImp.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.example.acquisition.service.impl; - - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.example.acquisition.model.Property; -import com.example.acquisition.repository.PropertyRepository; -import com.example.acquisition.interfaces.services.IPropertyService; - -@Service -public class PropertyServiceImp implements IPropertyService{ - - private PropertyRepository propertyRepository; - private final double PERCENTUAL = 0.3; - - @Autowired - public PropertyServiceImp(PropertyRepository repository) { - this.propertyRepository = repository; - } - - @Override - public Property findPropertyById(Long id) { - return propertyRepository.findPropertyById(id); - } - - @Override - public Double calculaParcela(Property property){ - double parcela = property.getPrice() * PERCENTUAL; - return parcela; - } - - @Override - public void updateProperty(Property property) { - propertyRepository.save(property); - } -} diff --git a/acquisition/src/main/java/com/example/acquisition/service/impl/UserServiceImp.java b/acquisition/src/main/java/com/example/acquisition/service/impl/UserServiceImp.java deleted file mode 100644 index 5873c7da..00000000 --- a/acquisition/src/main/java/com/example/acquisition/service/impl/UserServiceImp.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.example.acquisition.service.impl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import com.example.acquisition.exceptions.ValidacaoException; -import com.example.acquisition.service.ValidaCpfServiceImp; -import com.example.acquisition.service.ValidaRendaServiceImp; -import com.example.acquisition.service.ValidaStatusServiceImp; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Repository; -import org.springframework.stereotype.Service; -import com.example.acquisition.model.Property; -import com.example.acquisition.model.User; -import com.example.acquisition.repository.UserRepository; -import com.example.acquisition.interfaces.services.IUserService; -import com.example.acquisition.interfaces.services.IValidacaoService; - -@Service -public class UserServiceImp implements IUserService{ - List validations = Arrays.asList( - new ValidaCpfServiceImp(), - new ValidaStatusServiceImp() - ); - @Autowired - private UserRepository userRepository; - - @Autowired - public UserServiceImp(UserRepository repository) { - this.userRepository = repository; - } - - @Override - public User findUserById(Long id) { - return userRepository.findUserById(id); - } - - public void validateUser(User user, Property property) throws ValidacaoException { - validations.forEach(element->element.validate(user, property)); - } - -} diff --git a/acquisition/src/main/resources/application.yml b/acquisition/src/main/resources/application.yml deleted file mode 100644 index 31919347..00000000 --- a/acquisition/src/main/resources/application.yml +++ /dev/null @@ -1,41 +0,0 @@ -server: - port: 8084 - servlet: - context-path: /acquisitionService - -spring: - application: - name: acquisitionService - jpa: - show-sql: false - hibernate: - ddl-auto: update - properties: - hibernate: - dialect: org.hibernate.dialect.MySQL8Dialect - jmx: - enabled: false - datasource: - url: jdbc:mysql://localhost:3306/aquisition?useTimezone=true&serverTimezone=UTC - username: root - password: admin - - rabbitmq: - host: localhost - port: 5672 - username: guest - password: guest - -crud: - rabbitmq: - exchange: crud.exchange - queueProperty: crud.acquisition.property - queueUser: crud.acquisition.user - -eureka: - instance: - hostname: localhost - client: - serviceUrl: - defaultZone: http://localhost:8087/discovery/eureka - diff --git a/acquisition/src/test/java/com/example/acquisition/repository/AcquisitionRepositoryTest.java b/acquisition/src/test/java/com/example/acquisition/repository/AcquisitionRepositoryTest.java deleted file mode 100644 index 215df714..00000000 --- a/acquisition/src/test/java/com/example/acquisition/repository/AcquisitionRepositoryTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.example.acquisition.repository; - -import com.example.acquisition.model.Acquisition; -import com.example.acquisition.util.AcquisitionCreator; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Optional; - -class AcquisitionRepositoryTest { - - @Autowired - private AcquisitionRepository acquisitionRepository; - - @Test - void saveAcquisition(){ - Acquisition acquisitionToBeSaved = AcquisitionCreator.createAcquisitionToSaved(); - Acquisition acquisitionSaved = acquisitionRepository.save(acquisitionToBeSaved); - - Assertions.assertThat(acquisitionSaved).isNotNull(); - Assertions.assertThat(acquisitionSaved.getId()).isNotNull(); - - } - - @Test - @DisplayName("Save updates acquisition when Successful") - void save_AcquisitionUser_WhenSuccessful(){ - Acquisition acquisitionToBeSaved = AcquisitionCreator.createAcquisitionToSaved(); - Acquisition acquisitionSaved = this.acquisitionRepository.save(acquisitionToBeSaved); - - Acquisition acquisitionUpdated = this.acquisitionRepository.save(acquisitionSaved); - Assertions.assertThat(acquisitionSaved).isNotNull(); - Assertions.assertThat(acquisitionSaved.getId()).isNotNull(); - Assertions.assertThat(acquisitionUpdated.getId()).isEqualTo(acquisitionToBeSaved.getId()); - } - - @Test - @DisplayName("Deletes removes acquisition when Successful") - void delete_RemovesAcquisition_WhenSuccessful(){ - Acquisition acquisitionToBeSaved = AcquisitionCreator.createAcquisitionToSaved(); - Acquisition acquisitionSaved = this.acquisitionRepository.save(acquisitionToBeSaved); - - this.acquisitionRepository.delete(acquisitionSaved); - Optional userOptional = this.acquisitionRepository.findById(acquisitionSaved.getId()); - Assertions.assertThat(userOptional).isEmpty(); - - } - - @Test - @DisplayName("Find by acquisition when Successful") - void find_ByAcquisition_WhenSuccessful(){ - Acquisition acquisitionToBeSaved = AcquisitionCreator.createAcquisitionToSaved(); - Acquisition acquisitionSaved = this.acquisitionRepository.save(acquisitionToBeSaved); - Acquisition acquisitionFind = this.acquisitionRepository.findAcquisitionById(acquisitionSaved.getId()); - - Assertions.assertThat(acquisitionFind).isNotNull(); - Assertions.assertThat(acquisitionFind.getId()).isNotNull(); - - } - -} \ No newline at end of file diff --git a/acquisition/src/test/java/com/example/acquisition/service/impl/AcquisitionServiceImpTest.java b/acquisition/src/test/java/com/example/acquisition/service/impl/AcquisitionServiceImpTest.java deleted file mode 100644 index e0bfdff6..00000000 --- a/acquisition/src/test/java/com/example/acquisition/service/impl/AcquisitionServiceImpTest.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.example.acquisition.service.impl; - -import com.example.acquisition.model.Acquisition; -import com.example.acquisition.repository.AcquisitionRepository; -import com.example.acquisition.repository.UserRepository; -import com.example.acquisition.util.AcquisitionCreator; -import com.example.acquisition.util.AcquisitionPut; -import com.netflix.discovery.converters.Auto; -import lombok.extern.slf4j.Slf4j; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.ArgumentMatchers; -import org.mockito.BDDMockito; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.util.Arrays; - -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(SpringExtension.class) -@Slf4j -class AcquisitionServiceImpTest { - - @InjectMocks - private AcquisitionServiceImp acquisitionServiceImp; - @Mock - private AcquisitionRepository acquisitionRepository; - - @BeforeEach - void setUp(){ - BDDMockito.when(acquisitionRepository.save(ArgumentMatchers.any(Acquisition.class))) - .thenReturn(AcquisitionCreator.createValidUpdateAcquisition()); - - BDDMockito.doNothing().when(acquisitionRepository).delete(ArgumentMatchers.any(Acquisition.class)); - } - - - @Test - @DisplayName("Save acquisition when successful") - void save() { - - Assertions.assertThatCode(() -> acquisitionServiceImp.save(AcquisitionPut.createAcquisitionPutRequestBody())) - .doesNotThrowAnyException(); - } - - @Test - void findAcquisitionByProperty() { - acquisitionRepository.save(AcquisitionCreator.createValidAcquisition()); - Long expectedId = AcquisitionCreator.createValidAcquisition().getId(); - - Acquisition acquisition = acquisitionServiceImp.findAcquisitionById(AcquisitionCreator.createValidAcquisition().getId()); - Assertions.assertThat(acquisition) - .isNotNull(); - Assertions.assertThat(acquisition.getId()).isNotNull().isEqualTo(expectedId); - } -} \ No newline at end of file diff --git a/acquisition/src/test/java/com/example/acquisition/util/AcquisitionCreator.java b/acquisition/src/test/java/com/example/acquisition/util/AcquisitionCreator.java deleted file mode 100644 index 5834c001..00000000 --- a/acquisition/src/test/java/com/example/acquisition/util/AcquisitionCreator.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.example.acquisition.util; - -import com.example.acquisition.model.Acquisition; -import org.springframework.beans.factory.annotation.Autowired; - -public class AcquisitionCreator { - - public static Acquisition createAcquisitionToSaved() { - return Acquisition.builder() - .value(1123.0) - .user(null) - .property(PropertyCreator.createPropertyToSaved()) - .build(); - } - - public static Acquisition createValidAcquisition() { - return Acquisition.builder() - .value(1111.0) - .user(UserCreator.createUserToSaved()) - .property(PropertyCreator.createPropertyToTest1()) - .build(); - } - - public static Acquisition createValidUpdateAcquisition() { - return Acquisition.builder() - .value(1121.0) - .user(null) - .property(null) - .build(); - } - -} diff --git a/acquisition/src/test/java/com/example/acquisition/util/AcquisitionPut.java b/acquisition/src/test/java/com/example/acquisition/util/AcquisitionPut.java deleted file mode 100644 index 6adeb32e..00000000 --- a/acquisition/src/test/java/com/example/acquisition/util/AcquisitionPut.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.example.acquisition.util; - -import com.example.acquisition.model.Acquisition; - -public class AcquisitionPut { - public static Acquisition createAcquisitionPutRequestBody() { - return Acquisition.builder() - .id(AcquisitionCreator.createValidUpdateAcquisition().getId()) - .property(AcquisitionCreator.createValidUpdateAcquisition().getProperty()) - .build(); - } -} diff --git a/acquisition/src/test/java/com/example/acquisition/util/PropertyCreator.java b/acquisition/src/test/java/com/example/acquisition/util/PropertyCreator.java deleted file mode 100644 index 147c029c..00000000 --- a/acquisition/src/test/java/com/example/acquisition/util/PropertyCreator.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.example.acquisition.util; - -import com.example.acquisition.model.Property; - -public class PropertyCreator { - public static Property createPropertyToSaved() { - return Property.builder() - .id(133L) - .price(133.0) - .build(); - } - - public static Property createPropertyToTest1() { - return Property.builder() - .id(134L) - .price(133.0) - .build(); - } - - public static Property createPropertyToTest2() { - return Property.builder() - .id(135L) - .price(133.0) - .build(); - } -} diff --git a/acquisition/src/test/java/com/example/acquisition/util/UserCreator.java b/acquisition/src/test/java/com/example/acquisition/util/UserCreator.java deleted file mode 100644 index 1171bf9a..00000000 --- a/acquisition/src/test/java/com/example/acquisition/util/UserCreator.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.example.acquisition.util; - -import com.example.acquisition.model.User; - -public class UserCreator { - public static User createUserToSaved() { - return User.builder() - .name("João") - .renda(12321.0) - .cpf(String.valueOf(12312414)) - .id(13L) - .build(); - } -} diff --git a/auth/.gitignore b/auth/.gitignore deleted file mode 100644 index babf039f..00000000 --- a/auth/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -HELP.md -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -mvnw.cmd -mvnw -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/auth/pom.xml b/auth/pom.xml deleted file mode 100644 index 2021de13..00000000 --- a/auth/pom.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - 4.0.0 - - com.example - auth - 0.0.1-SNAPSHOT - Microserviço de Autenticação - - auth - - - 1.8 - com.example.auth.AuthApplication - 2020.0.1 - - - - org.springframework.boot - spring-boot-starter-parent - 2.4.2 - - - - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - org.springframework.boot - spring-boot-starter-security - - - - org.springframework.boot - spring-boot-devtools - true - - - - org.springframework.security - spring-security-test - test - - - - mysql - mysql-connector-java - - - - io.jsonwebtoken - jjwt - 0.9.1 - - - - io.springfox - springfox-swagger2 - 2.9.2 - - - - io.springfox - springfox-swagger-ui - 2.9.2 - - - - org.modelmapper - modelmapper - 2.3.5 - - - - org.springframework.boot - spring-boot-starter-amqp - - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/auth/src/main/java/com/example/auth/AuthApplication.java b/auth/src/main/java/com/example/auth/AuthApplication.java deleted file mode 100644 index 2eb56030..00000000 --- a/auth/src/main/java/com/example/auth/AuthApplication.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.example.auth; - -import org.modelmapper.ModelMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.client.discovery.EnableDiscoveryClient; -import org.springframework.context.annotation.Bean; - -import java.util.ArrayList; -import java.util.Arrays; - -import com.example.auth.model.Role; -import com.example.auth.model.User; -import com.example.auth.service.UserService; - -@SpringBootApplication -@EnableDiscoveryClient -public class AuthApplication implements CommandLineRunner { - - @Autowired - UserService userService; - - public static void main(String[] args) { - SpringApplication.run(AuthApplication.class, args); - } - - @Bean - public ModelMapper modelMapper() { - return new ModelMapper(); - } - - @Override - public void run(String... params) throws Exception { - User admin = new User(); - admin.setUsername("admin"); - admin.setPassword("admin"); - admin.setEmail("admin@email.com"); - admin.setRoles(new ArrayList(Arrays.asList(Role.ROLE_ADMIN))); - - userService.signup(admin); - - User client = new User(); - client.setUsername("client"); - client.setPassword("client"); - client.setEmail("client@email.com"); - client.setRoles(new ArrayList(Arrays.asList(Role.ROLE_CLIENT))); - - userService.signup(client); - } - -} diff --git a/auth/src/main/java/com/example/auth/configuration/AppConf.java b/auth/src/main/java/com/example/auth/configuration/AppConf.java deleted file mode 100644 index 02c2b492..00000000 --- a/auth/src/main/java/com/example/auth/configuration/AppConf.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.auth.configuration; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -@Configuration -public class AppConf implements WebMvcConfigurer { - - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/**") - .allowedOrigins("http://localhost:3000") - .allowedMethods("PUT", "GET", "POST", "DELETE"); - - } -} diff --git a/auth/src/main/java/com/example/auth/configuration/MessageConfig.java b/auth/src/main/java/com/example/auth/configuration/MessageConfig.java deleted file mode 100644 index f7c9fcab..00000000 --- a/auth/src/main/java/com/example/auth/configuration/MessageConfig.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.example.auth.configuration; - -import org.springframework.amqp.core.Exchange; -import org.springframework.amqp.core.ExchangeBuilder; -import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; -import org.springframework.amqp.support.converter.MessageConverter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class MessageConfig { - - @Value("${auth.rabbitmq.exchange}") - String exchange; - - @Bean - public Exchange declareExchange() { - return ExchangeBuilder.directExchange(exchange).durable(true).build(); - } - - @Bean - public MessageConverter jsonMessageConverter() { - return new Jackson2JsonMessageConverter(); - } -} diff --git a/auth/src/main/java/com/example/auth/configuration/SwaggerConfig.java b/auth/src/main/java/com/example/auth/configuration/SwaggerConfig.java deleted file mode 100644 index 44f4b06b..00000000 --- a/auth/src/main/java/com/example/auth/configuration/SwaggerConfig.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.example.auth.configuration; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import com.google.common.base.Predicates; - -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.ApiKey; -import springfox.documentation.service.AuthorizationScope; -import springfox.documentation.service.Contact; -import springfox.documentation.service.SecurityReference; -import springfox.documentation.service.Tag; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spi.service.contexts.SecurityContext; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableSwagger2 -public class SwaggerConfig { - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(Predicates.not(PathSelectors.regex("/error"))) - .build() - .apiInfo(metadata()) - .useDefaultResponseMessages(false) - .securitySchemes(Collections.singletonList(apiKey())) - .securityContexts(Collections.singletonList(securityContext())) - .tags(new Tag("users", "Operações sobre usuários")) - .genericModelSubstitutes(Optional.class); - - } - - private ApiInfo metadata() { - return new ApiInfoBuilder() - .title("API de autenticação com JSON Web Token") - .description("Esse é um exemplo de serviço de autenticação JWT. Você pode aprender mais sobre JWT em [https://jwt.io/](https://jwt.io/). Para este exemplo, você pode usar os usuários `admin` ou` client` (senha: admin e client respectivamente) para testar os filtros de autorização. Depois de ter logado com sucesso e obtido o token, você deve clicar no botão superior direito `Authorize` e começá-lo com o prefixo \" Bearer \".") - .version("1.0.0") - .license("MIT License").licenseUrl("http://opensource.org/licenses/MIT") - .contact(new Contact("Lucas Alexandre Fell", "https://github.com/fell-lucas", "lucasafell@gmail.com")) - .build(); - } - - private ApiKey apiKey() { - return new ApiKey("Authorization", "Authorization", "header"); - } - - private SecurityContext securityContext() { - return SecurityContext.builder() - .securityReferences(defaultAuth()) - .forPaths(PathSelectors.any()) - .build(); - } - - private List defaultAuth() { - AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); - AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; - authorizationScopes[0] = authorizationScope; - return Arrays.asList(new SecurityReference("Authorization", authorizationScopes)); - } - -} diff --git a/auth/src/main/java/com/example/auth/controller/UserController.java b/auth/src/main/java/com/example/auth/controller/UserController.java deleted file mode 100644 index cbf1e99f..00000000 --- a/auth/src/main/java/com/example/auth/controller/UserController.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.example.auth.controller; - -import javax.servlet.http.HttpServletRequest; - -import com.example.auth.dto.CompleteUserDTO; -import com.example.auth.dto.UserDTO; -import com.example.auth.exception.CustomHttpException; -import com.example.auth.model.User; -import com.example.auth.sender.SignupSender; -import com.example.auth.service.UserService; - -import org.modelmapper.ModelMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; -import io.swagger.annotations.Authorization; - -@RestController -@RequestMapping("/users") -@Api(tags = "users") -public class UserController { - - @Autowired - private UserService userService; - - @Autowired - private SignupSender signupSender; - - @Autowired - private ModelMapper modelMapper; - - @PostMapping("/signin") - @ApiOperation(value = "${UserController.signin}") - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Algo deu errado"), - @ApiResponse(code = 422, message = "Nome/senha inválidos") - }) - public ResponseEntity login( - @ApiParam("Email") @RequestParam String email, - @ApiParam("Senha") @RequestParam String password) { - try { - String token = userService.signin(email, password); - return new ResponseEntity<>(token, HttpStatus.OK); - } catch (CustomHttpException e) { - return new ResponseEntity<>(e.getMessage(), e.getHttpStatus()); - } - } - - @PostMapping("/signup") - @ApiOperation(value = "${UserController.signup}") - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Algo deu errado"), - @ApiResponse(code = 422, message = "Email em uso"), - }) - public ResponseEntity signup(@ApiParam("Usuário cadastrando") @RequestBody CompleteUserDTO user) { - // cria um usuario basico para salvar aqui no microsserviço de autenticação - // (usuario, email e senha) - // o usuario real vai para a fila do rabbit para ser consumido pelo CRUD - User basicUser = new User(); - basicUser.setUsername(user.getUsername()); - basicUser.setEmail(user.getEmail()); - basicUser.setPassword(user.getPassword()); - basicUser.setRoles(user.getRoles()); - try { - String token = userService.signup(basicUser); - signupSender.sendMessage(user); - return new ResponseEntity<>(token, HttpStatus.OK); - } catch (CustomHttpException e) { - return new ResponseEntity<>(e.getMessage(), e.getHttpStatus()); - } - } - - @DeleteMapping(value = "/{email}") - @PreAuthorize("hasRole('ROLE_ADMIN')") - @ApiOperation(value = "${UserController.delete}", authorizations = {@Authorization(value = "apiKey")}) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Algo deu errado"), - @ApiResponse(code = 403, message = "Acesso negado"), - @ApiResponse(code = 404, message = "O usuário não existe"), - @ApiResponse(code = 500, message = "Token JWT expirado ou inválido") - }) - public String delete( - @ApiParam("Email") @PathVariable String email) { - userService.delete(email); - return email; - } - - @GetMapping(value = "/{email}") - @PreAuthorize("hasRole('ROLE_ADMIN')") - @ApiOperation(value = "${UserController.search}", response = UserDTO.class, authorizations = {@Authorization(value = "apiKey")}) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Algo deu errado"), - @ApiResponse(code = 403, message = "Acesso negado"), - @ApiResponse(code = 404, message = "O usuário não existe"), - @ApiResponse(code = 500, message = "Token JWT expirado ou inválido") - }) - public UserDTO search( - @ApiParam("Email") @PathVariable String email) { - return modelMapper.map(userService.search(email), UserDTO.class); - } - - @GetMapping(value = "/me") - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_CLIENT')") - @ApiOperation(value = "${UserController.me}", response = UserDTO.class, authorizations = {@Authorization(value = "apiKey")}) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Algo deu errado"), - @ApiResponse(code = 403, message = "Acesso negado"), - @ApiResponse(code = 500, message = "Token JWT expirado ou inválido") - }) - public UserDTO whoami(HttpServletRequest req) { - return modelMapper.map(userService.whoami(req), UserDTO.class); - } - - @GetMapping("/refresh") - @PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_CLIENT')") - @ApiOperation(value = "${UserController.refresh}", response = UserDTO.class, authorizations = {@Authorization(value = "apiKey")}) - @ApiResponses(value = { - @ApiResponse(code = 400, message = "Algo deu errado"), - @ApiResponse(code = 403, message = "Acesso negado"), - }) - public String refresh(HttpServletRequest req) { - return userService.refresh(req.getRemoteUser()); - } -} diff --git a/auth/src/main/java/com/example/auth/dto/CompleteUserDTO.java b/auth/src/main/java/com/example/auth/dto/CompleteUserDTO.java deleted file mode 100644 index 05c66d80..00000000 --- a/auth/src/main/java/com/example/auth/dto/CompleteUserDTO.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.example.auth.dto; - -import io.swagger.annotations.ApiModelProperty; - -import java.util.List; - -import com.example.auth.model.Role; - -public class CompleteUserDTO { - - @ApiModelProperty(position = 0) - private String username; - @ApiModelProperty(position = 1) - private String email; - @ApiModelProperty(position = 2) - private String password; - @ApiModelProperty(position = 3) - private String cpf; - @ApiModelProperty(position = 4) - private String phone; - @ApiModelProperty(position = 5) - private String address; - @ApiModelProperty(position = 6) - List roles; - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getCpf() { - return cpf; - } - - public void setCpf(String cpf) { - this.cpf = cpf; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public List getRoles() { - return roles; - } - - public void setRoles(List roles) { - this.roles = roles; - } - -} diff --git a/auth/src/main/java/com/example/auth/dto/UserDTO.java b/auth/src/main/java/com/example/auth/dto/UserDTO.java deleted file mode 100644 index 5b04664c..00000000 --- a/auth/src/main/java/com/example/auth/dto/UserDTO.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.example.auth.dto; - -import io.swagger.annotations.ApiModelProperty; - -import java.util.List; - -import com.example.auth.model.Role; - -public class UserDTO { - - @ApiModelProperty(position = 0) - private String username; - @ApiModelProperty(position = 1) - private String email; - @ApiModelProperty(position = 2) - private String password; - @ApiModelProperty(position = 3) - List roles; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public List getRoles() { - return roles; - } - - public void setRoles(List roles) { - this.roles = roles; - } -} diff --git a/auth/src/main/java/com/example/auth/exception/CustomHttpException.java b/auth/src/main/java/com/example/auth/exception/CustomHttpException.java deleted file mode 100644 index eda4e22f..00000000 --- a/auth/src/main/java/com/example/auth/exception/CustomHttpException.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.auth.exception; - -import org.springframework.http.HttpStatus; - -public class CustomHttpException extends RuntimeException { - - private static final long serialVersionUID = 1L; - - private final String message; - private final HttpStatus httpStatus; - - public CustomHttpException(String message, HttpStatus httpStatus) { - this.message = message; - this.httpStatus = httpStatus; - } - - @Override - public String getMessage() { - return message; - } - - public HttpStatus getHttpStatus() { - return httpStatus; - } -} diff --git a/auth/src/main/java/com/example/auth/model/Role.java b/auth/src/main/java/com/example/auth/model/Role.java deleted file mode 100644 index e9f3781f..00000000 --- a/auth/src/main/java/com/example/auth/model/Role.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.example.auth.model; - -import org.springframework.security.core.GrantedAuthority; - -public enum Role implements GrantedAuthority { - ROLE_ADMIN, ROLE_CLIENT; - - public String getAuthority() { - return name(); - } - -} diff --git a/auth/src/main/java/com/example/auth/model/User.java b/auth/src/main/java/com/example/auth/model/User.java deleted file mode 100644 index 17c05862..00000000 --- a/auth/src/main/java/com/example/auth/model/User.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.example.auth.model; - -import java.util.List; - -import javax.persistence.Column; -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.validation.constraints.Size; - - -@Entity -public class User { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Integer id; - - @Size(min = 2, max = 255, message = "Tamanho mínimo do nome: 2 caracteres") - @Column(nullable = false) - private String username; - - @Column(unique = true, nullable = false) - private String email; - - @Size(min = 8, message = "Tamanho mínimo da senha: 8 caracteres") - private String password; - - @ElementCollection(fetch = FetchType.EAGER) - List roles; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public List getRoles(){ - return roles; - } - - public void setRoles(List roles) { - this.roles = roles; - } - -} diff --git a/auth/src/main/java/com/example/auth/repository/UserRepository.java b/auth/src/main/java/com/example/auth/repository/UserRepository.java deleted file mode 100644 index c86e4b52..00000000 --- a/auth/src/main/java/com/example/auth/repository/UserRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.auth.repository; - -import org.springframework.data.jpa.repository.JpaRepository; - -import javax.transaction.Transactional; - -import com.example.auth.model.User; - -public interface UserRepository extends JpaRepository { - - boolean existsByEmail(String email); - - User findByEmail(String username); - - @Transactional - void deleteByEmail(String username); -} diff --git a/auth/src/main/java/com/example/auth/security/JwtTokenFilter.java b/auth/src/main/java/com/example/auth/security/JwtTokenFilter.java deleted file mode 100644 index bd819573..00000000 --- a/auth/src/main/java/com/example/auth/security/JwtTokenFilter.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.example.auth.security; - -import java.io.IOException; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import com.example.auth.exception.CustomHttpException; - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.web.filter.OncePerRequestFilter; - -public class JwtTokenFilter extends OncePerRequestFilter { - - private JwtTokenProvider jwtTokenProvider; - - public JwtTokenFilter(JwtTokenProvider jwtTokenProvider) { - this.jwtTokenProvider = jwtTokenProvider; - } - - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - String token = jwtTokenProvider.resolveToken(request); - try { - if (token != null && jwtTokenProvider.validateToken(token)) { - Authentication auth = jwtTokenProvider.getAuthentication(token); - SecurityContextHolder.getContext().setAuthentication(auth); - } - } catch (CustomHttpException ex) { - SecurityContextHolder.clearContext(); - response.sendError(ex.getHttpStatus().value(), ex.getMessage()); - return; - } - - filterChain.doFilter(request, response); - } -} diff --git a/auth/src/main/java/com/example/auth/security/JwtTokenFilterConfigurer.java b/auth/src/main/java/com/example/auth/security/JwtTokenFilterConfigurer.java deleted file mode 100644 index d9d0e97f..00000000 --- a/auth/src/main/java/com/example/auth/security/JwtTokenFilterConfigurer.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.example.auth.security; - -import org.springframework.security.config.annotation.SecurityConfigurerAdapter; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.web.DefaultSecurityFilterChain; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; - -public class JwtTokenFilterConfigurer extends SecurityConfigurerAdapter { - - private JwtTokenProvider jwtTokenProvider; - - public JwtTokenFilterConfigurer(JwtTokenProvider jwtTokenProvider) { - this.jwtTokenProvider = jwtTokenProvider; - } - - @Override - public void configure(HttpSecurity http) throws Exception { - JwtTokenFilter customFilter = new JwtTokenFilter(jwtTokenProvider); - http.addFilterBefore(customFilter, UsernamePasswordAuthenticationFilter.class); - } -} diff --git a/auth/src/main/java/com/example/auth/security/JwtTokenProvider.java b/auth/src/main/java/com/example/auth/security/JwtTokenProvider.java deleted file mode 100644 index 68492be8..00000000 --- a/auth/src/main/java/com/example/auth/security/JwtTokenProvider.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.example.auth.security; - -import java.util.Base64; -import java.util.Date; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -import javax.annotation.PostConstruct; -import javax.servlet.http.HttpServletRequest; - -import com.example.auth.exception.CustomHttpException; -import com.example.auth.model.Role; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpStatus; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.stereotype.Component; - -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.JwtException; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; - -@Component -public class JwtTokenProvider { - - @Value("${security.jwt.token.secret_key:key_microservices}") - private String secretKey; - - @Value("${security.jwt.token.expire_time:3600000}") - private long validityInMilliseconds = 3600000; // 1 hora - - @Autowired - private MyUserDetails myUserDetails; - - @PostConstruct - protected void init() { - secretKey = Base64.getEncoder().encodeToString(secretKey.getBytes()); - } - - public String createToken(String username, List roles) { - - Claims claims = Jwts.claims().setSubject(username); - claims.put("auth", roles.stream() - .map(s -> new SimpleGrantedAuthority(s.getAuthority())) - .filter(Objects::nonNull) - .collect(Collectors.toList())); - - Date now = new Date(); - Date validity = new Date(now.getTime() + validityInMilliseconds); - - return Jwts.builder() - .setClaims(claims) - .setIssuedAt(now) - .setExpiration(validity) - .signWith(SignatureAlgorithm.HS256, secretKey) - .compact(); - } - - public Authentication getAuthentication(String token) { - UserDetails userDetails = myUserDetails.loadUserByUsername(getUsername(token)); - - return new UsernamePasswordAuthenticationToken(userDetails, "", userDetails.getAuthorities()); - } - - public String getUsername(String token) { - return Jwts.parser() - .setSigningKey(secretKey) - .parseClaimsJws(token) - .getBody() - .getSubject(); - } - - public String resolveToken(HttpServletRequest req) { - String bearerToken = req.getHeader("Authorization"); - if(bearerToken != null && bearerToken.startsWith("Bearer ")) { - return bearerToken.substring(7); - } - return null; - } - - public boolean validateToken(String token) { - try { - Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token); - return true; - } catch (JwtException | IllegalArgumentException e) { - throw new CustomHttpException("Token JWT inválido ou expirado", HttpStatus.INTERNAL_SERVER_ERROR); - } - } -} diff --git a/auth/src/main/java/com/example/auth/security/MyUserDetails.java b/auth/src/main/java/com/example/auth/security/MyUserDetails.java deleted file mode 100644 index 5969e599..00000000 --- a/auth/src/main/java/com/example/auth/security/MyUserDetails.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.example.auth.security; - -import com.example.auth.model.User; -import com.example.auth.repository.UserRepository; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.stereotype.Service; - -@Service -public class MyUserDetails implements UserDetailsService { - - @Autowired - private UserRepository userRepository; - - @Override - public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException { - final User user = userRepository.findByEmail(email); - - if(user == null) { - throw new UsernameNotFoundException("Usuário '" + email + "' não encontrado"); - } - - return org.springframework.security.core.userdetails.User - .withUsername(email) - .password(user.getPassword()) - .authorities(user.getRoles()) - .accountExpired(false) - .accountLocked(false) - .credentialsExpired(false) - .disabled(false) - .build(); - } - -} diff --git a/auth/src/main/java/com/example/auth/security/WebSecurityConfig.java b/auth/src/main/java/com/example/auth/security/WebSecurityConfig.java deleted file mode 100644 index 91dcbf9f..00000000 --- a/auth/src/main/java/com/example/auth/security/WebSecurityConfig.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.example.auth.security; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; - -@Configuration -@EnableWebSecurity -@EnableGlobalMethodSecurity(prePostEnabled = true) -public class WebSecurityConfig extends WebSecurityConfigurerAdapter { - - @Autowired - private JwtTokenProvider jwtTokenProvider; - - @Override - protected void configure(HttpSecurity http) throws Exception { - - // Disable CSRF (cross site request forgery) not applicable to JWT - http.csrf().disable(); - - // No session will be created or used by spring security - http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); - - // Entry points - http.authorizeRequests().antMatchers("/users/signin").permitAll().antMatchers("/users/signup").permitAll() - .anyRequest().authenticated(); - - // If a user try to access a resource without having enough permissions - http.exceptionHandling().accessDeniedPage("/login"); - - http.formLogin().usernameParameter("email").permitAll().and().logout().permitAll(); - - // Apply JWT - http.apply(new JwtTokenFilterConfigurer(jwtTokenProvider)); - } - - @Override - public void configure(WebSecurity web) throws Exception { - // Allow swagger to be accessed without authentication - web.ignoring().antMatchers("/v2/api-docs").antMatchers("/swagger-resources/**").antMatchers("/swagger-ui.html") - .antMatchers("/configuration/**").antMatchers("/webjars/**").antMatchers("/public"); - } - - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(12); - } - - @Override - @Bean - public AuthenticationManager authenticationManagerBean() throws Exception { - return super.authenticationManagerBean(); - } -} diff --git a/auth/src/main/java/com/example/auth/sender/SignupSender.java b/auth/src/main/java/com/example/auth/sender/SignupSender.java deleted file mode 100644 index 23001680..00000000 --- a/auth/src/main/java/com/example/auth/sender/SignupSender.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.example.auth.sender; - -import com.example.auth.dto.CompleteUserDTO; - -import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; - -@Component -public class SignupSender { - - @Value("${auth.rabbitmq.exchange}") - String exchange; - - @Value("${auth.rabbitmq.routingKeySignup}") - String routingKey; - - public RabbitTemplate rabbitTemplate; - - @Autowired - public SignupSender(RabbitTemplate rabbitTemplate) { - this.rabbitTemplate = rabbitTemplate; - } - - public void sendMessage(CompleteUserDTO user) { - rabbitTemplate.convertAndSend(exchange, routingKey, user); - } -} diff --git a/auth/src/main/java/com/example/auth/service/UserService.java b/auth/src/main/java/com/example/auth/service/UserService.java deleted file mode 100644 index 2716623a..00000000 --- a/auth/src/main/java/com/example/auth/service/UserService.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.example.auth.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; - -import javax.servlet.http.HttpServletRequest; - -import com.example.auth.exception.CustomHttpException; -import com.example.auth.model.User; -import com.example.auth.repository.UserRepository; -import com.example.auth.security.JwtTokenProvider; - -@Service -public class UserService { - - @Autowired - private UserRepository userRepository; - - @Autowired - private PasswordEncoder passwordEncoder; - - @Autowired - private JwtTokenProvider jwtTokenProvider; - - @Autowired - private AuthenticationManager authenticationManager; - - public String signin(String email, String password) { - try { - authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(email, password)); - return jwtTokenProvider.createToken(email, userRepository.findByEmail(email).getRoles()); - } catch(AuthenticationException e) { - throw new CustomHttpException("Combinação de email/senha inválida.", HttpStatus.UNPROCESSABLE_ENTITY); - } - } - - public String signup(User user) { - if (!userRepository.existsByEmail(user.getEmail())) { - user.setPassword(passwordEncoder.encode(user.getPassword())); - userRepository.save(user); - return jwtTokenProvider.createToken(user.getEmail(), user.getRoles()); - } else { - throw new CustomHttpException("Email já cadastrado.", HttpStatus.UNPROCESSABLE_ENTITY); - } - } - - public void delete(String username) { - userRepository.deleteByEmail(username); - } - - public User search(String username) { - User user = userRepository.findByEmail(username); - if(user == null) { - throw new CustomHttpException("O usuário não existe.", HttpStatus.NOT_FOUND); - } - return user; - } - - public User whoami(HttpServletRequest req) { - return userRepository.findByEmail(jwtTokenProvider.getUsername(jwtTokenProvider.resolveToken(req))); - } - - public String refresh(String username) { - return jwtTokenProvider.createToken(username, userRepository.findByEmail(username).getRoles()); - } - -} diff --git a/auth/src/main/resources/application.yml b/auth/src/main/resources/application.yml deleted file mode 100644 index 18856db7..00000000 --- a/auth/src/main/resources/application.yml +++ /dev/null @@ -1,57 +0,0 @@ -server: - port: 8083 - servlet: - context-path: /authService - -spring: - datasource: - url: jdbc:mysql://localhost:3306/auth_db?useTimezone=true&serverTimezone=UTC - username: root - password: admin - tomcat: - max-wait: 20000 - max-active: 50 - max-idle: 20 - min-idle: 15 - application: - name: authService - jpa: - hibernate: - ddl-auto: create - properties: - hibernate: - dialect: org.hibernate.dialect.MySQL8Dialect - format_sql: true - id: - new_generator_mappings: false - rabbitmq: - host: localhost - port: 5672 - username: admin - password: admin - -eureka: - instance: - hostname: localhost - client: - serviceUrl: - defaultZone: http://localhost:8087/discovery/eureka - -auth: - rabbitmq: - exchange: auth.exchange - routingKeySignup: auth.signup.routingKey - -security: - jwt: - token: - secret_key: key_microservices - expire_time: 300000 # 5 minutos - -UserController: - signin: Autentica usuário e retorna seu token JWT. - signup: Cria usuário e retorna seu token JWT - delete: Apaga usuário específico de acordo com ID - search: Retorna usuário específico de acordo com ID - me: Retorna dados do usuário atual - refresh: Reinicia o tempo do token JWT \ No newline at end of file diff --git a/payment/.gitignore b/payment/.gitignore deleted file mode 100644 index 549e00a2..00000000 --- a/payment/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -HELP.md -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/payment/Dockerfile b/payment/Dockerfile deleted file mode 100644 index d8615548..00000000 --- a/payment/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM openjdk:19-slim -MAINTAINER com.jmerlugof -VOLUME /tmp -EXPOSE 8088 - -COPY target/payment*.jar /payment.jar - -ENTRYPOINT ["java","-jar","-Dspring.profiles.active=docker-demo", "/payment.jar"] \ No newline at end of file diff --git a/payment/mvnw b/payment/mvnw deleted file mode 100755 index a16b5431..00000000 --- a/payment/mvnw +++ /dev/null @@ -1,310 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - export JAVA_HOME="`/usr/libexec/java_home`" - else - export JAVA_HOME="/Library/Java/Home" - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - - if [ -z "$1" ] - then - echo "Path not specified to find_maven_basedir" - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=`cd "$wdir/.."; pwd` - fi - # end of workaround - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -BASE_DIR=`find_maven_basedir "$(pwd)"` -if [ -z "$BASE_DIR" ]; then - exit 1; -fi - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found .mvn/wrapper/maven-wrapper.jar" - fi -else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." - fi - if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - fi - while IFS="=" read key value; do - case "$key" in (wrapperUrl) jarUrl="$value"; break ;; - esac - done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" - if [ "$MVNW_VERBOSE" = true ]; then - echo "Downloading from: $jarUrl" - fi - wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" - if $cygwin; then - wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` - fi - - if command -v wget > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found wget ... using wget" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget "$jarUrl" -O "$wrapperJarPath" - else - wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" - fi - elif command -v curl > /dev/null; then - if [ "$MVNW_VERBOSE" = true ]; then - echo "Found curl ... using curl" - fi - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl -o "$wrapperJarPath" "$jarUrl" -f - else - curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f - fi - - else - if [ "$MVNW_VERBOSE" = true ]; then - echo "Falling back to using Java to download" - fi - javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaClass=`cygpath --path --windows "$javaClass"` - fi - if [ -e "$javaClass" ]; then - if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Compiling MavenWrapperDownloader.java ..." - fi - # Compiling the Java class - ("$JAVA_HOME/bin/javac" "$javaClass") - fi - if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then - # Running the downloader - if [ "$MVNW_VERBOSE" = true ]; then - echo " - Running MavenWrapperDownloader.java ..." - fi - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -if [ "$MVNW_VERBOSE" = true ]; then - echo $MAVEN_PROJECTBASEDIR -fi -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` - [ -n "$MAVEN_PROJECTBASEDIR" ] && - MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` -fi - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/payment/mvnw.cmd b/payment/mvnw.cmd deleted file mode 100644 index c8d43372..00000000 --- a/payment/mvnw.cmd +++ /dev/null @@ -1,182 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" -set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - -FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B -) - -@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -@REM This allows using the maven wrapper in projects that prohibit checking in binary data. -if exist %WRAPPER_JAR% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM Provide a "standardized" way to retrieve the CLI args that will -@REM work with both Windows and non-Windows executions. -set MAVEN_CMD_LINE_ARGS=%* - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% diff --git a/payment/pom.xml b/payment/pom.xml deleted file mode 100644 index 31a1308e..00000000 --- a/payment/pom.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.4.2 - - - com.example - payment - 0.0.1-SNAPSHOT - payment - Microserviço de pagamento - - 1.8 - 2020.0.1 - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - org.springframework.boot - spring-boot-starter-amqp - - - - mysql - mysql-connector-java - runtime - - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - org.springframework.boot - spring-boot-starter-test - test - - - io.springfox - springfox-swagger2 - 2.9.2 - - - io.springfox - springfox-swagger-ui - 2.9.2 - - - org.projectlombok - lombok - 1.18.24 - provided - - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/payment/src/main/java/com/example/payment/PaymentApplication.java b/payment/src/main/java/com/example/payment/PaymentApplication.java deleted file mode 100644 index 33a4ba13..00000000 --- a/payment/src/main/java/com/example/payment/PaymentApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.payment; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class PaymentApplication { - - public static void main(String[] args) { - SpringApplication.run(PaymentApplication.class, args); - } - -} diff --git a/payment/src/main/java/com/example/payment/config/MessageConfig.java b/payment/src/main/java/com/example/payment/config/MessageConfig.java deleted file mode 100644 index a60d8df9..00000000 --- a/payment/src/main/java/com/example/payment/config/MessageConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.example.payment.config; - -import org.springframework.amqp.core.Exchange; -import org.springframework.amqp.core.ExchangeBuilder; -import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; -import org.springframework.amqp.support.converter.MessageConverter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class MessageConfig { - - @Value("${crud.rabbitmq.exchange}") - String exchange; - - @Bean - public Exchange declareExchange() { - return ExchangeBuilder.directExchange(exchange).durable(true).build(); - } - - @Bean - public MessageConverter jsonMessageConverter() { - return new Jackson2JsonMessageConverter(); - } - -} diff --git a/payment/src/main/java/com/example/payment/controller/AcquisitionController.java b/payment/src/main/java/com/example/payment/controller/AcquisitionController.java deleted file mode 100644 index 078f010b..00000000 --- a/payment/src/main/java/com/example/payment/controller/AcquisitionController.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.example.payment.controller; - -import java.util.List; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.example.payment.dto.AcquisitionDTO; -import com.example.payment.interfaces.service.IAcquisitionService; -import com.example.payment.model.Acquisition; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - -@RestController -@RequestMapping("/acquistion") -@Api(value = "MICROSERVICE Payment") -public class AcquisitionController { - - private IAcquisitionService acquisitionService; - - public AcquisitionController(IAcquisitionService service) { - this.acquisitionService = service; - } - - @PostMapping("/save") - @ApiOperation(value = "Salva uma aquisição") - public void saveAcquisition(@RequestBody AcquisitionDTO dto) { - Acquisition acquisition = new Acquisition(); - acquisition.setDate(dto.getDate()); - acquisition.setId(dto.getId()); - acquisition.setProperty(dto.getProperty()); - acquisition.setValue(dto.getValue()); - acquisitionService.saveAcquisition(acquisition); - } - - // Find all acquisitions - @GetMapping("/all") - @ApiOperation(value = "Lista com todas as aquisições") - public ResponseEntity getAllAcquisitions() { - List acquisitions = acquisitionService.findAllAcquisitions(); - return new ResponseEntity<>(acquisitions, HttpStatus.OK); - } - - // Get an acquisition - @GetMapping("/acquisition/find/{id}") - @ApiOperation(value = "Pega uma aquisição pelo seu id") - public ResponseEntity getAcquisitionById(@PathVariable("id") Long id) { - Acquisition acquisition = acquisitionService.findAcquisitionById(id); - return new ResponseEntity<>(acquisition, HttpStatus.OK); - } - - // Put acquisition - @PutMapping("/acquisition/update") - @ApiOperation(value = "Atualiza uma aquisição") - public ResponseEntity updateAcquisition(@RequestBody Acquisition acquisition) { - Acquisition updateAcquisition = acquisitionService.updateAcquisition(acquisition); - return new ResponseEntity<>(updateAcquisition, HttpStatus.OK); - } - -} diff --git a/payment/src/main/java/com/example/payment/controller/PaymentPropertyController.java b/payment/src/main/java/com/example/payment/controller/PaymentPropertyController.java deleted file mode 100644 index 53e29793..00000000 --- a/payment/src/main/java/com/example/payment/controller/PaymentPropertyController.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.example.payment.controller; - -import com.example.payment.dto.PaymentPropertyDTO; -import com.example.payment.interfaces.service.IPaymentPropertyService; -import com.example.payment.interfaces.service.IUserService; -import com.example.payment.model.PaymentProperty; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -@RestController -@RequestMapping("/paymentP") -@Api(value = "MICROSERVICE Payment") -public class PaymentPropertyController { - - private IPaymentPropertyService paymentPropertyService; - - private IUserService userService; - - @PostMapping("/save") - @ApiOperation(value = "Salva um pagamento de uma Propriedade") - public void savePaymentProperty(@RequestBody PaymentPropertyDTO dto){ - PaymentProperty paymentProperty = new PaymentProperty(); - paymentProperty.setPropertyPayment(dto.getPropertyPayment()); - paymentProperty.setDatePayment(dto.getDatePayment()); - paymentProperty.setValor(dto.getValor()); - paymentProperty.setClienteComprador(dto.getClienteComprador()); - paymentProperty.setStatus(dto.getStatus()); - userService.validarUsuario(paymentProperty.getClienteComprador(), paymentProperty.getPropertyPayment()); - paymentPropertyService.savePayment(paymentProperty); - } - - @PutMapping("/update") - @ApiOperation(value = "atualiza um pagamento de uma propriedade") - public ResponseEntity updatePaymentProperty(@RequestBody PaymentProperty paymentProperty) { - PaymentProperty updatePayment = paymentPropertyService.updatePayment(paymentProperty); - return new ResponseEntity<>(updatePayment, HttpStatus.OK); - } - - @GetMapping("/find/{id}") - @ApiOperation(value = "pega um pagamento de propriedade pelo id") - public ResponseEntity getPaymentPropertyById(@PathVariable("id") Long id) { - PaymentProperty paymentPropertyFinded = paymentPropertyService.findPaymentById(id); - return new ResponseEntity<>(paymentPropertyFinded, HttpStatus.OK); - } - -} diff --git a/payment/src/main/java/com/example/payment/controller/PaymentRentController.java b/payment/src/main/java/com/example/payment/controller/PaymentRentController.java deleted file mode 100644 index 83d58ab4..00000000 --- a/payment/src/main/java/com/example/payment/controller/PaymentRentController.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.example.payment.controller; - -import com.example.payment.dto.PaymentRentDTO; -import com.example.payment.interfaces.service.IPaymentRentService; -import com.example.payment.model.PaymentRent; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -@RestController -@RequestMapping("/paymentR") -@Api(value = "MICROSERVICE Payment") -public class PaymentRentController { - - private IPaymentRentService paymentRentService; - - @PostMapping("/save") - @ApiOperation(value = "Salva um pagamento de uma Propriedade") - public void savePaymentRent(@RequestBody PaymentRentDTO dto){ - PaymentRent paymentRent = new PaymentRent(); - paymentRent.setRentPayment(dto.getRentPayment()); - paymentRent.setDatePayment(dto.getDatePayment()); - paymentRent.setValor(dto.getValor()); - paymentRent.setClienteComprador(dto.getClienteComprador()); - paymentRent.setStatus(dto.getStatus()); - paymentRentService.savePayment(paymentRent); - } - - @PutMapping("/update") - @ApiOperation(value = "atualiza um pagamento de uma propriedade") - public ResponseEntity updatePaymentRent(@RequestBody PaymentRent paymentRent) { - PaymentRent updatePayment = paymentRentService.updatePayment(paymentRent); - return new ResponseEntity<>(updatePayment, HttpStatus.OK); - } - - @GetMapping("/find/{id}") - @ApiOperation(value = "pega um pagamento de propriedade pelo id") - public ResponseEntity getPaymentRentById(@PathVariable("id") Long id) { - PaymentRent paymentRentFinded = paymentRentService.findPaymentById(id); - return new ResponseEntity<>(paymentRentFinded, HttpStatus.OK); - } - -} diff --git a/payment/src/main/java/com/example/payment/controller/RentController.java b/payment/src/main/java/com/example/payment/controller/RentController.java deleted file mode 100644 index 812c87bd..00000000 --- a/payment/src/main/java/com/example/payment/controller/RentController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.example.payment.controller; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.example.payment.dto.RentDTO; -import com.example.payment.interfaces.service.IRentService; -import com.example.payment.model.Rent; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - -@RestController -@RequestMapping("/rent") -@Api(value = "MICROSERVICE Payment") -public class RentController { - - private IRentService rentService; - - public RentController(IRentService service) { - this.rentService = service; - } - - @PostMapping("/save") - @ApiOperation(value = "Salva uma arrendamento/aluguel") - public void saveRent(@RequestBody RentDTO dto) { - Rent rent = new Rent(); - rent.setData(dto.getData()); - rent.setPropertie(dto.getPropertie()); - rent.setValue(dto.getAmountValue()); - rentService.saveRent(rent); - } - - @PutMapping("/update") - @ApiOperation(value = "atualiza um arrendamento/aluguel") - public ResponseEntity updateRent(@RequestBody Rent rent) { - Rent updateRent = rentService.updateRent(rent); - return new ResponseEntity<>(updateRent, HttpStatus.OK); - } - - @GetMapping("/find/{id}") - @ApiOperation(value = "pega um arrendamento/aluguel pelo id") - public ResponseEntity getRentById(@PathVariable("id") Long id) { - Rent rentFinded = rentService.findRentById(id); - return new ResponseEntity<>(rentFinded, HttpStatus.OK); - } - -} diff --git a/payment/src/main/java/com/example/payment/dto/AcquisitionDTO.java b/payment/src/main/java/com/example/payment/dto/AcquisitionDTO.java deleted file mode 100644 index 6d396992..00000000 --- a/payment/src/main/java/com/example/payment/dto/AcquisitionDTO.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.example.payment.dto; - -import java.util.Date; - - -import com.example.payment.model.Property; - -public class AcquisitionDTO { - - private long id; - private Date date; - private Property property; - private Double value; - - - - public AcquisitionDTO(long id, Date date, Property property, Double value) { - this.id = id; - this.date = date; - this.property = property; - this.value = value; - } - public long getId() { - return id; - } - public void setId(long id) { - this.id = id; - } - public Date getDate() { - return date; - } - public void setDate(Date date) { - this.date = date; - } - public Property getProperty() { - return property; - } - public void setProperty(Property property) { - this.property = property; - } - public Double getValue() { - return value; - } - public void setValue(Double value) { - this.value = value; - } - -} diff --git a/payment/src/main/java/com/example/payment/dto/PaymentPropertyDTO.java b/payment/src/main/java/com/example/payment/dto/PaymentPropertyDTO.java deleted file mode 100644 index d9bfd54d..00000000 --- a/payment/src/main/java/com/example/payment/dto/PaymentPropertyDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.payment.dto; - -import com.example.payment.enums.PaymentStatusEnum; -import com.example.payment.model.Property; -import com.example.payment.model.User; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.util.ArrayList; -import java.util.Date; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -public class PaymentPropertyDTO { - private Long paymentId; - private User clienteComprador; - private int valor; - private Date datePayment; - private Property propertyPayment; - private PaymentStatusEnum status; -} diff --git a/payment/src/main/java/com/example/payment/dto/PaymentRentDTO.java b/payment/src/main/java/com/example/payment/dto/PaymentRentDTO.java deleted file mode 100644 index b4eb5d07..00000000 --- a/payment/src/main/java/com/example/payment/dto/PaymentRentDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.payment.dto; - -import com.example.payment.enums.PaymentStatusEnum; -import com.example.payment.model.Rent; -import com.example.payment.model.User; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.util.ArrayList; -import java.util.Date; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -public class PaymentRentDTO { - private Long paymentId; - private ArrayList clienteComprador; - private int valor; - private Date datePayment; - private Rent rentPayment; - private PaymentStatusEnum status; -} diff --git a/payment/src/main/java/com/example/payment/dto/PropertyAcquisitionDTO.java b/payment/src/main/java/com/example/payment/dto/PropertyAcquisitionDTO.java deleted file mode 100644 index 5acbe26b..00000000 --- a/payment/src/main/java/com/example/payment/dto/PropertyAcquisitionDTO.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.example.payment.dto; - -import com.example.payment.model.Acquisition; - -public class PropertyAcquisitionDTO { - - private Long id; - private Long idProperty; - private Integer amount; - private Acquisition acquisition; - - public PropertyAcquisitionDTO(Long id, Long idProperty, Integer amount, Acquisition acquisition) { - this.id = id; - this.idProperty = idProperty; - this.amount = amount; - this.acquisition = acquisition; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getIdProperty() { - return idProperty; - } - - public void setIdProperty(Long idProperty) { - this.idProperty = idProperty; - } - - public Integer getAmount() { - return amount; - } - - public void setAmount(Integer amount) { - this.amount = amount; - } - - public Acquisition getAcquisition() { - return acquisition; - } - - public void setAcquisition(Acquisition acquisition) { - this.acquisition = acquisition; - } - - - -} diff --git a/payment/src/main/java/com/example/payment/dto/PropertyDTO.java b/payment/src/main/java/com/example/payment/dto/PropertyDTO.java deleted file mode 100644 index 90fa2eda..00000000 --- a/payment/src/main/java/com/example/payment/dto/PropertyDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.example.payment.dto; - -public class PropertyDTO { - - private Long id; - private Integer amount; - - public PropertyDTO() { - } - - public PropertyDTO(Long id, Integer amount) { - this.id = id; - this.amount = amount; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Integer getAmount() { - return amount; - } - - public void setAmount(Integer amount) { - this.amount = amount; - } - -} diff --git a/payment/src/main/java/com/example/payment/dto/PropertyRentDTO.java b/payment/src/main/java/com/example/payment/dto/PropertyRentDTO.java deleted file mode 100644 index 80e411ad..00000000 --- a/payment/src/main/java/com/example/payment/dto/PropertyRentDTO.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.example.payment.dto; - -public class PropertyRentDTO { - - private Long id; - private Long idProperty; - private Integer amount; - - public PropertyRentDTO() { - } - - public PropertyRentDTO(Long id, Long idProperty, Integer amount) { - this.id = id; - this.idProperty = idProperty; - this.amount = amount; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Long getIdProperty() { - return idProperty; - } - - public void setIdProperty(Long idProperty) { - this.idProperty = idProperty; - } - - public Integer getAmount() { - return amount; - } - - public void setAmount(Integer amount) { - this.amount = amount; - } - -} diff --git a/payment/src/main/java/com/example/payment/dto/RentDTO.java b/payment/src/main/java/com/example/payment/dto/RentDTO.java deleted file mode 100644 index 8c805f19..00000000 --- a/payment/src/main/java/com/example/payment/dto/RentDTO.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.example.payment.dto; - -import java.util.Date; - -import com.example.payment.model.Property; - -public class RentDTO { - - private Long id; - private Date data; - private Property propertie; - private Double amountValue; - - public RentDTO() { - } - - public RentDTO(Long id, Date data, Property propertie, Double amountValue) { - this.id = id; - this.data = data; - this.propertie = propertie; - this.amountValue = amountValue; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Date getData() { - return data; - } - - public void setData(Date data) { - this.data = data; - } - - public Property getPropertie() { - return propertie; - } - - public void setPropertie(Property propertie) { - this.propertie = propertie; - } - - public Double getAmountValue() { - return amountValue; - } - - public void setAmountValue(Double amountValue) { - this.amountValue = amountValue; - } -} diff --git a/payment/src/main/java/com/example/payment/enums/PaymentStatusEnum.java b/payment/src/main/java/com/example/payment/enums/PaymentStatusEnum.java deleted file mode 100644 index 176a739b..00000000 --- a/payment/src/main/java/com/example/payment/enums/PaymentStatusEnum.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.example.payment.enums; - -public enum PaymentStatusEnum { - PAGO, - ATRASADO, - PENDENTE -} diff --git a/payment/src/main/java/com/example/payment/exceptions/ValidacaoException.java b/payment/src/main/java/com/example/payment/exceptions/ValidacaoException.java deleted file mode 100644 index 4a8317c0..00000000 --- a/payment/src/main/java/com/example/payment/exceptions/ValidacaoException.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.payment.exceptions; - -public class ValidacaoException extends RuntimeException { - - public ValidacaoException(String message){ - super(message); - } -} diff --git a/payment/src/main/java/com/example/payment/interfaces/service/IAcquisitionService.java b/payment/src/main/java/com/example/payment/interfaces/service/IAcquisitionService.java deleted file mode 100644 index 4ead4721..00000000 --- a/payment/src/main/java/com/example/payment/interfaces/service/IAcquisitionService.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.example.payment.interfaces.service; - -import java.util.List; - -import com.example.payment.model.Acquisition; - -public interface IAcquisitionService { - - void saveAcquisition(Acquisition acquisition); - Acquisition findAcquisitionById(Long id); - List findAllAcquisitions(); - void deleteAcquisition(Long id); - Acquisition updateAcquisition(Acquisition acquisition); - -} diff --git a/payment/src/main/java/com/example/payment/interfaces/service/IPaymentPropertyService.java b/payment/src/main/java/com/example/payment/interfaces/service/IPaymentPropertyService.java deleted file mode 100644 index cee5ba86..00000000 --- a/payment/src/main/java/com/example/payment/interfaces/service/IPaymentPropertyService.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.example.payment.interfaces.service; - -import com.example.payment.model.PaymentProperty; - -import java.util.List; - -public interface IPaymentPropertyService { - - void savePayment(PaymentProperty payment); - PaymentProperty findPaymentById(Long id); - List findAllPayments(); - void deletePayment(Long id); - PaymentProperty updatePayment(PaymentProperty payment); - boolean verificarAtraso(PaymentProperty payment); - boolean validarAtraso(PaymentProperty payment); -} diff --git a/payment/src/main/java/com/example/payment/interfaces/service/IPaymentRentService.java b/payment/src/main/java/com/example/payment/interfaces/service/IPaymentRentService.java deleted file mode 100644 index f955f0ec..00000000 --- a/payment/src/main/java/com/example/payment/interfaces/service/IPaymentRentService.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.example.payment.interfaces.service; - -import com.example.payment.model.PaymentProperty; -import com.example.payment.model.PaymentRent; - -import java.util.List; - -public interface IPaymentRentService { - - void savePayment(PaymentRent payment); - PaymentRent findPaymentById(Long id); - List findAllPayments(); - void deletePayment(Long id); - PaymentRent updatePayment(PaymentRent payment); - boolean verificarAtraso(PaymentRent payment); - boolean validarAtraso(PaymentRent payment); -} diff --git a/payment/src/main/java/com/example/payment/interfaces/service/IRentService.java b/payment/src/main/java/com/example/payment/interfaces/service/IRentService.java deleted file mode 100644 index a4fc0cc7..00000000 --- a/payment/src/main/java/com/example/payment/interfaces/service/IRentService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.payment.interfaces.service; - -import com.example.payment.model.Rent; - -public interface IRentService { - - void saveRent(Rent rent); - public Rent updateRent(Rent rent); - public Rent findRentById(Long id); - -} diff --git a/payment/src/main/java/com/example/payment/interfaces/service/IUserService.java b/payment/src/main/java/com/example/payment/interfaces/service/IUserService.java deleted file mode 100644 index 00443773..00000000 --- a/payment/src/main/java/com/example/payment/interfaces/service/IUserService.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.payment.interfaces.service; - -import com.example.payment.model.Property; -import com.example.payment.model.User; - -public interface IUserService { - - User findUserById(Long id); - void validarUsuario(User user, Property property); - -} diff --git a/payment/src/main/java/com/example/payment/interfaces/service/IValidacaoService.java b/payment/src/main/java/com/example/payment/interfaces/service/IValidacaoService.java deleted file mode 100644 index 030a634f..00000000 --- a/payment/src/main/java/com/example/payment/interfaces/service/IValidacaoService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.example.payment.interfaces.service; - -import com.example.payment.model.Property; -import com.example.payment.model.User; - -public interface IValidacaoService { - - void validar(User user, Property property); -} diff --git a/payment/src/main/java/com/example/payment/interfaces/service/IValidarCPFService.java b/payment/src/main/java/com/example/payment/interfaces/service/IValidarCPFService.java deleted file mode 100644 index 81cc2628..00000000 --- a/payment/src/main/java/com/example/payment/interfaces/service/IValidarCPFService.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.payment.interfaces.service; - -import com.example.payment.model.Property; -import com.example.payment.model.User; - -public interface IValidarCPFService { - void validar(User user, Property property); -} diff --git a/payment/src/main/java/com/example/payment/model/Acquisition.java b/payment/src/main/java/com/example/payment/model/Acquisition.java deleted file mode 100644 index 66341522..00000000 --- a/payment/src/main/java/com/example/payment/model/Acquisition.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.example.payment.model; - -import java.util.Date; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.OneToOne; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.format.annotation.DateTimeFormat; - -@Setter -@Getter -@Entity -public class Acquisition { - - @Id - private long id; - - @DateTimeFormat(pattern = "MM/dd/yyy") - @Column(name = "data", nullable = false) - private Date date; - - @OneToOne(cascade = CascadeType.ALL) - private Property property; - - @Column(name = "value", nullable = false) - private Double value; - - public Acquisition() { - } - - public Acquisition(long id, Date date, Property property, Double value) { - this.id = id; - this.date = date; - this.property = property; - this.value = value; - } - -} diff --git a/payment/src/main/java/com/example/payment/model/PaymentProperty.java b/payment/src/main/java/com/example/payment/model/PaymentProperty.java deleted file mode 100644 index c2341fa0..00000000 --- a/payment/src/main/java/com/example/payment/model/PaymentProperty.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.example.payment.model; - -import com.example.payment.enums.PaymentStatusEnum; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.persistence.*; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -@Setter -@Entity -@Table(name="Propertypayments") -public class PaymentProperty { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long paymentId; - @ManyToOne - @JoinColumn(name = "idUser") - private User clienteComprador; - @Column - private int valor; - @Column - @DateTimeFormat() - private Date datePayment; - @ManyToOne - @JoinColumn(name="idProperty") - private Property propertyPayment; - @Column - private PaymentStatusEnum status; - - public String getDatePaymentYear(){ - SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); - return sdf.format(this.datePayment); - } - - public String getDatePaymentMonth(){ - SimpleDateFormat sdf = new SimpleDateFormat("MM"); - return sdf.format(this.datePayment); - } - - public String getDatePaymentDay(){ - SimpleDateFormat sdf = new SimpleDateFormat("dd"); - return sdf.format(this.datePayment); - } - - -} diff --git a/payment/src/main/java/com/example/payment/model/PaymentRent.java b/payment/src/main/java/com/example/payment/model/PaymentRent.java deleted file mode 100644 index 8cbfc703..00000000 --- a/payment/src/main/java/com/example/payment/model/PaymentRent.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.example.payment.model; - -import com.example.payment.enums.PaymentStatusEnum; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.springframework.format.annotation.DateTimeFormat; - -import javax.persistence.*; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Entity -@Table(name="RentPayments") -public class PaymentRent { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long paymentId; - @ManyToMany - @JoinColumn(name = "idUser") - private ArrayList clienteComprador; - @Column - private int valor; - @Column - @DateTimeFormat() - private Date datePayment; - @ManyToOne - @JoinColumn(name="idRent") - private Rent rentPayment; - @Column - private PaymentStatusEnum status; - - public String getDatePaymentYear(){ - SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); - return sdf.format(this.datePayment); - } - - public String getDatePaymentMonth(){ - SimpleDateFormat sdf = new SimpleDateFormat("MM"); - return sdf.format(this.datePayment); - } - - public String getDatePaymentDay(){ - SimpleDateFormat sdf = new SimpleDateFormat("dd"); - return sdf.format(this.datePayment); - } -} diff --git a/payment/src/main/java/com/example/payment/model/Property.java b/payment/src/main/java/com/example/payment/model/Property.java deleted file mode 100644 index f48745d9..00000000 --- a/payment/src/main/java/com/example/payment/model/Property.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.example.payment.model; - -import lombok.Getter; -import lombok.Setter; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; - -@Getter -@Setter -@Entity -public class Property { - - @Id - private Long id; - - @Column(name = "amount", length = 10) - private Integer amount; - -} diff --git a/payment/src/main/java/com/example/payment/model/PropertyAcquisition.java b/payment/src/main/java/com/example/payment/model/PropertyAcquisition.java deleted file mode 100644 index 9c53fb17..00000000 --- a/payment/src/main/java/com/example/payment/model/PropertyAcquisition.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.example.payment.model; - -import lombok.Getter; -import lombok.Setter; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; - -@Getter -@Setter -@Entity -@Table(name = "property_acquisition") -public class PropertyAcquisition { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "id_property") - private Long idProperty; - - @Column(name = "amount") - private Integer amount; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "id_acquisition") - private Acquisition acquisition; - -} diff --git a/payment/src/main/java/com/example/payment/model/PropertyRent.java b/payment/src/main/java/com/example/payment/model/PropertyRent.java deleted file mode 100644 index 8b79969f..00000000 --- a/payment/src/main/java/com/example/payment/model/PropertyRent.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.example.payment.model; - -import lombok.Getter; -import lombok.Setter; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; - -@Setter -@Getter -@Entity -@Table(name = "property_rent") -public class PropertyRent { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "id_property") - private Long idProperty; - - @Column(name = "amount") - private Integer amount; - - @OneToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "id_rent") - private Rent rent; - -} diff --git a/payment/src/main/java/com/example/payment/model/Rent.java b/payment/src/main/java/com/example/payment/model/Rent.java deleted file mode 100644 index fd57718d..00000000 --- a/payment/src/main/java/com/example/payment/model/Rent.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.example.payment.model; - -import java.util.Date; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToOne; - -import lombok.Getter; -import lombok.Setter; -import org.springframework.format.annotation.DateTimeFormat; - -@Getter -@Setter -@Entity -public class Rent { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long idRent; - - @DateTimeFormat(pattern = "MM/dd/yyy") - @Column(name = "data", nullable = false) - private Date data; - - @OneToOne(cascade = CascadeType.ALL) - private Property propertie; - - @Column(name = "value", nullable = false) - private Double value; - - public Rent() { - } - - public Rent(Long idRent, Date data, Property propertie, Double value) { - this.idRent = idRent; - this.data = data; - this.propertie = propertie; - this.value = value; - } - -} diff --git a/payment/src/main/java/com/example/payment/model/User.java b/payment/src/main/java/com/example/payment/model/User.java deleted file mode 100644 index bc26f201..00000000 --- a/payment/src/main/java/com/example/payment/model/User.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.example.payment.model; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.persistence.*; -import java.util.List; - -@Setter -@Getter -@NoArgsConstructor -@AllArgsConstructor -@Entity -@Table(name="users") -public class User { - @Id - private Long idUser; - - @Column(name = "name") - private String name; - - @Column(name = "Cpf") - private String Cpf; - - @OneToMany - private List rents; - -} diff --git a/payment/src/main/java/com/example/payment/receiver/PropertyReceiver.java b/payment/src/main/java/com/example/payment/receiver/PropertyReceiver.java deleted file mode 100644 index 51a18a12..00000000 --- a/payment/src/main/java/com/example/payment/receiver/PropertyReceiver.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.example.payment.receiver; - -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.messaging.handler.annotation.Payload; -import org.springframework.stereotype.Component; - -import com.example.payment.model.Property; -import com.example.payment.repository.PropertyRepository; - -@Component -public class PropertyReceiver { - - private PropertyRepository propertyRepository; - - @Autowired - public PropertyReceiver(PropertyRepository propertyRepository) { - this.propertyRepository = propertyRepository; - } - - @RabbitListener(queues = {"${crud.rabbitmq.queue}"}) - public void receive(@Payload Property property) { - propertyRepository.save(property); - } -} diff --git a/payment/src/main/java/com/example/payment/repository/AcquisitionRepository.java b/payment/src/main/java/com/example/payment/repository/AcquisitionRepository.java deleted file mode 100644 index 40bdd643..00000000 --- a/payment/src/main/java/com/example/payment/repository/AcquisitionRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.payment.repository; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import com.example.payment.model.Acquisition; - -@Repository -public interface AcquisitionRepository extends JpaRepository { - - Acquisition findAcquisitionById(Long id); - -} diff --git a/payment/src/main/java/com/example/payment/repository/PaymentPropertyRepository.java b/payment/src/main/java/com/example/payment/repository/PaymentPropertyRepository.java deleted file mode 100644 index 45e06103..00000000 --- a/payment/src/main/java/com/example/payment/repository/PaymentPropertyRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.payment.repository; - -import com.example.payment.model.PaymentProperty; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface PaymentPropertyRepository extends JpaRepository { - public PaymentProperty findPaymentPropertyById(Long id); -} diff --git a/payment/src/main/java/com/example/payment/repository/PaymentRentRepository.java b/payment/src/main/java/com/example/payment/repository/PaymentRentRepository.java deleted file mode 100644 index d13105d7..00000000 --- a/payment/src/main/java/com/example/payment/repository/PaymentRentRepository.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.example.payment.repository; - -import com.example.payment.model.PaymentRent; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface PaymentRentRepository extends JpaRepository { - PaymentRent findPaymentRentById(Long id); -} diff --git a/payment/src/main/java/com/example/payment/repository/PropertyAcquisitionRepository.java b/payment/src/main/java/com/example/payment/repository/PropertyAcquisitionRepository.java deleted file mode 100644 index 0cc402da..00000000 --- a/payment/src/main/java/com/example/payment/repository/PropertyAcquisitionRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.payment.repository; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import com.example.payment.model.PropertyAcquisition; - -@Repository -public interface PropertyAcquisitionRepository extends JpaRepository{ - -} diff --git a/payment/src/main/java/com/example/payment/repository/PropertyRentRepository.java b/payment/src/main/java/com/example/payment/repository/PropertyRentRepository.java deleted file mode 100644 index eb938918..00000000 --- a/payment/src/main/java/com/example/payment/repository/PropertyRentRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.payment.repository; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import com.example.payment.model.PropertyRent; - -@Repository -public interface PropertyRentRepository extends JpaRepository{ - -} diff --git a/payment/src/main/java/com/example/payment/repository/PropertyRepository.java b/payment/src/main/java/com/example/payment/repository/PropertyRepository.java deleted file mode 100644 index 7b7edc1a..00000000 --- a/payment/src/main/java/com/example/payment/repository/PropertyRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.payment.repository; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import com.example.payment.model.Property; - -@Repository -public interface PropertyRepository extends JpaRepository { - -} diff --git a/payment/src/main/java/com/example/payment/repository/RentRepository.java b/payment/src/main/java/com/example/payment/repository/RentRepository.java deleted file mode 100644 index b6235dcf..00000000 --- a/payment/src/main/java/com/example/payment/repository/RentRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.payment.repository; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import com.example.payment.model.Rent; - -@Repository -public interface RentRepository extends JpaRepository { - Rent findRentById(Long id); -} diff --git a/payment/src/main/java/com/example/payment/repository/UserRepository.java b/payment/src/main/java/com/example/payment/repository/UserRepository.java deleted file mode 100644 index 83735494..00000000 --- a/payment/src/main/java/com/example/payment/repository/UserRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.example.payment.repository; - -import com.example.payment.model.User; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface UserRepository extends JpaRepository { - - User findUserById(Long id); - -} diff --git a/payment/src/main/java/com/example/payment/service/AcquisitionServiceImp.java b/payment/src/main/java/com/example/payment/service/AcquisitionServiceImp.java deleted file mode 100644 index 80b1f3c4..00000000 --- a/payment/src/main/java/com/example/payment/service/AcquisitionServiceImp.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.example.payment.service; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.example.payment.model.Acquisition; -import com.example.payment.interfaces.service.IAcquisitionService; -import com.example.payment.repository.AcquisitionRepository; - -@Service -public class AcquisitionServiceImp implements IAcquisitionService { - - private AcquisitionRepository acquisitionRepository; - - - @Autowired - public AcquisitionServiceImp(AcquisitionRepository acquisitionRepository) { - this.acquisitionRepository = acquisitionRepository; - } - - @Override - @Transactional - public void saveAcquisition(Acquisition acquisition) { - acquisitionRepository.save(acquisition); - } - - @Override - public Acquisition findAcquisitionById(Long id) { - return acquisitionRepository.findAcquisitionById(id); - } - - @Override - public List findAllAcquisitions() { - return acquisitionRepository.findAll(); - } - - @Override - public void deleteAcquisition(Long id) { - acquisitionRepository.deleteById(id); - } - - @Override - public Acquisition updateAcquisition(Acquisition acquisition) { - return acquisitionRepository.save(acquisition); - } - -} diff --git a/payment/src/main/java/com/example/payment/service/PaymentPropertyServiceImp.java b/payment/src/main/java/com/example/payment/service/PaymentPropertyServiceImp.java deleted file mode 100644 index e6f1a353..00000000 --- a/payment/src/main/java/com/example/payment/service/PaymentPropertyServiceImp.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.example.payment.service; - -import com.example.payment.enums.PaymentStatusEnum; -import com.example.payment.interfaces.service.IPaymentPropertyService; -import com.example.payment.model.PaymentProperty; -import com.example.payment.repository.PaymentPropertyRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.time.LocalDate; -import java.util.List; - -@Service -public class PaymentPropertyServiceImp implements IPaymentPropertyService { - - private PaymentPropertyRepository paymentPropertyRepository; - - @Autowired - public PaymentPropertyServiceImp(PaymentPropertyRepository paymentPropertyRepository){ - this.paymentPropertyRepository = paymentPropertyRepository; - } - - @Override - public void savePayment(PaymentProperty payment) { - this.paymentPropertyRepository.save(payment); - } - - @Override - public PaymentProperty findPaymentById(Long id) { - return this.paymentPropertyRepository.findPaymentPropertyById(id); - } - - @Override - public List findAllPayments() { - return paymentPropertyRepository.findAll(); - } - - @Override - public void deletePayment(Long id) { - paymentPropertyRepository.deleteById(id); - } - - @Override - public PaymentProperty updatePayment(PaymentProperty payment) { - return paymentPropertyRepository.save(payment); - } - - @Override - public boolean verificarAtraso(PaymentProperty payment){ - LocalDate localDate = LocalDate.now(); - if(Integer.parseInt(payment.getDatePaymentMonth())-Integer.parseInt(String.valueOf(localDate.getMonthValue()))==0) { - return false; - } - if ((Integer.parseInt(payment.getDatePaymentMonth()) - Integer.parseInt(String.valueOf(localDate.getMonthValue())) == 1 - && Integer.parseInt(payment.getDatePaymentMonth()) - Integer.parseInt(String.valueOf(localDate.getMonthValue())) == -1) - || ((Integer.parseInt(payment.getDatePaymentMonth()) == 12 && Integer.parseInt(String.valueOf(localDate.getMonthValue())) == 1))) { - if (Integer.parseInt(payment.getDatePaymentDay()) < Integer.parseInt(String.valueOf(localDate.getDayOfMonth()))) { - return false; - } else { - payment.setStatus(PaymentStatusEnum.ATRASADO); - return true; - } - } else { - payment.setStatus(PaymentStatusEnum.ATRASADO); - return true; - } - } - - @Override - public boolean validarAtraso(PaymentProperty payment){ - if(String.valueOf(payment.getStatus()).equals("PAGO")){ - return true; - } else { - return false; - } - } - - -} diff --git a/payment/src/main/java/com/example/payment/service/PaymentRentServiceImp.java b/payment/src/main/java/com/example/payment/service/PaymentRentServiceImp.java deleted file mode 100644 index 7ff6702c..00000000 --- a/payment/src/main/java/com/example/payment/service/PaymentRentServiceImp.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.example.payment.service; - -import com.example.payment.enums.PaymentStatusEnum; -import com.example.payment.interfaces.service.IPaymentRentService; -import com.example.payment.model.PaymentRent; -import com.example.payment.repository.PaymentRentRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.time.LocalDate; -import java.util.List; - -@Service -public class PaymentRentServiceImp implements IPaymentRentService { - - private PaymentRentRepository paymentRentRepository; - - @Autowired - public PaymentRentServiceImp(PaymentRentRepository paymentRentRepository){ - this.paymentRentRepository = paymentRentRepository; - } - - @Override - public void savePayment(PaymentRent payment) { - paymentRentRepository.save(payment); - } - - @Override - public PaymentRent findPaymentById(Long id) { - return paymentRentRepository.findPaymentRentById(id); - } - - @Override - public List findAllPayments() { - return paymentRentRepository.findAll(); - } - - @Override - public void deletePayment(Long id) { - paymentRentRepository.deleteById(id); - } - - @Override - public PaymentRent updatePayment(PaymentRent payment) { - return paymentRentRepository.save(payment); - } - - @Override - public boolean verificarAtraso(PaymentRent payment){ - LocalDate localDate = LocalDate.now(); - if(Integer.parseInt(payment.getDatePaymentMonth())-Integer.parseInt(String.valueOf(localDate.getMonthValue()))==0) { - return false; - } - if ((Integer.parseInt(payment.getDatePaymentMonth()) - Integer.parseInt(String.valueOf(localDate.getMonthValue())) == 1 - && Integer.parseInt(payment.getDatePaymentMonth()) - Integer.parseInt(String.valueOf(localDate.getMonthValue())) == -1) - || ((Integer.parseInt(payment.getDatePaymentMonth()) == 12 && Integer.parseInt(String.valueOf(localDate.getMonthValue())) == 1))) { - if (Integer.parseInt(payment.getDatePaymentDay()) < Integer.parseInt(String.valueOf(localDate.getDayOfMonth()))) { - return false; - } else { - payment.setStatus(PaymentStatusEnum.ATRASADO); - return true; - } - } else { - payment.setStatus(PaymentStatusEnum.ATRASADO); - return true; - } - } - - @Override - public boolean validarAtraso(PaymentRent payment){ - if(String.valueOf(payment.getStatus()).equals("PAGO")){ - return true; - } else { - return false; - } - } -} diff --git a/payment/src/main/java/com/example/payment/service/RentServiceImp.java b/payment/src/main/java/com/example/payment/service/RentServiceImp.java deleted file mode 100644 index 83e8820d..00000000 --- a/payment/src/main/java/com/example/payment/service/RentServiceImp.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.example.payment.service; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.example.payment.interfaces.service.IRentService; -import com.example.payment.model.Rent; -import com.example.payment.repository.RentRepository; - -@Service -public class RentServiceImp implements IRentService{ - - private RentRepository rentRepository; - - @Autowired - public RentServiceImp(RentRepository repository) { - this.rentRepository = repository; - } - - @Override - public void saveRent(Rent rent) { - rentRepository.save(rent); - } - - @Override - public Rent updateRent(Rent rent) { - return rentRepository.save(rent); - } - - @Override - public Rent findRentById(Long id) { - return rentRepository.findRentById(id); - } - - -} diff --git a/payment/src/main/java/com/example/payment/service/UserServiceImp.java b/payment/src/main/java/com/example/payment/service/UserServiceImp.java deleted file mode 100644 index 2536f0cb..00000000 --- a/payment/src/main/java/com/example/payment/service/UserServiceImp.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.example.payment.service; - -import java.util.List; - -import com.example.payment.interfaces.service.IUserService; -import com.example.payment.interfaces.service.IValidacaoService; -import com.example.payment.model.Property; -import com.example.payment.model.User; -import com.example.payment.repository.UserRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - - -@Service -public class UserServiceImp implements IUserService { - - private UserRepository userRepository; - List validacoes; - - @Autowired - public UserServiceImp(UserRepository repository) { - this.userRepository = repository; - } - - @Override - public User findUserById(Long id) { - return userRepository.findUserById(id); - } - - public void validarUsuario(User user, Property property){ - validacoes.forEach(element->element.validar(user, property)); - } - -} \ No newline at end of file diff --git a/payment/src/main/java/com/example/payment/service/ValidarCPFServiceImp.java b/payment/src/main/java/com/example/payment/service/ValidarCPFServiceImp.java deleted file mode 100644 index cf982f8c..00000000 --- a/payment/src/main/java/com/example/payment/service/ValidarCPFServiceImp.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.example.payment.service; - -import com.example.payment.exceptions.ValidacaoException; -import com.example.payment.interfaces.service.IValidarCPFService; -import com.example.payment.model.Property; -import com.example.payment.model.User; - -import java.util.InputMismatchException; - -public class ValidarCPFServiceImp implements IValidarCPFService { - - public static boolean ehCPF(String CPF) { - if (CPF.equals("00000000000") || - CPF.equals("11111111111") || - CPF.equals("22222222222") || CPF.equals("33333333333") || - CPF.equals("44444444444") || CPF.equals("55555555555") || - CPF.equals("66666666666") || CPF.equals("77777777777") || - CPF.equals("88888888888") || CPF.equals("99999999999") || - (CPF.length() != 11)) - return(false); - char dig10, dig11; - int sm, i, r, num, peso; - - try { - sm = 0; - peso = 10; - for (i=0; i<9; i++) { - num = (int)(CPF.charAt(i) - 48); - sm = sm + (num * peso); - peso = peso - 1; - } - r = 11 - (sm % 11); - if ((r == 10) || (r == 11)) - dig10 = '0'; - else dig10 = (char)(r + 48); - - sm = 0; - peso = 11; - for(i=0; i<10; i++) { - num = (int)(CPF.charAt(i) - 48); - sm = sm + (num * peso); - peso = peso - 1; - } - - r = 11 - (sm % 11); - if ((r == 10) || (r == 11)) - dig11 = '0'; - else dig11 = (char)(r + 48); - - if ((dig10 == CPF.charAt(9)) && (dig11 == CPF.charAt(10))) - return(true); - else return(false); - } catch (InputMismatchException erro) { - return(false); - } - } - - public void validar(User user, Property property){ - if(ehCPF(user.getCpf()) != true) { - throw new ValidacaoException("CPF inválido!"); - } - } -} diff --git a/payment/src/main/java/com/example/payment/swagger/config/SwaggerConfig.java b/payment/src/main/java/com/example/payment/swagger/config/SwaggerConfig.java deleted file mode 100644 index 23c24a5f..00000000 --- a/payment/src/main/java/com/example/payment/swagger/config/SwaggerConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.example.payment.swagger.config; - -import java.util.ArrayList; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.service.VendorExtension; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableSwagger2 -public class SwaggerConfig { - - @Bean - public Docket ContaApi() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("com.example.payment")) - .paths(PathSelectors.any()) - .build() - .apiInfo(metaInfo()); - } - - private ApiInfo metaInfo() { - - ApiInfo apiInfo = new ApiInfo( - "Payment API", - "API de Pagamento de alugueis e aquisições.", - "1.0", - "Terms of Service", - new Contact("Auri Gabriel", "https://www.linkedin.com/in/auri-gabriel-castro-de-melo-486712196/", - "ririmello.a@gmail.com"), - "Apache License Version 2.0", - "https://www.apache.org/licesen.html", new ArrayList() - ); - - return apiInfo; - } - -} - diff --git a/payment/src/main/resources/application.yml b/payment/src/main/resources/application.yml deleted file mode 100644 index 8869d4bd..00000000 --- a/payment/src/main/resources/application.yml +++ /dev/null @@ -1,39 +0,0 @@ -server: - port: 8082 - servlet: - context-path: /paymentService - -spring: - application: - name: paymentService - jpa: - show-sql: false - hibernate: - ddl-auto: update - properties: - hibernate: - dialect: org.hibernate.dialect.MySQL8Dialect - jmx: - enabled: false - datasource: - url: jdbc:mysql://localhost:3306/payment?useTimezone=true&serverTimezone=UTC - username: root - password: admin - - rabbitmq: - host: localhost - port: 5672 - username: guest - password: guest - -crud: - rabbitmq: - exchange: crud.exchange - queue: crud.payment.property - -eureka: - instance: - hostname: localhost - client: - serviceUrl: - defaultZone: http://localhost:8087/discovery/eureka \ No newline at end of file diff --git a/payment/src/test/java/com/example/payment/PaymentRentApplicationTests.java b/payment/src/test/java/com/example/payment/PaymentRentApplicationTests.java deleted file mode 100644 index 82c863b2..00000000 --- a/payment/src/test/java/com/example/payment/PaymentRentApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.example.payment; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class PaymentRentApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/rabbitmq/data/cluster_nodes.config b/rabbitmq/data/cluster_nodes.config deleted file mode 100644 index 29844aea..00000000 --- a/rabbitmq/data/cluster_nodes.config +++ /dev/null @@ -1 +0,0 @@ -{['rabbit@my-rabbit'],['rabbit@my-rabbit']}. diff --git a/rabbitmq/data/coordination/rabbit@my-rabbit/00000001.wal b/rabbitmq/data/coordination/rabbit@my-rabbit/00000001.wal deleted file mode 100644 index 698b19cb..00000000 --- a/rabbitmq/data/coordination/rabbit@my-rabbit/00000001.wal +++ /dev/null @@ -1 +0,0 @@ -RAWA \ No newline at end of file diff --git a/rabbitmq/data/coordination/rabbit@my-rabbit/meta.dets b/rabbitmq/data/coordination/rabbit@my-rabbit/meta.dets deleted file mode 100644 index c1ae47e3..00000000 Binary files a/rabbitmq/data/coordination/rabbit@my-rabbit/meta.dets and /dev/null differ diff --git a/rabbitmq/data/coordination/rabbit@my-rabbit/names.dets b/rabbitmq/data/coordination/rabbit@my-rabbit/names.dets deleted file mode 100644 index c1ae47e3..00000000 Binary files a/rabbitmq/data/coordination/rabbit@my-rabbit/names.dets and /dev/null differ diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/.config b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/.config deleted file mode 100644 index 0c886cd3..00000000 --- a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/.config +++ /dev/null @@ -1,2 +0,0 @@ -%% This file is auto-generated! Edit at your own risk! -{segment_entry_count, 2048}. \ No newline at end of file diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/.vhost b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/.vhost deleted file mode 100644 index 35ec3b9d..00000000 --- a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/.vhost +++ /dev/null @@ -1 +0,0 @@ -/ \ No newline at end of file diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/0.rdq b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/0.rdq deleted file mode 100644 index e69de29b..00000000 diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/clean.dot b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/clean.dot deleted file mode 100644 index 537b3436..00000000 --- a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/clean.dot +++ /dev/null @@ -1,2 +0,0 @@ -{client_refs,[]}. -{index_module,rabbit_msg_store_ets_index}. diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/file_summary.ets b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/file_summary.ets deleted file mode 100644 index 4704c633..00000000 Binary files a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/file_summary.ets and /dev/null differ diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/msg_store_index.ets b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/msg_store_index.ets deleted file mode 100644 index b8f68643..00000000 Binary files a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_persistent/msg_store_index.ets and /dev/null differ diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/0.rdq b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/0.rdq deleted file mode 100644 index e69de29b..00000000 diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/clean.dot b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/clean.dot deleted file mode 100644 index 537b3436..00000000 --- a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/clean.dot +++ /dev/null @@ -1,2 +0,0 @@ -{client_refs,[]}. -{index_module,rabbit_msg_store_ets_index}. diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/file_summary.ets b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/file_summary.ets deleted file mode 100644 index 4aa8cc3b..00000000 Binary files a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/file_summary.ets and /dev/null differ diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/msg_store_index.ets b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/msg_store_index.ets deleted file mode 100644 index 201b3a3c..00000000 Binary files a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/msg_store_transient/msg_store_index.ets and /dev/null differ diff --git a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/recovery.dets b/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/recovery.dets deleted file mode 100644 index c1ae47e3..00000000 Binary files a/rabbitmq/data/msg_stores/vhosts/628WB79CIFDYO9LJI6DKMI09L/recovery.dets and /dev/null differ diff --git a/rabbitmq/data/nodes_running_at_shutdown b/rabbitmq/data/nodes_running_at_shutdown deleted file mode 100644 index 5e2f5673..00000000 --- a/rabbitmq/data/nodes_running_at_shutdown +++ /dev/null @@ -1 +0,0 @@ -['rabbit@my-rabbit']. diff --git a/rabbitmq/data/quorum/rabbit@my-rabbit/00000001.wal b/rabbitmq/data/quorum/rabbit@my-rabbit/00000001.wal deleted file mode 100644 index 698b19cb..00000000 --- a/rabbitmq/data/quorum/rabbit@my-rabbit/00000001.wal +++ /dev/null @@ -1 +0,0 @@ -RAWA \ No newline at end of file diff --git a/rabbitmq/data/quorum/rabbit@my-rabbit/meta.dets b/rabbitmq/data/quorum/rabbit@my-rabbit/meta.dets deleted file mode 100644 index c1ae47e3..00000000 Binary files a/rabbitmq/data/quorum/rabbit@my-rabbit/meta.dets and /dev/null differ diff --git a/rabbitmq/data/quorum/rabbit@my-rabbit/names.dets b/rabbitmq/data/quorum/rabbit@my-rabbit/names.dets deleted file mode 100644 index c1ae47e3..00000000 Binary files a/rabbitmq/data/quorum/rabbit@my-rabbit/names.dets and /dev/null differ diff --git a/rabbitmq/data/rabbit_durable_exchange.DCD b/rabbitmq/data/rabbit_durable_exchange.DCD deleted file mode 100644 index f8dd237a..00000000 --- a/rabbitmq/data/rabbit_durable_exchange.DCD +++ /dev/null @@ -1 +0,0 @@ -cXM \ No newline at end of file diff --git a/rabbitmq/data/rabbit_durable_queue.DCD b/rabbitmq/data/rabbit_durable_queue.DCD deleted file mode 100644 index f8dd237a..00000000 --- a/rabbitmq/data/rabbit_durable_queue.DCD +++ /dev/null @@ -1 +0,0 @@ -cXM \ No newline at end of file diff --git a/rabbitmq/data/rabbit_durable_route.DCD b/rabbitmq/data/rabbit_durable_route.DCD deleted file mode 100644 index f8dd237a..00000000 --- a/rabbitmq/data/rabbit_durable_route.DCD +++ /dev/null @@ -1 +0,0 @@ -cXM \ No newline at end of file diff --git a/rabbitmq/data/rabbit_runtime_parameters.DCD b/rabbitmq/data/rabbit_runtime_parameters.DCD deleted file mode 100644 index f8dd237a..00000000 --- a/rabbitmq/data/rabbit_runtime_parameters.DCD +++ /dev/null @@ -1 +0,0 @@ -cXM \ No newline at end of file diff --git a/rabbitmq/data/rabbit_serial b/rabbitmq/data/rabbit_serial deleted file mode 100644 index d54c6b66..00000000 --- a/rabbitmq/data/rabbit_serial +++ /dev/null @@ -1 +0,0 @@ -1. diff --git a/rabbitmq/data/rabbit_topic_permission.DCD b/rabbitmq/data/rabbit_topic_permission.DCD deleted file mode 100644 index f8dd237a..00000000 --- a/rabbitmq/data/rabbit_topic_permission.DCD +++ /dev/null @@ -1 +0,0 @@ -cXM \ No newline at end of file diff --git a/rabbitmq/data/rabbit_user.DCD b/rabbitmq/data/rabbit_user.DCD deleted file mode 100644 index f8dd237a..00000000 --- a/rabbitmq/data/rabbit_user.DCD +++ /dev/null @@ -1 +0,0 @@ -cXM \ No newline at end of file diff --git a/rabbitmq/data/rabbit_user_permission.DCD b/rabbitmq/data/rabbit_user_permission.DCD deleted file mode 100644 index f8dd237a..00000000 --- a/rabbitmq/data/rabbit_user_permission.DCD +++ /dev/null @@ -1 +0,0 @@ -cXM \ No newline at end of file diff --git a/rabbitmq/data/rabbit_vhost.DCD b/rabbitmq/data/rabbit_vhost.DCD deleted file mode 100644 index f8dd237a..00000000 --- a/rabbitmq/data/rabbit_vhost.DCD +++ /dev/null @@ -1 +0,0 @@ -cXM \ No newline at end of file diff --git a/rabbitmq/data/schema.DAT b/rabbitmq/data/schema.DAT deleted file mode 100644 index b29a3dfb..00000000 Binary files a/rabbitmq/data/schema.DAT and /dev/null differ diff --git a/rabbitmq/data/schema_version b/rabbitmq/data/schema_version deleted file mode 100644 index 203a50c1..00000000 --- a/rabbitmq/data/schema_version +++ /dev/null @@ -1 +0,0 @@ -[store_msg,persistent_bytes,multiple_routing_keys,exchange_options,queue_options,topic_permission,vhost_limits,user_password_hashing,cluster_name,policy_apply_to,topic_trie_node,mirrored_supervisor,gm,user_admin_to_tags,exchange_event_serial,semi_durable_route,topic_trie,add_opts_to_listener,remove_user_scope,move_messages_to_vhost_store]. diff --git a/scheduling/.gitignore b/scheduling/.gitignore deleted file mode 100644 index 02b1ec8b..00000000 --- a/scheduling/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -HELP.md -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -mvnw -mvnw.cmd -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/scheduling/pom.xml b/scheduling/pom.xml deleted file mode 100644 index 7e397046..00000000 --- a/scheduling/pom.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 2.4.2 - - - com.unipampa - scheduling - 0.0.1-SNAPSHOT - scheduling - scheduling service for property visits - - 1.8 - 2020.0.1 - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - org.springframework.boot - spring-boot-starter-amqp - - - - mysql - mysql-connector-java - runtime - - - - org.springframework.cloud - spring-cloud-starter-netflix-eureka-client - - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - org.springframework.boot - spring-boot-starter-test - test - - - io.springfox - springfox-swagger2 - 2.9.2 - - - io.springfox - springfox-swagger-ui - 2.9.2 - - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/scheduling/src/main/java/com/unipampa/scheduling/SchedulingApplication.java b/scheduling/src/main/java/com/unipampa/scheduling/SchedulingApplication.java deleted file mode 100644 index 72acd961..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/SchedulingApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.unipampa.scheduling; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SchedulingApplication { - - public static void main(String[] args) { - SpringApplication.run(SchedulingApplication.class, args); - } -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/config/MessageConfig.java b/scheduling/src/main/java/com/unipampa/scheduling/config/MessageConfig.java deleted file mode 100644 index 62e27ad8..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/config/MessageConfig.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.unipampa.scheduling.config; - -import org.springframework.amqp.core.Exchange; -import org.springframework.amqp.core.ExchangeBuilder; -import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; -import org.springframework.amqp.support.converter.MessageConverter; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class MessageConfig { - - @Value("${crud.rabbitmq.exchange}") - String exchange; - - @Bean - public Exchange declareExchange() { - return ExchangeBuilder.directExchange(exchange).durable(true).build(); - } - - @Bean - public MessageConverter jsonMessageConverter() { - return new Jackson2JsonMessageConverter(); - } - -} \ No newline at end of file diff --git a/scheduling/src/main/java/com/unipampa/scheduling/controller/AppointmentController.java b/scheduling/src/main/java/com/unipampa/scheduling/controller/AppointmentController.java deleted file mode 100644 index 351821fa..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/controller/AppointmentController.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.unipampa.scheduling.controller; - -import java.util.List; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.unipampa.scheduling.dto.AppointmentDTO; -import com.unipampa.scheduling.interfaces.service.IAppointmentService; -import com.unipampa.scheduling.model.Appointment; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - -@RestController -@RequestMapping("/appointment") -@Api(value = "API Scheduling") -public class AppointmentController { - - private IAppointmentService appointmentService; - - public AppointmentController(IAppointmentService appointmentService) { - this.appointmentService = appointmentService; - } - - @PostMapping("/add") - @ApiOperation(value = "add an appointment") - public void saveAppointment(@RequestBody AppointmentDTO dto) { - Appointment appointment = new Appointment(); - appointment.setCustomer(dto.getCustomer()); - appointment.setDate(dto.getDate()); - appointment.setId(dto.getId()); - appointment.setProperty(dto.getProperty()); - appointmentService.saveAppointment(appointment); - } - - @GetMapping("/all") - @ApiOperation(value = "get all appointments") - public ResponseEntity getAllAppointments(){ - List appointments = appointmentService.findAllAppointments(); - return new ResponseEntity<>(appointments, HttpStatus.OK); - } - - @GetMapping("/find/{id}") - @ApiOperation(value = "get appointment by id") - public ResponseEntity getAppointmentById (@PathVariable("id") Long id) { - Appointment appointment = appointmentService.findAppointmentById(id); - return new ResponseEntity<>(appointment, HttpStatus.OK); - } - - @GetMapping("/find/{id}/days") - @ApiOperation(value = "get days until appointment by id") - public ResponseEntity getDaysUntilAppointment (@PathVariable("id") Long id) { - Appointment appointment = appointmentService.findAppointmentById(id); - return new ResponseEntity<>(appointment.daysUntilAppointment(), HttpStatus.OK); - } - - @PutMapping("/update") - @ApiOperation(value = "update an appointments") - public ResponseEntity updateAppointment(@RequestBody Appointment appointment) { - Appointment updateAppointment = appointmentService.updateAppointment(appointment); - return new ResponseEntity<>(updateAppointment, HttpStatus.OK); - } - - @DeleteMapping("/delete/{id}") - @ApiOperation(value = "delete a appointment by id") - public void deleteAppointment(@PathVariable("id") Long id) { - appointmentService.deleteAppointment(id); - } - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/dto/AppointmentDTO.java b/scheduling/src/main/java/com/unipampa/scheduling/dto/AppointmentDTO.java deleted file mode 100644 index 1992c555..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/dto/AppointmentDTO.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.unipampa.scheduling.dto; - -import java.time.LocalDateTime; - -import com.unipampa.scheduling.model.Customer; -import com.unipampa.scheduling.model.Property; - -public class AppointmentDTO { - - private Long id; - private LocalDateTime date; - private Property property; - private Customer customer; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public LocalDateTime getDate() { - return date; - } - - public void setDate(LocalDateTime date) { - this.date = date; - } - - public Property getProperty() { - return property; - } - - public void setProperty(Property property) { - this.property = property; - } - - public Customer getCustomer() { - return customer; - } - - public void setCustomer(Customer customer) { - this.customer = customer; - } - - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/dto/CustomerDTO.java b/scheduling/src/main/java/com/unipampa/scheduling/dto/CustomerDTO.java deleted file mode 100644 index baf08b61..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/dto/CustomerDTO.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.unipampa.scheduling.dto; - -public class CustomerDTO { - - private Long id; - private String email; - private String name; - private String phone; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/dto/PropertyDTO.java b/scheduling/src/main/java/com/unipampa/scheduling/dto/PropertyDTO.java deleted file mode 100644 index 054ae96b..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/dto/PropertyDTO.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.unipampa.scheduling.dto; - -public class PropertyDTO { - - private Long id; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/implement/service/AppointmentServiceImp.java b/scheduling/src/main/java/com/unipampa/scheduling/implement/service/AppointmentServiceImp.java deleted file mode 100644 index 947288ae..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/implement/service/AppointmentServiceImp.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.unipampa.scheduling.implement.service; - -import java.util.List; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.unipampa.scheduling.interfaces.service.IAppointmentService; -import com.unipampa.scheduling.model.Appointment; -import com.unipampa.scheduling.repository.AppointmentRepository; - -@Service -public class AppointmentServiceImp implements IAppointmentService { - - private AppointmentRepository appointmentRepository; - - - @Autowired - public AppointmentServiceImp(AppointmentRepository appointmentRepository) { - this.appointmentRepository = appointmentRepository; - } - - @Override - @Transactional - public void saveAppointment(Appointment appointment) { - appointmentRepository.save(appointment); - } - - @Override - public Appointment findAppointmentById(Long id) { - return appointmentRepository.findAppointmentById(id); - } - - @Override - public List findAllAppointments() { - return appointmentRepository.findAll(); - } - - @Override - public void deleteAppointment(Long id) { - appointmentRepository.deleteById(id); - } - - @Override - public Appointment updateAppointment(Appointment appointment) { - return appointmentRepository.save(appointment); - } - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/interfaces/service/IAppointmentService.java b/scheduling/src/main/java/com/unipampa/scheduling/interfaces/service/IAppointmentService.java deleted file mode 100644 index d85ac314..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/interfaces/service/IAppointmentService.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.unipampa.scheduling.interfaces.service; - -import java.util.List; - -import com.unipampa.scheduling.model.Appointment; - -public interface IAppointmentService { - - void saveAppointment(Appointment appointment); - Appointment findAppointmentById(Long id); - List findAllAppointments(); - void deleteAppointment(Long id); - Appointment updateAppointment(Appointment appointment); - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/message/CustomerReceiveMessage.java b/scheduling/src/main/java/com/unipampa/scheduling/message/CustomerReceiveMessage.java deleted file mode 100644 index 667f2a68..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/message/CustomerReceiveMessage.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.unipampa.scheduling.message; - -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.messaging.handler.annotation.Payload; -import org.springframework.stereotype.Component; - -import com.unipampa.scheduling.model.Customer; -import com.unipampa.scheduling.repository.CustomerRepository; - -@Component -public class CustomerReceiveMessage { - - private CustomerRepository customerRepository; - - @Autowired - public CustomerReceiveMessage(CustomerRepository customerRepository) { - this.customerRepository = customerRepository; - } - - @RabbitListener(queues = {"${crud.rabbitmq.queueUser}"}) - public void receive(@Payload Customer customer) { - customerRepository.save(customer); - } - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/message/PropertyReceiveMessage.java b/scheduling/src/main/java/com/unipampa/scheduling/message/PropertyReceiveMessage.java deleted file mode 100644 index 44e21dc4..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/message/PropertyReceiveMessage.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.unipampa.scheduling.message; - -import org.springframework.amqp.rabbit.annotation.RabbitListener; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.messaging.handler.annotation.Payload; -import org.springframework.stereotype.Component; - -import com.unipampa.scheduling.model.Property; -import com.unipampa.scheduling.repository.PropertyRepository; - -@Component -public class PropertyReceiveMessage { - - private PropertyRepository propertyRepository; - - @Autowired - public PropertyReceiveMessage(PropertyRepository propertyRepository) { - this.propertyRepository = propertyRepository; - } - - @RabbitListener(queues = {"${crud.rabbitmq.queueProperty}"}) - public void receive(@Payload Property property) { - propertyRepository.save(property); - } -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/model/Appointment.java b/scheduling/src/main/java/com/unipampa/scheduling/model/Appointment.java deleted file mode 100644 index e4db9c2a..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/model/Appointment.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.unipampa.scheduling.model; - -import java.time.LocalDate; -import java.time.LocalDateTime; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.OneToOne; -import javax.persistence.Table; - -import org.springframework.format.annotation.DateTimeFormat; - - -@Entity -@Table(name = "tbl_appointments") -public class Appointment { - - LocalDate dataLocal; - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @DateTimeFormat(pattern = "MM/dd/yyy") - @Column(name = "date", nullable = false) - private LocalDateTime date; - - @OneToOne(cascade = CascadeType.ALL) - private Property property; - - @OneToOne(cascade = CascadeType.ALL) - private Customer customer; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public LocalDateTime getDate() { - return date; - } - - public void setDate(LocalDateTime date) { - this.date = date; - } - - public Property getProperty() { - return property; - } - - public void setProperty(Property property) { - this.property = property; - } - - public Customer getCustomer() { - return customer; - } - - public void setCustomer(Customer customer) { - this.customer = customer; - } - - public int daysUntilAppointment() { - return date.compareTo(LocalDateTime.now()); - } -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/model/Customer.java b/scheduling/src/main/java/com/unipampa/scheduling/model/Customer.java deleted file mode 100644 index 59a3cd07..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/model/Customer.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.unipampa.scheduling.model; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; - -@Entity -public class Customer { - - @Id - @Column(name = "id") - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(name = "email") - private String email; - - @Column(name = "name") - private String name; - - @Column(name = "phone") - private String phone; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/model/Property.java b/scheduling/src/main/java/com/unipampa/scheduling/model/Property.java deleted file mode 100644 index d9c2afd5..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/model/Property.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.unipampa.scheduling.model; - -import javax.persistence.Entity; -import javax.persistence.Id; - -@Entity -public class Property { - - @Id - private Long id; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/repository/AppointmentRepository.java b/scheduling/src/main/java/com/unipampa/scheduling/repository/AppointmentRepository.java deleted file mode 100644 index 8d0a3636..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/repository/AppointmentRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.unipampa.scheduling.repository; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import com.unipampa.scheduling.model.Appointment; - -@Repository -public interface AppointmentRepository extends JpaRepository { - - Appointment findAppointmentById(Long id); - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/repository/CustomerRepository.java b/scheduling/src/main/java/com/unipampa/scheduling/repository/CustomerRepository.java deleted file mode 100644 index 70b5e066..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/repository/CustomerRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.unipampa.scheduling.repository; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import com.unipampa.scheduling.model.Customer; - -@Repository -public interface CustomerRepository extends JpaRepository { - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/repository/PropertyRepository.java b/scheduling/src/main/java/com/unipampa/scheduling/repository/PropertyRepository.java deleted file mode 100644 index 9d300731..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/repository/PropertyRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.unipampa.scheduling.repository; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import com.unipampa.scheduling.model.Property; - -@Repository -public interface PropertyRepository extends JpaRepository { - -} diff --git a/scheduling/src/main/java/com/unipampa/scheduling/swagger/config/SwaggerConfig.java b/scheduling/src/main/java/com/unipampa/scheduling/swagger/config/SwaggerConfig.java deleted file mode 100644 index 81539e8f..00000000 --- a/scheduling/src/main/java/com/unipampa/scheduling/swagger/config/SwaggerConfig.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.unipampa.scheduling.swagger.config; - -import java.util.ArrayList; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.service.VendorExtension; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableSwagger2 -public class SwaggerConfig { - - @Bean - public Docket ContaApi() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.basePackage("com.unipampa.scheduling")) - .paths(PathSelectors.any()) - .build() - .apiInfo(metaInfo()); - } - - private ApiInfo metaInfo() { - - ApiInfo apiInfo = new ApiInfo( - "Scheduling API", - "API de agendamento.", - "1.0", - "Terms of Service", - new Contact("Auri Gabriel", "https://www.linkedin.com/in/auri-gabriel-castro-de-melo-486712196/", - "ririmello.a@gmail.com"), - "Apache License Version 2.0", - "https://www.apache.org/licesen.html", new ArrayList() - ); - - return apiInfo; - } - -} - diff --git a/scheduling/src/main/resources/application.yml b/scheduling/src/main/resources/application.yml deleted file mode 100644 index 0fa36c44..00000000 --- a/scheduling/src/main/resources/application.yml +++ /dev/null @@ -1,40 +0,0 @@ -server: - port: 8086 - servlet: - context-path: /schedulingService - -spring: - application: - name: schedulingService - jpa: - show-sql: false - hibernate: - ddl-auto: update - properties: - hibernate: - dialect: org.hib ernate.dialect.MySQL8Dialect - jmx: - enabled: false - datasource: - url: jdbc:mysql://localhost:3306/scheduling?useTimezone=true&serverTimezone=UTC - username: root - password: admin - - rabbitmq: - host: localhost - port: 5672 - username: guest - password: guest - -eureka: - instance: - hostname: localhost - client: - serviceUrl: - defaultZone: http://localhost:8087/discovery/eureka - -crud: - rabbitmq: - exchange: crud.exchange - queueProperty: crud.scheduling.property - queueUser: crud.scheduling.user \ No newline at end of file diff --git a/scheduling/src/test/java/com/unipampa/scheduling/SchedulingApplicationTests.java b/scheduling/src/test/java/com/unipampa/scheduling/SchedulingApplicationTests.java deleted file mode 100644 index 0afdf315..00000000 --- a/scheduling/src/test/java/com/unipampa/scheduling/SchedulingApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.unipampa.scheduling; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class SchedulingApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/scripts/init.sql b/scripts/init.sql deleted file mode 100644 index af39f26a..00000000 --- a/scripts/init.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE DATABASE auth_db; -CREATE DATABASE crud_db; -CREATE DATABASE rent; -CREATE DATABASE payment; -CREATE DATABASE scheduling; -CREATE DATABASE aquisition; \ No newline at end of file diff --git a/tests-api/pom.xml b/tests-api/pom.xml deleted file mode 100644 index 509afe79..00000000 --- a/tests-api/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - 4.0.0 - - org.example - tests-api - 1.0-SNAPSHOT - - - 8 - 8 - UTF-8 - - - - - junit - junit - 4.12 - test - - - io.rest-assured - rest-assured - 4.3.0 - test - - - \ No newline at end of file diff --git a/tests-api/src/test/java/org/example/tests/APITestRent.java b/tests-api/src/test/java/org/example/tests/APITestRent.java deleted file mode 100644 index 59c36c89..00000000 --- a/tests-api/src/test/java/org/example/tests/APITestRent.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.example.tests; - -import io.restassured.RestAssured; -import io.restassured.http.ContentType; -import org.junit.BeforeClass; -import org.junit.Test; - -public class APITestRent { - - @BeforeClass - public static void setup() { - RestAssured.baseURI = "http://localhost:8085/rentService/rent"; - } - - @Test - public void mustSaveRent_Successfully() { - RestAssured.given() - .body(" { \"condominium\": 777, \"dateAdjustmentIGPM\": \"2023-01-31\", \"description\": \"stringgfgdf\", \"endDateRent\": \"2024-01-16\", \"energy\": 150, \"id_customer\": 2, \"id_property\": 1, \"iptu\": 150, \"startDateRent\": \"2023-01-16\", \"value\": 150, \"water\": 150 }") - .contentType(ContentType.JSON) - .when() - .post("/save") - .then() - .statusCode(201); - } - - @Test - public void mustUpdateRent_Successfully() { - RestAssured.given() - .body(" { \"id\": 2, \"description\": \"atualizou\", \"energy\": 177, \"iptu\": 888, \"value\": 1555, \"water\": 80 }") - .contentType(ContentType.JSON) - .when() - .put("/update") - .then() - .statusCode(204); - } - - @Test - public void mustDeleteRent_Successfully() { - RestAssured.given() - .when() - .delete("/delete/2") - .then() - .statusCode(204); - } - - @Test - public void mustFindByIdRent_Successfully() { - RestAssured.given() - .when() - .get("/find/1") - .then() - .statusCode(200); - } - - @Test - public void mustReturnsListRents_Successfully() { - RestAssured.given() - .when() - .get("/all") - .then() - .statusCode(200); - } - - @Test - public void mustReturnsListOfRents_WithIdOfCustomer_Successfully() { - RestAssured.given() - .when() - .get("rents/customer/1") - .then() - .log().all() - .statusCode(200); - } - -}